00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef KWIN_WORKSPACE_H
00023 #define KWIN_WORKSPACE_H
00024
00025 #include <QTimer>
00026 #include <QVector>
00027 #include <kshortcut.h>
00028 #include <QCursor>
00029 #include <netwm.h>
00030 #include <kxmessages.h>
00031 #include <QDateTime>
00032 #include <kmanagerselection.h>
00033
00034 #include "utils.h"
00035 #include "kdecoration.h"
00036 #include "sm.h"
00037
00038 #include <X11/Xlib.h>
00039
00040 class QMenu;
00041 class KConfig;
00042 class KActionCollection;
00043 class KStartupInfo;
00044 class KStartupInfoId;
00045 class KStartupInfoData;
00046 class QSlider;
00047 class QPushButton;
00048
00049 namespace KWin
00050 {
00051
00052 class Client;
00053 class TabBox;
00054 class PopupInfo;
00055 class RootInfo;
00056 class PluginMgr;
00057 class Placement;
00058 class Rules;
00059 class WindowRules;
00060
00061 class Workspace : public QObject, public KDecorationDefines
00062 {
00063 Q_OBJECT
00064 public:
00065 Workspace( bool restore = false );
00066 virtual ~Workspace();
00067
00068 static Workspace * self() { return _self; }
00069
00070 bool workspaceEvent( XEvent * );
00071 bool workspaceEvent( QEvent * );
00072
00073 KDecoration* createDecoration( KDecorationBridge* bridge );
00074
00075 bool hasClient( const Client * );
00076
00077 template< typename T > Client* findClient( T predicate ) const;
00078 template< typename T1, typename T2 > void forEachClient( T1 procedure, T2 predicate );
00079 template< typename T > void forEachClient( T procedure );
00080 template< typename T > Unmanaged* findUnmanaged( T predicate ) const;
00081 template< typename T1, typename T2 > void forEachUnmanaged( T1 procedure, T2 predicate );
00082 template< typename T > void forEachUnmanaged( T procedure );
00083
00084 QRect clientArea( clientAreaOption, const QPoint& p, int desktop ) const;
00085 QRect clientArea( clientAreaOption, const Client* c ) const;
00086 QRect clientArea( clientAreaOption, int screen, int desktop ) const;
00087
00091 void killWindowId( Window window);
00092
00093 void killWindow() { slotKillWindow(); }
00094
00095 bool initializing() const;
00096
00101 Client* activeClient() const;
00102
00103
00104
00105 Client* mostRecentlyActivatedClient() const;
00106
00107 void activateClient( Client*, bool force = false );
00108 void requestFocus( Client* c, bool force = false );
00109 void takeActivity( Client* c, int flags, bool handled );
00110 void handleTakeActivity( Client* c, Time timestamp, int flags );
00111 bool allowClientActivation( const Client* c, Time time = -1U, bool focus_in = false, bool ignore_desktop = false );
00112 void restoreFocus();
00113 void gotFocusIn( const Client* );
00114 void setShouldGetFocus( Client* );
00115 bool fakeRequestedActivity( Client* c );
00116 void unfakeActivity( Client* c );
00117 bool activateNextClient( Client* c );
00118 bool focusChangeEnabled() { return block_focus == 0; }
00119
00120 void updateColormap();
00121
00125 void setClientIsMoving( Client *c );
00126
00127 void place( Client *c, QRect& area );
00128 void placeSmart( Client* c, const QRect& area );
00129
00130 QPoint adjustClientPosition( Client* c, QPoint pos );
00131 QRect adjustClientSize( Client* c, QRect moveResizeGeom, int mode );
00132 void raiseClient( Client* c, bool nogroup = false );
00133 void lowerClient( Client* c, bool nogroup = false );
00134 void raiseClientRequest( Client* c, NET::RequestSource src, Time timestamp );
00135 void lowerClientRequest( Client* c, NET::RequestSource src, Time timestamp );
00136 void restackClientUnderActive( Client* );
00137 void updateClientLayer( Client* c );
00138 void raiseOrLowerClient( Client * );
00139 void restoreSessionStackingOrder( Client* c );
00140 void reconfigure();
00141 void forceRestacking();
00142
00143 void clientHidden( Client* );
00144 void clientAttentionChanged( Client* c, bool set );
00145
00146 void checkElectricBorder(const QPoint &pos, Time time);
00147 void reserveElectricBorder( ElectricBorder border );
00148 void unreserveElectricBorder( ElectricBorder border );
00149 void reserveElectricBorderSwitching( bool reserve );
00150
00154 int currentDesktop() const;
00158 int numberOfDesktops() const;
00159 void setNumberOfDesktops( int n );
00160 void calcDesktopLayout(int* x, int* y, Qt::Orientation* orientation) const;
00161 int desktopToRight( int desktop, bool wrap ) const;
00162 int desktopToLeft( int desktop, bool wrap ) const;
00163 int desktopUp( int desktop, bool wrap ) const;
00164 int desktopDown( int desktop, bool wrap ) const;
00165
00166 int activeScreen() const;
00167 int numScreens() const;
00168 void checkActiveScreen( const Client* c );
00169 void setActiveScreenMouse( const QPoint &mousepos );
00170 QRect screenGeometry( int screen ) const;
00171 int screenNumber( const QPoint &pos ) const;
00172
00173
00174 Client* currentTabBoxClient() const;
00175 ClientList currentTabBoxClientList() const;
00176 int currentTabBoxDesktop() const;
00177 QList< int > currentTabBoxDesktopList() const;
00178 void setTabBoxClient(Client*);
00179 void setTabBoxDesktop(int);
00180 Client* nextClientFocusChain(Client*) const;
00181 Client* previousClientFocusChain(Client*) const;
00182 Client* nextClientStatic(Client*) const;
00183 Client* previousClientStatic(Client*) const;
00184 int nextDesktopFocusChain( int iDesktop ) const;
00185 int previousDesktopFocusChain( int iDesktop ) const;
00186 int nextDesktopStatic( int iDesktop ) const;
00187 int previousDesktopStatic( int iDesktop ) const;
00188 void refTabBox();
00189 void unrefTabBox();
00190 void closeTabBox();
00191
00196 const ClientList& stackingOrder() const;
00197
00198 ClientList ensureStackingOrder( const ClientList& clients ) const;
00199
00200 Client* topClientOnDesktop( int desktop, bool unconstrained = false, bool only_normal = true ) const;
00201 Client* findDesktop( bool topmost, int desktop ) const;
00202 void sendClientToDesktop( Client* c, int desktop, bool dont_activate );
00203 void windowToPreviousDesktop( Client* c );
00204 void windowToNextDesktop( Client* c );
00205 void sendClientToScreen( Client* c, int screen );
00206
00207
00208 void showWindowMenuAt( unsigned long id, int x, int y );
00209
00210 void loadEffect( const QString& name );
00211 void toggleEffect( const QString& name );
00212 void reloadEffect( const QString& name );
00213
00214 void unloadEffect( const QString& name );
00215
00216 QStringList loadedEffects() const;
00217 QStringList listOfEffects() const;
00218
00219
00224 void showWindowMenu( const QRect &pos, Client* cl );
00228 void showWindowMenu( int x, int y, Client* cl );
00229 void showWindowMenu( QPoint pos, Client* cl );
00230
00231 void updateMinimizedOfTransients( Client* );
00232 void updateOnAllDesktopsOfTransients( Client* );
00233 void checkTransients( Window w );
00234
00235 void performWindowOperation( Client* c, WindowOperation op );
00236
00237 void storeSession( KConfig* config, SMSavePhase phase );
00238
00239 SessionInfo* takeSessionInfo( Client* );
00240 WindowRules findWindowRules( const Client*, bool );
00241 void rulesUpdated();
00242 void discardUsedWindowRules( Client* c, bool withdraw );
00243 void disableRulesUpdates( bool disable );
00244 bool rulesUpdatesDisabled() const;
00245
00246
00247 void cascadeDesktop();
00248 void unclutterDesktop();
00249 void doNotManage( const QString & );
00250 QList< int > decorationSupportedColors() const;
00251 bool setCurrentDesktop( int new_desktop );
00252 void nextDesktop();
00253 void previousDesktop();
00254 void circulateDesktopApplications();
00255 void setCurrentScreen( int new_screen );
00256
00257 QString desktopName( int desk ) const;
00258 void updateDesktopLayout();
00259 void setShowingDesktop( bool showing );
00260 void resetShowingDesktop( bool keep_hidden );
00261 bool showingDesktop() const;
00262
00263 bool isNotManaged( const QString& title );
00264
00265 void sendPingToWindow( Window w, Time timestamp );
00266 void sendTakeActivity( Client* c, Time timestamp, long flags );
00267
00268 void removeClient( Client*, allowed_t );
00269 void setActiveClient( Client*, allowed_t );
00270 Group* findGroup( Window leader ) const;
00271 void addGroup( Group* group, allowed_t );
00272 void removeGroup( Group* group, allowed_t );
00273 Group* findClientLeaderGroup( const Client* c ) const;
00274
00275 void removeUnmanaged( Unmanaged*, allowed_t );
00276 void removeDeleted( Deleted*, allowed_t );
00277 void addDeleted( Deleted*, allowed_t );
00278
00279 bool checkStartupNotification( Window w, KStartupInfoId& id, KStartupInfoData& data );
00280
00281 void focusToNull();
00282 enum FocusChainChange { FocusChainMakeFirst, FocusChainMakeLast, FocusChainUpdate };
00283 void updateFocusChains( Client* c, FocusChainChange change );
00284
00285 bool forcedGlobalMouseGrab() const;
00286 void clientShortcutUpdated( Client* c );
00287 bool shortcutAvailable( const KShortcut& cut, Client* ignore = NULL ) const;
00288 bool globalShortcutsDisabled() const;
00289 void disableGlobalShortcuts( bool disable );
00290 void disableGlobalShortcutsForClient( bool disable );
00291 QPoint cursorPos() const;
00292
00293 void sessionSaveStarted();
00294 void sessionSaveDone();
00295 void setWasUserInteraction();
00296 bool wasUserInteraction() const;
00297 bool sessionSaving() const;
00298
00299 bool managingTopMenus() const;
00300 int topMenuHeight() const;
00301 void updateCurrentTopMenu();
00302
00303 int packPositionLeft( const Client* cl, int oldx, bool left_edge ) const;
00304 int packPositionRight( const Client* cl, int oldx, bool right_edge ) const;
00305 int packPositionUp( const Client* cl, int oldy, bool top_edge ) const;
00306 int packPositionDown( const Client* cl, int oldy, bool bottom_edge ) const;
00307
00308 static QStringList configModules(bool controlCenter);
00309
00310 void cancelDelayFocus();
00311 void requestDelayFocus( Client* );
00312 void updateFocusMousePosition( const QPoint& pos );
00313 QPoint focusMousePosition() const;
00314
00315 void toggleTopDockShadows(bool on);
00316
00317
00318
00319 void addRepaint( const QRect& r );
00320 void addRepaint( const QRegion& r );
00321 void addRepaint( int x, int y, int w, int h );
00322
00323 bool createOverlay();
00324
00325 void setupOverlay( Window window );
00326 void showOverlay();
00327
00328 void destroyOverlay();
00329 Window overlayWindow();
00330
00331 public slots:
00332 void addRepaintFull();
00333 void refresh();
00334
00335 void slotSwitchDesktopNext();
00336 void slotSwitchDesktopPrevious();
00337 void slotSwitchDesktopRight();
00338 void slotSwitchDesktopLeft();
00339 void slotSwitchDesktopUp();
00340 void slotSwitchDesktopDown();
00341
00342 void slotSwitchToDesktop( int );
00343 void slotSwitchToDesktop1() { return slotSwitchToDesktop( 1 ); }
00344 void slotSwitchToDesktop2() { return slotSwitchToDesktop( 2 ); }
00345 void slotSwitchToDesktop3() { return slotSwitchToDesktop( 3 ); }
00346 void slotSwitchToDesktop4() { return slotSwitchToDesktop( 4 ); }
00347 void slotSwitchToDesktop5() { return slotSwitchToDesktop( 5 ); }
00348 void slotSwitchToDesktop6() { return slotSwitchToDesktop( 6 ); }
00349 void slotSwitchToDesktop7() { return slotSwitchToDesktop( 7 ); }
00350 void slotSwitchToDesktop8() { return slotSwitchToDesktop( 8 ); }
00351 void slotSwitchToDesktop9() { return slotSwitchToDesktop( 9 ); }
00352 void slotSwitchToDesktop10() { return slotSwitchToDesktop( 10 ); }
00353 void slotSwitchToDesktop11() { return slotSwitchToDesktop( 11 ); }
00354 void slotSwitchToDesktop12() { return slotSwitchToDesktop( 12 ); }
00355 void slotSwitchToDesktop13() { return slotSwitchToDesktop( 13 ); }
00356 void slotSwitchToDesktop14() { return slotSwitchToDesktop( 14 ); }
00357 void slotSwitchToDesktop15() { return slotSwitchToDesktop( 15 ); }
00358 void slotSwitchToDesktop16() { return slotSwitchToDesktop( 16 ); }
00359 void slotSwitchToDesktop17() { return slotSwitchToDesktop( 17 ); }
00360 void slotSwitchToDesktop18() { return slotSwitchToDesktop( 18 ); }
00361 void slotSwitchToDesktop19() { return slotSwitchToDesktop( 19 ); }
00362 void slotSwitchToDesktop20() { return slotSwitchToDesktop( 20 ); }
00363
00364 void slotWindowToDesktop( int );
00365 void slotWindowToDesktop1() { return slotWindowToDesktop( 1 ); }
00366 void slotWindowToDesktop2() { return slotWindowToDesktop( 2 ); }
00367 void slotWindowToDesktop3() { return slotWindowToDesktop( 3 ); }
00368 void slotWindowToDesktop4() { return slotWindowToDesktop( 4 ); }
00369 void slotWindowToDesktop5() { return slotWindowToDesktop( 5 ); }
00370 void slotWindowToDesktop6() { return slotWindowToDesktop( 6 ); }
00371 void slotWindowToDesktop7() { return slotWindowToDesktop( 7 ); }
00372 void slotWindowToDesktop8() { return slotWindowToDesktop( 8 ); }
00373 void slotWindowToDesktop9() { return slotWindowToDesktop( 9 ); }
00374 void slotWindowToDesktop10() { return slotWindowToDesktop( 10 ); }
00375 void slotWindowToDesktop11() { return slotWindowToDesktop( 11 ); }
00376 void slotWindowToDesktop12() { return slotWindowToDesktop( 12 ); }
00377 void slotWindowToDesktop13() { return slotWindowToDesktop( 13 ); }
00378 void slotWindowToDesktop14() { return slotWindowToDesktop( 14 ); }
00379 void slotWindowToDesktop15() { return slotWindowToDesktop( 15 ); }
00380 void slotWindowToDesktop16() { return slotWindowToDesktop( 16 ); }
00381 void slotWindowToDesktop17() { return slotWindowToDesktop( 17 ); }
00382 void slotWindowToDesktop18() { return slotWindowToDesktop( 18 ); }
00383 void slotWindowToDesktop19() { return slotWindowToDesktop( 19 ); }
00384 void slotWindowToDesktop20() { return slotWindowToDesktop( 20 ); }
00385
00386 void slotSwitchToScreen( int );
00387 void slotSwitchToScreen0() { return slotSwitchToScreen( 0 ); }
00388 void slotSwitchToScreen1() { return slotSwitchToScreen( 1 ); }
00389 void slotSwitchToScreen2() { return slotSwitchToScreen( 2 ); }
00390 void slotSwitchToScreen3() { return slotSwitchToScreen( 3 ); }
00391 void slotSwitchToScreen4() { return slotSwitchToScreen( 4 ); }
00392 void slotSwitchToScreen5() { return slotSwitchToScreen( 5 ); }
00393 void slotSwitchToScreen6() { return slotSwitchToScreen( 6 ); }
00394 void slotSwitchToScreen7() { return slotSwitchToScreen( 7 ); }
00395 void slotWindowToScreen( int );
00396 void slotWindowToScreen0() { return slotWindowToScreen( 0 ); }
00397 void slotWindowToScreen1() { return slotWindowToScreen( 1 ); }
00398 void slotWindowToScreen2() { return slotWindowToScreen( 2 ); }
00399 void slotWindowToScreen3() { return slotWindowToScreen( 3 ); }
00400 void slotWindowToScreen4() { return slotWindowToScreen( 4 ); }
00401 void slotWindowToScreen5() { return slotWindowToScreen( 5 ); }
00402 void slotWindowToScreen6() { return slotWindowToScreen( 6 ); }
00403 void slotWindowToScreen7() { return slotWindowToScreen( 7 ); }
00404 void slotSwitchToNextScreen();
00405 void slotWindowToNextScreen();
00406
00407 void slotWindowMaximize();
00408 void slotWindowMaximizeVertical();
00409 void slotWindowMaximizeHorizontal();
00410 void slotWindowMinimize();
00411 void slotWindowShade();
00412 void slotWindowRaise();
00413 void slotWindowLower();
00414 void slotWindowRaiseOrLower();
00415 void slotActivateAttentionWindow();
00416 void slotWindowPackLeft();
00417 void slotWindowPackRight();
00418 void slotWindowPackUp();
00419 void slotWindowPackDown();
00420 void slotWindowGrowHorizontal();
00421 void slotWindowGrowVertical();
00422 void slotWindowShrinkHorizontal();
00423 void slotWindowShrinkVertical();
00424
00425 void slotWalkThroughDesktops();
00426 void slotWalkBackThroughDesktops();
00427 void slotWalkThroughDesktopList();
00428 void slotWalkBackThroughDesktopList();
00429 void slotWalkThroughWindows();
00430 void slotWalkBackThroughWindows();
00431
00432 void slotWindowOperations();
00433 void slotWindowClose();
00434 void slotWindowMove();
00435 void slotWindowResize();
00436 void slotWindowAbove();
00437 void slotWindowBelow();
00438 void slotWindowOnAllDesktops();
00439 void slotWindowFullScreen();
00440 void slotWindowNoBorder();
00441
00442 void slotWindowToNextDesktop();
00443 void slotWindowToPreviousDesktop();
00444 void slotWindowToDesktopRight();
00445 void slotWindowToDesktopLeft();
00446 void slotWindowToDesktopUp();
00447 void slotWindowToDesktopDown();
00448
00449 void slotMouseEmulation();
00450 void slotDisableGlobalShortcuts();
00451
00452 void slotSettingsChanged( int category );
00453
00454 void slotReconfigure();
00455 void slotReinitCompositing();
00456
00457 void slotKillWindow();
00458
00459 void slotGrabWindow();
00460 void slotGrabDesktop();
00461
00462 void slotSetupWindowShortcut();
00463 void setupWindowShortcutDone( bool );
00464 void slotToggleCompositing();
00465
00466 void updateClientArea();
00467
00468 private slots:
00469 void desktopPopupAboutToShow();
00470 void clientPopupAboutToShow();
00471 void slotSendToDesktop( QAction* );
00472 void clientPopupActivated( QAction* );
00473 void configureWM();
00474 void desktopResized();
00475 void slotUpdateToolWindows();
00476 void lostTopMenuSelection();
00477 void lostTopMenuOwner();
00478 void delayFocus();
00479 void gotTemporaryRulesMessage( const QString& );
00480 void cleanupTemporaryRules();
00481 void writeWindowRules();
00482 void slotBlockShortcuts(int data);
00483 void slotReloadConfig();
00484 void setPopupClientOpacity( QAction* action );
00485 void setupCompositing();
00486 void performCompositing();
00487 void lostCMSelection();
00488 void updateElectricBorders();
00489 void resetCursorPosTime();
00490
00491 protected:
00492 bool keyPressMouseEmulation( XKeyEvent& ev );
00493
00494 private:
00495 void init();
00496 void initShortcuts();
00497 void readShortcuts();
00498 void initDesktopPopup();
00499 void setupWindowShortcut( Client* c );
00500 void checkCursorPos();
00501
00502 bool startKDEWalkThroughWindows();
00503 bool startWalkThroughDesktops( TabBoxMode mode );
00504 bool startWalkThroughDesktops();
00505 bool startWalkThroughDesktopList();
00506 void KDEWalkThroughWindows( bool forward );
00507 void CDEWalkThroughWindows( bool forward );
00508 void walkThroughDesktops( bool forward );
00509 void KDEOneStepThroughWindows( bool forward );
00510 void oneStepThroughDesktops( bool forward, TabBoxMode mode );
00511 void oneStepThroughDesktops( bool forward );
00512 void oneStepThroughDesktopList( bool forward );
00513 bool establishTabBoxGrab();
00514 void removeTabBoxGrab();
00515
00516 void updateStackingOrder( bool propagate_new_clients = false );
00517 ToplevelList compositingStackingOrder() const;
00518 void propagateClients( bool propagate_new_clients );
00519 ClientList constrainedStackingOrder();
00520 void raiseClientWithinApplication( Client* c );
00521 void lowerClientWithinApplication( Client* c );
00522 bool allowFullClientRaising( const Client* c, Time timestamp );
00523 bool keepTransientAbove( const Client* mainwindow, const Client* transient );
00524 void blockStackingUpdates( bool block );
00525 void addTopMenu( Client* c );
00526 void removeTopMenu( Client* c );
00527 void setupTopMenuHandling();
00528 void updateTopMenuGeometry( Client* c = NULL );
00529 void updateToolWindows( bool also_hide );
00530
00531
00532 Client* createClient( Window w, bool is_mapped );
00533 void addClient( Client* c, allowed_t );
00534 Unmanaged* createUnmanaged( Window w );
00535 void addUnmanaged( Unmanaged* c, allowed_t );
00536
00537 Window findSpecialEventWindow( XEvent* e );
00538
00539 void randomPlacement(Client* c);
00540 void smartPlacement(Client* c);
00541 void cascadePlacement(Client* c, bool re_init = false);
00542
00543
00544 void loadDesktopSettings();
00545 void saveDesktopSettings();
00546
00547
00548 WId getMouseEmulationWindow();
00549 enum MouseEmulation { EmuPress, EmuRelease, EmuMove };
00550 unsigned int sendFakedMouseEvent( const QPoint &pos, WId win, MouseEmulation type, int button, unsigned int state );
00551
00552 void tabBoxKeyPress( int key );
00553 void tabBoxKeyRelease( const XKeyEvent& ev );
00554
00555
00556 void destroyElectricBorders();
00557 bool electricBorderEvent(XEvent * e);
00558 void electricBorderSwitchDesktop( ElectricBorder border, const QPoint& pos );
00559
00560
00561
00562 void helperDialog( const QString& message, const Client* c );
00563
00564 QMenu* clientPopup();
00565 void closeActivePopup();
00566
00567 void updateClientArea( bool force );
00568
00569 void finishCompositing();
00570 bool windowRepaintsPending() const;
00571
00572 int current_desktop;
00573 int number_of_desktops;
00574 QVector<int> desktop_focus_chain;
00575
00576 QWidget* active_popup;
00577 Client* active_popup_client;
00578
00579 void loadSessionInfo();
00580 void loadWindowRules();
00581 void editWindowRules( Client* c, bool whole_app );
00582
00583 QList<SessionInfo*> session;
00584 QList<Rules*> rules;
00585 KXMessages temporaryRulesMessages;
00586 QTimer rulesUpdatedTimer;
00587 bool rules_updates_disabled;
00588 static const char* windowTypeToTxt( NET::WindowType type );
00589 static NET::WindowType txtToWindowType( const char* txt );
00590 static bool sessionInfoWindowTypeMatch( Client* c, SessionInfo* info );
00591
00592 Client* active_client;
00593 Client* last_active_client;
00594 Client* most_recently_raised;
00595 Client* movingClient;
00596 Client* pending_take_activity;
00597 int active_screen;
00598
00599
00600 QTimer* delayFocusTimer;
00601 Client* delayfocus_client;
00602 QPoint focusMousePos;
00603
00604 ClientList clients;
00605 ClientList desktops;
00606 UnmanagedList unmanaged;
00607 DeletedList deleted;
00608
00609 ClientList unconstrained_stacking_order;
00610 ClientList stacking_order;
00611 bool force_restacking;
00612 QVector< ClientList > focus_chain;
00613 ClientList global_focus_chain;
00614 ClientList should_get_focus;
00615 ClientList attention_chain;
00616
00617 bool showing_desktop;
00618 ClientList showing_desktop_clients;
00619 int block_showing_desktop;
00620
00621 GroupList groups;
00622
00623 bool was_user_interaction;
00624 bool session_saving;
00625 int session_active_client;
00626 int session_desktop;
00627
00628 bool control_grab;
00629 bool tab_grab;
00630
00631
00632
00633 KShortcut cutWalkThroughDesktops, cutWalkThroughDesktopsReverse;
00634 KShortcut cutWalkThroughDesktopList, cutWalkThroughDesktopListReverse;
00635 KShortcut cutWalkThroughWindows, cutWalkThroughWindowsReverse;
00636 bool mouse_emulation;
00637 unsigned int mouse_emulation_state;
00638 WId mouse_emulation_window;
00639 int block_focus;
00640
00641 TabBox* tab_box;
00642 PopupInfo* popupinfo;
00643
00644 QMenu *popup;
00645 QMenu *advanced_popup;
00646 QMenu *trans_popup;
00647 QMenu *desk_popup;
00648
00649 void modalActionsSwitch( bool enabled );
00650
00651 KActionCollection *keys;
00652 KActionCollection *client_keys;
00653 QAction *mResizeOpAction;
00654 QAction *mMoveOpAction;
00655 QAction *mMaximizeOpAction;
00656 QAction *mShadeOpAction;
00657 QAction *mKeepAboveOpAction;
00658 QAction *mKeepBelowOpAction;
00659 QAction *mFullScreenOpAction;
00660 QAction *mNoBorderOpAction;
00661 QAction *mMinimizeOpAction;
00662 QAction *mCloseOpAction;
00663 ShortcutDialog* client_keys_dialog;
00664 Client* client_keys_client;
00665 KActionCollection *disable_shortcuts_keys;
00666 bool global_shortcuts_disabled;
00667 bool global_shortcuts_disabled_for_client;
00668
00669 PluginMgr *mgr;
00670
00671 RootInfo *rootInfo;
00672 QWidget* supportWindow;
00673
00674
00675 QStringList doNotManageList;
00676
00677
00678 Colormap default_colormap;
00679 Colormap installed_colormap;
00680
00681
00682 QTimer reconfigureTimer;
00683
00684 QTimer updateToolWindowsTimer;
00685
00686 static Workspace *_self;
00687
00688 bool workspaceInit;
00689
00690 KStartupInfo* startup;
00691
00692 ElectricBorder electric_current_border;
00693 Window electric_windows[ ELECTRIC_COUNT ];
00694 int electricLeft;
00695 int electricRight;
00696 int electricTop;
00697 int electricBottom;
00698 Time electric_time_first;
00699 Time electric_time_last;
00700 QPoint electric_push_point;
00701 int electric_reserved[ ELECTRIC_COUNT ];
00702
00703 Qt::Orientation layoutOrientation;
00704 int layoutX;
00705 int layoutY;
00706
00707 Placement *initPositioning;
00708
00709 QVector< QRect > workarea;
00710 QVector< QVector< QRect > > screenarea;
00711
00712 bool managing_topmenus;
00713 KSelectionOwner* topmenu_selection;
00714 KSelectionWatcher* topmenu_watcher;
00715 ClientList topmenus;
00716 mutable int topmenu_height;
00717 QWidget* topmenu_space;
00718
00719 int set_active_client_recursion;
00720 int block_stacking_updates;
00721 bool blocked_propagating_new_clients;
00722 Window null_focus_window;
00723 bool forced_global_mouse_grab;
00724 friend class StackingUpdatesBlocker;
00725
00726 KSelectionOwner* cm_selection;
00727 bool compositingSuspended;
00728 QTimer compositeTimer;
00729 QTime lastCompositePaint;
00730 int compositeRate;
00731 QRegion repaints_region;
00732 Window overlay;
00733 bool overlay_visible;
00734 bool overlay_shown;
00735 QSlider *transSlider;
00736 QPushButton *transButton;
00737
00738 private:
00739 friend bool performTransiencyCheck();
00740 };
00741
00742
00743 class StackingUpdatesBlocker
00744 {
00745 public:
00746 StackingUpdatesBlocker( Workspace* w )
00747 : ws( w ) { ws->blockStackingUpdates( true ); }
00748 ~StackingUpdatesBlocker()
00749 { ws->blockStackingUpdates( false ); }
00750 private:
00751 Workspace* ws;
00752 };
00753
00754
00755 class RootInfo : public NETRootInfo
00756 {
00757 private:
00758 typedef KWin::Client Client;
00759 public:
00760 RootInfo( Workspace* ws, Display *dpy, Window w, const char *name, unsigned long pr[], int pr_num, int scr= -1);
00761 protected:
00762 virtual void changeNumberOfDesktops(int n);
00763 virtual void changeCurrentDesktop(int d);
00764 virtual void changeActiveWindow(Window w,NET::RequestSource src, Time timestamp, Window active_window);
00765 virtual void closeWindow(Window w);
00766 virtual void moveResize(Window w, int x_root, int y_root, unsigned long direction);
00767 virtual void moveResizeWindow(Window w, int flags, int x, int y, int width, int height );
00768 virtual void gotPing(Window w, Time timestamp);
00769 virtual void restackWindow(Window w, RequestSource source, Window above, int detail, Time timestamp);
00770 virtual void gotTakeActivity(Window w, Time timestamp, long flags );
00771 virtual void changeShowingDesktop( bool showing );
00772 private:
00773 Workspace* workspace;
00774 };
00775
00776
00777 inline bool Workspace::initializing() const
00778 {
00779 return workspaceInit;
00780 }
00781
00782 inline Client* Workspace::activeClient() const
00783 {
00784 return active_client;
00785 }
00786
00787 inline Client* Workspace::mostRecentlyActivatedClient() const
00788 {
00789 return should_get_focus.count() > 0 ? should_get_focus.last() : active_client;
00790 }
00791
00792 inline int Workspace::currentDesktop() const
00793 {
00794 return current_desktop;
00795 }
00796
00797 inline int Workspace::numberOfDesktops() const
00798 {
00799 return number_of_desktops;
00800 }
00801
00802 inline void Workspace::addGroup( Group* group, allowed_t )
00803 {
00804 groups.append( group );
00805 }
00806
00807 inline void Workspace::removeGroup( Group* group, allowed_t )
00808 {
00809 groups.removeAll( group );
00810 }
00811
00812 inline const ClientList& Workspace::stackingOrder() const
00813 {
00814
00815 return stacking_order;
00816 }
00817
00818 inline void Workspace::showWindowMenu(QPoint pos, Client* cl)
00819 {
00820 showWindowMenu(QRect(pos, pos), cl);
00821 }
00822
00823 inline void Workspace::showWindowMenu(int x, int y, Client* cl)
00824 {
00825 showWindowMenu(QRect(QPoint(x, y), QPoint(x, y)), cl);
00826 }
00827
00828 inline
00829 void Workspace::setWasUserInteraction()
00830 {
00831 was_user_interaction = true;
00832 }
00833
00834 inline
00835 bool Workspace::wasUserInteraction() const
00836 {
00837 return was_user_interaction;
00838 }
00839
00840 inline
00841 bool Workspace::managingTopMenus() const
00842 {
00843 return managing_topmenus;
00844 }
00845
00846 inline void Workspace::sessionSaveStarted()
00847 {
00848 session_saving = true;
00849 }
00850
00851 inline void Workspace::sessionSaveDone()
00852 {
00853 session_saving = false;
00854 }
00855
00856 inline bool Workspace::sessionSaving() const
00857 {
00858 return session_saving;
00859 }
00860
00861 inline bool Workspace::forcedGlobalMouseGrab() const
00862 {
00863 return forced_global_mouse_grab;
00864 }
00865
00866 inline bool Workspace::showingDesktop() const
00867 {
00868 return showing_desktop;
00869 }
00870
00871 inline bool Workspace::globalShortcutsDisabled() const
00872 {
00873 return global_shortcuts_disabled || global_shortcuts_disabled_for_client;
00874 }
00875
00876 inline Window Workspace::overlayWindow()
00877 {
00878 return overlay;
00879 }
00880
00881 inline
00882 bool Workspace::rulesUpdatesDisabled() const
00883 {
00884 return rules_updates_disabled;
00885 }
00886
00887 inline
00888 void Workspace::forceRestacking()
00889 {
00890 force_restacking = true;
00891 StackingUpdatesBlocker blocker( this );
00892 }
00893
00894 inline
00895 void Workspace::updateFocusMousePosition( const QPoint& pos )
00896 {
00897 focusMousePos = pos;
00898 }
00899
00900 inline
00901 QPoint Workspace::focusMousePosition() const
00902 {
00903 return focusMousePos;
00904 }
00905
00906 template< typename T >
00907 inline Client* Workspace::findClient( T predicate ) const
00908 {
00909 if( Client* ret = findClientInList( clients, predicate ))
00910 return ret;
00911 if( Client* ret = findClientInList( desktops, predicate ))
00912 return ret;
00913 return NULL;
00914 }
00915
00916 template< typename T1, typename T2 >
00917 inline void Workspace::forEachClient( T1 procedure, T2 predicate )
00918 {
00919 for ( ClientList::ConstIterator it = clients.begin(); it != clients.end(); ++it)
00920 if ( predicate( const_cast< const Client* >( *it)))
00921 procedure( *it );
00922 for ( ClientList::ConstIterator it = desktops.begin(); it != desktops.end(); ++it)
00923 if ( predicate( const_cast< const Client* >( *it)))
00924 procedure( *it );
00925 }
00926
00927 template< typename T >
00928 inline void Workspace::forEachClient( T procedure )
00929 {
00930 return forEachClient( procedure, TruePredicate());
00931 }
00932
00933 template< typename T >
00934 inline Unmanaged* Workspace::findUnmanaged( T predicate ) const
00935 {
00936 return findUnmanagedInList( unmanaged, predicate );
00937 }
00938
00939 template< typename T1, typename T2 >
00940 inline void Workspace::forEachUnmanaged( T1 procedure, T2 predicate )
00941 {
00942 for ( UnmanagedList::ConstIterator it = unmanaged.begin(); it != unmanaged.end(); ++it)
00943 if ( predicate( const_cast< const Unmanaged* >( *it)))
00944 procedure( *it );
00945 }
00946
00947 template< typename T >
00948 inline void Workspace::forEachUnmanaged( T procedure )
00949 {
00950 return forEachUnmanaged( procedure, TruePredicate());
00951 }
00952
00953 KWIN_COMPARE_PREDICATE( ClientMatchPredicate, Client, const Client*, cl == value );
00954 inline bool Workspace::hasClient( const Client* c )
00955 {
00956 return findClient( ClientMatchPredicate( c ));
00957 }
00958
00959 }
00960
00961 #endif