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