workspace.h

00001 /*****************************************************************
00002  KWin - the KDE window manager
00003  This file is part of the KDE project.
00004 
00005 Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
00006 Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
00007 
00008 You can Freely distribute this program under the GNU General Public
00009 License. See the file "COPYING" for the exact licensing terms.
00010 ******************************************************************/
00011 
00012 #ifndef KWIN_WORKSPACE_H
00013 #define KWIN_WORKSPACE_H
00014 
00015 #include <qtimer.h>
00016 #include <qvaluevector.h>
00017 #include <kshortcut.h>
00018 #include <qcursor.h>
00019 #include <netwm.h>
00020 #include <kxmessages.h>
00021 
00022 #include "KWinInterface.h"
00023 #include "utils.h"
00024 #include "kdecoration.h"
00025 #include "sm.h"
00026 
00027 #include <X11/Xlib.h>
00028 
00029 class QPopupMenu;
00030 class KConfig;
00031 class KGlobalAccel;
00032 class KShortcutDialog;
00033 class KStartupInfo;
00034 class KStartupInfoId;
00035 class KStartupInfoData;
00036 class QSlider;
00037 class QPushButton;
00038 class KProcess;
00039 
00040 namespace KWinInternal
00041 {
00042 
00043 class Client;
00044 class TabBox;
00045 class PopupInfo;
00046 class RootInfo;
00047 class PluginMgr;
00048 class Placement;
00049 class Rules;
00050 class WindowRules;
00051 
00052 class SystemTrayWindow
00053     {
00054     public:
00055         SystemTrayWindow()
00056             : win(0),winFor(0)
00057             {}
00058         SystemTrayWindow( WId w )
00059             : win(w),winFor(0)
00060             {}
00061         SystemTrayWindow( WId w, WId wf  )
00062             : win(w),winFor(wf)
00063             {}
00064 
00065         bool operator==( const SystemTrayWindow& other )
00066             { return win == other.win; }
00067         WId win;
00068         WId winFor;
00069     };
00070 
00071 typedef QValueList<SystemTrayWindow> SystemTrayWindowList;
00072 
00073 class Workspace : public QObject, public KWinInterface, public KDecorationDefines
00074     {
00075     Q_OBJECT
00076     public:
00077         Workspace( bool restore = FALSE );
00078         virtual ~Workspace();
00079 
00080         static Workspace * self() { return _self; }
00081 
00082         bool workspaceEvent( XEvent * );
00083 
00084         KDecoration* createDecoration( KDecorationBridge* bridge );
00085 
00086         bool hasClient( const Client * );
00087 
00088         template< typename T > Client* findClient( T predicate );
00089         template< typename T1, typename T2 > void forEachClient( T1 procedure, T2 predicate );
00090         template< typename T > void forEachClient( T procedure );
00091 
00092         QRect clientArea( clientAreaOption, const QPoint& p, int desktop ) const;
00093         QRect clientArea( clientAreaOption, const Client* c ) const;
00094 
00098         void killWindowId( Window window);
00099 
00100         void killWindow() { slotKillWindow(); }
00101 
00102         WId rootWin() const;
00103 
00104         bool initializing() const;
00105 
00110         Client* activeClient() const;
00111         // Client that was activated, but it's not yet really activeClient(), because
00112         // we didn't process yet the matching FocusIn event. Used mostly in focus
00113         // stealing prevention code.
00114         Client* mostRecentlyActivatedClient() const;
00115 
00116         void activateClient( Client*, bool force = FALSE  );
00117         void requestFocus( Client* c, bool force = FALSE );
00118         void takeActivity( Client* c, int flags, bool handled ); // flags are ActivityFlags
00119         void handleTakeActivity( Client* c, Time timestamp, int flags ); // flags are ActivityFlags
00120         bool allowClientActivation( const Client* c, Time time = -1U, bool focus_in = false );
00121         void restoreFocus();
00122         void gotFocusIn( const Client* );
00123         void setShouldGetFocus( Client* );
00124         bool fakeRequestedActivity( Client* c );
00125         void unfakeActivity( Client* c );
00126         bool activateNextClient( Client* c );
00127         bool focusChangeEnabled() { 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 );
00140         QRect adjustClientSize( Client* c, QRect moveResizeGeom, int mode );
00141         void raiseClient( Client* c );
00142         void lowerClient( Client* c );
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 reconfigure();
00149 
00150         void clientHidden( Client*  );
00151         void clientAttentionChanged( Client* c, bool set );
00152 
00153         void clientMoved(const QPoint &pos, Time time);
00154 
00158         int currentDesktop() const;
00162         int numberOfDesktops() const;
00163         void setNumberOfDesktops( int n );
00164 
00165         QWidget* desktopWidget();
00166 
00167     // for TabBox
00168         Client* nextFocusChainClient(Client*) const;
00169         Client* previousFocusChainClient(Client*) const;
00170         Client* nextStaticClient(Client*) const;
00171         Client* previousStaticClient(Client*) const;
00172         int nextDesktopFocusChain( int iDesktop ) const;
00173         int previousDesktopFocusChain( int iDesktop ) const;
00174         void closeTabBox();
00175 
00180         const ClientList& stackingOrder() const;
00181 
00182         ClientList ensureStackingOrder( const ClientList& clients ) const;
00183 
00184         Client* topClientOnDesktop( int desktop, bool unconstrained = false, bool only_normal = true ) const;
00185         Client* findDesktop( bool topmost, int desktop ) const;
00186         void sendClientToDesktop( Client* c, int desktop, bool dont_activate );
00187         void windowToPreviousDesktop( Client* c );
00188         void windowToNextDesktop( Client* c );
00189 
00190     // KDE4 remove me - and it's also in the DCOP interface :(
00191         void showWindowMenuAt( unsigned long id, int x, int y );
00192 
00197         void showWindowMenu( const QRect &pos, Client* cl );
00201         void showWindowMenu( int x, int y, Client* cl );
00202         void showWindowMenu( QPoint pos, Client* cl );
00203 
00204         void updateMinimizedOfTransients( Client* );
00205         void updateOnAllDesktopsOfTransients( Client* );
00206         void checkTransients( Window w );
00207 
00208         void performWindowOperation( Client* c, WindowOperation op );
00209 
00210         void storeSession( KConfig* config, SMSavePhase phase );
00211 
00212         SessionInfo* takeSessionInfo( Client* );
00213         WindowRules findWindowRules( const Client*, bool );
00214         void rulesUpdated();
00215         void discardUsedWindowRules( Client* c, bool withdraw );
00216 
00217     // dcop interface
00218         void cascadeDesktop();
00219         void unclutterDesktop();
00220         void doNotManage(QString);
00221         bool setCurrentDesktop( int new_desktop );
00222         void nextDesktop();
00223         void previousDesktop();
00224         void circulateDesktopApplications();
00225 
00226         QString desktopName( int desk ) const;
00227         void setDesktopLayout(int o, int x, int y);
00228         void setShowingDesktop( bool showing );
00229         void resetShowingDesktop( bool keep_hidden );
00230         bool showingDesktop() const;
00231 
00232         bool isNotManaged( const QString& title );  // ### setter or getter ?
00233 
00234         void sendPingToWindow( Window w, Time timestamp ); // called from Client::pingWindow()
00235         void sendTakeActivity( Client* c, Time timestamp, long flags ); // called from Client::takeActivity()
00236         
00237         bool kompmgrIsRunning();
00238         void setOpacity(unsigned long winId, unsigned int opacityPercent);
00239         void setShadowSize(unsigned long winId, unsigned int shadowSizePercent);
00240         void setUnshadowed(unsigned long winId); // redundant, equals setShadowSize(inId, 0)
00241 
00242     // only called from Client::destroyClient() or Client::releaseWindow()
00243         void removeClient( Client*, allowed_t );
00244         void setActiveClient( Client*, allowed_t );
00245         Group* findGroup( Window leader ) const;
00246         void addGroup( Group* group, allowed_t );
00247         void removeGroup( Group* group, allowed_t );
00248         Group* findClientLeaderGroup( const Client* c ) const;
00249 
00250         bool checkStartupNotification( Window w, KStartupInfoId& id, KStartupInfoData& data );
00251 
00252         void focusToNull(); // SELI public?
00253         enum FocusChainChange { FocusChainMakeFirst, FocusChainMakeLast, FocusChainUpdate };
00254         void updateFocusChains( Client* c, FocusChainChange change );
00255         
00256         bool forcedGlobalMouseGrab() const;
00257         void clientShortcutUpdated( Client* c );
00258         bool shortcutAvailable( const KShortcut& cut, Client* ignore = NULL ) const;
00259         bool globalShortcutsDisabled() const;
00260         void disableGlobalShortcuts( bool disable );
00261         void disableGlobalShortcutsForClient( bool disable );
00262 
00263         void sessionSaveStarted();
00264         void sessionSaveDone();
00265         void setWasUserInteraction();
00266         bool wasUserInteraction() const;
00267         bool sessionSaving() const;
00268 
00269         bool managingTopMenus() const;
00270         int topMenuHeight() const;
00271         void updateCurrentTopMenu();
00272 
00273         int packPositionLeft( const Client* cl, int oldx, bool left_edge ) const;
00274         int packPositionRight( const Client* cl, int oldx, bool right_edge ) const;
00275         int packPositionUp( const Client* cl, int oldy, bool top_edge ) const;
00276         int packPositionDown( const Client* cl, int oldy, bool bottom_edge ) const;
00277 
00278         static QStringList configModules(bool controlCenter);
00279 
00280         void cancelDelayFocus();
00281         void requestDelayFocus( Client* );
00282         
00283         void toggleTopDockShadows(bool on);
00284 
00285     public slots:
00286         void refresh();
00287     // keybindings
00288         void slotSwitchDesktopNext();
00289         void slotSwitchDesktopPrevious();
00290         void slotSwitchDesktopRight();
00291         void slotSwitchDesktopLeft();
00292         void slotSwitchDesktopUp();
00293         void slotSwitchDesktopDown();
00294 
00295         void slotSwitchToDesktop( int );
00296     //void slotSwitchToWindow( int );
00297         void slotWindowToDesktop( int );
00298     //void slotWindowToListPosition( int );
00299 
00300         void slotWindowMaximize();
00301         void slotWindowMaximizeVertical();
00302         void slotWindowMaximizeHorizontal();
00303         void slotWindowMinimize();
00304         void slotWindowShade();
00305         void slotWindowRaise();
00306         void slotWindowLower();
00307         void slotWindowRaiseOrLower();
00308         void slotActivateAttentionWindow();
00309         void slotWindowPackLeft();
00310         void slotWindowPackRight();
00311         void slotWindowPackUp();
00312         void slotWindowPackDown();
00313         void slotWindowGrowHorizontal();
00314         void slotWindowGrowVertical();
00315         void slotWindowShrinkHorizontal();
00316         void slotWindowShrinkVertical();
00317 
00318         void slotWalkThroughDesktops();
00319         void slotWalkBackThroughDesktops();
00320         void slotWalkThroughDesktopList();
00321         void slotWalkBackThroughDesktopList();
00322         void slotWalkThroughWindows();
00323         void slotWalkBackThroughWindows();
00324 
00325         void slotWindowOperations();
00326         void slotWindowClose();
00327         void slotWindowMove();
00328         void slotWindowResize();
00329         void slotWindowAbove();
00330         void slotWindowBelow();
00331         void slotWindowOnAllDesktops();
00332         void slotWindowFullScreen();
00333         void slotWindowNoBorder();
00334 
00335         void slotWindowToNextDesktop();
00336         void slotWindowToPreviousDesktop();
00337         void slotWindowToDesktopRight();
00338         void slotWindowToDesktopLeft();
00339         void slotWindowToDesktopUp();
00340         void slotWindowToDesktopDown();
00341 
00342         void slotMouseEmulation();
00343         void slotDisableGlobalShortcuts();
00344 
00345         void slotSettingsChanged( int category );
00346 
00347         void slotReconfigure();
00348 
00349         void slotKillWindow();
00350 
00351         void slotGrabWindow();
00352         void slotGrabDesktop();
00353 
00354         void slotSetupWindowShortcut();
00355         void setupWindowShortcutDone( bool );
00356 
00357         void updateClientArea();
00358         
00359         // kompmgr, also dcop
00360         void startKompmgr();
00361 
00362     private slots:
00363         void desktopPopupAboutToShow();
00364         void clientPopupAboutToShow();
00365         void slotSendToDesktop( int );
00366         void clientPopupActivated( int );
00367         void configureWM();
00368         void desktopResized();
00369         void slotUpdateToolWindows();
00370         void lostTopMenuSelection();
00371         void lostTopMenuOwner();
00372         void delayFocus();
00373         void gotTemporaryRulesMessage( const QString& );
00374         void cleanupTemporaryRules();
00375         void writeWindowRules();
00376         void kipcMessage( int id, int data );
00377         // kompmgr
00378         void setPopupClientOpacity(int v);
00379         void resetClientOpacity();
00380         void setTransButtonText(int value);
00381         void unblockKompmgrRestart();
00382         void restartKompmgr();
00383         void handleKompmgrOutput( KProcess *proc, char *buffer, int buflen);
00384         void stopKompmgr();
00385         // end 
00386 
00387     protected:
00388         bool keyPressMouseEmulation( XKeyEvent& ev );
00389         bool netCheck( XEvent* e );
00390 
00391     private:
00392         void init();
00393         void initShortcuts();
00394         void readShortcuts();
00395         void initDesktopPopup();
00396         void setupWindowShortcut( Client* c );
00397 
00398         bool startKDEWalkThroughWindows();
00399         bool startWalkThroughDesktops( int mode ); // TabBox::Mode::DesktopMode | DesktopListMode
00400         bool startWalkThroughDesktops();
00401         bool startWalkThroughDesktopList();
00402         void KDEWalkThroughWindows( bool forward );
00403         void CDEWalkThroughWindows( bool forward );
00404         void walkThroughDesktops( bool forward );
00405         void KDEOneStepThroughWindows( bool forward );
00406         void oneStepThroughDesktops( bool forward, int mode ); // TabBox::Mode::DesktopMode | DesktopListMode
00407         void oneStepThroughDesktops( bool forward );
00408         void oneStepThroughDesktopList( bool forward );
00409         bool establishTabBoxGrab();
00410         void removeTabBoxGrab();
00411         int desktopToRight( int desktop ) const;
00412         int desktopToLeft( int desktop ) const;
00413         int desktopUp( int desktop ) const;
00414         int desktopDown( int desktop ) const;
00415 
00416         void updateStackingOrder( bool propagate_new_clients = false );
00417         void propagateClients( bool propagate_new_clients ); // called only from updateStackingOrder
00418         ClientList constrainedStackingOrder();
00419         void raiseClientWithinApplication( Client* c );
00420         void lowerClientWithinApplication( Client* c );
00421         bool allowFullClientRaising( const Client* c, Time timestamp );
00422         bool keepTransientAbove( const Client* mainwindow, const Client* transient );
00423         void blockStackingUpdates( bool block );
00424         void addTopMenu( Client* c );
00425         void removeTopMenu( Client* c );
00426         void setupTopMenuHandling();
00427         void updateTopMenuGeometry( Client* c = NULL );
00428         void updateToolWindows( bool also_hide );
00429 
00430     // this is the right way to create a new client
00431         Client* createClient( Window w, bool is_mapped );
00432         void addClient( Client* c, allowed_t );
00433 
00434         Window findSpecialEventWindow( XEvent* e );
00435 
00436         void randomPlacement(Client* c);
00437         void smartPlacement(Client* c);
00438         void cascadePlacement(Client* c, bool re_init = false);
00439 
00440         bool addSystemTrayWin( WId w );
00441         bool removeSystemTrayWin( WId w, bool check );
00442         void propagateSystemTrayWins();
00443         SystemTrayWindow findSystemTrayWin( WId w );
00444 
00445     // desktop names and number of desktops
00446         void loadDesktopSettings();
00447         void saveDesktopSettings();
00448 
00449     // mouse emulation
00450         WId getMouseEmulationWindow();
00451         enum MouseEmulation { EmuPress, EmuRelease, EmuMove };
00452         unsigned int sendFakedMouseEvent( QPoint pos, WId win, MouseEmulation type, int button, unsigned int state ); // returns the new state
00453 
00454         void tabBoxKeyPress( const KKeyNative& keyX );
00455         void tabBoxKeyRelease( const XKeyEvent& ev );
00456 
00457     // electric borders
00458         void checkElectricBorders( bool force = false );
00459         void createBorderWindows();
00460         void destroyBorderWindows();
00461         bool electricBorder(XEvent * e);
00462         void raiseElectricBorders();
00463 
00464     // ------------------
00465     
00466         void helperDialog( const QString& message, const Client* c );
00467 
00468         void calcDesktopLayout(int &x, int &y) const;
00469 
00470         QPopupMenu* clientPopup();
00471         void closeActivePopup();
00472 
00473         void updateClientArea( bool force );
00474 
00475         SystemTrayWindowList systemTrayWins;
00476 
00477         int current_desktop;
00478         int number_of_desktops;
00479         QMemArray<int> desktop_focus_chain;
00480 
00481         QWidget* active_popup;
00482         Client* active_popup_client;
00483 
00484         QWidget* desktop_widget;
00485 
00486         void loadSessionInfo();
00487         void loadWindowRules();
00488         void editWindowRules( Client* c, bool whole_app );
00489 
00490         QPtrList<SessionInfo> session;
00491         QValueList<Rules*> rules;
00492         KXMessages temporaryRulesMessages;
00493         QTimer rulesUpdatedTimer;
00494         static const char* windowTypeToTxt( NET::WindowType type );
00495         static NET::WindowType txtToWindowType( const char* txt );
00496         static bool sessionInfoWindowTypeMatch( Client* c, SessionInfo* info );
00497 
00498         Client* active_client;
00499         Client* last_active_client;
00500         Client* most_recently_raised; // used _only_ by raiseOrLowerClient()
00501         Client* movingClient;
00502         Client* pending_take_activity;
00503 
00504     // delay(ed) window focus timer and client
00505         QTimer* delayFocusTimer;
00506         Client* delayfocus_client;
00507 
00508         ClientList clients;
00509         ClientList desktops;
00510 
00511         ClientList unconstrained_stacking_order; // topmost last
00512         ClientList stacking_order; // topmost last
00513         QValueVector< ClientList > focus_chain; // currently active last
00514         ClientList global_focus_chain; // this one is only for things like tabbox's MRU
00515         ClientList should_get_focus; // last is most recent
00516         ClientList attention_chain;
00517         
00518         bool showing_desktop;
00519         ClientList showing_desktop_clients;
00520         int block_showing_desktop;
00521 
00522         GroupList groups;
00523 
00524         bool was_user_interaction;
00525         bool session_saving;
00526         int session_active_client;
00527         int session_desktop;
00528 
00529         bool control_grab;
00530         bool tab_grab;
00531     //KKeyNative walkThroughDesktopsKeycode, walkBackThroughDesktopsKeycode;
00532     //KKeyNative walkThroughDesktopListKeycode, walkBackThroughDesktopListKeycode;
00533     //KKeyNative walkThroughWindowsKeycode, walkBackThroughWindowsKeycode;
00534         KShortcut cutWalkThroughDesktops, cutWalkThroughDesktopsReverse;
00535         KShortcut cutWalkThroughDesktopList, cutWalkThroughDesktopListReverse;
00536         KShortcut cutWalkThroughWindows, cutWalkThroughWindowsReverse;
00537         bool mouse_emulation;
00538         unsigned int mouse_emulation_state;
00539         WId mouse_emulation_window;
00540         int block_focus;
00541 
00542         TabBox* tab_box;
00543         PopupInfo* popupinfo;
00544 
00545         QPopupMenu *popup;
00546         QPopupMenu *advanced_popup;
00547         QPopupMenu *desk_popup;
00548         int desk_popup_index;
00549 
00550         KGlobalAccel *keys;
00551         KGlobalAccel *client_keys;
00552         ShortcutDialog* client_keys_dialog;
00553         Client* client_keys_client;
00554         KGlobalAccel *disable_shortcuts_keys;
00555         bool global_shortcuts_disabled;
00556         bool global_shortcuts_disabled_for_client;
00557 
00558         WId root;
00559 
00560         PluginMgr *mgr;
00561 
00562         RootInfo *rootInfo;
00563         QWidget* supportWindow;
00564 
00565     // swallowing
00566         QStringList doNotManageList;
00567 
00568     // colormap handling
00569         Colormap default_colormap;
00570         Colormap installed_colormap;
00571 
00572     // Timer to collect requests for 'reconfigure'
00573         QTimer reconfigureTimer;
00574 
00575         QTimer updateToolWindowsTimer;
00576 
00577         static Workspace *_self;
00578 
00579         bool workspaceInit;
00580 
00581         KStartupInfo* startup;
00582 
00583         bool electric_have_borders;
00584         int electric_current_border;
00585         WId electric_top_border;
00586         WId electric_bottom_border;
00587         WId electric_left_border;
00588         WId electric_right_border;
00589         int electricLeft;
00590         int electricRight;
00591         int electricTop;
00592         int electricBottom;
00593         Time electric_time_first;
00594         Time electric_time_last;
00595         QPoint electric_push_point;
00596 
00597         Qt::Orientation layoutOrientation;
00598         int layoutX;
00599         int layoutY;
00600 
00601         Placement *initPositioning;
00602 
00603         QRect* workarea; //  array of workareas for virtual desktops
00604         QRect** screenarea; // array of workareas per xinerama screen for all virtual desktops
00605 
00606         bool managing_topmenus;
00607         KSelectionOwner* topmenu_selection;
00608         KSelectionWatcher* topmenu_watcher;
00609         ClientList topmenus; // doesn't own them
00610         mutable int topmenu_height;
00611         QWidget* topmenu_space;
00612 
00613         int set_active_client_recursion;
00614         int block_stacking_updates; // when >0, stacking updates are temporarily disabled
00615         bool blocked_propagating_new_clients; // propagate also new clients after enabling stacking updates?
00616         Window null_focus_window;
00617         bool forced_global_mouse_grab;
00618         friend class StackingUpdatesBlocker;
00619         
00620         //kompmgr
00621         QSlider *transSlider;
00622         QPushButton *transButton;
00623         // not used yet
00624         /*Client* topDock;
00625         int maximizedWindowCounter;
00626         int topDockShadowSize;*/
00627         //end
00628         
00629      signals:
00630         void kompmgrStarted();
00631         void kompmgrStopped();
00632 
00633     private:
00634         friend bool performTransiencyCheck();
00635     };
00636 
00637 // helper for Workspace::blockStackingUpdates() being called in pairs (true/false)
00638 class StackingUpdatesBlocker
00639     {
00640     public:
00641         StackingUpdatesBlocker( Workspace* w )
00642             : ws( w ) { ws->blockStackingUpdates( true ); }
00643         ~StackingUpdatesBlocker()
00644             { ws->blockStackingUpdates( false ); }
00645     private:
00646         Workspace* ws;
00647     };
00648 
00649 // NET WM Protocol handler class
00650 class RootInfo : public NETRootInfo4
00651     {
00652     private:
00653         typedef KWinInternal::Client Client;  // because of NET::Client
00654     public:
00655         RootInfo( Workspace* ws, Display *dpy, Window w, const char *name, unsigned long pr[], int pr_num, int scr= -1);
00656     protected:
00657         virtual void changeNumberOfDesktops(int n);
00658         virtual void changeCurrentDesktop(int d);
00659 //    virtual void changeActiveWindow(Window w); the extended version is used
00660         virtual void changeActiveWindow(Window w,NET::RequestSource src, Time timestamp, Window active_window);
00661         virtual void closeWindow(Window w);
00662         virtual void moveResize(Window w, int x_root, int y_root, unsigned long direction);
00663         virtual void moveResizeWindow(Window w, int flags, int x, int y, int width, int height );
00664         virtual void gotPing(Window w, Time timestamp);
00665         virtual void restackWindow(Window w, RequestSource source, Window above, int detail, Time timestamp);
00666         virtual void gotTakeActivity(Window w, Time timestamp, long flags );
00667         virtual void changeShowingDesktop( bool showing );
00668     private:
00669         Workspace* workspace;
00670     };
00671 
00672 
00673 inline WId Workspace::rootWin() const
00674     {
00675     return root;
00676     }
00677 
00678 inline bool Workspace::initializing() const
00679     {
00680     return workspaceInit;
00681     }
00682 
00683 inline Client* Workspace::activeClient() const
00684     {
00685     return active_client;
00686     }
00687 
00688 inline Client* Workspace::mostRecentlyActivatedClient() const
00689     {
00690     return should_get_focus.count() > 0 ? should_get_focus.last() : active_client;
00691     }
00692 
00693 inline int Workspace::currentDesktop() const
00694     {
00695     return current_desktop;
00696     }
00697 
00698 inline int Workspace::numberOfDesktops() const
00699     {
00700     return number_of_desktops;
00701     }
00702 
00703 inline void Workspace::addGroup( Group* group, allowed_t )
00704     {
00705     groups.append( group );
00706     }
00707 
00708 inline void Workspace::removeGroup( Group* group, allowed_t )
00709     {
00710     groups.remove( group );
00711     }
00712 
00713 inline const ClientList& Workspace::stackingOrder() const
00714     {
00715 // TODO    Q_ASSERT( block_stacking_updates == 0 );
00716     return stacking_order;
00717     }
00718 
00719 inline void Workspace::showWindowMenu(QPoint pos, Client* cl)
00720     {
00721     showWindowMenu(QRect(pos, pos), cl);
00722     }
00723 
00724 inline void Workspace::showWindowMenu(int x, int y, Client* cl)
00725     {
00726     showWindowMenu(QRect(QPoint(x, y), QPoint(x, y)), cl);
00727     }
00728 
00729 inline
00730 void Workspace::setWasUserInteraction()
00731     {
00732     was_user_interaction = true;
00733     }
00734 
00735 inline
00736 bool Workspace::wasUserInteraction() const
00737     {
00738     return was_user_interaction;
00739     }
00740 
00741 inline
00742 bool Workspace::managingTopMenus() const
00743     {
00744     return managing_topmenus;
00745     }
00746 
00747 inline void Workspace::sessionSaveStarted()
00748     {
00749     session_saving = true;
00750     }
00751 
00752 inline void Workspace::sessionSaveDone()
00753     {
00754     session_saving = false;
00755     }
00756 
00757 inline bool Workspace::sessionSaving() const
00758     {
00759     return session_saving;
00760     }
00761 
00762 inline bool Workspace::forcedGlobalMouseGrab() const
00763     {
00764     return forced_global_mouse_grab;
00765     }
00766 
00767 inline bool Workspace::showingDesktop() const
00768     {
00769     return showing_desktop;
00770     }
00771 
00772 inline bool Workspace::globalShortcutsDisabled() const
00773     {
00774     return global_shortcuts_disabled || global_shortcuts_disabled_for_client;
00775     }
00776 
00777 template< typename T >
00778 inline Client* Workspace::findClient( T predicate )
00779     {
00780     if( Client* ret = findClientInList( clients, predicate ))
00781         return ret;
00782     if( Client* ret = findClientInList( desktops, predicate ))
00783         return ret;
00784     return NULL;
00785     }
00786 
00787 template< typename T1, typename T2 >
00788 inline void Workspace::forEachClient( T1 procedure, T2 predicate )
00789     {
00790     for ( ClientList::ConstIterator it = clients.begin(); it != clients.end(); ++it)
00791         if ( predicate( const_cast< const Client* >( *it)))
00792             procedure( *it );
00793     for ( ClientList::ConstIterator it = desktops.begin(); it != desktops.end(); ++it)
00794         if ( predicate( const_cast< const Client* >( *it)))
00795             procedure( *it );
00796     }
00797 
00798 template< typename T >
00799 inline void Workspace::forEachClient( T procedure )
00800     {
00801     return forEachClient( procedure, TruePredicate());
00802     }
00803 
00804 KWIN_COMPARE_PREDICATE( ClientMatchPredicate, const Client*, cl == value );
00805 inline bool Workspace::hasClient( const Client* c )
00806     {
00807     return findClient( ClientMatchPredicate( c ));
00808     }
00809 
00810 } // namespace
00811 
00812 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys