not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / kwin / bridge.cpp
blob412c398e43b6c0d3d4330f240ce932fa8d8049bd
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"
25 #include "effects.h"
27 #include <kconfiggroup.h>
29 namespace KWin
32 Bridge::Bridge( Client* cl )
33 : c( cl )
37 #define BRIDGE_HELPER( rettype, prototype, args1, args2, cst ) \
38 rettype Bridge::prototype ( args1 ) cst \
39 { \
40 return c->prototype( args2 ); \
43 BRIDGE_HELPER( bool, isActive,,, const )
44 BRIDGE_HELPER( bool, isCloseable,,, const )
45 BRIDGE_HELPER( bool, isMaximizable,,, const )
46 BRIDGE_HELPER( Bridge::MaximizeMode, maximizeMode,,, const )
47 BRIDGE_HELPER( bool, isMinimizable,,, const )
48 BRIDGE_HELPER( bool, providesContextHelp,,, const )
49 BRIDGE_HELPER( int, desktop,,, const )
50 BRIDGE_HELPER( bool, isModal,,, const )
51 BRIDGE_HELPER( bool, isShadeable,,, const )
52 BRIDGE_HELPER( bool, isShade,,, const )
53 BRIDGE_HELPER( bool, keepAbove,,, const )
54 BRIDGE_HELPER( bool, keepBelow,,, const )
55 BRIDGE_HELPER( bool, isMovable,,, const )
56 BRIDGE_HELPER( bool, isResizable,,, const )
57 BRIDGE_HELPER( QString, caption,,, const )
58 BRIDGE_HELPER( void, processMousePressEvent, QMouseEvent* e, e, )
59 BRIDGE_HELPER( QRect, geometry,,, const )
60 BRIDGE_HELPER( void, closeWindow,,, )
61 BRIDGE_HELPER( void, maximize, MaximizeMode m, m, )
62 BRIDGE_HELPER( void, minimize,,, )
63 BRIDGE_HELPER( void, showContextHelp,,, )
64 BRIDGE_HELPER( void, setDesktop, int desktop, desktop, )
66 void Bridge::setKeepAbove( bool set )
68 if( c->keepAbove() != set )
69 c->workspace()->performWindowOperation( c, KeepAboveOp );
72 void Bridge::setKeepBelow( bool set )
74 if( c->keepBelow() != set )
75 c->workspace()->performWindowOperation( c, KeepBelowOp );
78 NET::WindowType Bridge::windowType( unsigned long supported_types ) const
80 return c->windowType( false, supported_types );
83 QIcon Bridge::icon() const
85 QIcon ret( c->icon());
86 ret.addPixmap( c->miniIcon());
87 return ret;
90 bool Bridge::isSetShade() const
92 return c->shadeMode() != ShadeNone;
95 void Bridge::showWindowMenu( const QPoint &p )
97 c->workspace()->showWindowMenu( p, c );
100 void Bridge::showWindowMenu( const QRect &p )
102 c->workspace()->showWindowMenu( p, c );
105 void Bridge::performWindowOperation( WindowOperation op )
107 c->workspace()->performWindowOperation( c, op );
110 void Bridge::setMask( const QRegion& r, int mode )
112 c->setMask( r, mode );
115 bool Bridge::isPreview() const
117 return false;
120 QRect Bridge::iconGeometry() const
122 NETRect r = c->info->iconGeometry();
123 return QRect( r.pos.x, r.pos.y, r.size.width, r.size.height );
126 WId Bridge::windowId() const
128 return c->window();
131 void Bridge::titlebarDblClickOperation()
133 c->workspace()->performWindowOperation( c, options->operationTitlebarDblClick());
136 void Bridge::titlebarMouseWheelOperation( int delta )
138 c->performMouseCommand( options->operationTitlebarMouseWheel( delta ), cursorPos());
141 void Bridge::setShade( bool set )
143 c->setShade( set ? ShadeNormal : ShadeNone );
146 int Bridge::currentDesktop() const
148 return c->workspace()->currentDesktop();
151 QWidget* Bridge::initialParentWidget() const
153 return NULL;
156 Qt::WFlags Bridge::initialWFlags() const
158 return 0;
161 QRegion Bridge::unobscuredRegion( const QRegion& r ) const
163 QRegion reg( r );
164 const ClientList stacking_order = c->workspace()->stackingOrder();
165 int pos = stacking_order.indexOf( c );
166 ++pos;
167 for(; pos < stacking_order.count(); ++pos )
169 if( !stacking_order[pos]->isShown( true ))
170 continue; // these don't obscure the window
171 if( c->isOnAllDesktops())
173 if( !stacking_order[ pos ]->isOnCurrentDesktop())
174 continue;
176 else
178 if( !stacking_order[ pos ]->isOnDesktop( c->desktop()))
179 continue;
181 /* the clients all have their mask-regions in local coords
182 so we have to translate them to a shared coord system
183 we choose ours */
184 int dx = stacking_order[ pos ]->x() - c->x();
185 int dy = stacking_order[ pos ]->y() - c->y();
186 QRegion creg = stacking_order[ pos ]->mask();
187 creg.translate(dx, dy);
188 reg -= creg;
189 if (reg.isEmpty())
191 // early out, we are completely obscured
192 break;
195 return reg;
198 void Bridge::grabXServer( bool grab )
200 if( grab )
201 KWin::grabXServer();
202 else
203 KWin::ungrabXServer();
206 void Bridge::repaintShadow()
208 // TODO
211 bool Bridge::compositingActive() const
213 return c->workspace()->compositingActive();
216 bool Bridge::shadowsActive() const
218 if( !c->workspace()->compositingActive() )
219 return false;
220 if( effects && static_cast<EffectsHandlerImpl*>( effects )->isEffectLoaded( "kwin4_effect_shadow" ))
221 { // The shadow effect has a setting to disable decoration shadows, take it into account.
222 KConfigGroup conf = static_cast<EffectsHandlerImpl*>( effects )->effectConfig( "Shadow" );
223 return !conf.readEntry( "forceDecoratedToDefault", false );
225 return false;
228 double Bridge::opacity() const
230 return c->opacity();
234 } // namespace