12 #ifndef KWIN_WORKSPACE_H
13 #define KWIN_WORKSPACE_H
16 #include <tqvaluevector.h>
17 #include <kshortcut.h>
20 #include <kxmessages.h>
22 #include "KWinInterface.h"
24 #include "kdecoration.h"
32 class KShortcutDialog;
35 class KStartupInfoData;
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);
101 void killWindow() { slotKillWindow(); }
105 bool initializing()
const;
111 Client* activeClient()
const;
115 Client* mostRecentlyActivatedClient()
const;
117 void activateClient( Client*,
bool force = FALSE );
118 void requestFocus( Client* c,
bool force = FALSE );
119 void takeActivity( Client* c,
int flags,
bool handled );
120 void handleTakeActivity( Client* c, Time timestamp,
int flags );
121 bool allowClientActivation(
const Client* c, Time time = -1U,
bool focus_in =
false );
123 void gotFocusIn(
const Client* );
124 void setShouldGetFocus( Client* );
125 bool fakeRequestedActivity( Client* c );
126 void unfakeActivity( Client* c );
127 bool activateNextClient( Client* c );
128 bool focusChangeEnabled() {
return block_focus == 0; }
130 void updateColormap();
135 void setClientIsMoving( Client *c );
137 void place( Client *c, TQRect& area );
138 void placeSmart( Client* c,
const TQRect& area );
140 TQPoint adjustClientPosition( Client* c, TQPoint pos );
141 TQRect adjustClientSize( Client* c, TQRect moveResizeGeom,
int mode );
142 void raiseClient( Client* c );
143 void lowerClient( Client* c );
144 void raiseClientRequest( Client* c, NET::RequestSource src, Time timestamp );
145 void lowerClientRequest( Client* c, NET::RequestSource src, Time timestamp );
146 void restackClientUnderActive( Client* );
147 void updateClientLayer( Client* c );
148 void raiseOrLowerClient( Client * );
151 void clientHidden( Client* );
152 void clientAttentionChanged( Client* c,
bool set );
154 void clientMoved(
const TQPoint &pos, Time time);
159 int currentDesktop()
const;
163 int numberOfDesktops()
const;
164 void setNumberOfDesktops(
int n );
166 int activeScreen()
const;
167 int numScreens()
const;
168 void checkActiveScreen(
const Client* c );
169 void setActiveScreenMouse( TQPoint mousepos );
170 TQRect screenGeometry(
int screen )
const;
171 int screenNumber( TQPoint pos )
const;
173 TQWidget* desktopWidget();
176 Client* nextFocusChainClient(Client*)
const;
177 Client* previousFocusChainClient(Client*)
const;
178 Client* nextStaticClient(Client*)
const;
179 Client* previousStaticClient(Client*)
const;
180 int nextDesktopFocusChain(
int iDesktop )
const;
181 int previousDesktopFocusChain(
int iDesktop )
const;
188 const ClientList& stackingOrder()
const;
190 ClientList ensureStackingOrder(
const ClientList& clients )
const;
192 Client* topClientOnDesktop(
int desktop,
bool unconstrained =
false,
bool only_normal =
true )
const;
193 Client* findDesktop(
bool topmost,
int desktop )
const;
194 void sendClientToDesktop( Client* c,
int desktop,
bool dont_activate );
195 void windowToPreviousDesktop( Client* c );
196 void windowToNextDesktop( Client* c );
197 void sendClientToScreen( Client* c,
int screen );
200 void showWindowMenuAt(
unsigned long id,
int x,
int y );
201 void kDestopResized();
207 void showWindowMenu(
const TQRect &pos, Client* cl );
211 void showWindowMenu(
int x,
int y, Client* cl );
212 void showWindowMenu( TQPoint pos, Client* cl );
214 void updateMinimizedOfTransients( Client* );
215 void updateOnAllDesktopsOfTransients( Client* );
216 void checkTransients( Window w );
218 void performWindowOperation( Client* c, WindowOperation op );
220 void storeSession( KConfig* config, SMSavePhase phase );
222 SessionInfo* takeSessionInfo( Client* );
223 WindowRules findWindowRules(
const Client*,
bool );
225 void discardUsedWindowRules( Client* c,
bool withdraw );
226 void disableRulesUpdates(
bool disable );
227 bool rulesUpdatesDisabled()
const;
230 void cascadeDesktop();
231 void unclutterDesktop();
232 void doNotManage(TQString);
233 bool setCurrentDesktop(
int new_desktop );
234 void updateOverlappingShadows(WId window);
235 void setShadowed(WId window,
bool shadowed);
237 void previousDesktop();
238 void circulateDesktopApplications();
239 void setCurrentScreen(
int new_screen );
241 TQString desktopName(
int desk )
const;
242 virtual void setDesktopLayout(
int ,
int ,
int );
243 void updateDesktopLayout();
244 void setShowingDesktop(
bool showing );
245 void resetShowingDesktop(
bool keep_hidden );
246 bool showingDesktop()
const;
248 bool isNotManaged(
const TQString& title );
250 void sendPingToWindow( Window w, Time timestamp );
251 void sendTakeActivity( Client* c, Time timestamp,
long flags );
253 bool kompmgrIsRunning();
254 void setOpacity(
unsigned long winId,
unsigned int opacityPercent);
255 void setShadowSize(
unsigned long winId,
unsigned int shadowSizePercent);
256 void setUnshadowed(
unsigned long winId);
259 void removeClient( Client*, allowed_t );
260 void setActiveClient( Client*, allowed_t );
261 Group* findGroup( Window leader )
const;
262 void addGroup( Group* group, allowed_t );
263 void removeGroup( Group* group, allowed_t );
264 Group* findClientLeaderGroup(
const Client* c )
const;
266 bool checkStartupNotification( Window w, KStartupInfoId&
id, KStartupInfoData& data );
269 enum FocusChainChange { FocusChainMakeFirst, FocusChainMakeLast, FocusChainUpdate };
270 void updateFocusChains( Client* c, FocusChainChange change );
272 bool forcedGlobalMouseGrab()
const;
273 void clientShortcutUpdated( Client* c );
274 bool shortcutAvailable(
const KShortcut& cut, Client* ignore = NULL )
const;
275 bool globalShortcutsDisabled()
const;
276 void disableGlobalShortcuts(
bool disable );
277 void disableGlobalShortcutsForClient(
bool disable );
279 void sessionSaveStarted();
280 void sessionSaveDone();
281 void setWasUserInteraction();
282 bool wasUserInteraction()
const;
283 bool sessionSaving()
const;
285 bool managingTopMenus()
const;
286 int topMenuHeight()
const;
287 void updateCurrentTopMenu();
289 int packPositionLeft(
const Client* cl,
int oldx,
bool left_edge )
const;
290 int packPositionRight(
const Client* cl,
int oldx,
bool right_edge )
const;
291 int packPositionUp(
const Client* cl,
int oldy,
bool top_edge )
const;
292 int packPositionDown(
const Client* cl,
int oldy,
bool bottom_edge )
const;
294 static TQStringList configModules(
bool controlCenter);
296 void cancelDelayFocus();
297 void requestDelayFocus( Client* );
298 void updateFocusMousePosition(
const TQPoint& pos );
299 TQPoint focusMousePosition()
const;
301 void toggleTopDockShadows(
bool on);
306 void slotSwitchDesktopNext();
307 void slotSwitchDesktopPrevious();
308 void slotSwitchDesktopRight();
309 void slotSwitchDesktopLeft();
310 void slotSwitchDesktopUp();
311 void slotSwitchDesktopDown();
313 void slotSwitchToDesktop(
int );
315 void slotWindowToDesktop(
int );
317 void slotSwitchToScreen(
int );
318 void slotWindowToScreen(
int );
319 void slotSwitchToNextScreen();
320 void slotWindowToNextScreen();
322 void slotWindowMaximize();
323 void slotWindowMaximizeVertical();
324 void slotWindowMaximizeHorizontal();
325 void slotWindowMinimize();
326 void slotWindowShade();
327 void slotWindowRaise();
328 void slotWindowLower();
329 void slotWindowRaiseOrLower();
330 void slotActivateAttentionWindow();
331 void slotWindowPackLeft();
332 void slotWindowPackRight();
333 void slotWindowPackUp();
334 void slotWindowPackDown();
335 void slotWindowGrowHorizontal();
336 void slotWindowGrowVertical();
337 void slotWindowShrinkHorizontal();
338 void slotWindowShrinkVertical();
340 void slotWalkThroughDesktops();
341 void slotWalkBackThroughDesktops();
342 void slotWalkThroughDesktopList();
343 void slotWalkBackThroughDesktopList();
344 void slotWalkThroughWindows();
345 void slotWalkBackThroughWindows();
347 void slotWindowOperations();
348 void slotWindowClose();
349 void slotWindowMove();
350 void slotWindowResize();
351 void slotWindowAbove();
352 void slotWindowBelow();
353 void slotWindowOnAllDesktops();
354 void slotWindowFullScreen();
355 void slotWindowNoBorder();
357 void slotWindowToNextDesktop();
358 void slotWindowToPreviousDesktop();
359 void slotWindowToDesktopRight();
360 void slotWindowToDesktopLeft();
361 void slotWindowToDesktopUp();
362 void slotWindowToDesktopDown();
364 void slotMouseEmulation();
365 void slotDisableGlobalShortcuts();
367 void slotSettingsChanged(
int category );
369 void slotReconfigure();
371 void slotKillWindow();
373 void slotGrabWindow();
374 void slotGrabDesktop();
376 void slotSetupWindowShortcut();
377 void setupWindowShortcutDone(
bool );
379 void updateClientArea();
385 void desktopPopupAboutToShow();
386 void clientPopupAboutToShow();
387 void slotSendToDesktop(
int );
388 void clientPopupActivated(
int );
390 void desktopResized();
391 void slotUpdateToolWindows();
392 void lostTopMenuSelection();
393 void lostTopMenuOwner();
395 void gotTemporaryRulesMessage(
const TQString& );
396 void cleanupTemporaryRules();
397 void writeWindowRules();
398 void kipcMessage(
int id,
int data );
400 void setPopupClientOpacity(
int v);
401 void resetClientOpacity();
402 void setTransButtonText(
int value);
403 void unblockKompmgrRestart();
404 void restartKompmgr( KProcess *proc );
405 void handleKompmgrOutput( KProcess *proc,
char *buffer,
int buflen);
410 bool keyPressMouseEmulation( XKeyEvent& ev );
414 void initShortcuts();
415 void readShortcuts();
416 void initDesktopPopup();
417 void setupWindowShortcut( Client* c );
419 bool startKDEWalkThroughWindows();
420 bool startWalkThroughDesktops(
int mode );
421 bool startWalkThroughDesktops();
422 bool startWalkThroughDesktopList();
423 void KDEWalkThroughWindows(
bool forward );
424 void CDEWalkThroughWindows(
bool forward );
425 void walkThroughDesktops(
bool forward );
426 void KDEOneStepThroughWindows(
bool forward );
427 void oneStepThroughDesktops(
bool forward,
int mode );
428 void oneStepThroughDesktops(
bool forward );
429 void oneStepThroughDesktopList(
bool forward );
430 bool establishTabBoxGrab();
431 void removeTabBoxGrab();
432 int desktopToRight(
int desktop )
const;
433 int desktopToLeft(
int desktop )
const;
434 int desktopUp(
int desktop )
const;
435 int desktopDown(
int desktop )
const;
437 void updateStackingOrder(
bool propagate_new_clients =
false );
438 void propagateClients(
bool propagate_new_clients );
439 ClientList constrainedStackingOrder();
440 void raiseClientWithinApplication( Client* c );
441 void lowerClientWithinApplication( Client* c );
442 bool allowFullClientRaising(
const Client* c, Time timestamp );
443 bool keepTransientAbove(
const Client* mainwindow,
const Client*
transient );
444 void blockStackingUpdates(
bool block );
445 void addTopMenu( Client* c );
446 void removeTopMenu( Client* c );
447 void setupTopMenuHandling();
448 void updateTopMenuGeometry( Client* c = NULL );
449 void updateToolWindows(
bool also_hide );
452 Client* createClient( Window w,
bool is_mapped );
453 void addClient( Client* c, allowed_t );
455 Window findSpecialEventWindow( XEvent* e );
457 void randomPlacement(Client* c);
458 void smartPlacement(Client* c);
459 void cascadePlacement(Client* c,
bool re_init =
false);
461 bool addSystemTrayWin( WId w );
462 bool removeSystemTrayWin( WId w,
bool check );
463 void propagateSystemTrayWins();
464 SystemTrayWindow findSystemTrayWin( WId w );
467 void loadDesktopSettings();
468 void saveDesktopSettings();
471 WId getMouseEmulationWindow();
472 enum MouseEmulation { EmuPress, EmuRelease, EmuMove };
473 unsigned int sendFakedMouseEvent( TQPoint pos, WId win, MouseEmulation type,
int button,
unsigned int state );
475 void tabBoxKeyPress(
const KKeyNative& keyX );
476 void tabBoxKeyRelease(
const XKeyEvent& ev );
479 void checkElectricBorders(
bool force =
false );
480 void createBorderWindows();
481 void destroyBorderWindows();
482 bool electricBorder(XEvent * e);
483 void raiseElectricBorders();
487 void helperDialog(
const TQString& message,
const Client* c );
489 void calcDesktopLayout(
int &x,
int &y)
const;
491 TQPopupMenu* clientPopup();
492 void closeActivePopup();
494 void updateClientArea(
bool force );
496 SystemTrayWindowList systemTrayWins;
499 int number_of_desktops;
500 TQMemArray<int> desktop_focus_chain;
503 TQWidget* active_popup;
504 Client* active_popup_client;
506 TQWidget* desktop_widget;
508 void loadSessionInfo();
509 void loadWindowRules();
510 void editWindowRules( Client* c,
bool whole_app );
512 TQPtrList<SessionInfo> session;
513 TQValueList<Rules*> rules;
514 KXMessages temporaryRulesMessages;
515 TQTimer rulesUpdatedTimer;
516 bool rules_updates_disabled;
517 static const char* windowTypeToTxt( NET::WindowType type );
518 static NET::WindowType txtToWindowType(
const char* txt );
519 static bool sessionInfoWindowTypeMatch( Client* c, SessionInfo* info );
521 Client* active_client;
522 Client* last_active_client;
523 Client* next_active_client;
524 Client* most_recently_raised;
525 Client* movingClient;
526 Client* pending_take_activity;
529 TQTimer* delayFocusTimer;
530 Client* delayfocus_client;
531 TQPoint focusMousePos;
536 ClientList unconstrained_stacking_order;
537 ClientList stacking_order;
538 TQValueVector< ClientList > focus_chain;
539 ClientList global_focus_chain;
540 ClientList should_get_focus;
541 ClientList attention_chain;
543 bool showing_desktop;
544 ClientList showing_desktop_clients;
545 int block_showing_desktop;
549 bool was_user_interaction;
551 int session_active_client;
559 KShortcut cutWalkThroughDesktops, cutWalkThroughDesktopsReverse;
560 KShortcut cutWalkThroughDesktopList, cutWalkThroughDesktopListReverse;
561 KShortcut cutWalkThroughWindows, cutWalkThroughWindowsReverse;
562 bool mouse_emulation;
563 unsigned int mouse_emulation_state;
564 WId mouse_emulation_window;
568 PopupInfo* popupinfo;
571 TQPopupMenu *advanced_popup;
572 TQPopupMenu *desk_popup;
573 int desk_popup_index;
576 KGlobalAccel *client_keys;
577 ShortcutDialog* client_keys_dialog;
578 Client* client_keys_client;
579 KGlobalAccel *disable_shortcuts_keys;
580 bool global_shortcuts_disabled;
581 bool global_shortcuts_disabled_for_client;
588 TQWidget* supportWindow;
591 TQStringList doNotManageList;
594 Colormap default_colormap;
595 Colormap installed_colormap;
598 TQTimer reconfigureTimer;
600 TQTimer updateToolWindowsTimer;
602 static Workspace *_self;
606 KStartupInfo* startup;
608 bool electric_have_borders;
609 int electric_current_border;
610 WId electric_top_border;
611 WId electric_bottom_border;
612 WId electric_left_border;
613 WId electric_right_border;
618 Time electric_time_first;
619 Time electric_time_last;
620 TQPoint electric_push_point;
622 Qt::Orientation layoutOrientation;
626 Placement *initPositioning;
631 bool managing_topmenus;
632 KSelectionOwner* topmenu_selection;
633 KSelectionWatcher* topmenu_watcher;
635 mutable int topmenu_height;
636 TQWidget* topmenu_space;
638 int set_active_client_recursion;
639 int block_stacking_updates;
640 bool blocked_propagating_new_clients;
641 Window null_focus_window;
642 bool forced_global_mouse_grab;
643 friend class StackingUpdatesBlocker;
646 TQSlider *transSlider;
647 TQPushButton *transButton;
655 void kompmgrStarted();
656 void kompmgrStopped();
659 friend bool performTransiencyCheck();
663 class StackingUpdatesBlocker
666 StackingUpdatesBlocker( Workspace* w )
667 : ws( w ) { ws->blockStackingUpdates(
true ); }
668 ~StackingUpdatesBlocker()
669 { ws->blockStackingUpdates(
false ); }
675 class RootInfo :
public NETRootInfo4
680 RootInfo( Workspace* ws, Display *dpy, Window w,
const char *name,
unsigned long pr[],
int pr_num,
int scr= -1);
682 virtual void changeNumberOfDesktops(
int n);
683 virtual void changeCurrentDesktop(
int d);
685 virtual void changeActiveWindow(Window w,NET::RequestSource src, Time timestamp, Window active_window);
686 virtual void closeWindow(Window w);
687 virtual void moveResize(Window w,
int x_root,
int y_root,
unsigned long direction);
688 virtual void moveResizeWindow(Window w,
int flags,
int x,
int y,
int width,
int height );
689 virtual void gotPing(Window w, Time timestamp);
690 virtual void restackWindow(Window w, RequestSource source, Window above,
int detail, Time timestamp);
691 virtual void gotTakeActivity(Window w, Time timestamp,
long flags );
692 virtual void changeShowingDesktop(
bool showing );
694 Workspace* workspace;
698 inline WId Workspace::rootWin()
const
703 inline bool Workspace::initializing()
const
705 return workspaceInit;
708 inline Client* Workspace::activeClient()
const
718 return next_active_client != NULL ? next_active_client : active_client;
721 inline Client* Workspace::mostRecentlyActivatedClient()
const
723 return should_get_focus.count() > 0 ? should_get_focus.last() : active_client;
726 inline int Workspace::currentDesktop()
const
728 return current_desktop;
731 inline int Workspace::numberOfDesktops()
const
733 return number_of_desktops;
736 inline void Workspace::addGroup( Group* group, allowed_t )
738 groups.append( group );
741 inline void Workspace::removeGroup( Group* group, allowed_t )
743 groups.remove( group );
746 inline const ClientList& Workspace::stackingOrder()
const
749 return stacking_order;
752 inline void Workspace::showWindowMenu(TQPoint pos, Client* cl)
754 showWindowMenu(TQRect(pos, pos), cl);
757 inline void Workspace::showWindowMenu(
int x,
int y, Client* cl)
759 showWindowMenu(TQRect(TQPoint(x, y), TQPoint(x, y)), cl);
763 void Workspace::setWasUserInteraction()
765 was_user_interaction =
true;
769 bool Workspace::wasUserInteraction()
const
771 return was_user_interaction;
775 bool Workspace::managingTopMenus()
const
777 return managing_topmenus;
780 inline void Workspace::sessionSaveStarted()
782 session_saving =
true;
785 inline void Workspace::sessionSaveDone()
787 session_saving =
false;
790 inline bool Workspace::sessionSaving()
const
792 return session_saving;
795 inline bool Workspace::forcedGlobalMouseGrab()
const
797 return forced_global_mouse_grab;
800 inline bool Workspace::showingDesktop()
const
802 return showing_desktop;
805 inline bool Workspace::globalShortcutsDisabled()
const
807 return global_shortcuts_disabled || global_shortcuts_disabled_for_client;
811 bool Workspace::rulesUpdatesDisabled()
const
813 return rules_updates_disabled;
817 void Workspace::updateFocusMousePosition(
const TQPoint& pos )
823 TQPoint Workspace::focusMousePosition()
const
825 return focusMousePos;
828 template<
typename T >
829 inline Client* Workspace::findClient( T predicate )
831 if( Client* ret = findClientInList( clients, predicate ))
833 if( Client* ret = findClientInList( desktops, predicate ))
838 template<
typename T1,
typename T2 >
839 inline void Workspace::forEachClient( T1 procedure, T2 predicate )
841 for ( ClientList::ConstIterator it = clients.begin(); it != clients.end(); ++it)
842 if ( predicate( const_cast< const Client* >( *it)))
844 for ( ClientList::ConstIterator it = desktops.begin(); it != desktops.end(); ++it)
845 if ( predicate( const_cast< const Client* >( *it)))
849 template<
typename T >
850 inline void Workspace::forEachClient( T procedure )
852 return forEachClient( procedure, TruePredicate());
855 KWIN_COMPARE_PREDICATE( ClientMatchPredicate,
const Client*, cl == value );
856 inline bool Workspace::hasClient(
const Client* c )
858 return findClient( ClientMatchPredicate( c ));