bridge.cpp
00001 /***************************************************************** 00002 KWin - the KDE window manager 00003 This file is part of the KDE project. 00004 00005 Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org> 00006 00007 You can Freely distribute this program under the GNU General Public 00008 License. See the file "COPYING" for the exact licensing terms. 00009 ******************************************************************/ 00010 00011 #include "bridge.h" 00012 00013 #include "client.h" 00014 #include "options.h" 00015 00016 namespace KWinInternal 00017 { 00018 00019 Bridge::Bridge( Client* cl ) 00020 : c( cl ) 00021 { 00022 } 00023 00024 Bridge::~Bridge() 00025 { 00026 } 00027 00028 #define BRIDGE_HELPER( rettype, prototype, args1, args2, cst ) \ 00029 rettype Bridge::prototype ( args1 ) cst \ 00030 { \ 00031 return c->prototype( args2 ); \ 00032 } 00033 00034 BRIDGE_HELPER( bool, isActive,,, const ) 00035 BRIDGE_HELPER( bool, isCloseable,,, const ) 00036 BRIDGE_HELPER( bool, isMaximizable,,, const ) 00037 BRIDGE_HELPER( Bridge::MaximizeMode, maximizeMode,,, const ) 00038 BRIDGE_HELPER( bool, isMinimizable,,, const ) 00039 BRIDGE_HELPER( bool, providesContextHelp,,, const ) 00040 BRIDGE_HELPER( int, desktop,,, const ) 00041 BRIDGE_HELPER( bool, isModal,,, const ) 00042 BRIDGE_HELPER( bool, isShadeable,,, const ) 00043 BRIDGE_HELPER( bool, isShade,,, const ) 00044 BRIDGE_HELPER( bool, keepAbove,,, const ) 00045 BRIDGE_HELPER( bool, keepBelow,,, const ) 00046 BRIDGE_HELPER( bool, isMovable,,, const ) 00047 BRIDGE_HELPER( bool, isResizable,,, const ) 00048 BRIDGE_HELPER( TQString, caption,,, const ) 00049 BRIDGE_HELPER( void, processMousePressEvent, TQMouseEvent* e, e, ) 00050 BRIDGE_HELPER( TQRect, geometry,,, const ) 00051 BRIDGE_HELPER( void, closeWindow,,, ) 00052 BRIDGE_HELPER( void, maximize, MaximizeMode m, m, ) 00053 BRIDGE_HELPER( void, minimize,,, ) 00054 BRIDGE_HELPER( void, showContextHelp,,, ) 00055 BRIDGE_HELPER( void, setDesktop, int desktop, desktop, ) 00056 00057 void Bridge::setKeepAbove( bool set ) 00058 { 00059 if( c->keepAbove() != set ) 00060 c->workspace()->performWindowOperation( c, KeepAboveOp ); 00061 } 00062 00063 void Bridge::setKeepBelow( bool set ) 00064 { 00065 if( c->keepBelow() != set ) 00066 c->workspace()->performWindowOperation( c, KeepBelowOp ); 00067 } 00068 00069 NET::WindowType Bridge::windowType( unsigned long supported_types ) const 00070 { 00071 return c->windowType( false, supported_types ); 00072 } 00073 00074 TQIconSet Bridge::icon() const 00075 { 00076 return TQIconSet( c->miniIcon(), c->icon()); 00077 } 00078 00079 bool Bridge::isSetShade() const 00080 { 00081 return c->shadeMode() != ShadeNone; 00082 } 00083 00084 void Bridge::showWindowMenu( TQPoint p ) 00085 { 00086 c->workspace()->showWindowMenu( p, c ); 00087 } 00088 00089 void Bridge::showWindowMenu( const TQRect &p ) 00090 { 00091 c->workspace()->showWindowMenu( p, c ); 00092 } 00093 00094 void Bridge::performWindowOperation( WindowOperation op ) 00095 { 00096 c->workspace()->performWindowOperation( c, op ); 00097 } 00098 00099 void Bridge::setMask( const TQRegion& r, int mode ) 00100 { 00101 c->setMask( r, mode ); 00102 } 00103 00104 bool Bridge::isPreview() const 00105 { 00106 return false; 00107 } 00108 00109 TQRect Bridge::iconGeometry() const 00110 { 00111 NETRect r = c->info->iconGeometry(); 00112 return TQRect( r.pos.x, r.pos.y, r.size.width, r.size.height ); 00113 } 00114 00115 TQWidget* Bridge::workspaceWidget() const 00116 { 00117 return c->workspace()->desktopWidget(); 00118 } 00119 00120 WId Bridge::windowId() const 00121 { 00122 return c->window(); 00123 } 00124 00125 void Bridge::titlebarDblClickOperation() 00126 { 00127 c->workspace()->performWindowOperation( c, options->operationTitlebarDblClick()); 00128 } 00129 00130 void Bridge::titlebarMouseWheelOperation( int delta ) 00131 { 00132 c->performMouseCommand( options->operationTitlebarMouseWheel( delta ), TQCursor::pos()); 00133 } 00134 00135 void Bridge::setShade( bool set ) 00136 { 00137 c->setShade( set ? ShadeNormal : ShadeNone ); 00138 } 00139 00140 int Bridge::currentDesktop() const 00141 { 00142 return c->workspace()->currentDesktop(); 00143 } 00144 00145 TQWidget* Bridge::initialParentWidget() const 00146 { 00147 return NULL; 00148 } 00149 00150 Qt::WFlags Bridge::initialWFlags() const 00151 { 00152 return 0; 00153 } 00154 00155 void Bridge::helperShowHide( bool show ) 00156 { 00157 if( show ) 00158 c->rawShow(); 00159 else 00160 c->rawHide(); 00161 } 00162 00163 TQRegion Bridge::unobscuredRegion( const TQRegion& r ) const 00164 { 00165 TQRegion reg( r ); 00166 const ClientList stacking_order = c->workspace()->stackingOrder(); 00167 ClientList::ConstIterator it = stacking_order.find( c ); 00168 ++it; 00169 for(; 00170 it != stacking_order.end(); 00171 ++it ) 00172 { 00173 if( !(*it)->isShown( true )) 00174 continue; // these don't obscure the window 00175 if( c->isOnAllDesktops()) 00176 { 00177 if( !(*it)->isOnCurrentDesktop()) 00178 continue; 00179 } 00180 else 00181 { 00182 if( !(*it)->isOnDesktop( c->desktop())) 00183 continue; 00184 } 00185 /* the clients all have their mask-regions in local coords 00186 so we have to translate them to a shared coord system 00187 we choose ours */ 00188 int dx = (*it)->x() - c->x(); 00189 int dy = (*it)->y() - c->y(); 00190 TQRegion creg = (*it)->mask(); 00191 creg.translate(dx, dy); 00192 reg -= creg; 00193 if (reg.isEmpty()) 00194 { 00195 // early out, we are completely obscured 00196 break; 00197 } 00198 } 00199 return reg; 00200 } 00201 00202 void Bridge::grabXServer( bool grab ) 00203 { 00204 if( grab ) 00205 KWinInternal::grabXServer(); 00206 else 00207 KWinInternal::ungrabXServer(); 00208 } 00209 00210 } // namespace