12 #ifndef KWIN_WORKSPACE_H
13 #define KWIN_WORKSPACE_H
16 #include <tqvaluevector.h>
17 #include <tdeshortcut.h>
20 #include <kxmessages.h>
22 #include "KWinInterface.h"
24 #include "kdecoration.h"
32 class TDEShortcutDialog;
34 class TDEStartupInfoId;
35 class TDEStartupInfoData;
40 namespace KWinInternal
52 class SystemTrayWindow
58 SystemTrayWindow( WId w )
61 SystemTrayWindow( WId w, WId wf )
65 bool operator==(
const SystemTrayWindow& other )
66 {
return win == other.win; }
71 typedef TQValueList<SystemTrayWindow> SystemTrayWindowList;
73 class Workspace :
public TQObject,
public KWinInterface,
public KDecorationDefines
77 Workspace(
bool restore = FALSE );
80 static Workspace *
self() {
return _self; }
82 bool workspaceEvent( XEvent * );
84 KDecoration* createDecoration( KDecorationBridge* bridge );
86 bool hasClient(
const Client * );
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 );
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;
99 void killWindowId( Window window );
100 void suspendWindowId( Window window );
101 void resumeWindowId( Window window );
102 bool isResumeableWindowID( Window window );
104 void killWindow() { slotKillWindow(); }
105 void suspendWindow() { slotSuspendWindow(); }
106 void resumeWindow() { slotResumeWindow(); }
110 bool initializing()
const;
116 Client* activeClient()
const;
120 Client* mostRecentlyActivatedClient()
const;
122 void activateClient( Client*,
bool force = FALSE );
123 void requestFocus( Client* c,
bool force = FALSE );
124 void takeActivity( Client* c,
int flags,
bool handled );
125 void handleTakeActivity( Client* c, Time timestamp,
int flags );
126 bool allowClientActivation(
const Client* c, Time time = -1U,
bool focus_in =
false );
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; }
135 void updateColormap();
140 void setClientIsMoving( Client *c );
142 void place( Client *c, TQRect& area );
143 void placeSmart( Client* c,
const TQRect& area );
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 * );
156 void clientHidden( Client* );
157 void clientAttentionChanged( Client* c,
bool set );
159 void checkActiveBorder(
const TQPoint &pos, Time time);
160 void reserveActiveBorder(ActiveBorder border);
161 void unreserveActiveBorder(ActiveBorder border);
162 void reserveActiveBorderSwitching(
bool reserve);
167 int currentDesktop()
const;
171 int numberOfDesktops()
const;
172 void setNumberOfDesktops(
int n );
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;
181 TQWidget* desktopWidget();
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;
196 const ClientList& stackingOrder()
const;
198 ClientList ensureStackingOrder(
const ClientList& clients )
const;
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 );
207 void showWindowMenuAt(
unsigned long id,
int x,
int y );
208 void showWindowMenu(
unsigned long id );
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();
220 void showWindowMenu(
const TQRect &pos, Client* cl );
224 void showWindowMenu(
int x,
int y, Client* cl );
225 void showWindowMenu( TQPoint pos, Client* cl );
227 void updateMinimizedOfTransients( Client* );
228 void updateOnAllDesktopsOfTransients( Client* );
229 void checkTransients( Window w );
231 void performWindowOperation( Client* c, WindowOperation op );
233 void storeSession( TDEConfig* config, SMSavePhase phase );
235 SessionInfo* takeSessionInfo( Client* );
236 WindowRules findWindowRules(
const Client*,
bool );
238 void discardUsedWindowRules( Client* c,
bool withdraw );
239 void disableRulesUpdates(
bool disable );
240 bool rulesUpdatesDisabled()
const;
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);
250 void previousDesktop();
251 void circulateDesktopApplications();
252 void setCurrentScreen(
int new_screen );
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;
261 bool isNotManaged(
const TQString& title );
263 void sendPingToWindow( Window w, Time timestamp );
264 void sendTakeActivity( Client* c, Time timestamp,
long flags );
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);
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;
279 bool checkStartupNotification( Window w, TDEStartupInfoId&
id, TDEStartupInfoData& data );
282 enum FocusChainChange { FocusChainMakeFirst, FocusChainMakeLast, FocusChainUpdate };
283 void updateFocusChains( Client* c, FocusChainChange change );
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 );
292 void sessionSaveStarted();
293 void sessionSaveDone();
294 void setWasUserInteraction();
295 bool wasUserInteraction()
const;
296 bool sessionSaving()
const;
298 bool managingTopMenus()
const;
299 int topMenuHeight()
const;
300 void updateCurrentTopMenu();
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;
307 static TQStringList configModules(
bool controlCenter);
309 void cancelDelayFocus();
310 void requestDelayFocus( Client* );
311 void updateFocusMousePosition(
const TQPoint& pos );
312 TQPoint focusMousePosition()
const;
314 void toggleTopDockShadows(
bool on);
319 void slotSwitchDesktopNext();
320 void slotSwitchDesktopPrevious();
321 void slotSwitchDesktopRight();
322 void slotSwitchDesktopLeft();
323 void slotSwitchDesktopUp();
324 void slotSwitchDesktopDown();
326 void slotSwitchToDesktop(
int );
328 void slotWindowToDesktop(
int );
330 void slotSwitchToScreen(
int );
331 void slotWindowToScreen(
int );
332 void slotSwitchToNextScreen();
333 void slotWindowToNextScreen();
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();
353 void slotWalkThroughDesktops();
354 void slotWalkBackThroughDesktops();
355 void slotWalkThroughApps();
356 void slotWalkBackThroughApps();
358 void slotWalkThroughDesktopList();
359 void slotWalkBackThroughDesktopList();
360 void slotWalkThroughWindows();
361 void slotWalkBackThroughWindows();
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();
373 void slotWindowToNextDesktop();
374 void slotWindowToPreviousDesktop();
375 void slotWindowToDesktopRight();
376 void slotWindowToDesktopLeft();
377 void slotWindowToDesktopUp();
378 void slotWindowToDesktopDown();
380 void slotMouseEmulation();
381 void slotDisableGlobalShortcuts();
383 void slotSettingsChanged(
int category );
385 void slotReconfigure();
387 void slotKillWindow();
388 void slotSuspendWindow();
389 void slotResumeWindow();
391 void slotGrabWindow();
392 void slotGrabDesktop();
394 void slotSetupWindowShortcut();
395 void setupWindowShortcutDone(
bool );
397 void updateClientArea();
403 void desktopPopupAboutToShow();
404 void clientPopupAboutToShow();
405 void slotSendToDesktop(
int );
406 void clientPopupActivated(
int );
408 void desktopResized();
409 void slotUpdateToolWindows();
410 void lostTopMenuSelection();
411 void lostTopMenuOwner();
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);
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);
427 void kompmgrReloadSettings();
431 bool keyPressMouseEmulation( XKeyEvent& ev );
435 void initShortcuts();
436 void readShortcuts();
437 void initDesktopPopup();
438 void setupWindowShortcut( Client* c );
440 bool startKDEWalkThroughWindows();
441 bool startWalkThroughDesktops(
int mode );
442 bool startWalkThroughDesktops();
443 bool startWalkThroughDesktopList();
444 void KDEWalkThroughWindows(
bool forward );
445 void CDEWalkThroughWindows(
bool forward );
446 void walkThroughDesktops(
bool forward );
447 void KDEOneStepThroughWindows(
bool forward );
448 void oneStepThroughDesktops(
bool forward,
int mode );
449 void oneStepThroughDesktops(
bool forward );
450 void oneStepThroughDesktopList(
bool forward );
451 bool establishTabBoxGrab();
452 void removeTabBoxGrab();
453 int desktopToRight(
int desktop )
const;
454 int desktopToLeft(
int desktop )
const;
455 int desktopUp(
int desktop )
const;
456 int desktopDown(
int desktop )
const;
458 void updateStackingOrder(
bool propagate_new_clients =
false );
459 void propagateClients(
bool propagate_new_clients );
460 ClientList constrainedStackingOrder();
461 void raiseClientWithinApplication( Client* c );
462 void lowerClientWithinApplication( Client* c );
463 bool allowFullClientRaising(
const Client* c, Time timestamp );
464 bool keepTransientAbove(
const Client* mainwindow,
const Client*
transient );
465 void blockStackingUpdates(
bool block );
466 void addTopMenu( Client* c );
467 void removeTopMenu( Client* c );
468 void setupTopMenuHandling();
469 void updateTopMenuGeometry( Client* c = NULL );
470 void updateToolWindows(
bool also_hide );
473 Client* createClient( Window w,
bool is_mapped );
474 void addClient( Client* c, allowed_t );
476 Window findSpecialEventWindow( XEvent* e );
478 void randomPlacement(Client* c);
479 void smartPlacement(Client* c);
480 void cascadePlacement(Client* c,
bool re_init =
false);
482 bool addSystemTrayWin( WId w );
483 bool removeSystemTrayWin( WId w,
bool check );
484 void propagateSystemTrayWins();
485 SystemTrayWindow findSystemTrayWin( WId w );
488 void loadDesktopSettings();
489 void saveDesktopSettings();
492 WId getMouseEmulationWindow();
493 enum MouseEmulation { EmuPress, EmuRelease, EmuMove };
494 unsigned int sendFakedMouseEvent( TQPoint pos, WId win, MouseEmulation type,
int button,
unsigned int state );
496 void tabBoxKeyPress(
const KKeyNative& keyX );
497 void tabBoxKeyRelease(
const XKeyEvent& ev );
500 void destroyActiveBorders();
501 bool activeBorderEvent(XEvent *e);
502 void activeBorderSwitchDesktop(ActiveBorder border,
const TQPoint& pos);
506 void helperDialog(
const TQString& message,
const Client* c );
508 void calcDesktopLayout(
int &x,
int &y)
const;
510 TQPopupMenu* makeTileMenu();
511 TQPopupMenu* clientPopup();
512 void closeActivePopup();
514 void updateClientArea(
bool force );
516 SystemTrayWindowList systemTrayWins;
519 int number_of_desktops;
520 TQMemArray<int> desktop_focus_chain;
523 TQWidget* active_popup;
524 Client* active_popup_client;
526 TQWidget* desktop_widget;
528 void loadSessionInfo();
529 void loadWindowRules();
530 void editWindowRules( Client* c,
bool whole_app );
532 TQPtrList<SessionInfo> session;
533 TQValueList<Rules*> rules;
534 KXMessages temporaryRulesMessages;
535 TQTimer rulesUpdatedTimer;
536 bool rules_updates_disabled;
537 static const char* windowTypeToTxt( NET::WindowType type );
538 static NET::WindowType txtToWindowType(
const char* txt );
539 static bool sessionInfoWindowTypeMatch( Client* c, SessionInfo* info );
541 Client* active_client;
542 Client* last_active_client;
543 Client* next_active_client;
544 Client* most_recently_raised;
545 Client* movingClient;
546 Client* pending_take_activity;
549 TQTimer* delayFocusTimer;
550 Client* delayfocus_client;
551 TQPoint focusMousePos;
556 ClientList unconstrained_stacking_order;
557 ClientList stacking_order;
558 TQValueVector< ClientList > focus_chain;
559 ClientList global_focus_chain;
560 ClientList should_get_focus;
561 ClientList attention_chain;
563 bool showing_desktop;
564 ClientList showing_desktop_clients;
565 int block_showing_desktop;
569 bool was_user_interaction;
571 int session_active_client;
579 TDEShortcut cutWalkThroughDesktops, cutWalkThroughDesktopsReverse;
580 TDEShortcut cutWalkThroughDesktopList, cutWalkThroughDesktopListReverse;
581 TDEShortcut cutWalkThroughWindows, cutWalkThroughWindowsReverse;
582 TDEShortcut cutWalkThroughApps, cutWalkThroughAppsReverse;
583 bool mouse_emulation;
584 unsigned int mouse_emulation_state;
585 WId mouse_emulation_window;
589 PopupInfo* popupinfo;
592 TQPopupMenu *advanced_popup;
593 TQPopupMenu *desk_popup;
594 int desk_popup_index;
595 int tile_popup_index;
597 TDEGlobalAccel *keys;
598 TDEGlobalAccel *client_keys;
599 ShortcutDialog* client_keys_dialog;
600 Client* client_keys_client;
601 TDEGlobalAccel *disable_shortcuts_keys;
602 bool global_shortcuts_disabled;
603 bool global_shortcuts_disabled_for_client;
610 TQWidget* supportWindow;
613 TQStringList doNotManageList;
616 Colormap default_colormap;
617 Colormap installed_colormap;
620 TQTimer reconfigureTimer;
622 TQTimer updateToolWindowsTimer;
624 static Workspace *_self;
628 TDEStartupInfo* startup;
630 ActiveBorder active_current_border;
631 Window active_windows[ ACTIVE_BORDER_COUNT ];
636 Time active_time_first;
637 Time active_time_last;
638 Time active_time_last_trigger;
639 TQPoint active_push_point;
640 int active_reserved[ ACTIVE_BORDER_COUNT ];
642 TQt::Orientation layoutOrientation;
646 Placement *initPositioning;
651 bool managing_topmenus;
652 TDESelectionOwner* topmenu_selection;
653 TDESelectionWatcher* topmenu_watcher;
655 mutable int topmenu_height;
656 TQWidget* topmenu_space;
658 int set_active_client_recursion;
659 int block_stacking_updates;
660 bool blocked_propagating_new_clients;
661 Window null_focus_window;
662 bool forced_global_mouse_grab;
663 friend class StackingUpdatesBlocker;
667 TQSlider *transSlider;
668 TQPushButton *transButton;
676 Window outline_right;
678 Window outline_bottom;
680 void kompmgrStarted();
681 void kompmgrStopped();
684 friend bool performTransiencyCheck();
688 class StackingUpdatesBlocker
691 StackingUpdatesBlocker( Workspace* w )
692 : ws( w ) { ws->blockStackingUpdates(
true ); }
693 ~StackingUpdatesBlocker()
694 { ws->blockStackingUpdates(
false ); }
700 class RootInfo :
public NETRootInfo4
705 RootInfo( Workspace* ws, Display *dpy, Window w,
const char *name,
unsigned long pr[],
int pr_num,
int scr= -1);
707 virtual void changeNumberOfDesktops(
int n);
708 virtual void changeCurrentDesktop(
int d);
710 virtual void changeActiveWindow(Window w,NET::RequestSource src, Time timestamp, Window active_window);
711 virtual void closeWindow(Window w);
712 virtual void moveResize(Window w,
int x_root,
int y_root,
unsigned long direction);
713 virtual void moveResizeWindow(Window w,
int flags,
int x,
int y,
int width,
int height );
714 virtual void gotPing(Window w, Time timestamp);
715 virtual void restackWindow(Window w, RequestSource source, Window above,
int detail, Time timestamp);
716 virtual void gotTakeActivity(Window w, Time timestamp,
long flags );
717 virtual void changeShowingDesktop(
bool showing );
719 Workspace* workspace;
723 inline WId Workspace::rootWin()
const
728 inline bool Workspace::initializing()
const
730 return workspaceInit;
733 inline Client* Workspace::activeClient()
const
743 return next_active_client != NULL ? next_active_client : active_client;
746 inline Client* Workspace::mostRecentlyActivatedClient()
const
748 return should_get_focus.count() > 0 ? should_get_focus.last() : active_client;
751 inline int Workspace::currentDesktop()
const
753 return current_desktop;
756 inline int Workspace::numberOfDesktops()
const
758 return number_of_desktops;
761 inline void Workspace::addGroup( Group* group, allowed_t )
763 groups.append( group );
766 inline void Workspace::removeGroup( Group* group, allowed_t )
768 groups.remove( group );
771 inline const ClientList& Workspace::stackingOrder()
const
774 return stacking_order;
777 inline void Workspace::showWindowMenu(TQPoint pos, Client* cl)
779 showWindowMenu(TQRect(pos, pos), cl);
782 inline void Workspace::showWindowMenu(
int x,
int y, Client* cl)
784 showWindowMenu(TQRect(TQPoint(x, y), TQPoint(x, y)), cl);
788 void Workspace::setWasUserInteraction()
790 was_user_interaction =
true;
794 bool Workspace::wasUserInteraction()
const
796 return was_user_interaction;
800 bool Workspace::managingTopMenus()
const
802 return managing_topmenus;
805 inline void Workspace::sessionSaveStarted()
807 session_saving =
true;
810 inline void Workspace::sessionSaveDone()
812 session_saving =
false;
815 inline bool Workspace::sessionSaving()
const
817 return session_saving;
820 inline bool Workspace::forcedGlobalMouseGrab()
const
822 return forced_global_mouse_grab;
825 inline bool Workspace::showingDesktop()
const
827 return showing_desktop;
830 inline bool Workspace::globalShortcutsDisabled()
const
832 return global_shortcuts_disabled || global_shortcuts_disabled_for_client;
836 bool Workspace::rulesUpdatesDisabled()
const
838 return rules_updates_disabled;
842 void Workspace::updateFocusMousePosition(
const TQPoint& pos )
848 TQPoint Workspace::focusMousePosition()
const
850 return focusMousePos;
853 template<
typename T >
854 inline Client* Workspace::findClient( T predicate )
856 if( Client* ret = findClientInList( clients, predicate ))
858 if( Client* ret = findClientInList( desktops, predicate ))
863 template<
typename T1,
typename T2 >
864 inline void Workspace::forEachClient( T1 procedure, T2 predicate )
866 for ( ClientList::ConstIterator it = clients.begin(); it != clients.end(); ++it)
867 if ( predicate(
const_cast< const Client*
>( *it)))
869 for ( ClientList::ConstIterator it = desktops.begin(); it != desktops.end(); ++it)
870 if ( predicate(
const_cast< const Client*
>( *it)))
874 template<
typename T >
875 inline void Workspace::forEachClient( T procedure )
877 return forEachClient( procedure, TruePredicate());
880 KWIN_COMPARE_PREDICATE( ClientMatchPredicate,
const Client*, cl == value );
881 inline bool Workspace::hasClient(
const Client* c )
883 return findClient( ClientMatchPredicate( c ));
The Client class encapsulates a window decoration frame.