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         void disableRulesUpdates( bool disable );
00217         bool rulesUpdatesDisabled() const;
00218 
00219     // dcop interface
00220         void cascadeDesktop();
00221         void unclutterDesktop();
00222         void doNotManage(QString);
00223         bool setCurrentDesktop( int new_desktop );
00224         void nextDesktop();
00225         void previousDesktop();
00226         void circulateDesktopApplications();
00227 
00228         QString desktopName( int desk ) const;
00229         virtual void setDesktopLayout(int , int , int );
00230         void updateDesktopLayout();
00231         void setShowingDesktop( bool showing );
00232         void resetShowingDesktop( bool keep_hidden );
00233         bool showingDesktop() const;
00234 
00235         bool isNotManaged( const QString& title );  // ### setter or getter ?
00236 
00237         void sendPingToWindow( Window w, Time timestamp ); // called from Client::pingWindow()
00238         void sendTakeActivity( Client* c, Time timestamp, long flags ); // called from Client::takeActivity()
00239         
00240         bool kompmgrIsRunning();
00241         void setOpacity(unsigned long winId, unsigned int opacityPercent);
00242         void setShadowSize(unsigned long winId, unsigned int shadowSizePercent);
00243         void setUnshadowed(unsigned long winId); // redundant, equals setShadowSize(inId, 0)
00244 
00245     // only called from Client::destroyClient() or Client::releaseWindow()
00246         void removeClient( Client*, allowed_t );
00247         void setActiveClient( Client*, allowed_t );
00248         Group* findGroup( Window leader ) const;
00249         void addGroup( Group* group, allowed_t );
00250         void removeGroup( Group* group, allowed_t );
00251         Group* findClientLeaderGroup( const Client* c ) const;
00252 
00253         bool checkStartupNotification( Window w, KStartupInfoId& id, KStartupInfoData& data );
00254 
00255         void focusToNull(); // SELI public?
00256         enum FocusChainChange { FocusChainMakeFirst, FocusChainMakeLast, FocusChainUpdate };
00257         void updateFocusChains( Client* c, FocusChainChange change );
00258         
00259         bool forcedGlobalMouseGrab() const;
00260         void clientShortcutUpdated( Client* c );
00261         bool shortcutAvailable( const KShortcut& cut, Client* ignore = NULL ) const;
00262         bool globalShortcutsDisabled() const;
00263         void disableGlobalShortcuts( bool disable );
00264         void disableGlobalShortcutsForClient( bool disable );
00265 
00266         void sessionSaveStarted();
00267         void sessionSaveDone();
00268         void setWasUserInteraction();
00269         bool wasUserInteraction() const;
00270         bool sessionSaving() const;
00271 
00272         bool managingTopMenus() const;
00273         int topMenuHeight() const;
00274         void updateCurrentTopMenu();
00275 
00276         int packPositionLeft( const Client* cl, int oldx, bool left_edge ) const;
00277         int packPositionRight( const Client* cl, int oldx, bool right_edge ) const;
00278         int packPositionUp( const Client* cl, int oldy, bool top_edge ) const;
00279         int packPositionDown( const Client* cl, int oldy, bool bottom_edge ) const;
00280 
00281         static QStringList configModules(bool controlCenter);
00282 
00283         void cancelDelayFocus();
00284         void requestDelayFocus( Client* );
00285         void updateFocusMousePosition( const QPoint& pos );
00286         QPoint focusMousePosition() const;
00287         
00288         void toggleTopDockShadows(bool on);
00289 
00290     public slots:
00291         void refresh();
00292     // keybindings
00293         void slotSwitchDesktopNext();
00294         void slotSwitchDesktopPrevious();
00295         void slotSwitchDesktopRight();
00296         void slotSwitchDesktopLeft();
00297         void slotSwitchDesktopUp();
00298         void slotSwitchDesktopDown();
00299 
00300         void slotSwitchToDesktop( int );
00301     //void slotSwitchToWindow( int );
00302         void slotWindowToDesktop( int );
00303     //void slotWindowToListPosition( int );
00304 
00305         void slotWindowMaximize();
00306         void slotWindowMaximizeVertical();
00307         void slotWindowMaximizeHorizontal();
00308         void slotWindowMinimize();
00309         void slotWindowShade();
00310         void slotWindowRaise();
00311         void slotWindowLower();
00312         void slotWindowRaiseOrLower();
00313         void slotActivateAttentionWindow();
00314         void slotWindowPackLeft();
00315         void slotWindowPackRight();
00316         void slotWindowPackUp();
00317         void slotWindowPackDown();
00318         void slotWindowGrowHorizontal();
00319         void slotWindowGrowVertical();
00320         void slotWindowShrinkHorizontal();
00321         void slotWindowShrinkVertical();
00322 
00323         void slotWalkThroughDesktops();
00324         void slotWalkBackThroughDesktops();
00325         void slotWalkThroughDesktopList();
00326         void slotWalkBackThroughDesktopList();
00327         void slotWalkThroughWindows();
00328         void slotWalkBackThroughWindows();
00329 
00330         void slotWindowOperations();
00331         void slotWindowClose();
00332         void slotWindowMove();
00333         void slotWindowResize();
00334         void slotWindowAbove();
00335         void slotWindowBelow();
00336         void slotWindowOnAllDesktops();
00337         void slotWindowFullScreen();
00338         void slotWindowNoBorder();
00339 
00340         void slotWindowToNextDesktop();
00341         void slotWindowToPreviousDesktop();
00342         void slotWindowToDesktopRight();
00343         void slotWindowToDesktopLeft();
00344         void slotWindowToDesktopUp();
00345         void slotWindowToDesktopDown();
00346 
00347         void slotMouseEmulation();
00348         void slotDisableGlobalShortcuts();
00349 
00350         void slotSettingsChanged( int category );
00351 
00352         void slotReconfigure();
00353 
00354         void slotKillWindow();
00355 
00356         void slotGrabWindow();
00357         void slotGrabDesktop();
00358 
00359         void slotSetupWindowShortcut();
00360         void setupWindowShortcutDone( bool );
00361 
00362         void updateClientArea();
00363         
00364         // kompmgr, also dcop
00365         void startKompmgr();
00366 
00367     private slots:
00368         void desktopPopupAboutToShow();
00369         void clientPopupAboutToShow();
00370         void slotSendToDesktop( int );
00371         void clientPopupActivated( int );
00372         void configureWM();
00373         void desktopResized();
00374         void slotUpdateToolWindows();
00375         void lostTopMenuSelection();
00376         void lostTopMenuOwner();
00377         void delayFocus();
00378         void gotTemporaryRulesMessage( const QString& );
00379         void cleanupTemporaryRules();
00380         void writeWindowRules();
00381         void kipcMessage( int id, int data );
00382         // kompmgr
00383         void setPopupClientOpacity(int v);
00384         void resetClientOpacity();
00385         void setTransButtonText(int value);
00386         void unblockKompmgrRestart();
00387         void restartKompmgr();
00388         void handleKompmgrOutput( KProcess *proc, char *buffer, int buflen);
00389         void stopKompmgr();
00390         // end 
00391 
00392     protected:
00393         bool keyPressMouseEmulation( XKeyEvent& ev );
00394 
00395     private:
00396         void init();
00397         void initShortcuts();
00398         void readShortcuts();
00399         void initDesktopPopup();
00400         void setupWindowShortcut( Client* c );
00401 
00402         bool startKDEWalkThroughWindows();
00403         bool startWalkThroughDesktops( int mode ); // TabBox::Mode::DesktopMode | DesktopListMode
00404         bool startWalkThroughDesktops();
00405         bool startWalkThroughDesktopList();
00406         void KDEWalkThroughWindows( bool forward );
00407         void CDEWalkThroughWindows( bool forward );
00408         void walkThroughDesktops( bool forward );
00409         void KDEOneStepThroughWindows( bool forward );
00410         void oneStepThroughDesktops( bool forward, int mode ); // TabBox::Mode::DesktopMode | DesktopListMode
00411         void oneStepThroughDesktops( bool forward );
00412         void oneStepThroughDesktopList( bool forward );
00413         bool establishTabBoxGrab();
00414         void removeTabBoxGrab();
00415         int desktopToRight( int desktop ) const;
00416         int desktopToLeft( int desktop ) const;
00417         int desktopUp( int desktop ) const;
00418         int desktopDown( int desktop ) const;
00419 
00420         void updateStackingOrder( bool propagate_new_clients = false );
00421         void propagateClients( bool propagate_new_clients ); // called only from updateStackingOrder
00422         ClientList constrainedStackingOrder();
00423         void raiseClientWithinApplication( Client* c );
00424         void lowerClientWithinApplication( Client* c );
00425         bool allowFullClientRaising( const Client* c, Time timestamp );
00426         bool keepTransientAbove( const Client* mainwindow, const Client* transient );
00427         void blockStackingUpdates( bool block );
00428         void addTopMenu( Client* c );
00429         void removeTopMenu( Client* c );
00430         void setupTopMenuHandling();
00431         void updateTopMenuGeometry( Client* c = NULL );
00432         void updateToolWindows( bool also_hide );
00433 
00434     // this is the right way to create a new client
00435         Client* createClient( Window w, bool is_mapped );
00436         void addClient( Client* c, allowed_t );
00437 
00438         Window findSpecialEventWindow( XEvent* e );
00439 
00440         void randomPlacement(Client* c);
00441         void smartPlacement(Client* c);
00442         void cascadePlacement(Client* c, bool re_init = false);
00443 
00444         bool addSystemTrayWin( WId w );
00445         bool removeSystemTrayWin( WId w, bool check );
00446         void propagateSystemTrayWins();
00447         SystemTrayWindow findSystemTrayWin( WId w );
00448 
00449     // desktop names and number of desktops
00450         void loadDesktopSettings();
00451         void saveDesktopSettings();
00452 
00453     // mouse emulation
00454         WId getMouseEmulationWindow();
00455         enum MouseEmulation { EmuPress, EmuRelease, EmuMove };
00456         unsigned int sendFakedMouseEvent( QPoint pos, WId win, MouseEmulation type, int button, unsigned int state ); // returns the new state
00457 
00458         void tabBoxKeyPress( const KKeyNative& keyX );
00459         void tabBoxKeyRelease( const XKeyEvent& ev );
00460 
00461     // electric borders
00462         void checkElectricBorders( bool force = false );
00463         void createBorderWindows();
00464         void destroyBorderWindows();
00465         bool electricBorder(XEvent * e);
00466         void raiseElectricBorders();
00467 
00468     // ------------------
00469     
00470         void helperDialog( const QString& message, const Client* c );
00471 
00472         void calcDesktopLayout(int &x, int &y) const;
00473 
00474         QPopupMenu* clientPopup();
00475         void closeActivePopup();
00476 
00477         void updateClientArea( bool force );
00478 
00479         SystemTrayWindowList systemTrayWins;
00480 
00481         int current_desktop;
00482         int number_of_desktops;
00483         QMemArray<int> desktop_focus_chain;
00484 
00485         QWidget* active_popup;
00486         Client* active_popup_client;
00487 
00488         QWidget* desktop_widget;
00489 
00490         void loadSessionInfo();
00491         void loadWindowRules();
00492         void editWindowRules( Client* c, bool whole_app );
00493 
00494         QPtrList<SessionInfo> session;
00495         QValueList<Rules*> rules;
00496         KXMessages temporaryRulesMessages;
00497         QTimer rulesUpdatedTimer;
00498         bool rules_updates_disabled;
00499         static const char* windowTypeToTxt( NET::WindowType type );
00500         static NET::WindowType txtToWindowType( const char* txt );
00501         static bool sessionInfoWindowTypeMatch( Client* c, SessionInfo* info );
00502 
00503         Client* active_client;
00504         Client* last_active_client;
00505         Client* most_recently_raised; // used _only_ by raiseOrLowerClient()
00506         Client* movingClient;
00507         Client* pending_take_activity;
00508 
00509     // delay(ed) window focus timer and client
00510         QTimer* delayFocusTimer;
00511         Client* delayfocus_client;
00512         QPoint focusMousePos;
00513 
00514         ClientList clients;
00515         ClientList desktops;
00516 
00517         ClientList unconstrained_stacking_order; // topmost last
00518         ClientList stacking_order; // topmost last
00519         QValueVector< ClientList > focus_chain; // currently active last
00520         ClientList global_focus_chain; // this one is only for things like tabbox's MRU
00521         ClientList should_get_focus; // last is most recent
00522         ClientList attention_chain;
00523         
00524         bool showing_desktop;
00525         ClientList showing_desktop_clients;
00526         int block_showing_desktop;
00527 
00528         GroupList groups;
00529 
00530         bool was_user_interaction;
00531         bool session_saving;
00532         int session_active_client;
00533         int session_desktop;
00534 
00535         bool control_grab;
00536         bool tab_grab;
00537     //KKeyNative walkThroughDesktopsKeycode, walkBackThroughDesktopsKeycode;
00538     //KKeyNative walkThroughDesktopListKeycode, walkBackThroughDesktopListKeycode;
00539     //KKeyNative walkThroughWindowsKeycode, walkBackThroughWindowsKeycode;
00540         KShortcut cutWalkThroughDesktops, cutWalkThroughDesktopsReverse;
00541         KShortcut cutWalkThroughDesktopList, cutWalkThroughDesktopListReverse;
00542         KShortcut cutWalkThroughWindows, cutWalkThroughWindowsReverse;
00543         bool mouse_emulation;
00544         unsigned int mouse_emulation_state;
00545         WId mouse_emulation_window;
00546         int block_focus;
00547 
00548         TabBox* tab_box;
00549         PopupInfo* popupinfo;
00550 
00551         QPopupMenu *popup;
00552         QPopupMenu *advanced_popup;
00553         QPopupMenu *desk_popup;
00554         int desk_popup_index;
00555 
00556         KGlobalAccel *keys;
00557         KGlobalAccel *client_keys;
00558         ShortcutDialog* client_keys_dialog;
00559         Client* client_keys_client;
00560         KGlobalAccel *disable_shortcuts_keys;
00561         bool global_shortcuts_disabled;
00562         bool global_shortcuts_disabled_for_client;
00563 
00564         WId root;
00565 
00566         PluginMgr *mgr;
00567 
00568         RootInfo *rootInfo;
00569         QWidget* supportWindow;
00570 
00571     // swallowing
00572         QStringList doNotManageList;
00573 
00574     // colormap handling
00575         Colormap default_colormap;
00576         Colormap installed_colormap;
00577 
00578     // Timer to collect requests for 'reconfigure'
00579         QTimer reconfigureTimer;
00580 
00581         QTimer updateToolWindowsTimer;
00582 
00583         static Workspace *_self;
00584 
00585         bool workspaceInit;
00586 
00587         KStartupInfo* startup;
00588 
00589         bool electric_have_borders;
00590         int electric_current_border;
00591         WId electric_top_border;
00592         WId electric_bottom_border;
00593         WId electric_left_border;
00594         WId electric_right_border;
00595         int electricLeft;
00596         int electricRight;
00597         int electricTop;
00598         int electricBottom;
00599         Time electric_time_first;
00600         Time electric_time_last;
00601         QPoint electric_push_point;
00602 
00603         Qt::Orientation layoutOrientation;
00604         int layoutX;
00605         int layoutY;
00606 
00607         Placement *initPositioning;
00608 
00609         QRect* workarea; //  array of workareas for virtual desktops
00610         QRect** screenarea; // array of workareas per xinerama screen for all virtual desktops
00611 
00612         bool managing_topmenus;
00613         KSelectionOwner* topmenu_selection;
00614         KSelectionWatcher* topmenu_watcher;
00615         ClientList topmenus; // doesn't own them
00616         mutable int topmenu_height;
00617         QWidget* topmenu_space;
00618 
00619         int set_active_client_recursion;
00620         int block_stacking_updates; // when >0, stacking updates are temporarily disabled
00621         bool blocked_propagating_new_clients; // propagate also new clients after enabling stacking updates?
00622         Window null_focus_window;
00623         bool forced_global_mouse_grab;
00624         friend class StackingUpdatesBlocker;
00625         
00626         //kompmgr
00627         QSlider *transSlider;
00628         QPushButton *transButton;
00629         // not used yet
00630         /*Client* topDock;
00631         int maximizedWindowCounter;
00632         int topDockShadowSize;*/
00633         //end
00634         
00635      signals:
00636         void kompmgrStarted();
00637         void kompmgrStopped();
00638 
00639     private:
00640         friend bool performTransiencyCheck();
00641     };
00642 
00643 // helper for Workspace::blockStackingUpdates() being called in pairs (true/false)
00644 class StackingUpdatesBlocker
00645     {
00646     public:
00647         StackingUpdatesBlocker( Workspace* w )
00648             : ws( w ) { ws->blockStackingUpdates( true ); }
00649         ~StackingUpdatesBlocker()
00650             { ws->blockStackingUpdates( false ); }
00651     private:
00652         Workspace* ws;
00653     };
00654 
00655 // NET WM Protocol handler class
00656 class RootInfo : public NETRootInfo4
00657     {
00658     private:
00659         typedef KWinInternal::Client Client;  // because of NET::Client
00660     public:
00661         RootInfo( Workspace* ws, Display *dpy, Window w, const char *name, unsigned long pr[], int pr_num, int scr= -1);
00662     protected:
00663         virtual void changeNumberOfDesktops(int n);
00664         virtual void changeCurrentDesktop(int d);
00665 //    virtual void changeActiveWindow(Window w); the extended version is used
00666         virtual void changeActiveWindow(Window w,NET::RequestSource src, Time timestamp, Window active_window);
00667         virtual void closeWindow(Window w);
00668         virtual void moveResize(Window w, int x_root, int y_root, unsigned long direction);
00669         virtual void moveResizeWindow(Window w, int flags, int x, int y, int width, int height );
00670         virtual void gotPing(Window w, Time timestamp);
00671         virtual void restackWindow(Window w, RequestSource source, Window above, int detail, Time timestamp);
00672         virtual void gotTakeActivity(Window w, Time timestamp, long flags );
00673         virtual void changeShowingDesktop( bool showing );
00674     private:
00675         Workspace* workspace;
00676     };
00677 
00678 
00679 inline WId Workspace::rootWin() const
00680     {
00681     return root;
00682     }
00683 
00684 inline bool Workspace::initializing() const
00685     {
00686     return workspaceInit;
00687     }
00688 
00689 inline Client* Workspace::activeClient() const
00690     {
00691     return active_client;
00692     }
00693 
00694 inline Client* Workspace::mostRecentlyActivatedClient() const
00695     {
00696     return should_get_focus.count() > 0 ? should_get_focus.last() : active_client;
00697     }
00698 
00699 inline int Workspace::currentDesktop() const
00700     {
00701     return current_desktop;
00702     }
00703 
00704 inline int Workspace::numberOfDesktops() const
00705     {
00706     return number_of_desktops;
00707     }
00708 
00709 inline void Workspace::addGroup( Group* group, allowed_t )
00710     {
00711     groups.append( group );
00712     }
00713 
00714 inline void Workspace::removeGroup( Group* group, allowed_t )
00715     {
00716     groups.remove( group );
00717     }
00718 
00719 inline const ClientList& Workspace::stackingOrder() const
00720     {
00721 // TODO    Q_ASSERT( block_stacking_updates == 0 );
00722     return stacking_order;
00723     }
00724 
00725 inline void Workspace::showWindowMenu(QPoint pos, Client* cl)
00726     {
00727     showWindowMenu(QRect(pos, pos), cl);
00728     }
00729 
00730 inline void Workspace::showWindowMenu(int x, int y, Client* cl)
00731     {
00732     showWindowMenu(QRect(QPoint(x, y), QPoint(x, y)), cl);
00733     }
00734 
00735 inline
00736 void Workspace::setWasUserInteraction()
00737     {
00738     was_user_interaction = true;
00739     }
00740 
00741 inline
00742 bool Workspace::wasUserInteraction() const
00743     {
00744     return was_user_interaction;
00745     }
00746 
00747 inline
00748 bool Workspace::managingTopMenus() const
00749     {
00750     return managing_topmenus;
00751     }
00752 
00753 inline void Workspace::sessionSaveStarted()
00754     {
00755     session_saving = true;
00756     }
00757 
00758 inline void Workspace::sessionSaveDone()
00759     {
00760     session_saving = false;
00761     }
00762 
00763 inline bool Workspace::sessionSaving() const
00764     {
00765     return session_saving;
00766     }
00767 
00768 inline bool Workspace::forcedGlobalMouseGrab() const
00769     {
00770     return forced_global_mouse_grab;
00771     }
00772 
00773 inline bool Workspace::showingDesktop() const
00774     {
00775     return showing_desktop;
00776     }
00777 
00778 inline bool Workspace::globalShortcutsDisabled() const
00779     {
00780     return global_shortcuts_disabled || global_shortcuts_disabled_for_client;
00781     }
00782 
00783 inline
00784 bool Workspace::rulesUpdatesDisabled() const
00785     {
00786     return rules_updates_disabled;
00787     }
00788 
00789 inline
00790 void Workspace::updateFocusMousePosition( const QPoint& pos )
00791     {
00792     focusMousePos = pos;
00793     }
00794 
00795 inline
00796 QPoint Workspace::focusMousePosition() const
00797     {
00798     return focusMousePos;
00799     }
00800 
00801 template< typename T >
00802 inline Client* Workspace::findClient( T predicate )
00803     {
00804     if( Client* ret = findClientInList( clients, predicate ))
00805         return ret;
00806     if( Client* ret = findClientInList( desktops, predicate ))
00807         return ret;
00808     return NULL;
00809     }
00810 
00811 template< typename T1, typename T2 >
00812 inline void Workspace::forEachClient( T1 procedure, T2 predicate )
00813     {
00814     for ( ClientList::ConstIterator it = clients.begin(); it != clients.end(); ++it)
00815         if ( predicate( const_cast< const Client* >( *it)))
00816             procedure( *it );
00817     for ( ClientList::ConstIterator it = desktops.begin(); it != desktops.end(); ++it)
00818         if ( predicate( const_cast< const Client* >( *it)))
00819             procedure( *it );
00820     }
00821 
00822 template< typename T >
00823 inline void Workspace::forEachClient( T procedure )
00824     {
00825     return forEachClient( procedure, TruePredicate());
00826     }
00827 
00828 KWIN_COMPARE_PREDICATE( ClientMatchPredicate, const Client*, cl == value );
00829 inline bool Workspace::hasClient( const Client* c )
00830     {
00831     return findClient( ClientMatchPredicate( c ));
00832     }
00833 
00834 } // namespace
00835 
00836 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys