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