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