• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • twin
 

twin

  • twin
workspace.h
1 /*****************************************************************
2  KWin - the KDE window manager
3  This file is part of the KDE project.
4 
5 Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
6 Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
7 
8 You can Freely distribute this program under the GNU General Public
9 License. See the file "COPYING" for the exact licensing terms.
10 ******************************************************************/
11 
12 #ifndef KWIN_WORKSPACE_H
13 #define KWIN_WORKSPACE_H
14 
15 #include <tqtimer.h>
16 #include <tqvaluevector.h>
17 #include <tdeshortcut.h>
18 #include <tqcursor.h>
19 #include <netwm.h>
20 #include <kxmessages.h>
21 
22 #include "KWinInterface.h"
23 #include "utils.h"
24 #include "kdecoration.h"
25 #include "sm.h"
26 
27 #include <X11/Xlib.h>
28 
29 class TQPopupMenu;
30 class TDEConfig;
31 class TDEGlobalAccel;
32 class TDEShortcutDialog;
33 class TDEStartupInfo;
34 class TDEStartupInfoId;
35 class TDEStartupInfoData;
36 class TQSlider;
37 class TQPushButton;
38 class TDEProcess;
39 
40 namespace KWinInternal
41 {
42 
43 class Client;
44 class TabBox;
45 class PopupInfo;
46 class RootInfo;
47 class PluginMgr;
48 class Placement;
49 class Rules;
50 class WindowRules;
51 
52 class SystemTrayWindow
53  {
54  public:
55  SystemTrayWindow()
56  : win(0),winFor(0)
57  {}
58  SystemTrayWindow( WId w )
59  : win(w),winFor(0)
60  {}
61  SystemTrayWindow( WId w, WId wf )
62  : win(w),winFor(wf)
63  {}
64 
65  bool operator==( const SystemTrayWindow& other )
66  { return win == other.win; }
67  WId win;
68  WId winFor;
69  };
70 
71 typedef TQValueList<SystemTrayWindow> SystemTrayWindowList;
72 
73 class Workspace : public TQObject, public KWinInterface, public KDecorationDefines
74  {
75  TQ_OBJECT
76  public:
77  Workspace( bool restore = false );
78  virtual ~Workspace();
79 
80  static Workspace * self() { return _self; }
81 
82  bool workspaceEvent( XEvent * );
83 
84  KDecoration* createDecoration( KDecorationBridge* bridge );
85 
86  bool hasClient( const Client * );
87 
88  template< typename T > Client* findClient( T predicate );
89  template< typename T1, typename T2 > void forEachClient( T1 procedure, T2 predicate );
90  template< typename T > void forEachClient( T procedure );
91 
92  TQRect clientArea( clientAreaOption, const TQPoint& p, int desktop ) const;
93  TQRect clientArea( clientAreaOption, const Client* c ) const;
94  TQRect clientArea( clientAreaOption, int screen, int desktop ) const;
95 
99  void killWindowId( Window window );
100  void suspendWindowId( Window window );
101  void resumeWindowId( Window window );
102  bool isResumeableWindowID( Window window );
103 
104  void killWindow() { slotKillWindow(); }
105  void suspendWindow() { slotSuspendWindow(); }
106  void resumeWindow() { slotResumeWindow(); }
107 
108  WId rootWin() const;
109 
110  bool initializing() const;
111 
116  Client* activeClient() const;
117  // Client that was activated, but it's not yet really activeClient(), because
118  // we didn't process yet the matching FocusIn event. Used mostly in focus
119  // stealing prevention code.
120  Client* mostRecentlyActivatedClient() const;
121 
122  void activateClient( Client*, bool force = false );
123  void requestFocus( Client* c, bool force = false );
124  void takeActivity( Client* c, int flags, bool handled ); // flags are ActivityFlags
125  void handleTakeActivity( Client* c, Time timestamp, int flags ); // flags are ActivityFlags
126  bool allowClientActivation( const Client* c, Time time = -1U, bool focus_in = false );
127  void restoreFocus();
128  void gotFocusIn( const Client* );
129  void setShouldGetFocus( Client* );
130  bool fakeRequestedActivity( Client* c );
131  void unfakeActivity( Client* c );
132  bool activateNextClient( Client* c );
133  bool focusChangeEnabled() { return block_focus == 0; }
134 
135  void updateColormap();
136 
140  void setClientIsMoving( Client *c );
141 
142  void place( Client *c, TQRect& area );
143  void placeSmart( Client* c, const TQRect& area );
144 
145  TQPoint adjustClientPosition( Client* c, TQPoint pos );
146  TQRect adjustClientSize( Client* c, TQRect moveResizeGeom, int mode );
147  void raiseClient( Client* c );
148  void lowerClient( Client* c );
149  void raiseClientRequest( Client* c, NET::RequestSource src, Time timestamp );
150  void lowerClientRequest( Client* c, NET::RequestSource src, Time timestamp );
151  void restackClientUnderActive( Client* );
152  void updateClientLayer( Client* c );
153  void raiseOrLowerClient( Client * );
154  void reconfigure();
155 
156  void clientHidden( Client* );
157  void clientAttentionChanged( Client* c, bool set );
158 
159  void checkActiveBorder(const TQPoint &pos, Time time);
160  void reserveActiveBorder(ActiveBorder border);
161  void unreserveActiveBorder(ActiveBorder border);
162  void reserveActiveBorderSwitching(bool reserve);
163 
167  int currentDesktop() const;
171  int numberOfDesktops() const;
172  void setNumberOfDesktops( int n );
173 
174  int activeScreen() const;
175  int numScreens() const;
176  void checkActiveScreen( const Client* c );
177  void setActiveScreenMouse( TQPoint mousepos );
178  TQRect screenGeometry( int screen ) const;
179  int screenNumber( TQPoint pos ) const;
180 
181  TQWidget* desktopWidget();
182 
183  // for TabBox
184  Client* nextFocusChainClient(Client*) const;
185  Client* previousFocusChainClient(Client*) const;
186  Client* nextStaticClient(Client*) const;
187  Client* previousStaticClient(Client*) const;
188  int nextDesktopFocusChain( int iDesktop ) const;
189  int previousDesktopFocusChain( int iDesktop ) const;
190  void closeTabBox();
191 
196  const ClientList& stackingOrder() const;
197 
198  ClientList ensureStackingOrder( const ClientList& clients ) const;
199 
200  Client* topClientOnDesktop( int desktop, bool unconstrained = false, bool only_normal = true ) const;
201  Client* findDesktop( bool topmost, int desktop ) const;
202  void sendClientToDesktop( Client* c, int desktop, bool dont_activate );
203  void windowToPreviousDesktop( Client* c );
204  void windowToNextDesktop( Client* c );
205  void sendClientToScreen( Client* c, int screen );
206 
207  void showWindowMenuAt( unsigned long id, int x, int y );
208  void showWindowMenu( unsigned long id );
209 
210  void tileWindowToBorder(unsigned long w1, int location);
211  void tileTwoWindowsHorizontally(unsigned long w1, unsigned long w2);
212  void tileTwoWindowsVertically(unsigned long w1, unsigned long w2);
213  void tileFourWindowsInGrid(unsigned long w1, unsigned long w2, unsigned long w3, unsigned long w4);
214  void kDestopResized();
215 
220  void showWindowMenu( const TQRect &pos, Client* cl );
224  void showWindowMenu( int x, int y, Client* cl );
225  void showWindowMenu( TQPoint pos, Client* cl );
226 
227  void updateMinimizedOfTransients( Client* );
228  void updateOnAllDesktopsOfTransients( Client* );
229  void checkTransients( Window w );
230 
231  void performWindowOperation( Client* c, WindowOperation op );
232 
233  void storeSession( TDEConfig* config, SMSavePhase phase );
234 
235  SessionInfo* takeSessionInfo( Client* );
236  WindowRules findWindowRules( const Client*, bool );
237  void rulesUpdated();
238  void discardUsedWindowRules( Client* c, bool withdraw );
239  void disableRulesUpdates( bool disable );
240  bool rulesUpdatesDisabled() const;
241 
242  // dcop interface
243  void cascadeDesktop();
244  void unclutterDesktop();
245  void doNotManage(TQString);
246  bool setCurrentDesktop( int new_desktop );
247  void updateOverlappingShadows(WId window);
248  void setShadowed(WId window, bool shadowed);
249  void nextDesktop();
250  void previousDesktop();
251  void circulateDesktopApplications();
252  void setCurrentScreen( int new_screen );
253 
254  TQString desktopName( int desk ) const;
255  virtual void setDesktopLayout(int , int , int );
256  void updateDesktopLayout();
257  void setShowingDesktop( bool showing );
258  void resetShowingDesktop( bool keep_hidden );
259  bool showingDesktop() const;
260 
261  bool isNotManaged( const TQString& title ); // ### setter or getter ?
262 
263  void sendPingToWindow( Window w, Time timestamp ); // called from Client::pingWindow()
264  void sendTakeActivity( Client* c, Time timestamp, long flags ); // called from Client::takeActivity()
265 
266  bool kompmgrIsRunning();
267  void setOpacity(unsigned long winId, unsigned int opacityPercent);
268  void setShadowSize(unsigned long winId, unsigned int shadowSizePercent);
269  void setUnshadowed(unsigned long winId); // redundant, equals setShadowSize(inId, 0)
270 
271  // only called from Client::destroyClient() or Client::releaseWindow()
272  void removeClient( Client*, allowed_t );
273  void setActiveClient( Client*, allowed_t );
274  Group* findGroup( Window leader ) const;
275  void addGroup( Group* group, allowed_t );
276  void removeGroup( Group* group, allowed_t );
277  Group* findClientLeaderGroup( const Client* c ) const;
278 
279  bool checkStartupNotification( Window w, TDEStartupInfoId& id, TDEStartupInfoData& data );
280 
281  void focusToNull(); // SELI public?
282  enum FocusChainChange { FocusChainMakeFirst, FocusChainMakeLast, FocusChainUpdate };
283  void updateFocusChains( Client* c, FocusChainChange change );
284 
285  bool forcedGlobalMouseGrab() const;
286  void clientShortcutUpdated( Client* c );
287  bool shortcutAvailable( const TDEShortcut& cut, Client* ignore = NULL ) const;
288  bool globalShortcutsDisabled() const;
289  void disableGlobalShortcuts( bool disable );
290  void disableGlobalShortcutsForClient( bool disable );
291 
292  void sessionSaveStarted();
293  void sessionSaveDone();
294  void setWasUserInteraction();
295  bool wasUserInteraction() const;
296  bool sessionSaving() const;
297 
298  bool managingTopMenus() const;
299  int topMenuHeight() const;
300  void updateCurrentTopMenu();
301 
302  int packPositionLeft( const Client* cl, int oldx, bool left_edge ) const;
303  int packPositionRight( const Client* cl, int oldx, bool right_edge ) const;
304  int packPositionUp( const Client* cl, int oldy, bool top_edge ) const;
305  int packPositionDown( const Client* cl, int oldy, bool bottom_edge ) const;
306 
307  static TQStringList configModules(bool controlCenter);
308 
309  void cancelDelayFocus();
310  void requestDelayFocus( Client* );
311  void updateFocusMousePosition( const TQPoint& pos );
312  TQPoint focusMousePosition() const;
313 
314  void toggleTopDockShadows(bool on);
315 
316  public slots:
317  void refresh();
318  // keybindings
319  void slotSwitchDesktopNext();
320  void slotSwitchDesktopPrevious();
321  void slotSwitchDesktopRight();
322  void slotSwitchDesktopLeft();
323  void slotSwitchDesktopUp();
324  void slotSwitchDesktopDown();
325 
326  void slotSwitchToDesktop( int );
327  //void slotSwitchToWindow( int );
328  void slotWindowToDesktop( int );
329  //void slotWindowToListPosition( int );
330  void slotSwitchToScreen( int );
331  void slotWindowToScreen( int );
332  void slotSwitchToNextScreen();
333  void slotWindowToNextScreen();
334 
335  void slotWindowMaximize();
336  void slotWindowMaximizeVertical();
337  void slotWindowMaximizeHorizontal();
338  void slotWindowMinimize();
339  void slotWindowShade();
340  void slotWindowRaise();
341  void slotWindowLower();
342  void slotWindowRaiseOrLower();
343  void slotActivateAttentionWindow();
344  void slotWindowPackLeft();
345  void slotWindowPackRight();
346  void slotWindowPackUp();
347  void slotWindowPackDown();
348  void slotWindowGrowHorizontal();
349  void slotWindowGrowVertical();
350  void slotWindowShrinkHorizontal();
351  void slotWindowShrinkVertical();
352 
353  void slotWalkThroughDesktops();
354  void slotWalkBackThroughDesktops();
355  void slotWalkThroughApps();
356  void slotWalkBackThroughApps();
357 
358  void slotWalkThroughDesktopList();
359  void slotWalkBackThroughDesktopList();
360  void slotWalkThroughWindows();
361  void slotWalkBackThroughWindows();
362 
363  void slotWindowOperations();
364  void slotWindowClose();
365  void slotWindowMove();
366  void slotWindowResize();
367  void slotWindowAbove();
368  void slotWindowBelow();
369  void slotWindowOnAllDesktops();
370  void slotWindowFullScreen();
371  void slotWindowNoBorder();
372 
373  void slotWindowToNextDesktop();
374  void slotWindowToPreviousDesktop();
375  void slotWindowToDesktopRight();
376  void slotWindowToDesktopLeft();
377  void slotWindowToDesktopUp();
378  void slotWindowToDesktopDown();
379 
380  void slotMouseEmulation();
381  void slotDisableGlobalShortcuts();
382 
383  void slotSettingsChanged( int category );
384 
385  void slotReconfigure();
386 
387  void slotKillWindow();
388  void slotSuspendWindow();
389  void slotResumeWindow();
390 
391  void slotGrabWindow();
392  void slotGrabDesktop();
393 
394  void slotSetupWindowShortcut();
395  void setupWindowShortcutDone( bool );
396 
397  void updateClientArea();
398 
399  // kompmgr, also dcop
400  void startKompmgr();
401 
402  private slots:
403  void desktopPopupAboutToShow();
404  void clientPopupAboutToShow();
405  void slotSendToDesktop( int );
406  void clientPopupActivated( int );
407  void configureWM();
408  void desktopResized();
409  void slotUpdateToolWindows();
410  void lostTopMenuSelection();
411  void lostTopMenuOwner();
412  void delayFocus();
413  void gotTemporaryRulesMessage( const TQString& );
414  void cleanupTemporaryRules();
415  void writeWindowRules();
416  void kipcMessage( int id, int data );
417  void updateActiveBorders();
418  void tileCurrentWindowToBorder(int position);
419  // kompmgr
420  void setPopupClientOpacity(int v);
421  void resetClientOpacity();
422  void setTransButtonText(int value);
423  void unblockKompmgrRestart();
424  void restartKompmgr( TDEProcess *proc );
425  void handleKompmgrOutput( TDEProcess *proc, char *buffer, int buflen);
426  void stopKompmgr();
427  void killKompmgr();
428  void kompmgrReloadSettings();
429  // end
430 
431  protected:
432  bool keyPressMouseEmulation( XKeyEvent& ev );
433 
434  private:
435  void init();
436  void initShortcuts();
437  void readShortcuts();
438  void initDesktopPopup();
439  void setupWindowShortcut( Client* c );
440 
441  bool startKDEWalkThroughWindows();
442  bool startWalkThroughDesktops( int mode ); // TabBox::Mode::DesktopMode | DesktopListMode
443  bool startWalkThroughDesktops();
444  bool startWalkThroughDesktopList();
445  void KDEWalkThroughWindows( bool forward );
446  void CDEWalkThroughWindows( bool forward );
447  void walkThroughDesktops( bool forward );
448  void KDEOneStepThroughWindows( bool forward );
449  void oneStepThroughDesktops( bool forward, int mode ); // TabBox::Mode::DesktopMode | DesktopListMode
450  void oneStepThroughDesktops( bool forward );
451  void oneStepThroughDesktopList( bool forward );
452  bool establishTabBoxGrab();
453  void removeTabBoxGrab();
454  int desktopToRight( int desktop ) const;
455  int desktopToLeft( int desktop ) const;
456  int desktopUp( int desktop ) const;
457  int desktopDown( int desktop ) const;
458 
459  void updateStackingOrder( bool propagate_new_clients = false );
460  void propagateClients( bool propagate_new_clients ); // called only from updateStackingOrder
461  ClientList constrainedStackingOrder();
462  void raiseClientWithinApplication( Client* c );
463  void lowerClientWithinApplication( Client* c );
464  bool allowFullClientRaising( const Client* c, Time timestamp );
465  bool keepTransientAbove( const Client* mainwindow, const Client* transient );
466  void blockStackingUpdates( bool block );
467  void addTopMenu( Client* c );
468  void removeTopMenu( Client* c );
469  void setupTopMenuHandling();
470  void updateTopMenuGeometry( Client* c = NULL );
471  void updateToolWindows( bool also_hide );
472 
473  // this is the right way to create a new client
474  Client* createClient( Window w, bool is_mapped );
475  void addClient( Client* c, allowed_t );
476 
477  Window findSpecialEventWindow( XEvent* e );
478 
479  void randomPlacement(Client* c);
480  void smartPlacement(Client* c);
481  void cascadePlacement(Client* c, bool re_init = false);
482 
483  bool addSystemTrayWin( WId w );
484  bool removeSystemTrayWin( WId w, bool check );
485  void propagateSystemTrayWins();
486  SystemTrayWindow findSystemTrayWin( WId w );
487 
488  // desktop names and number of desktops
489  void loadDesktopSettings();
490  void saveDesktopSettings();
491 
492  // mouse emulation
493  WId getMouseEmulationWindow();
494  enum MouseEmulation { EmuPress, EmuRelease, EmuMove };
495  unsigned int sendFakedMouseEvent( TQPoint pos, WId win, MouseEmulation type, int button, unsigned int state ); // returns the new state
496 
497  void tabBoxKeyPress( const KKeyNative& keyX );
498  void tabBoxKeyRelease( const XKeyEvent& ev );
499 
500  // active borders
501  void destroyActiveBorders();
502  bool activeBorderEvent(XEvent *e);
503  void activeBorderSwitchDesktop(ActiveBorder border, const TQPoint& pos);
504 
505  // ------------------
506 
507  void helperDialog( const TQString& message, const Client* c );
508 
509  void calcDesktopLayout(int &x, int &y) const;
510 
511  TQPopupMenu* makeTileMenu();
512  TQPopupMenu* clientPopup();
513  void closeActivePopup();
514 
515  void updateClientArea( bool force );
516 
517  SystemTrayWindowList systemTrayWins;
518 
519  int current_desktop;
520  int number_of_desktops;
521  TQMemArray<int> desktop_focus_chain;
522  int active_screen;
523 
524  TQWidget* active_popup;
525  Client* active_popup_client;
526 
527  TQWidget* desktop_widget;
528 
529  void loadSessionInfo();
530  void loadWindowRules();
531  void editWindowRules( Client* c, bool whole_app );
532 
533  TQPtrList<SessionInfo> session;
534  TQValueList<Rules*> rules;
535  KXMessages temporaryRulesMessages;
536  TQTimer rulesUpdatedTimer;
537  bool rules_updates_disabled;
538  static const char* windowTypeToTxt( NET::WindowType type );
539  static NET::WindowType txtToWindowType( const char* txt );
540  static bool sessionInfoWindowTypeMatch( Client* c, SessionInfo* info );
542  static uint percentToUint(int percent);
543 
544  Client* active_client;
545  Client* last_active_client;
546  Client* next_active_client; // will be active after active_client deactivates
547  Client* most_recently_raised; // used _only_ by raiseOrLowerClient()
548  Client* movingClient;
549  Client* pending_take_activity;
550 
551  // delay(ed) window focus timer and client
552  TQTimer* delayFocusTimer;
553  Client* delayfocus_client;
554  TQPoint focusMousePos;
555 
556  ClientList clients;
557  ClientList desktops;
558 
559  ClientList unconstrained_stacking_order; // topmost last
560  ClientList stacking_order; // topmost last
561  TQValueVector< ClientList > focus_chain; // currently active last
562  ClientList global_focus_chain; // this one is only for things like tabbox's MRU
563  ClientList should_get_focus; // last is most recent
564  ClientList attention_chain;
565 
566  bool showing_desktop;
567  ClientList showing_desktop_clients;
568  int block_showing_desktop;
569 
570  GroupList groups;
571 
572  bool was_user_interaction;
573  bool session_saving;
574  int session_active_client;
575  int session_desktop;
576 
577  bool control_grab;
578  bool tab_grab;
579  //KKeyNative walkThroughDesktopsKeycode, walkBackThroughDesktopsKeycode;
580  //KKeyNative walkThroughDesktopListKeycode, walkBackThroughDesktopListKeycode;
581  //KKeyNative walkThroughWindowsKeycode, walkBackThroughWindowsKeycode;
582  TDEShortcut cutWalkThroughDesktops, cutWalkThroughDesktopsReverse;
583  TDEShortcut cutWalkThroughDesktopList, cutWalkThroughDesktopListReverse;
584  TDEShortcut cutWalkThroughWindows, cutWalkThroughWindowsReverse;
585  TDEShortcut cutWalkThroughApps, cutWalkThroughAppsReverse;
586  bool mouse_emulation;
587  unsigned int mouse_emulation_state;
588  WId mouse_emulation_window;
589  int block_focus;
590 
591  TabBox* tab_box;
592  PopupInfo* popupinfo;
593 
594  TQPopupMenu *popup;
595  TQPopupMenu *advanced_popup;
596  TQPopupMenu *desk_popup;
597  int desk_popup_index;
598  int tile_popup_index;
599 
600  TDEGlobalAccel *keys;
601  TDEGlobalAccel *client_keys;
602  ShortcutDialog* client_keys_dialog;
603  Client* client_keys_client;
604  TDEGlobalAccel *disable_shortcuts_keys;
605  bool global_shortcuts_disabled;
606  bool global_shortcuts_disabled_for_client;
607 
608  WId root;
609 
610  PluginMgr *mgr;
611 
612  RootInfo *rootInfo;
613  TQWidget* supportWindow;
614 
615  // swallowing
616  TQStringList doNotManageList;
617 
618  // colormap handling
619  Colormap default_colormap;
620  Colormap installed_colormap;
621 
622  // Timer to collect requests for 'reconfigure'
623  TQTimer reconfigureTimer;
624 
625  TQTimer updateToolWindowsTimer;
626 
627  static Workspace *_self;
628 
629  bool workspaceInit;
630 
631  TDEStartupInfo* startup;
632 
633  ActiveBorder active_current_border;
634  Window active_windows[ ACTIVE_BORDER_COUNT ];
635  int activeLeft;
636  int activeRight;
637  int activeTop;
638  int activeBottom;
639  Time active_time_first;
640  Time active_time_last;
641  Time active_time_last_trigger;
642  TQPoint active_push_point;
643  int active_reserved[ ACTIVE_BORDER_COUNT ]; // corners/edges used by something
644 
645  TQt::Orientation layoutOrientation;
646  int layoutX;
647  int layoutY;
648 
649  Placement *initPositioning;
650 
651  TQRect* workarea; // array of workareas for virtual desktops
652  TQRect** screenarea; // array of workareas per xinerama screen for all virtual desktops
653 
654  bool managing_topmenus;
655  TDESelectionOwner* topmenu_selection;
656  TDESelectionWatcher* topmenu_watcher;
657  ClientList topmenus; // doesn't own them
658  mutable int topmenu_height;
659  TQWidget* topmenu_space;
660 
661  int set_active_client_recursion;
662  int block_stacking_updates; // when >0, stacking updates are temporarily disabled
663  bool blocked_propagating_new_clients; // propagate also new clients after enabling stacking updates?
664  Window null_focus_window;
665  bool forced_global_mouse_grab;
666  friend class StackingUpdatesBlocker;
667  friend class Client;
668 
669  //kompmgr
670  TDEProcess* kompmgr;
671  TDESelectionOwner* kompmgr_selection;
672  TQTimer *kompmgr_kill_timer;
673  bool allowKompmgrRestart;
674 
675  TQSlider *transSlider;
676  TQPushButton *transButton;
677  // not used yet
678  /*Client* topDock;
679  int maximizedWindowCounter;
680  int topDockShadowSize;*/
681  //end
682 
683  Window outline_left;
684  Window outline_right;
685  Window outline_top;
686  Window outline_bottom;
687  signals:
688  void kompmgrStarted();
689  void kompmgrStopped();
690 
691  private:
692  friend bool performTransiencyCheck();
693  };
694 
695 // helper for Workspace::blockStackingUpdates() being called in pairs (true/false)
696 class StackingUpdatesBlocker
697  {
698  public:
699  StackingUpdatesBlocker( Workspace* w )
700  : ws( w ) { ws->blockStackingUpdates( true ); }
701  ~StackingUpdatesBlocker()
702  { ws->blockStackingUpdates( false ); }
703  private:
704  Workspace* ws;
705  };
706 
707 // NET WM Protocol handler class
708 class RootInfo : public NETRootInfo4
709  {
710  private:
711  typedef KWinInternal::Client Client; // because of NET::Client
712  public:
713  RootInfo( Workspace* ws, Display *dpy, Window w, const char *name, unsigned long pr[], int pr_num, int scr= -1);
714  protected:
715  virtual void changeNumberOfDesktops(int n);
716  virtual void changeCurrentDesktop(int d);
717 // virtual void changeActiveWindow(Window w); the extended version is used
718  virtual void changeActiveWindow(Window w,NET::RequestSource src, Time timestamp, Window active_window);
719  virtual void closeWindow(Window w);
720  virtual void moveResize(Window w, int x_root, int y_root, unsigned long direction);
721  virtual void moveResizeWindow(Window w, int flags, int x, int y, int width, int height );
722  virtual void gotPing(Window w, Time timestamp);
723  virtual void restackWindow(Window w, RequestSource source, Window above, int detail, Time timestamp);
724  virtual void gotTakeActivity(Window w, Time timestamp, long flags );
725  virtual void changeShowingDesktop( bool showing );
726  private:
727  Workspace* workspace;
728  };
729 
730 
731 inline WId Workspace::rootWin() const
732  {
733  return root;
734  }
735 
736 inline bool Workspace::initializing() const
737  {
738  return workspaceInit;
739  }
740 
741 inline Client* Workspace::activeClient() const
742  {
743  // next_active_client is a kludge for drop shadows. If a window that is
744  // activated is not also raised (i.e. when focus follows mouse), then the
745  // newly activated window and its shadow won't cover visual artifacts that
746  // might exist in the inactive window's shadow. We work around this by
747  // (re)drawing the inactive window's shadow after the active window's shadow
748  // is drawn, but to do that the inactive window needs to know which window
749  // will become active next. next_active_client is a Client pointer for that
750  // purpose.
751  return next_active_client != NULL ? next_active_client : active_client;
752  }
753 
754 inline Client* Workspace::mostRecentlyActivatedClient() const
755  {
756  return should_get_focus.count() > 0 ? should_get_focus.last() : active_client;
757  }
758 
759 inline int Workspace::currentDesktop() const
760  {
761  return current_desktop;
762  }
763 
764 inline int Workspace::numberOfDesktops() const
765  {
766  return number_of_desktops;
767  }
768 
769 inline void Workspace::addGroup( Group* group, allowed_t )
770  {
771  groups.append( group );
772  }
773 
774 inline void Workspace::removeGroup( Group* group, allowed_t )
775  {
776  groups.remove( group );
777  }
778 
779 inline const ClientList& Workspace::stackingOrder() const
780  {
781 // TODO Q_ASSERT( block_stacking_updates == 0 );
782  return stacking_order;
783  }
784 
785 inline void Workspace::showWindowMenu(TQPoint pos, Client* cl)
786  {
787  showWindowMenu(TQRect(pos, pos), cl);
788  }
789 
790 inline void Workspace::showWindowMenu(int x, int y, Client* cl)
791  {
792  showWindowMenu(TQRect(TQPoint(x, y), TQPoint(x, y)), cl);
793  }
794 
795 inline
796 void Workspace::setWasUserInteraction()
797  {
798  was_user_interaction = true;
799  }
800 
801 inline
802 bool Workspace::wasUserInteraction() const
803  {
804  return was_user_interaction;
805  }
806 
807 inline
808 bool Workspace::managingTopMenus() const
809  {
810  return managing_topmenus;
811  }
812 
813 inline void Workspace::sessionSaveStarted()
814  {
815  session_saving = true;
816  }
817 
818 inline void Workspace::sessionSaveDone()
819  {
820  session_saving = false;
821  }
822 
823 inline bool Workspace::sessionSaving() const
824  {
825  return session_saving;
826  }
827 
828 inline bool Workspace::forcedGlobalMouseGrab() const
829  {
830  return forced_global_mouse_grab;
831  }
832 
833 inline bool Workspace::showingDesktop() const
834  {
835  return showing_desktop;
836  }
837 
838 inline bool Workspace::globalShortcutsDisabled() const
839  {
840  return global_shortcuts_disabled || global_shortcuts_disabled_for_client;
841  }
842 
843 inline
844 bool Workspace::rulesUpdatesDisabled() const
845  {
846  return rules_updates_disabled;
847  }
848 
849 inline
850 void Workspace::updateFocusMousePosition( const TQPoint& pos )
851  {
852  focusMousePos = pos;
853  }
854 
855 inline
856 TQPoint Workspace::focusMousePosition() const
857  {
858  return focusMousePos;
859  }
860 
861 template< typename T >
862 inline Client* Workspace::findClient( T predicate )
863  {
864  if( Client* ret = findClientInList( clients, predicate ))
865  return ret;
866  if( Client* ret = findClientInList( desktops, predicate ))
867  return ret;
868  return NULL;
869  }
870 
871 template< typename T1, typename T2 >
872 inline void Workspace::forEachClient( T1 procedure, T2 predicate )
873  {
874  for ( ClientList::ConstIterator it = clients.begin(); it != clients.end(); ++it)
875  if ( predicate( const_cast< const Client* >( *it)))
876  procedure( *it );
877  for ( ClientList::ConstIterator it = desktops.begin(); it != desktops.end(); ++it)
878  if ( predicate( const_cast< const Client* >( *it)))
879  procedure( *it );
880  }
881 
882 template< typename T >
883 inline void Workspace::forEachClient( T procedure )
884  {
885  return forEachClient( procedure, TruePredicate());
886  }
887 
888 KWIN_COMPARE_PREDICATE( ClientMatchPredicate, const Client*, cl == value );
889 inline bool Workspace::hasClient( const Client* c )
890  {
891  return findClient( ClientMatchPredicate( c ));
892  }
893 
894 } // namespace
895 
896 #endif
KWinInternal::Client
The Client class encapsulates a window decoration frame.
Definition: client.h:46

twin

Skip menu "twin"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members

twin

Skip menu "twin"
  • kate
  • libkonq
  • twin
  •   lib
Generated for twin by doxygen 1.8.17
This website is maintained by Timothy Pearson.