Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / workspace / kwin / bridge.cpp
blobe59cfe619ccf9b614fdfaafcac52c255b1f3e9ad
1 /********************************************************************
2 KWin - the KDE window manager
3 This file is part of the KDE project.
5 Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *********************************************************************/
21 #include "bridge.h"
23 #include "client.h"
24 #include "options.h"
26 namespace KWin
29 Bridge::Bridge( Client* cl )
30 : c( cl )
34 #define BRIDGE_HELPER( rettype, prototype, args1, args2, cst ) \
35 rettype Bridge::prototype ( args1 ) cst \
36 { \
37 return c->prototype( args2 ); \
40 BRIDGE_HELPER( bool, isActive,,, const )
41 BRIDGE_HELPER( bool, isCloseable,,, const )
42 BRIDGE_HELPER( bool, isMaximizable,,, const )
43 BRIDGE_HELPER( Bridge::MaximizeMode, maximizeMode,,, const )
44 BRIDGE_HELPER( bool, isMinimizable,,, const )
45 BRIDGE_HELPER( bool, providesContextHelp,,, const )
46 BRIDGE_HELPER( int, desktop,,, const )
47 BRIDGE_HELPER( bool, isModal,,, const )
48 BRIDGE_HELPER( bool, isShadeable,,, const )
49 BRIDGE_HELPER( bool, isShade,,, const )
50 BRIDGE_HELPER( bool, keepAbove,,, const )
51 BRIDGE_HELPER( bool, keepBelow,,, const )
52 BRIDGE_HELPER( bool, isMovable,,, const )
53 BRIDGE_HELPER( bool, isResizable,,, const )
54 BRIDGE_HELPER( QString, caption,,, const )
55 BRIDGE_HELPER( void, processMousePressEvent, QMouseEvent* e, e, )
56 BRIDGE_HELPER( QRect, geometry,,, const )
57 BRIDGE_HELPER( void, closeWindow,,, )
58 BRIDGE_HELPER( void, maximize, MaximizeMode m, m, )
59 BRIDGE_HELPER( void, minimize,,, )
60 BRIDGE_HELPER( void, showContextHelp,,, )
61 BRIDGE_HELPER( void, setDesktop, int desktop, desktop, )
63 void Bridge::setKeepAbove( bool set )
65 if( c->keepAbove() != set )
66 c->workspace()->performWindowOperation( c, KeepAboveOp );
69 void Bridge::setKeepBelow( bool set )
71 if( c->keepBelow() != set )
72 c->workspace()->performWindowOperation( c, KeepBelowOp );
75 NET::WindowType Bridge::windowType( unsigned long supported_types ) const
77 return c->windowType( false, supported_types );
80 QIcon Bridge::icon() const
82 QIcon ret( c->icon());
83 ret.addPixmap( c->miniIcon());
84 return ret;
87 bool Bridge::isSetShade() const
89 return c->shadeMode() != ShadeNone;
92 void Bridge::showWindowMenu( const QPoint &p )
94 c->workspace()->showWindowMenu( p, c );
97 void Bridge::showWindowMenu( const QRect &p )
99 c->workspace()->showWindowMenu( p, c );
102 void Bridge::performWindowOperation( WindowOperation op )
104 c->workspace()->performWindowOperation( c, op );
107 void Bridge::setMask( const QRegion& r, int mode )
109 c->setMask( r, mode );
112 bool Bridge::isPreview() const
114 return false;
117 QRect Bridge::iconGeometry() const
119 NETRect r = c->info->iconGeometry();
120 return QRect( r.pos.x, r.pos.y, r.size.width, r.size.height );
123 WId Bridge::windowId() const
125 return c->window();
128 void Bridge::titlebarDblClickOperation()
130 c->workspace()->performWindowOperation( c, options->operationTitlebarDblClick());
133 void Bridge::titlebarMouseWheelOperation( int delta )
135 c->performMouseCommand( options->operationTitlebarMouseWheel( delta ), cursorPos());
138 void Bridge::setShade( bool set )
140 c->setShade( set ? ShadeNormal : ShadeNone );
143 int Bridge::currentDesktop() const
145 return c->workspace()->currentDesktop();
148 QWidget* Bridge::initialParentWidget() const
150 return NULL;
153 Qt::WFlags Bridge::initialWFlags() const
155 return 0;
158 QRegion Bridge::unobscuredRegion( const QRegion& r ) const
160 QRegion reg( r );
161 const ClientList stacking_order = c->workspace()->stackingOrder();
162 int pos = stacking_order.indexOf( c );
163 ++pos;
164 for(; pos < stacking_order.count(); ++pos )
166 if( !stacking_order[pos]->isShown( true ))
167 continue; // these don't obscure the window
168 if( c->isOnAllDesktops())
170 if( !stacking_order[ pos ]->isOnCurrentDesktop())
171 continue;
173 else
175 if( !stacking_order[ pos ]->isOnDesktop( c->desktop()))
176 continue;
178 /* the clients all have their mask-regions in local coords
179 so we have to translate them to a shared coord system
180 we choose ours */
181 int dx = stacking_order[ pos ]->x() - c->x();
182 int dy = stacking_order[ pos ]->y() - c->y();
183 QRegion creg = stacking_order[ pos ]->mask();
184 creg.translate(dx, dy);
185 reg -= creg;
186 if (reg.isEmpty())
188 // early out, we are completely obscured
189 break;
192 return reg;
195 void Bridge::grabXServer( bool grab )
197 if( grab )
198 KWin::grabXServer();
199 else
200 KWin::ungrabXServer();
203 } // namespace