Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / workspace / kwin / workspace.h
blob0fa62776ffe492985b473e6f939616403509aedf
1 /********************************************************************
2 KWin - the KDE window manager
3 This file is part of the KDE project.
5 Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
6 Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 *********************************************************************/
22 #ifndef KWIN_WORKSPACE_H
23 #define KWIN_WORKSPACE_H
25 #include <QTimer>
26 #include <QVector>
27 #include <kshortcut.h>
28 #include <QCursor>
29 #include <netwm.h>
30 #include <kxmessages.h>
31 #include <QDateTime>
32 #include <kmanagerselection.h>
34 #include "utils.h"
35 #include "kdecoration.h"
36 #include "sm.h"
38 #include <X11/Xlib.h>
40 class QMenu;
41 class KConfig;
42 class KActionCollection;
43 class KStartupInfo;
44 class KStartupInfoId;
45 class KStartupInfoData;
46 class QSlider;
47 class QPushButton;
49 namespace KWin
52 class Client;
53 class TabBox;
54 class PopupInfo;
55 class RootInfo;
56 class PluginMgr;
57 class Placement;
58 class Rules;
59 class WindowRules;
61 class Workspace : public QObject, public KDecorationDefines
63 Q_OBJECT
64 public:
65 Workspace( bool restore = false );
66 virtual ~Workspace();
68 static Workspace * self() { return _self; }
70 bool workspaceEvent( XEvent * );
71 bool workspaceEvent( QEvent * );
73 KDecoration* createDecoration( KDecorationBridge* bridge );
75 bool hasClient( const Client * );
77 template< typename T > Client* findClient( T predicate );
78 template< typename T1, typename T2 > void forEachClient( T1 procedure, T2 predicate );
79 template< typename T > void forEachClient( T procedure );
80 template< typename T > Unmanaged* findUnmanaged( T predicate );
81 template< typename T1, typename T2 > void forEachUnmanaged( T1 procedure, T2 predicate );
82 template< typename T > void forEachUnmanaged( T procedure );
84 QRect clientArea( clientAreaOption, const QPoint& p, int desktop ) const;
85 QRect clientArea( clientAreaOption, const Client* c ) const;
86 QRect clientArea( clientAreaOption, int screen, int desktop ) const;
88 /**
89 * @internal
91 void killWindowId( Window window);
93 void killWindow() { slotKillWindow(); }
95 bool initializing() const;
97 /**
98 * Returns the active client, i.e. the client that has the focus (or None
99 * if no client has the focus)
101 Client* activeClient() const;
102 // Client that was activated, but it's not yet really activeClient(), because
103 // we didn't process yet the matching FocusIn event. Used mostly in focus
104 // stealing prevention code.
105 Client* mostRecentlyActivatedClient() const;
107 void activateClient( Client*, bool force = false );
108 void requestFocus( Client* c, bool force = false );
109 void takeActivity( Client* c, int flags, bool handled ); // flags are ActivityFlags
110 void handleTakeActivity( Client* c, Time timestamp, int flags ); // flags are ActivityFlags
111 bool allowClientActivation( const Client* c, Time time = -1U, bool focus_in = false, bool ignore_desktop = false );
112 void restoreFocus();
113 void gotFocusIn( const Client* );
114 void setShouldGetFocus( Client* );
115 bool fakeRequestedActivity( Client* c );
116 void unfakeActivity( Client* c );
117 bool activateNextClient( Client* c );
118 bool focusChangeEnabled() { return block_focus == 0; }
120 void updateColormap();
123 * Indicates that the client c is being moved around by the user.
125 void setClientIsMoving( Client *c );
127 void place( Client *c, QRect& area );
128 void placeSmart( Client* c, const QRect& area );
130 QPoint adjustClientPosition( Client* c, QPoint pos );
131 QRect adjustClientSize( Client* c, QRect moveResizeGeom, int mode );
132 void raiseClient( Client* c );
133 void lowerClient( Client* c );
134 void raiseClientRequest( Client* c, NET::RequestSource src, Time timestamp );
135 void lowerClientRequest( Client* c, NET::RequestSource src, Time timestamp );
136 void restackClientUnderActive( Client* );
137 void updateClientLayer( Client* c );
138 void raiseOrLowerClient( Client * );
139 void restoreSessionStackingOrder( Client* c );
140 void restackUnmanaged( Unmanaged* c, Window above );
141 void reconfigure();
142 void forceRestacking();
144 void clientHidden( Client* );
145 void clientAttentionChanged( Client* c, bool set );
147 void checkElectricBorder(const QPoint &pos, Time time);
148 void reserveElectricBorder( ElectricBorder border );
149 void unreserveElectricBorder( ElectricBorder border );
150 void reserveElectricBorderSwitching( bool reserve );
153 * Returns the current virtual desktop of this workspace
155 int currentDesktop() const;
157 * Returns the number of virtual desktops of this workspace
159 int numberOfDesktops() const;
160 void setNumberOfDesktops( int n );
161 void calcDesktopLayout(int* x, int* y, Qt::Orientation* orientation) const;
162 int desktopToRight( int desktop, bool wrap ) const;
163 int desktopToLeft( int desktop, bool wrap ) const;
164 int desktopUp( int desktop, bool wrap ) const;
165 int desktopDown( int desktop, bool wrap ) const;
167 int activeScreen() const;
168 int numScreens() const;
169 void checkActiveScreen( const Client* c );
170 void setActiveScreenMouse( const QPoint &mousepos );
171 QRect screenGeometry( int screen ) const;
172 int screenNumber( const QPoint &pos ) const;
174 // for TabBox
175 Client* currentTabBoxClient() const;
176 ClientList currentTabBoxClientList() const;
177 int currentTabBoxDesktop() const;
178 QList< int > currentTabBoxDesktopList() const;
179 void setTabBoxClient(Client*);
180 void setTabBoxDesktop(int);
181 Client* nextClientFocusChain(Client*) const;
182 Client* previousClientFocusChain(Client*) const;
183 Client* nextClientStatic(Client*) const;
184 Client* previousClientStatic(Client*) const;
185 int nextDesktopFocusChain( int iDesktop ) const;
186 int previousDesktopFocusChain( int iDesktop ) const;
187 int nextDesktopStatic( int iDesktop ) const;
188 int previousDesktopStatic( int iDesktop ) const;
189 void refTabBox();
190 void unrefTabBox();
191 void closeTabBox();
194 * Returns the list of clients sorted in stacking order, with topmost client
195 * at the last position
197 const ClientList& stackingOrder() const;
199 ClientList ensureStackingOrder( const ClientList& clients ) const;
201 Client* topClientOnDesktop( int desktop, bool unconstrained = false, bool only_normal = true ) const;
202 Client* findDesktop( bool topmost, int desktop ) const;
203 void sendClientToDesktop( Client* c, int desktop, bool dont_activate );
204 void windowToPreviousDesktop( Client* c );
205 void windowToNextDesktop( Client* c );
206 void sendClientToScreen( Client* c, int screen );
208 // KDE4 remove me - and it's also in the DCOP interface :(
209 void showWindowMenuAt( unsigned long id, int x, int y );
211 void loadEffect( const QString& name );
212 void toggleEffect( const QString& name );
213 void reloadEffect( const QString& name );
215 void unloadEffect( const QString& name );
218 * Shows the menu operations menu for the client and makes it active if
219 * it's not already.
221 void showWindowMenu( const QRect &pos, Client* cl );
223 * Backwards compatibility.
225 void showWindowMenu( int x, int y, Client* cl );
226 void showWindowMenu( QPoint pos, Client* cl );
228 void updateMinimizedOfTransients( Client* );
229 void updateOnAllDesktopsOfTransients( Client* );
230 void checkTransients( Window w );
232 void performWindowOperation( Client* c, WindowOperation op );
234 void storeSession( KConfig* config, SMSavePhase phase );
236 SessionInfo* takeSessionInfo( Client* );
237 WindowRules findWindowRules( const Client*, bool );
238 void rulesUpdated();
239 void discardUsedWindowRules( Client* c, bool withdraw );
240 void disableRulesUpdates( bool disable );
241 bool rulesUpdatesDisabled() const;
243 // dcop interface
244 void cascadeDesktop();
245 void unclutterDesktop();
246 void doNotManage( const QString & );
247 bool setCurrentDesktop( int new_desktop );
248 void nextDesktop();
249 void previousDesktop();
250 void circulateDesktopApplications();
251 void setCurrentScreen( int new_screen );
253 QString desktopName( int desk ) const;
254 void updateDesktopLayout();
255 void setShowingDesktop( bool showing );
256 void resetShowingDesktop( bool keep_hidden );
257 bool showingDesktop() const;
259 bool isNotManaged( const QString& title ); // ### setter or getter ?
261 void sendPingToWindow( Window w, Time timestamp ); // called from Client::pingWindow()
262 void sendTakeActivity( Client* c, Time timestamp, long flags ); // called from Client::takeActivity()
264 void removeClient( Client*, allowed_t ); // only called from Client::destroyClient() or Client::releaseWindow()
265 void setActiveClient( Client*, allowed_t );
266 Group* findGroup( Window leader ) const;
267 void addGroup( Group* group, allowed_t );
268 void removeGroup( Group* group, allowed_t );
269 Group* findClientLeaderGroup( const Client* c ) const;
271 void removeUnmanaged( Unmanaged*, allowed_t ); // only called from Unmanaged::release()
272 void removeDeleted( Deleted*, allowed_t );
273 void addDeleted( Deleted*, allowed_t );
275 bool checkStartupNotification( Window w, KStartupInfoId& id, KStartupInfoData& data );
277 void focusToNull(); // SELI public?
278 enum FocusChainChange { FocusChainMakeFirst, FocusChainMakeLast, FocusChainUpdate };
279 void updateFocusChains( Client* c, FocusChainChange change );
281 bool forcedGlobalMouseGrab() const;
282 void clientShortcutUpdated( Client* c );
283 bool shortcutAvailable( const KShortcut& cut, Client* ignore = NULL ) const;
284 bool globalShortcutsDisabled() const;
285 void disableGlobalShortcuts( bool disable );
286 void disableGlobalShortcutsForClient( bool disable );
287 QPoint cursorPos() const;
289 void sessionSaveStarted();
290 void sessionSaveDone();
291 void setWasUserInteraction();
292 bool wasUserInteraction() const;
293 bool sessionSaving() const;
295 bool managingTopMenus() const;
296 int topMenuHeight() const;
297 void updateCurrentTopMenu();
299 int packPositionLeft( const Client* cl, int oldx, bool left_edge ) const;
300 int packPositionRight( const Client* cl, int oldx, bool right_edge ) const;
301 int packPositionUp( const Client* cl, int oldy, bool top_edge ) const;
302 int packPositionDown( const Client* cl, int oldy, bool bottom_edge ) const;
304 static QStringList configModules(bool controlCenter);
306 void cancelDelayFocus();
307 void requestDelayFocus( Client* );
308 void updateFocusMousePosition( const QPoint& pos );
309 QPoint focusMousePosition() const;
311 void toggleTopDockShadows(bool on);
313 // when adding repaints caused by a window, you probably want to use
314 // either Toplevel::addRepaint() or Toplevel::addWorkspaceRepaint()
315 void addRepaint( const QRect& r );
316 void addRepaint( int x, int y, int w, int h );
317 void addRepaintFull();
318 // creates XComposite overlay window, call initOverlay() afterwards
319 bool createOverlay();
320 // init overlay and the destination window in it
321 void setupOverlay( Window window );
322 // destroys XComposite overlay window
323 void destroyOverlay();
324 Window overlayWindow();
326 public slots:
327 void refresh();
328 // keybindings
329 void slotSwitchDesktopNext();
330 void slotSwitchDesktopPrevious();
331 void slotSwitchDesktopRight();
332 void slotSwitchDesktopLeft();
333 void slotSwitchDesktopUp();
334 void slotSwitchDesktopDown();
336 void slotSwitchToDesktop( int );
337 void slotSwitchToDesktop1() { return slotSwitchToDesktop( 1 ); }
338 void slotSwitchToDesktop2() { return slotSwitchToDesktop( 2 ); }
339 void slotSwitchToDesktop3() { return slotSwitchToDesktop( 3 ); }
340 void slotSwitchToDesktop4() { return slotSwitchToDesktop( 4 ); }
341 void slotSwitchToDesktop5() { return slotSwitchToDesktop( 5 ); }
342 void slotSwitchToDesktop6() { return slotSwitchToDesktop( 6 ); }
343 void slotSwitchToDesktop7() { return slotSwitchToDesktop( 7 ); }
344 void slotSwitchToDesktop8() { return slotSwitchToDesktop( 8 ); }
345 void slotSwitchToDesktop9() { return slotSwitchToDesktop( 9 ); }
346 void slotSwitchToDesktop10() { return slotSwitchToDesktop( 10 ); }
347 void slotSwitchToDesktop11() { return slotSwitchToDesktop( 11 ); }
348 void slotSwitchToDesktop12() { return slotSwitchToDesktop( 12 ); }
349 void slotSwitchToDesktop13() { return slotSwitchToDesktop( 13 ); }
350 void slotSwitchToDesktop14() { return slotSwitchToDesktop( 14 ); }
351 void slotSwitchToDesktop15() { return slotSwitchToDesktop( 15 ); }
352 void slotSwitchToDesktop16() { return slotSwitchToDesktop( 16 ); }
353 void slotSwitchToDesktop17() { return slotSwitchToDesktop( 17 ); }
354 void slotSwitchToDesktop18() { return slotSwitchToDesktop( 18 ); }
355 void slotSwitchToDesktop19() { return slotSwitchToDesktop( 19 ); }
356 void slotSwitchToDesktop20() { return slotSwitchToDesktop( 20 ); }
357 //void slotSwitchToWindow( int );
358 void slotWindowToDesktop( int );
359 void slotWindowToDesktop1() { return slotWindowToDesktop( 1 ); }
360 void slotWindowToDesktop2() { return slotWindowToDesktop( 2 ); }
361 void slotWindowToDesktop3() { return slotWindowToDesktop( 3 ); }
362 void slotWindowToDesktop4() { return slotWindowToDesktop( 4 ); }
363 void slotWindowToDesktop5() { return slotWindowToDesktop( 5 ); }
364 void slotWindowToDesktop6() { return slotWindowToDesktop( 6 ); }
365 void slotWindowToDesktop7() { return slotWindowToDesktop( 7 ); }
366 void slotWindowToDesktop8() { return slotWindowToDesktop( 8 ); }
367 void slotWindowToDesktop9() { return slotWindowToDesktop( 9 ); }
368 void slotWindowToDesktop10() { return slotWindowToDesktop( 10 ); }
369 void slotWindowToDesktop11() { return slotWindowToDesktop( 11 ); }
370 void slotWindowToDesktop12() { return slotWindowToDesktop( 12 ); }
371 void slotWindowToDesktop13() { return slotWindowToDesktop( 13 ); }
372 void slotWindowToDesktop14() { return slotWindowToDesktop( 14 ); }
373 void slotWindowToDesktop15() { return slotWindowToDesktop( 15 ); }
374 void slotWindowToDesktop16() { return slotWindowToDesktop( 16 ); }
375 void slotWindowToDesktop17() { return slotWindowToDesktop( 17 ); }
376 void slotWindowToDesktop18() { return slotWindowToDesktop( 18 ); }
377 void slotWindowToDesktop19() { return slotWindowToDesktop( 19 ); }
378 void slotWindowToDesktop20() { return slotWindowToDesktop( 20 ); }
379 //void slotWindowToListPosition( int );
380 void slotSwitchToScreen( int );
381 void slotSwitchToScreen0() { return slotSwitchToScreen( 0 ); }
382 void slotSwitchToScreen1() { return slotSwitchToScreen( 1 ); }
383 void slotSwitchToScreen2() { return slotSwitchToScreen( 2 ); }
384 void slotSwitchToScreen3() { return slotSwitchToScreen( 3 ); }
385 void slotSwitchToScreen4() { return slotSwitchToScreen( 4 ); }
386 void slotSwitchToScreen5() { return slotSwitchToScreen( 5 ); }
387 void slotSwitchToScreen6() { return slotSwitchToScreen( 6 ); }
388 void slotSwitchToScreen7() { return slotSwitchToScreen( 7 ); }
389 void slotWindowToScreen( int );
390 void slotWindowToScreen0() { return slotWindowToScreen( 0 ); }
391 void slotWindowToScreen1() { return slotWindowToScreen( 1 ); }
392 void slotWindowToScreen2() { return slotWindowToScreen( 2 ); }
393 void slotWindowToScreen3() { return slotWindowToScreen( 3 ); }
394 void slotWindowToScreen4() { return slotWindowToScreen( 4 ); }
395 void slotWindowToScreen5() { return slotWindowToScreen( 5 ); }
396 void slotWindowToScreen6() { return slotWindowToScreen( 6 ); }
397 void slotWindowToScreen7() { return slotWindowToScreen( 7 ); }
398 void slotSwitchToNextScreen();
399 void slotWindowToNextScreen();
401 void slotWindowMaximize();
402 void slotWindowMaximizeVertical();
403 void slotWindowMaximizeHorizontal();
404 void slotWindowMinimize();
405 void slotWindowShade();
406 void slotWindowRaise();
407 void slotWindowLower();
408 void slotWindowRaiseOrLower();
409 void slotActivateAttentionWindow();
410 void slotWindowPackLeft();
411 void slotWindowPackRight();
412 void slotWindowPackUp();
413 void slotWindowPackDown();
414 void slotWindowGrowHorizontal();
415 void slotWindowGrowVertical();
416 void slotWindowShrinkHorizontal();
417 void slotWindowShrinkVertical();
419 void slotWalkThroughDesktops();
420 void slotWalkBackThroughDesktops();
421 void slotWalkThroughDesktopList();
422 void slotWalkBackThroughDesktopList();
423 void slotWalkThroughWindows();
424 void slotWalkBackThroughWindows();
426 void slotWindowOperations();
427 void slotWindowClose();
428 void slotWindowMove();
429 void slotWindowResize();
430 void slotWindowAbove();
431 void slotWindowBelow();
432 void slotWindowOnAllDesktops();
433 void slotWindowFullScreen();
434 void slotWindowNoBorder();
436 void slotWindowToNextDesktop();
437 void slotWindowToPreviousDesktop();
438 void slotWindowToDesktopRight();
439 void slotWindowToDesktopLeft();
440 void slotWindowToDesktopUp();
441 void slotWindowToDesktopDown();
443 void slotMouseEmulation();
444 void slotDisableGlobalShortcuts();
446 void slotSettingsChanged( int category );
448 void slotReconfigure();
449 void slotReinitCompositing();
451 void slotKillWindow();
453 void slotGrabWindow();
454 void slotGrabDesktop();
456 void slotSetupWindowShortcut();
457 void setupWindowShortcutDone( bool );
459 void updateClientArea();
461 private slots:
462 void desktopPopupAboutToShow();
463 void clientPopupAboutToShow();
464 void slotSendToDesktop( QAction* );
465 void clientPopupActivated( QAction* );
466 void configureWM();
467 void desktopResized();
468 void slotUpdateToolWindows();
469 void lostTopMenuSelection();
470 void lostTopMenuOwner();
471 void delayFocus();
472 void gotTemporaryRulesMessage( const QString& );
473 void cleanupTemporaryRules();
474 void writeWindowRules();
475 void slotBlockShortcuts(int data);
476 void slotReloadConfig();
477 void setPopupClientOpacity( QAction* action );
478 void setupCompositing();
479 void performCompositing();
480 void lostCMSelection();
481 void updateElectricBorders();
482 void resetCursorPosTime();
484 protected:
485 bool keyPressMouseEmulation( XKeyEvent& ev );
487 private:
488 void init();
489 void initShortcuts();
490 void readShortcuts();
491 void initDesktopPopup();
492 void setupWindowShortcut( Client* c );
493 void checkCursorPos();
495 bool startKDEWalkThroughWindows();
496 bool startWalkThroughDesktops( TabBoxMode mode ); // TabBoxDesktopMode | TabBoxDesktopListMode
497 bool startWalkThroughDesktops();
498 bool startWalkThroughDesktopList();
499 void KDEWalkThroughWindows( bool forward );
500 void CDEWalkThroughWindows( bool forward );
501 void walkThroughDesktops( bool forward );
502 void KDEOneStepThroughWindows( bool forward );
503 void oneStepThroughDesktops( bool forward, TabBoxMode mode ); // TabBoxDesktopMode | TabBoxDesktopListMode
504 void oneStepThroughDesktops( bool forward );
505 void oneStepThroughDesktopList( bool forward );
506 bool establishTabBoxGrab();
507 void removeTabBoxGrab();
509 void updateStackingOrder( bool propagate_new_clients = false );
510 void propagateClients( bool propagate_new_clients ); // called only from updateStackingOrder
511 ClientList constrainedStackingOrder();
512 void raiseClientWithinApplication( Client* c );
513 void lowerClientWithinApplication( Client* c );
514 bool allowFullClientRaising( const Client* c, Time timestamp );
515 bool keepTransientAbove( const Client* mainwindow, const Client* transient );
516 void blockStackingUpdates( bool block );
517 void addTopMenu( Client* c );
518 void removeTopMenu( Client* c );
519 void setupTopMenuHandling();
520 void updateTopMenuGeometry( Client* c = NULL );
521 void updateToolWindows( bool also_hide );
523 // this is the right way to create a new client
524 Client* createClient( Window w, bool is_mapped );
525 void addClient( Client* c, allowed_t );
526 Unmanaged* createUnmanaged( Window w );
527 void addUnmanaged( Unmanaged* c, allowed_t );
529 Window findSpecialEventWindow( XEvent* e );
531 void randomPlacement(Client* c);
532 void smartPlacement(Client* c);
533 void cascadePlacement(Client* c, bool re_init = false);
535 // desktop names and number of desktops
536 void loadDesktopSettings();
537 void saveDesktopSettings();
539 // mouse emulation
540 WId getMouseEmulationWindow();
541 enum MouseEmulation { EmuPress, EmuRelease, EmuMove };
542 unsigned int sendFakedMouseEvent( const QPoint &pos, WId win, MouseEmulation type, int button, unsigned int state ); // returns the new state
544 void tabBoxKeyPress( int key );
545 void tabBoxKeyRelease( const XKeyEvent& ev );
547 // electric borders
548 void destroyElectricBorders();
549 bool electricBorderEvent(XEvent * e);
550 void electricBorderSwitchDesktop( ElectricBorder border, const QPoint& pos );
552 // ------------------
554 void helperDialog( const QString& message, const Client* c );
556 QMenu* clientPopup();
557 void closeActivePopup();
559 void updateClientArea( bool force );
561 void finishCompositing();
562 bool windowRepaintsPending() const;
564 int current_desktop;
565 int number_of_desktops;
566 QVector<int> desktop_focus_chain;
568 QWidget* active_popup;
569 Client* active_popup_client;
571 void loadSessionInfo();
572 void loadWindowRules();
573 void editWindowRules( Client* c, bool whole_app );
575 QList<SessionInfo*> session;
576 QList<Rules*> rules;
577 KXMessages temporaryRulesMessages;
578 QTimer rulesUpdatedTimer;
579 bool rules_updates_disabled;
580 static const char* windowTypeToTxt( NET::WindowType type );
581 static NET::WindowType txtToWindowType( const char* txt );
582 static bool sessionInfoWindowTypeMatch( Client* c, SessionInfo* info );
584 Client* active_client;
585 Client* last_active_client;
586 Client* most_recently_raised; // used _only_ by raiseOrLowerClient()
587 Client* movingClient;
588 Client* pending_take_activity;
589 int active_screen;
591 // delay(ed) window focus timer and client
592 QTimer* delayFocusTimer;
593 Client* delayfocus_client;
594 QPoint focusMousePos;
596 ClientList clients;
597 ClientList desktops;
598 UnmanagedList unmanaged;
599 DeletedList deleted;
601 ClientList unconstrained_stacking_order; // topmost last
602 ClientList stacking_order; // topmost last
603 UnmanagedList unmanaged_stacking_order;
604 bool force_restacking;
605 QVector< ClientList > focus_chain; // currently ative last
606 ClientList global_focus_chain; // this one is only for things like tabbox's MRU
607 ClientList should_get_focus; // last is most recent
608 ClientList attention_chain;
610 bool showing_desktop;
611 ClientList showing_desktop_clients;
612 int block_showing_desktop;
614 GroupList groups;
616 bool was_user_interaction;
617 bool session_saving;
618 int session_active_client;
619 int session_desktop;
621 bool control_grab;
622 bool tab_grab;
623 //KKeyNative walkThroughDesktopsKeycode, walkBackThroughDesktopsKeycode;
624 //KKeyNative walkThroughDesktopListKeycode, walkBackThroughDesktopListKeycode;
625 //KKeyNative walkThroughWindowsKeycode, walkBackThroughWindowsKeycode;
626 KShortcut cutWalkThroughDesktops, cutWalkThroughDesktopsReverse;
627 KShortcut cutWalkThroughDesktopList, cutWalkThroughDesktopListReverse;
628 KShortcut cutWalkThroughWindows, cutWalkThroughWindowsReverse;
629 bool mouse_emulation;
630 unsigned int mouse_emulation_state;
631 WId mouse_emulation_window;
632 int block_focus;
634 TabBox* tab_box;
635 PopupInfo* popupinfo;
637 QMenu *popup;
638 QMenu *advanced_popup;
639 QMenu *trans_popup;
640 QMenu *desk_popup;
642 void modalActionsSwitch( bool enabled );
644 KActionCollection *keys;
645 KActionCollection *client_keys;
646 QAction *mResizeOpAction;
647 QAction *mMoveOpAction;
648 QAction *mMaximizeOpAction;
649 QAction *mShadeOpAction;
650 QAction *mKeepAboveOpAction;
651 QAction *mKeepBelowOpAction;
652 QAction *mFullScreenOpAction;
653 QAction *mNoBorderOpAction;
654 QAction *mMinimizeOpAction;
655 QAction *mCloseOpAction;
656 ShortcutDialog* client_keys_dialog;
657 Client* client_keys_client;
658 KActionCollection *disable_shortcuts_keys;
659 bool global_shortcuts_disabled;
660 bool global_shortcuts_disabled_for_client;
662 PluginMgr *mgr;
664 RootInfo *rootInfo;
665 QWidget* supportWindow;
667 // swallowing
668 QStringList doNotManageList;
670 // colormap handling
671 Colormap default_colormap;
672 Colormap installed_colormap;
674 // Timer to collect requests for 'reconfigure'
675 QTimer reconfigureTimer;
677 QTimer updateToolWindowsTimer;
679 static Workspace *_self;
681 bool workspaceInit;
683 KStartupInfo* startup;
685 ElectricBorder electric_current_border;
686 Window electric_windows[ ELECTRIC_COUNT ];
687 int electricLeft;
688 int electricRight;
689 int electricTop;
690 int electricBottom;
691 Time electric_time_first;
692 Time electric_time_last;
693 QPoint electric_push_point;
694 int electric_reserved[ ELECTRIC_COUNT ]; // corners/edges used by something
696 Qt::Orientation layoutOrientation;
697 int layoutX;
698 int layoutY;
700 Placement *initPositioning;
702 QRect* workarea; // array of workareas for virtual desktops
703 QRect** screenarea; // array of workareas per xinerama screen for all virtual desktops
705 bool managing_topmenus;
706 KSelectionOwner* topmenu_selection;
707 KSelectionWatcher* topmenu_watcher;
708 ClientList topmenus; // doesn't own them
709 mutable int topmenu_height;
710 QWidget* topmenu_space;
712 int set_active_client_recursion;
713 int block_stacking_updates; // when >0, stacking updates are temporarily disabled
714 bool blocked_propagating_new_clients; // propagate also new clients after enabling stacking updates?
715 Window null_focus_window;
716 bool forced_global_mouse_grab;
717 friend class StackingUpdatesBlocker;
719 KSelectionOwner* cm_selection;
720 QTimer compositeTimer;
721 QTime lastCompositePaint;
722 int compositeRate;
723 QRegion repaints_region;
724 Window overlay; // XComposite overlay window
725 bool overlay_visible;
726 QSlider *transSlider;
727 QPushButton *transButton;
729 private:
730 friend bool performTransiencyCheck();
733 // helper for Workspace::blockStackingUpdates() being called in pairs (true/false)
734 class StackingUpdatesBlocker
736 public:
737 StackingUpdatesBlocker( Workspace* w )
738 : ws( w ) { ws->blockStackingUpdates( true ); }
739 ~StackingUpdatesBlocker()
740 { ws->blockStackingUpdates( false ); }
741 private:
742 Workspace* ws;
745 // NET WM Protocol handler class
746 class RootInfo : public NETRootInfo
748 private:
749 typedef KWin::Client Client; // because of NET::Client
750 public:
751 RootInfo( Workspace* ws, Display *dpy, Window w, const char *name, unsigned long pr[], int pr_num, int scr= -1);
752 protected:
753 virtual void changeNumberOfDesktops(int n);
754 virtual void changeCurrentDesktop(int d);
755 virtual void changeActiveWindow(Window w,NET::RequestSource src, Time timestamp, Window active_window);
756 virtual void closeWindow(Window w);
757 virtual void moveResize(Window w, int x_root, int y_root, unsigned long direction);
758 virtual void moveResizeWindow(Window w, int flags, int x, int y, int width, int height );
759 virtual void gotPing(Window w, Time timestamp);
760 virtual void restackWindow(Window w, RequestSource source, Window above, int detail, Time timestamp);
761 virtual void gotTakeActivity(Window w, Time timestamp, long flags );
762 virtual void changeShowingDesktop( bool showing );
763 private:
764 Workspace* workspace;
768 inline bool Workspace::initializing() const
770 return workspaceInit;
773 inline Client* Workspace::activeClient() const
775 return active_client;
778 inline Client* Workspace::mostRecentlyActivatedClient() const
780 return should_get_focus.count() > 0 ? should_get_focus.last() : active_client;
783 inline int Workspace::currentDesktop() const
785 return current_desktop;
788 inline int Workspace::numberOfDesktops() const
790 return number_of_desktops;
793 inline void Workspace::addGroup( Group* group, allowed_t )
795 groups.append( group );
798 inline void Workspace::removeGroup( Group* group, allowed_t )
800 groups.removeAll( group );
803 inline const ClientList& Workspace::stackingOrder() const
805 // TODO Q_ASSERT( block_stacking_updates == 0 );
806 return stacking_order;
809 inline void Workspace::showWindowMenu(QPoint pos, Client* cl)
811 showWindowMenu(QRect(pos, pos), cl);
814 inline void Workspace::showWindowMenu(int x, int y, Client* cl)
816 showWindowMenu(QRect(QPoint(x, y), QPoint(x, y)), cl);
819 inline
820 void Workspace::setWasUserInteraction()
822 was_user_interaction = true;
825 inline
826 bool Workspace::wasUserInteraction() const
828 return was_user_interaction;
831 inline
832 bool Workspace::managingTopMenus() const
834 return managing_topmenus;
837 inline void Workspace::sessionSaveStarted()
839 session_saving = true;
842 inline void Workspace::sessionSaveDone()
844 session_saving = false;
847 inline bool Workspace::sessionSaving() const
849 return session_saving;
852 inline bool Workspace::forcedGlobalMouseGrab() const
854 return forced_global_mouse_grab;
857 inline bool Workspace::showingDesktop() const
859 return showing_desktop;
862 inline bool Workspace::globalShortcutsDisabled() const
864 return global_shortcuts_disabled || global_shortcuts_disabled_for_client;
867 inline Window Workspace::overlayWindow()
869 return overlay;
872 inline
873 bool Workspace::rulesUpdatesDisabled() const
875 return rules_updates_disabled;
878 inline
879 void Workspace::forceRestacking()
881 force_restacking = true;
882 StackingUpdatesBlocker blocker( this ); // do restacking if not blocked
885 inline
886 void Workspace::updateFocusMousePosition( const QPoint& pos )
888 focusMousePos = pos;
891 inline
892 QPoint Workspace::focusMousePosition() const
894 return focusMousePos;
897 template< typename T >
898 inline Client* Workspace::findClient( T predicate )
900 if( Client* ret = findClientInList( clients, predicate ))
901 return ret;
902 if( Client* ret = findClientInList( desktops, predicate ))
903 return ret;
904 return NULL;
907 template< typename T1, typename T2 >
908 inline void Workspace::forEachClient( T1 procedure, T2 predicate )
910 for ( ClientList::ConstIterator it = clients.begin(); it != clients.end(); ++it)
911 if ( predicate( const_cast< const Client* >( *it)))
912 procedure( *it );
913 for ( ClientList::ConstIterator it = desktops.begin(); it != desktops.end(); ++it)
914 if ( predicate( const_cast< const Client* >( *it)))
915 procedure( *it );
918 template< typename T >
919 inline void Workspace::forEachClient( T procedure )
921 return forEachClient( procedure, TruePredicate());
924 template< typename T >
925 inline Unmanaged* Workspace::findUnmanaged( T predicate )
927 return findUnmanagedInList( unmanaged, predicate );
930 template< typename T1, typename T2 >
931 inline void Workspace::forEachUnmanaged( T1 procedure, T2 predicate )
933 for ( UnmanagedList::ConstIterator it = unmanaged.begin(); it != unmanaged.end(); ++it)
934 if ( predicate( const_cast< const Unmanaged* >( *it)))
935 procedure( *it );
938 template< typename T >
939 inline void Workspace::forEachUnmanaged( T procedure )
941 return forEachUnmanaged( procedure, TruePredicate());
944 KWIN_COMPARE_PREDICATE( ClientMatchPredicate, Client, const Client*, cl == value );
945 inline bool Workspace::hasClient( const Client* c )
947 return findClient( ClientMatchPredicate( c ));
950 } // namespace
952 #endif