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 ) 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         void stopKompmgr();
00238         bool kompmgrIsRunning();
00239         void setOpacity(unsigned long winId, unsigned int opacityPercent);
00240         void setShadowSize(unsigned long winId, unsigned int shadowSizePercent);
00241         void setUnshadowed(unsigned long winId); // redundant, equals setShadowSize(inId, 0)
00242 
00243     // only called from Client::destroyClient() or Client::releaseWindow()
00244         void removeClient( Client*, allowed_t );
00245         void setActiveClient( Client*, allowed_t );
00246         Group* findGroup( Window leader ) const;
00247         void addGroup( Group* group, allowed_t );
00248         void removeGroup( Group* group, allowed_t );
00249         Group* findClientLeaderGroup( const Client* c ) const;
00250 
00251         bool checkStartupNotification( Window w, KStartupInfoId& id, KStartupInfoData& data );
00252 
00253         void focusToNull(); // SELI public?
00254         enum FocusChainChange { FocusChainMakeFirst, FocusChainMakeLast, FocusChainUpdate };
00255         void updateFocusChains( Client* c, FocusChainChange change );
00256         
00257         bool forcedGlobalMouseGrab() const;
00258         void clientShortcutUpdated( Client* c );
00259         bool shortcutAvailable( const KShortcut& cut, Client* ignore = NULL ) const;
00260         bool globalShortcutsDisabled() const;
00261         void disableGlobalShortcuts( bool disable );
00262         void disableGlobalShortcutsForClient( bool disable );
00263 
00264         void sessionSaveStarted();
00265         void sessionSaveDone();
00266         void setWasUserInteraction();
00267         bool wasUserInteraction() const;
00268         bool sessionSaving() const;
00269 
00270         bool managingTopMenus() const;
00271         int topMenuHeight() const;
00272         void updateCurrentTopMenu();
00273 
00274         int packPositionLeft( const Client* cl, int oldx, bool left_edge ) const;
00275         int packPositionRight( const Client* cl, int oldx, bool right_edge ) const;
00276         int packPositionUp( const Client* cl, int oldy, bool top_edge ) const;
00277         int packPositionDown( const Client* cl, int oldy, bool bottom_edge ) const;
00278 
00279         static QStringList configModules(bool controlCenter);
00280 
00281         void cancelDelayFocus();
00282         void requestDelayFocus( Client* );
00283         
00284         void toggleTopDockShadows(bool on);
00285 
00286     public slots:
00287         void refresh();
00288     // keybindings
00289         void slotSwitchDesktopNext();
00290         void slotSwitchDesktopPrevious();
00291         void slotSwitchDesktopRight();
00292         void slotSwitchDesktopLeft();
00293         void slotSwitchDesktopUp();
00294         void slotSwitchDesktopDown();
00295 
00296         void slotSwitchToDesktop( int );
00297     //void slotSwitchToWindow( int );
00298         void slotWindowToDesktop( int );
00299     //void slotWindowToListPosition( int );
00300 
00301         void slotWindowMaximize();
00302         void slotWindowMaximizeVertical();
00303         void slotWindowMaximizeHorizontal();
00304         void slotWindowMinimize();
00305         void slotWindowShade();
00306         void slotWindowRaise();
00307         void slotWindowLower();
00308         void slotWindowRaiseOrLower();
00309         void slotActivateAttentionWindow();
00310         void slotWindowPackLeft();
00311         void slotWindowPackRight();
00312         void slotWindowPackUp();
00313         void slotWindowPackDown();
00314         void slotWindowGrowHorizontal();
00315         void slotWindowGrowVertical();
00316         void slotWindowShrinkHorizontal();
00317         void slotWindowShrinkVertical();
00318 
00319         void slotWalkThroughDesktops();
00320         void slotWalkBackThroughDesktops();
00321         void slotWalkThroughDesktopList();
00322         void slotWalkBackThroughDesktopList();
00323         void slotWalkThroughWindows();
00324         void slotWalkBackThroughWindows();
00325 
00326         void slotWindowOperations();
00327         void slotWindowClose();
00328         void slotWindowMove();
00329         void slotWindowResize();
00330         void slotWindowAbove();
00331         void slotWindowBelow();
00332         void slotWindowOnAllDesktops();
00333         void slotWindowFullScreen();
00334         void slotWindowNoBorder();
00335 
00336         void slotWindowToNextDesktop();
00337         void slotWindowToPreviousDesktop();
00338         void slotWindowToDesktopRight();
00339         void slotWindowToDesktopLeft();
00340         void slotWindowToDesktopUp();
00341         void slotWindowToDesktopDown();
00342 
00343         void slotMouseEmulation();
00344         void slotDisableGlobalShortcuts();
00345 
00346         void slotSettingsChanged( int category );
00347 
00348         void slotReconfigure();
00349 
00350         void slotKillWindow();
00351 
00352         void slotGrabWindow();
00353         void slotGrabDesktop();
00354 
00355         void slotSetupWindowShortcut();
00356         void setupWindowShortcutDone( bool );
00357 
00358         void updateClientArea();
00359         
00360         // kompmgr, also dcop
00361         void startKompmgr();
00362 
00363     private slots:
00364         void desktopPopupAboutToShow();
00365         void clientPopupAboutToShow();
00366         void slotSendToDesktop( int );
00367         void clientPopupActivated( int );
00368         void configureWM();
00369         void desktopResized();
00370         void slotUpdateToolWindows();
00371         void lostTopMenuSelection();
00372         void lostTopMenuOwner();
00373         void delayFocus();
00374         void gotTemporaryRulesMessage( const QString& );
00375         void cleanupTemporaryRules();
00376         void writeWindowRules();
00377         void kipcMessage( int id, int data );
00378         // kompmgr
00379         void setPopupClientOpacity(int v);
00380         void resetClientOpacity();
00381         void setTransButtonText(int value);
00382         void unblockKompmgrRestart();
00383         void restartKompmgr();
00384         void handleKompmgrOutput( KProcess *proc, char *buffer, int buflen);
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;
00512         ClientList stacking_order;
00513         QValueVector< ClientList > focus_chain;
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 
00634 // helper for Workspace::blockStackingUpdates() being called in pairs (true/false)
00635 class StackingUpdatesBlocker
00636     {
00637     public:
00638         StackingUpdatesBlocker( Workspace* w )
00639             : ws( w ) { ws->blockStackingUpdates( true ); }
00640         ~StackingUpdatesBlocker()
00641             { ws->blockStackingUpdates( false ); }
00642     private:
00643         Workspace* ws;
00644     };
00645 
00646 // NET WM Protocol handler class
00647 class RootInfo : public NETRootInfo4
00648     {
00649     private:
00650         typedef KWinInternal::Client Client;  // because of NET::Client
00651     public:
00652         RootInfo( Workspace* ws, Display *dpy, Window w, const char *name, unsigned long pr[], int pr_num, int scr= -1);
00653     protected:
00654         virtual void changeNumberOfDesktops(int n);
00655         virtual void changeCurrentDesktop(int d);
00656 //    virtual void changeActiveWindow(Window w); the extended version is used
00657         virtual void changeActiveWindow(Window w,NET::RequestSource src, Time timestamp, Window active_window);
00658         virtual void closeWindow(Window w);
00659         virtual void moveResize(Window w, int x_root, int y_root, unsigned long direction);
00660         virtual void moveResizeWindow(Window w, int flags, int x, int y, int width, int height );
00661         virtual void gotPing(Window w, Time timestamp);
00662         virtual void restackWindow(Window w, RequestSource source, Window above, int detail, Time timestamp);
00663         virtual void gotTakeActivity(Window w, Time timestamp, long flags );
00664         virtual void changeShowingDesktop( bool showing );
00665     private:
00666         Workspace* workspace;
00667     };
00668 
00669 
00670 inline WId Workspace::rootWin() const
00671     {
00672     return root;
00673     }
00674 
00675 inline bool Workspace::initializing() const
00676     {
00677     return workspaceInit;
00678     }
00679 
00680 inline Client* Workspace::activeClient() const
00681     {
00682     return active_client;
00683     }
00684 
00685 inline Client* Workspace::mostRecentlyActivatedClient() const
00686     {
00687     return should_get_focus.count() > 0 ? should_get_focus.last() : active_client;
00688     }
00689 
00690 inline int Workspace::currentDesktop() const
00691     {
00692     return current_desktop;
00693     }
00694 
00695 inline int Workspace::numberOfDesktops() const
00696     {
00697     return number_of_desktops;
00698     }
00699 
00700 inline void Workspace::addGroup( Group* group, allowed_t )
00701     {
00702     groups.append( group );
00703     }
00704 
00705 inline void Workspace::removeGroup( Group* group, allowed_t )
00706     {
00707     groups.remove( group );
00708     }
00709 
00710 inline const ClientList& Workspace::stackingOrder() const
00711     {
00712 // TODO    Q_ASSERT( block_stacking_updates == 0 );
00713     return stacking_order;
00714     }
00715 
00716 inline void Workspace::showWindowMenu(QPoint pos, Client* cl)
00717     {
00718     showWindowMenu(QRect(pos, pos), cl);
00719     }
00720 
00721 inline void Workspace::showWindowMenu(int x, int y, Client* cl)
00722     {
00723     showWindowMenu(QRect(QPoint(x, y), QPoint(x, y)), cl);
00724     }
00725 
00726 inline
00727 void Workspace::setWasUserInteraction()
00728     {
00729     was_user_interaction = true;
00730     }
00731 
00732 inline
00733 bool Workspace::wasUserInteraction() const
00734     {
00735     return was_user_interaction;
00736     }
00737 
00738 inline
00739 bool Workspace::managingTopMenus() const
00740     {
00741     return managing_topmenus;
00742     }
00743 
00744 inline void Workspace::sessionSaveStarted()
00745     {
00746     session_saving = true;
00747     }
00748 
00749 inline void Workspace::sessionSaveDone()
00750     {
00751     session_saving = false;
00752     }
00753 
00754 inline bool Workspace::sessionSaving() const
00755     {
00756     return session_saving;
00757     }
00758 
00759 inline bool Workspace::forcedGlobalMouseGrab() const
00760     {
00761     return forced_global_mouse_grab;
00762     }
00763 
00764 inline bool Workspace::showingDesktop() const
00765     {
00766     return showing_desktop;
00767     }
00768 
00769 inline bool Workspace::globalShortcutsDisabled() const
00770     {
00771     return global_shortcuts_disabled || global_shortcuts_disabled_for_client;
00772     }
00773 
00774 template< typename T >
00775 inline Client* Workspace::findClient( T predicate )
00776     {
00777     if( Client* ret = findClientInList( clients, predicate ))
00778         return ret;
00779     if( Client* ret = findClientInList( desktops, predicate ))
00780         return ret;
00781     return NULL;
00782     }
00783 
00784 template< typename T1, typename T2 >
00785 inline void Workspace::forEachClient( T1 procedure, T2 predicate )
00786     {
00787     for ( ClientList::ConstIterator it = clients.begin(); it != clients.end(); ++it)
00788         if ( predicate( const_cast< const Client* >( *it)))
00789             procedure( *it );
00790     for ( ClientList::ConstIterator it = desktops.begin(); it != desktops.end(); ++it)
00791         if ( predicate( const_cast< const Client* >( *it)))
00792             procedure( *it );
00793     }
00794 
00795 template< typename T >
00796 inline void Workspace::forEachClient( T procedure )
00797     {
00798     return forEachClient( procedure, TruePredicate());
00799     }
00800 
00801 KWIN_COMPARE_PREDICATE( ClientMatchPredicate, const Client*, cl == value );
00802 inline bool Workspace::hasClient( const Client* c )
00803     {
00804     return findClient( ClientMatchPredicate( c ));
00805     }
00806 
00807 } // namespace
00808 
00809 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys