kwin Library API Documentation

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( QString, caption,,, const )
00045 BRIDGE_HELPER( void, processMousePressEvent, QMouseEvent* e, e, )
00046 BRIDGE_HELPER( QRect, 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 BRIDGE_HELPER( void, setKeepAbove, bool set, set, )
00053 BRIDGE_HELPER( void, setKeepBelow, bool set, set, )
00054 
00055 NET::WindowType Bridge::windowType( unsigned long supported_types ) const
00056     {
00057     return c->windowType( false, supported_types );
00058     }
00059 
00060 QIconSet Bridge::icon() const
00061     {
00062     return QIconSet( c->miniIcon(), c->icon());
00063     }
00064 
00065 bool Bridge::isSetShade() const
00066     {
00067     return c->shadeMode() != ShadeNone;
00068     }
00069 
00070 void Bridge::showWindowMenu( QPoint p )
00071     {
00072     c->workspace()->showWindowMenu( p, c );
00073     }
00074 
00075 void Bridge::showWindowMenu( const QRect &p )
00076     {
00077     c->workspace()->showWindowMenu( p, c );
00078     }
00079 
00080 void Bridge::performWindowOperation( WindowOperation op )
00081     {
00082     c->workspace()->performWindowOperation( c, op );
00083     }
00084 
00085 void Bridge::setMask( const QRegion& r, int mode )
00086     {
00087     c->setMask( r, mode );
00088     }
00089 
00090 bool Bridge::isPreview() const
00091     {
00092     return false;
00093     }
00094 
00095 QRect Bridge::iconGeometry() const
00096     {
00097     NETRect r = c->info->iconGeometry();
00098     return QRect( r.pos.x, r.pos.y, r.size.width, r.size.height );
00099     }
00100 
00101 QWidget* Bridge::workspaceWidget() const
00102     {
00103     return c->workspace()->desktopWidget();
00104     }
00105 
00106 WId Bridge::windowId() const
00107     {
00108     return c->window();
00109     }
00110 
00111 void Bridge::titlebarDblClickOperation()
00112     {
00113     c->workspace()->performWindowOperation( c, options->operationTitlebarDblClick());
00114     }
00115 
00116 void Bridge::setShade( bool set )
00117     {
00118     c->setShade( set ? ShadeNormal : ShadeNone );
00119     }
00120 
00121 int Bridge::currentDesktop() const
00122     {
00123     return c->workspace()->currentDesktop();
00124     }
00125 
00126 QWidget* Bridge::initialParentWidget() const
00127     {
00128     return NULL;
00129     }
00130 
00131 Qt::WFlags Bridge::initialWFlags() const
00132     {
00133     return 0;
00134     }
00135 
00136 void Bridge::helperShowHide( bool show )
00137     {
00138     if( show )
00139         c->rawShow();
00140     else
00141         c->rawHide();
00142     }
00143 
00144 QRegion Bridge::unobscuredRegion( const QRegion& r ) const
00145     {
00146     QRegion reg( r );
00147     const ClientList stacking_order = c->workspace()->stackingOrder();
00148     ClientList::ConstIterator it = stacking_order.find( c );
00149     ++it;
00150     for(;
00151          it != stacking_order.end();
00152          ++it )
00153         {
00154         if( !(*it)->isShown( true ))
00155             continue; // these don't obscure the window
00156         if( c->isOnAllDesktops())
00157             {
00158             if( !(*it)->isOnCurrentDesktop())
00159                 continue;
00160             }
00161         else
00162             {
00163             if( !(*it)->isOnDesktop( c->desktop()))
00164                 continue;
00165             }
00166         /* the clients all have their mask-regions in local coords
00167        so we have to translate them to a shared coord system
00168        we choose ours */
00169     int dx = (*it)->x() - c->x();
00170     int dy = (*it)->y() - c->y();
00171     QRegion creg = (*it)->mask();
00172     creg.translate(dx, dy);
00173     reg -= creg;
00174     if (reg.isEmpty())
00175             {
00176         // early out, we are completely obscured
00177         break;
00178         }
00179         }
00180     return reg;
00181     }
00182 
00183 void Bridge::grabXServer( bool grab )
00184     {
00185     if( grab )
00186         KWinInternal::grabXServer();
00187     else
00188         KWinInternal::ungrabXServer();
00189     }
00190 
00191 } // namespace
KDE Logo
This file is part of the documentation for kwin Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Jun 13 19:28:00 2006 by doxygen 1.4.3 written by Dimitri van Heesch, © 1997-2003