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;
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 );
208 void showWindowMenuAt(
unsigned long id,
int x,
int y );
209 void kDestopResized();
215 void showWindowMenu(
const TQRect &pos, Client* cl );
219 void showWindowMenu(
int x,
int y, Client* cl );
220 void showWindowMenu( TQPoint pos, Client* cl );
222 void updateMinimizedOfTransients( Client* );
223 void updateOnAllDesktopsOfTransients( Client* );
224 void checkTransients( Window w );
226 void performWindowOperation( Client* c, WindowOperation op );
228 void storeSession( TDEConfig* config, SMSavePhase phase );
230 SessionInfo* takeSessionInfo( Client* );
231 WindowRules findWindowRules(
const Client*,
bool );
233 void discardUsedWindowRules( Client* c,
bool withdraw );
234 void disableRulesUpdates(
bool disable );
235 bool rulesUpdatesDisabled()
const;
238 void cascadeDesktop();
239 void unclutterDesktop();
240 void doNotManage(TQString);
241 bool setCurrentDesktop(
int new_desktop );
242 void updateOverlappingShadows(WId window);
243 void setShadowed(WId window,
bool shadowed);
245 void previousDesktop();
246 void circulateDesktopApplications();
247 void setCurrentScreen(
int new_screen );
249 TQString desktopName(
int desk )
const;
250 virtual void setDesktopLayout(
int ,
int ,
int );
251 void updateDesktopLayout();
252 void setShowingDesktop(
bool showing );
253 void resetShowingDesktop(
bool keep_hidden );
254 bool showingDesktop()
const;
256 bool isNotManaged(
const TQString& title );
258 void sendPingToWindow( Window w, Time timestamp );
259 void sendTakeActivity( Client* c, Time timestamp,
long flags );
261 bool kompmgrIsRunning();
262 void setOpacity(
unsigned long winId,
unsigned int opacityPercent);
263 void setShadowSize(
unsigned long winId,
unsigned int shadowSizePercent);
264 void setUnshadowed(
unsigned long winId);
267 void removeClient( Client*, allowed_t );
268 void setActiveClient( Client*, allowed_t );
269 Group* findGroup( Window leader )
const;
270 void addGroup( Group* group, allowed_t );
271 void removeGroup( Group* group, allowed_t );
272 Group* findClientLeaderGroup(
const Client* c )
const;
274 bool checkStartupNotification( Window w, TDEStartupInfoId&
id, TDEStartupInfoData& data );
277 enum FocusChainChange { FocusChainMakeFirst, FocusChainMakeLast, FocusChainUpdate };
278 void updateFocusChains( Client* c, FocusChainChange change );
280 bool forcedGlobalMouseGrab()
const;
281 void clientShortcutUpdated( Client* c );
282 bool shortcutAvailable(
const TDEShortcut& cut, Client* ignore = NULL )
const;
283 bool globalShortcutsDisabled()
const;
284 void disableGlobalShortcuts(
bool disable );
285 void disableGlobalShortcutsForClient(
bool disable );
287 void sessionSaveStarted();
288 void sessionSaveDone();
289 void setWasUserInteraction();
290 bool wasUserInteraction()
const;
291 bool sessionSaving()
const;
293 bool managingTopMenus()
const;
294 int topMenuHeight()
const;
295 void updateCurrentTopMenu();
297 int packPositionLeft(
const Client* cl,
int oldx,
bool left_edge )
const;
298 int packPositionRight(
const Client* cl,
int oldx,
bool right_edge )
const;
299 int packPositionUp(
const Client* cl,
int oldy,
bool top_edge )
const;
300 int packPositionDown(
const Client* cl,
int oldy,
bool bottom_edge )
const;
302 static TQStringList configModules(
bool controlCenter);
304 void cancelDelayFocus();
305 void requestDelayFocus( Client* );
306 void updateFocusMousePosition(
const TQPoint& pos );
307 TQPoint focusMousePosition()
const;
309 void toggleTopDockShadows(
bool on);
314 void slotSwitchDesktopNext();
315 void slotSwitchDesktopPrevious();
316 void slotSwitchDesktopRight();
317 void slotSwitchDesktopLeft();
318 void slotSwitchDesktopUp();
319 void slotSwitchDesktopDown();
321 void slotSwitchToDesktop(
int );
323 void slotWindowToDesktop(
int );
325 void slotSwitchToScreen(
int );
326 void slotWindowToScreen(
int );
327 void slotSwitchToNextScreen();
328 void slotWindowToNextScreen();
330 void slotWindowMaximize();
331 void slotWindowMaximizeVertical();
332 void slotWindowMaximizeHorizontal();
333 void slotWindowMinimize();
334 void slotWindowShade();
335 void slotWindowRaise();
336 void slotWindowLower();
337 void slotWindowRaiseOrLower();
338 void slotActivateAttentionWindow();
339 void slotWindowPackLeft();
340 void slotWindowPackRight();
341 void slotWindowPackUp();
342 void slotWindowPackDown();
343 void slotWindowGrowHorizontal();
344 void slotWindowGrowVertical();
345 void slotWindowShrinkHorizontal();
346 void slotWindowShrinkVertical();
348 void slotWalkThroughDesktops();
349 void slotWalkBackThroughDesktops();
350 void slotWalkThroughApps();
351 void slotWalkBackThroughApps();
353 void slotWalkThroughDesktopList();
354 void slotWalkBackThroughDesktopList();
355 void slotWalkThroughWindows();
356 void slotWalkBackThroughWindows();
358 void slotWindowOperations();
359 void slotWindowClose();
360 void slotWindowMove();
361 void slotWindowResize();
362 void slotWindowAbove();
363 void slotWindowBelow();
364 void slotWindowOnAllDesktops();
365 void slotWindowFullScreen();
366 void slotWindowNoBorder();
368 void slotWindowToNextDesktop();
369 void slotWindowToPreviousDesktop();
370 void slotWindowToDesktopRight();
371 void slotWindowToDesktopLeft();
372 void slotWindowToDesktopUp();
373 void slotWindowToDesktopDown();
375 void slotMouseEmulation();
376 void slotDisableGlobalShortcuts();
378 void slotSettingsChanged(
int category );
380 void slotReconfigure();
382 void slotKillWindow();
383 void slotSuspendWindow();
384 void slotResumeWindow();
386 void slotGrabWindow();
387 void slotGrabDesktop();
389 void slotSetupWindowShortcut();
390 void setupWindowShortcutDone(
bool );
392 void updateClientArea();
398 void desktopPopupAboutToShow();
399 void clientPopupAboutToShow();
400 void slotSendToDesktop(
int );
401 void clientPopupActivated(
int );
403 void desktopResized();
404 void slotUpdateToolWindows();
405 void lostTopMenuSelection();
406 void lostTopMenuOwner();
408 void gotTemporaryRulesMessage(
const TQString& );
409 void cleanupTemporaryRules();
410 void writeWindowRules();
411 void kipcMessage(
int id,
int data );
412 void updateActiveBorders();
414 void setPopupClientOpacity(
int v);
415 void resetClientOpacity();
416 void setTransButtonText(
int value);
417 void unblockKompmgrRestart();
418 void restartKompmgr( TDEProcess *proc );
419 void handleKompmgrOutput( TDEProcess *proc,
char *buffer,
int buflen);
421 void kompmgrReloadSettings();
425 bool keyPressMouseEmulation( XKeyEvent& ev );
429 void initShortcuts();
430 void readShortcuts();
431 void initDesktopPopup();
432 void setupWindowShortcut( Client* c );
434 bool startKDEWalkThroughWindows();
435 bool startWalkThroughDesktops(
int mode );
436 bool startWalkThroughDesktops();
437 bool startWalkThroughDesktopList();
438 void KDEWalkThroughWindows(
bool forward );
439 void CDEWalkThroughWindows(
bool forward );
440 void walkThroughDesktops(
bool forward );
441 void KDEOneStepThroughWindows(
bool forward );
442 void oneStepThroughDesktops(
bool forward,
int mode );
443 void oneStepThroughDesktops(
bool forward );
444 void oneStepThroughDesktopList(
bool forward );
445 bool establishTabBoxGrab();
446 void removeTabBoxGrab();
447 int desktopToRight(
int desktop )
const;
448 int desktopToLeft(
int desktop )
const;
449 int desktopUp(
int desktop )
const;
450 int desktopDown(
int desktop )
const;
452 void updateStackingOrder(
bool propagate_new_clients =
false );
453 void propagateClients(
bool propagate_new_clients );
454 ClientList constrainedStackingOrder();
455 void raiseClientWithinApplication( Client* c );
456 void lowerClientWithinApplication( Client* c );
457 bool allowFullClientRaising(
const Client* c, Time timestamp );
458 bool keepTransientAbove(
const Client* mainwindow,
const Client*
transient );
459 void blockStackingUpdates(
bool block );
460 void addTopMenu( Client* c );
461 void removeTopMenu( Client* c );
462 void setupTopMenuHandling();
463 void updateTopMenuGeometry( Client* c = NULL );
464 void updateToolWindows(
bool also_hide );
467 Client* createClient( Window w,
bool is_mapped );
468 void addClient( Client* c, allowed_t );
470 Window findSpecialEventWindow( XEvent* e );
472 void randomPlacement(Client* c);
473 void smartPlacement(Client* c);
474 void cascadePlacement(Client* c,
bool re_init =
false);
476 bool addSystemTrayWin( WId w );
477 bool removeSystemTrayWin( WId w,
bool check );
478 void propagateSystemTrayWins();
479 SystemTrayWindow findSystemTrayWin( WId w );
482 void loadDesktopSettings();
483 void saveDesktopSettings();
486 WId getMouseEmulationWindow();
487 enum MouseEmulation { EmuPress, EmuRelease, EmuMove };
488 unsigned int sendFakedMouseEvent( TQPoint pos, WId win, MouseEmulation type,
int button,
unsigned int state );
490 void tabBoxKeyPress(
const KKeyNative& keyX );
491 void tabBoxKeyRelease(
const XKeyEvent& ev );
494 void destroyActiveBorders();
495 bool activeBorderEvent(XEvent *e);
496 void activeBorderSwitchDesktop(ActiveBorder border,
const TQPoint& pos);
500 void helperDialog(
const TQString& message,
const Client* c );
502 void calcDesktopLayout(
int &x,
int &y)
const;
504 TQPopupMenu* clientPopup();
505 void closeActivePopup();
507 void updateClientArea(
bool force );
509 SystemTrayWindowList systemTrayWins;
512 int number_of_desktops;
513 TQMemArray<int> desktop_focus_chain;
516 TQWidget* active_popup;
517 Client* active_popup_client;
519 TQWidget* desktop_widget;
521 void loadSessionInfo();
522 void loadWindowRules();
523 void editWindowRules( Client* c,
bool whole_app );
525 TQPtrList<SessionInfo> session;
526 TQValueList<Rules*> rules;
527 KXMessages temporaryRulesMessages;
528 TQTimer rulesUpdatedTimer;
529 bool rules_updates_disabled;
530 static const char* windowTypeToTxt( NET::WindowType type );
531 static NET::WindowType txtToWindowType(
const char* txt );
532 static bool sessionInfoWindowTypeMatch( Client* c, SessionInfo* info );
534 Client* active_client;
535 Client* last_active_client;
536 Client* next_active_client;
537 Client* most_recently_raised;
538 Client* movingClient;
539 Client* pending_take_activity;
542 TQTimer* delayFocusTimer;
543 Client* delayfocus_client;
544 TQPoint focusMousePos;
549 ClientList unconstrained_stacking_order;
550 ClientList stacking_order;
551 TQValueVector< ClientList > focus_chain;
552 ClientList global_focus_chain;
553 ClientList should_get_focus;
554 ClientList attention_chain;
556 bool showing_desktop;
557 ClientList showing_desktop_clients;
558 int block_showing_desktop;
562 bool was_user_interaction;
564 int session_active_client;
572 TDEShortcut cutWalkThroughDesktops, cutWalkThroughDesktopsReverse;
573 TDEShortcut cutWalkThroughDesktopList, cutWalkThroughDesktopListReverse;
574 TDEShortcut cutWalkThroughWindows, cutWalkThroughWindowsReverse;
575 TDEShortcut cutWalkThroughApps, cutWalkThroughAppsReverse;
576 bool mouse_emulation;
577 unsigned int mouse_emulation_state;
578 WId mouse_emulation_window;
582 PopupInfo* popupinfo;
585 TQPopupMenu *advanced_popup;
586 TQPopupMenu *desk_popup;
587 int desk_popup_index;
589 TDEGlobalAccel *keys;
590 TDEGlobalAccel *client_keys;
591 ShortcutDialog* client_keys_dialog;
592 Client* client_keys_client;
593 TDEGlobalAccel *disable_shortcuts_keys;
594 bool global_shortcuts_disabled;
595 bool global_shortcuts_disabled_for_client;
602 TQWidget* supportWindow;
605 TQStringList doNotManageList;
608 Colormap default_colormap;
609 Colormap installed_colormap;
612 TQTimer reconfigureTimer;
614 TQTimer updateToolWindowsTimer;
616 static Workspace *_self;
620 TDEStartupInfo* startup;
622 ActiveBorder active_current_border;
623 Window active_windows[ ACTIVE_BORDER_COUNT ];
628 Time active_time_first;
629 Time active_time_last;
630 Time active_time_last_trigger;
631 TQPoint active_push_point;
632 int active_reserved[ ACTIVE_BORDER_COUNT ];
634 TQt::Orientation layoutOrientation;
638 Placement *initPositioning;
643 bool managing_topmenus;
644 TDESelectionOwner* topmenu_selection;
645 TDESelectionWatcher* topmenu_watcher;
647 mutable int topmenu_height;
648 TQWidget* topmenu_space;
650 int set_active_client_recursion;
651 int block_stacking_updates;
652 bool blocked_propagating_new_clients;
653 Window null_focus_window;
654 bool forced_global_mouse_grab;
655 friend class StackingUpdatesBlocker;
659 TQSlider *transSlider;
660 TQPushButton *transButton;
668 Window outline_right;
670 Window outline_bottom;
672 void kompmgrStarted();
673 void kompmgrStopped();
676 friend bool performTransiencyCheck();
680 class StackingUpdatesBlocker
683 StackingUpdatesBlocker( Workspace* w )
684 : ws( w ) { ws->blockStackingUpdates(
true ); }
685 ~StackingUpdatesBlocker()
686 { ws->blockStackingUpdates(
false ); }
692 class RootInfo :
public NETRootInfo4
697 RootInfo( Workspace* ws, Display *dpy, Window w,
const char *name,
unsigned long pr[],
int pr_num,
int scr= -1);
699 virtual void changeNumberOfDesktops(
int n);
700 virtual void changeCurrentDesktop(
int d);
702 virtual void changeActiveWindow(Window w,NET::RequestSource src, Time timestamp, Window active_window);
703 virtual void closeWindow(Window w);
704 virtual void moveResize(Window w,
int x_root,
int y_root,
unsigned long direction);
705 virtual void moveResizeWindow(Window w,
int flags,
int x,
int y,
int width,
int height );
706 virtual void gotPing(Window w, Time timestamp);
707 virtual void restackWindow(Window w, RequestSource source, Window above,
int detail, Time timestamp);
708 virtual void gotTakeActivity(Window w, Time timestamp,
long flags );
709 virtual void changeShowingDesktop(
bool showing );
711 Workspace* workspace;
715 inline WId Workspace::rootWin()
const 720 inline bool Workspace::initializing()
const 722 return workspaceInit;
725 inline Client* Workspace::activeClient()
const 735 return next_active_client != NULL ? next_active_client : active_client;
738 inline Client* Workspace::mostRecentlyActivatedClient()
const 740 return should_get_focus.count() > 0 ? should_get_focus.last() : active_client;
743 inline int Workspace::currentDesktop()
const 745 return current_desktop;
748 inline int Workspace::numberOfDesktops()
const 750 return number_of_desktops;
753 inline void Workspace::addGroup( Group* group, allowed_t )
755 groups.append( group );
758 inline void Workspace::removeGroup( Group* group, allowed_t )
760 groups.remove( group );
763 inline const ClientList& Workspace::stackingOrder()
const 766 return stacking_order;
769 inline void Workspace::showWindowMenu(TQPoint pos, Client* cl)
771 showWindowMenu(TQRect(pos, pos), cl);
774 inline void Workspace::showWindowMenu(
int x,
int y, Client* cl)
776 showWindowMenu(TQRect(TQPoint(x, y), TQPoint(x, y)), cl);
780 void Workspace::setWasUserInteraction()
782 was_user_interaction =
true;
786 bool Workspace::wasUserInteraction()
const 788 return was_user_interaction;
792 bool Workspace::managingTopMenus()
const 794 return managing_topmenus;
797 inline void Workspace::sessionSaveStarted()
799 session_saving =
true;
802 inline void Workspace::sessionSaveDone()
804 session_saving =
false;
807 inline bool Workspace::sessionSaving()
const 809 return session_saving;
812 inline bool Workspace::forcedGlobalMouseGrab()
const 814 return forced_global_mouse_grab;
817 inline bool Workspace::showingDesktop()
const 819 return showing_desktop;
822 inline bool Workspace::globalShortcutsDisabled()
const 824 return global_shortcuts_disabled || global_shortcuts_disabled_for_client;
828 bool Workspace::rulesUpdatesDisabled()
const 830 return rules_updates_disabled;
834 void Workspace::updateFocusMousePosition(
const TQPoint& pos )
840 TQPoint Workspace::focusMousePosition()
const 842 return focusMousePos;
845 template<
typename T >
846 inline Client* Workspace::findClient( T predicate )
848 if( Client* ret = findClientInList( clients, predicate ))
850 if( Client* ret = findClientInList( desktops, predicate ))
855 template<
typename T1,
typename T2 >
856 inline void Workspace::forEachClient( T1 procedure, T2 predicate )
858 for ( ClientList::ConstIterator it = clients.begin(); it != clients.end(); ++it)
859 if ( predicate( const_cast< const Client* >( *it)))
861 for ( ClientList::ConstIterator it = desktops.begin(); it != desktops.end(); ++it)
862 if ( predicate( const_cast< const Client* >( *it)))
866 template<
typename T >
867 inline void Workspace::forEachClient( T procedure )
869 return forEachClient( procedure, TruePredicate());
872 KWIN_COMPARE_PREDICATE( ClientMatchPredicate,
const Client*, cl == value );
873 inline bool Workspace::hasClient(
const Client* c )
875 return findClient( ClientMatchPredicate( c ));
The Client class encapsulates a window decoration frame.