• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

KWin

bridge.cpp

Go to the documentation of this file.
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 This program is free software; you can redistribute it and/or modify
00008 it under the terms of the GNU General Public License as published by
00009 the Free Software Foundation; either version 2 of the License, or
00010 (at your option) any later version.
00011 
00012 This program is distributed in the hope that it will be useful,
00013 but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with this program.  If not, see <http://www.gnu.org/licenses/>.
00019 *********************************************************************/
00020 
00021 #include "bridge.h"
00022 
00023 #include "client.h"
00024 #include "options.h"
00025 #include "effects.h"
00026 
00027 #include <kconfiggroup.h>
00028 
00029 namespace KWin
00030 {
00031 
00032 Bridge::Bridge( Client* cl )
00033     : c( cl )
00034     {
00035     }
00036 
00037 #define BRIDGE_HELPER( rettype, prototype, args1, args2, cst ) \
00038 rettype Bridge::prototype ( args1 ) cst \
00039     { \
00040     return c->prototype( args2 ); \
00041     }
00042 
00043 BRIDGE_HELPER( bool, isActive,,, const )
00044 BRIDGE_HELPER( bool, isCloseable,,, const )
00045 BRIDGE_HELPER( bool, isMaximizable,,, const )
00046 BRIDGE_HELPER( Bridge::MaximizeMode, maximizeMode,,, const )
00047 BRIDGE_HELPER( bool, isMinimizable,,, const )
00048 BRIDGE_HELPER( bool, providesContextHelp,,, const )
00049 BRIDGE_HELPER( int, desktop,,, const )
00050 BRIDGE_HELPER( bool, isModal,,, const )
00051 BRIDGE_HELPER( bool, isShadeable,,, const )
00052 BRIDGE_HELPER( bool, isShade,,, const )
00053 BRIDGE_HELPER( bool, keepAbove,,, const )
00054 BRIDGE_HELPER( bool, keepBelow,,, const )
00055 BRIDGE_HELPER( bool, isMovable,,, const )
00056 BRIDGE_HELPER( bool, isResizable,,, const )
00057 BRIDGE_HELPER( QString, caption,,, const )
00058 BRIDGE_HELPER( void, processMousePressEvent, QMouseEvent* e, e, )
00059 BRIDGE_HELPER( QRect, geometry,,, const )
00060 BRIDGE_HELPER( void, closeWindow,,, )
00061 BRIDGE_HELPER( void, maximize, MaximizeMode m, m, )
00062 BRIDGE_HELPER( void, minimize,,, )
00063 BRIDGE_HELPER( void, showContextHelp,,, )
00064 BRIDGE_HELPER( void, setDesktop, int desktop, desktop, )
00065 
00066 void Bridge::setKeepAbove( bool set )
00067     {
00068     if( c->keepAbove() != set )
00069         c->workspace()->performWindowOperation( c, KeepAboveOp );
00070     }
00071 
00072 void Bridge::setKeepBelow( bool set )
00073     {
00074     if( c->keepBelow() != set )
00075         c->workspace()->performWindowOperation( c, KeepBelowOp );
00076     }
00077 
00078 NET::WindowType Bridge::windowType( unsigned long supported_types ) const
00079     {
00080     return c->windowType( false, supported_types );
00081     }
00082 
00083 QIcon Bridge::icon() const
00084     {
00085     QIcon ret( c->icon());
00086     ret.addPixmap( c->miniIcon());
00087     return ret;
00088     }
00089 
00090 bool Bridge::isSetShade() const
00091     {
00092     return c->shadeMode() != ShadeNone;
00093     }
00094 
00095 void Bridge::showWindowMenu( const QPoint &p )
00096     {
00097     c->workspace()->showWindowMenu( p, c );
00098     }
00099 
00100 void Bridge::showWindowMenu( const QRect &p )
00101     {
00102     c->workspace()->showWindowMenu( p, c );
00103     }
00104 
00105 void Bridge::performWindowOperation( WindowOperation op )
00106     {
00107     c->workspace()->performWindowOperation( c, op );
00108     }
00109 
00110 void Bridge::setMask( const QRegion& r, int mode )
00111     {
00112     c->setMask( r, mode );
00113     }
00114 
00115 bool Bridge::isPreview() const
00116     {
00117     return false;
00118     }
00119 
00120 QRect Bridge::iconGeometry() const
00121     {
00122     NETRect r = c->info->iconGeometry();
00123     return QRect( r.pos.x, r.pos.y, r.size.width, r.size.height );
00124     }
00125 
00126 WId Bridge::windowId() const
00127     {
00128     return c->window();
00129     }
00130 
00131 void Bridge::titlebarDblClickOperation()
00132     {
00133     c->workspace()->performWindowOperation( c, options->operationTitlebarDblClick());
00134     }
00135 
00136 void Bridge::titlebarMouseWheelOperation( int delta )
00137     {
00138     c->performMouseCommand( options->operationTitlebarMouseWheel( delta ), cursorPos());
00139     }
00140 
00141 void Bridge::setShade( bool set )
00142     {
00143     c->setShade( set ? ShadeNormal : ShadeNone );
00144     }
00145 
00146 int Bridge::currentDesktop() const
00147     {
00148     return c->workspace()->currentDesktop();
00149     }
00150 
00151 QWidget* Bridge::initialParentWidget() const
00152     {
00153     return NULL;
00154     }
00155 
00156 Qt::WFlags Bridge::initialWFlags() const
00157     {
00158     return 0;
00159     }
00160 
00161 QRegion Bridge::unobscuredRegion( const QRegion& r ) const
00162     {
00163     QRegion reg( r );
00164     const ClientList stacking_order = c->workspace()->stackingOrder();
00165     int pos = stacking_order.indexOf( c );
00166     ++pos;
00167     for(; pos < stacking_order.count(); ++pos )
00168         {
00169         if( !stacking_order[pos]->isShown( true ))
00170             continue; // these don't obscure the window
00171         if( c->isOnAllDesktops())
00172             {
00173             if( !stacking_order[ pos ]->isOnCurrentDesktop())
00174                 continue;
00175             }
00176         else
00177             {
00178             if( !stacking_order[ pos ]->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 = stacking_order[ pos ]->x() - c->x();
00185         int dy = stacking_order[ pos ]->y() - c->y();
00186         QRegion creg = stacking_order[ pos ]->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         KWin::grabXServer();
00202     else
00203         KWin::ungrabXServer();
00204     }
00205 
00206 void Bridge::repaintShadow()
00207     {
00208     // TODO
00209     }
00210 
00211 bool Bridge::compositingActive() const
00212     {
00213     return c->workspace()->compositingActive();
00214     }
00215 
00216 bool Bridge::shadowsActive() const
00217     {
00218     if( !c->workspace()->compositingActive() )
00219         return false;
00220     if( effects && static_cast<EffectsHandlerImpl*>( effects )->isEffectLoaded( "kwin4_effect_shadow" ))
00221         { // The shadow effect has a setting to disable decoration shadows, take it into account.
00222         KConfigGroup conf = static_cast<EffectsHandlerImpl*>( effects )->effectConfig( "Shadow" );
00223         return !conf.readEntry( "forceDecoratedToDefault", false );
00224         }
00225     return false;
00226     }
00227 
00228 double Bridge::opacity() const
00229     {
00230     return c->opacity();
00231     }
00232 
00233 
00234 } // namespace

KWin

Skip menu "KWin"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal