21 #include <tdeshortcut.h>
24 #include <X11/Xutil.h>
29 #include "workspace.h"
30 #include "kdecoration.h"
35 class TDEStartupInfoData;
37 namespace KWinInternal
46 class Client :
public TQObject,
public KDecorationDefines
51 Window window()
const;
52 Window frameId()
const;
53 Window wrapperId()
const;
54 Window decorationId()
const;
56 Workspace* workspace()
const;
57 const Client* transientFor()
const;
59 bool isTransient()
const;
60 bool isModalSystemNotification()
const;
61 bool groupTransient()
const;
62 bool wasOriginallyGroupTransient()
const;
63 ClientList mainClients()
const;
64 bool hasTransient(
const Client* c,
bool indirect )
const;
65 const ClientList& transients()
const;
66 void checkTransient( Window w );
68 const Group* group()
const;
70 void checkGroup( Group* gr = NULL,
bool force =
false );
71 void changeClientLeaderGroup( Group* gr );
73 NET::WindowType windowType(
bool direct =
false,
int supported_types = SUPPORTED_WINDOW_TYPES_MASK )
const;
74 const WindowRules* rules()
const;
75 void removeRule( Rules* r );
76 void setupWindowRules(
bool ignore_temporary );
77 void applyWindowRules();
78 void updateWindowRules();
80 TQRect geometry()
const;
82 TQSize minSize()
const;
83 TQSize maxSize()
const;
90 TQPoint clientPos()
const;
91 TQSize clientSize()
const;
94 virtual bool eventFilter( TQObject* o, TQEvent* e );
96 bool manage( Window w,
bool isMapped );
107 TQSize
adjustedSize(
const TQSize&, Sizemode mode = SizemodeAny )
const;
108 TQSize adjustedSize()
const;
110 TQPixmap icon()
const;
111 TQPixmap miniIcon()
const;
113 bool isActive()
const;
114 void setActive(
bool,
bool updateOpacity =
true );
116 bool isSuspendable()
const;
117 bool isResumeable()
const;
120 void setDesktop(
int );
122 bool isOnCurrentDesktop()
const;
123 bool isOnAllDesktops()
const;
124 void setOnAllDesktops(
bool set );
126 bool isOnScreen(
int screen )
const;
130 bool isShown(
bool shaded_is_shown )
const;
132 bool isShade()
const;
133 ShadeMode shadeMode()
const;
134 void setShade( ShadeMode mode );
135 bool isShadeable()
const;
137 bool isMinimized()
const;
138 bool isMaximizable()
const;
139 TQRect geometryRestore()
const;
140 MaximizeMode maximizeModeRestore()
const;
141 MaximizeMode maximizeMode()
const;
143 void setMaximize(
bool vertically,
bool horizontally );
145 void setFullScreen(
bool set,
bool user );
146 bool isFullScreen()
const;
147 bool isFullScreenable(
bool fullscreen_hack =
false )
const;
148 bool userCanSetFullScreen()
const;
149 TQRect geometryFSRestore()
const {
return geom_fs_restore; }
150 int fullScreenMode()
const {
return fullscreen_mode; }
152 bool isUserNoBorder()
const;
153 void setUserNoBorder(
bool set );
154 void setUserNoBorder(
bool set,
bool force );
155 bool userCanSetNoBorder()
const;
156 bool isUserNoBorderForced()
const;
157 bool noBorder()
const;
159 bool skipTaskbar(
bool from_outside =
false )
const;
160 void setSkipTaskbar(
bool set,
bool from_outside );
162 bool skipPager()
const;
163 void setSkipPager(
bool );
166 void setKeepAbove(
bool );
167 bool keepBelow()
const;
168 void setKeepBelow(
bool );
170 Layer belongsToLayer()
const;
171 void invalidateLayer();
173 void setModal(
bool modal );
174 bool isModal()
const;
177 bool wantsTabFocus()
const;
178 bool wantsInput()
const;
179 bool hasNETSupport()
const;
181 bool isDesktop()
const;
183 bool isToolbar()
const;
184 bool isTopMenu()
const;
186 bool isNormalWindow()
const;
187 bool isDialog()
const;
188 bool isSplash()
const;
189 bool isUtility()
const;
194 bool isSpecialWindow()
const;
197 bool isCloseable()
const;
199 void takeActivity(
int flags,
bool handled, allowed_t );
200 void takeFocus( allowed_t );
201 void demandAttention(
bool set =
true );
203 void setMask(
const TQRegion& r,
int mode = X::Unsorted );
204 TQRegion mask()
const;
206 void updateDecoration(
bool check_workspace_pos,
bool force =
false );
207 void checkBorderSizes();
210 bool isShadowed()
const;
211 void setShadowed(
bool shadowed);
212 Window shadowId()
const;
216 friend void Workspace::raiseClient(
Client *);
220 friend void Workspace::updateOverlappingShadows(WId);
226 void setGeometry(
int x,
int y,
int w,
int h, ForceGeometry_t force = NormalGeometrySet );
227 void setGeometry(
const TQRect& r, ForceGeometry_t force = NormalGeometrySet );
228 void move(
int x,
int y, ForceGeometry_t force = NormalGeometrySet );
229 void move(
const TQPoint & p, ForceGeometry_t force = NormalGeometrySet );
231 void plainResize(
int w,
int h, ForceGeometry_t force = NormalGeometrySet );
232 void plainResize(
const TQSize& s, ForceGeometry_t force = NormalGeometrySet );
234 void resizeWithChecks(
int w,
int h, ForceGeometry_t force = NormalGeometrySet );
235 void resizeWithChecks(
const TQSize& s, ForceGeometry_t force = NormalGeometrySet );
236 void keepInArea( TQRect area,
bool partial =
false );
237 void setActiveBorderMode( ActiveMaximizingMode mode );
238 void setActiveBorderPos( TQPoint pos );
239 void setActiveBorder( ActiveBorder border);
240 ActiveMaximizingMode activeBorderMode()
const;
241 TQPoint activeBorderPos()
const;
242 ActiveBorder activeBorder()
const;
243 void setActiveBorderMaximizing(
bool maximizing);
244 void cancelActiveBorderMaximizing();
245 bool isActiveBorderMaximizing()
const;
246 TQRect activeBorderMaximizeGeometry();
247 void tileToBorder(ActiveBorder border);
249 void growHorizontal();
250 void shrinkHorizontal();
252 void shrinkVertical();
255 TDEShortcut shortcut()
const;
256 void setShortcut(
const TQString& cut );
258 bool performMouseCommand( Options::MouseCommand, TQPoint globalPos,
bool handled =
false );
260 TQCString windowRole()
const;
262 TQCString resourceName()
const;
263 TQCString resourceClass()
const;
271 Colormap colormap()
const;
274 void updateVisibility();
276 void hideClient(
bool hide );
278 TQString
caption(
bool full =
true )
const;
279 void updateCaption();
281 void keyPressEvent( uint key_code );
282 void updateMouseGrab();
283 Window moveResizeGrabWindow()
const;
285 const TQPoint calculateGravitation(
bool invert,
int gravity = 0 )
const;
287 void NETMoveResize(
int x_root,
int y_root, NET::Direction direction );
288 void NETMoveResizeWindow(
int flags,
int x,
int y,
int width,
int height );
289 void restackWindow( Window above,
int detail, NET::RequestSource source, Time timestamp,
bool send_event =
false );
291 void gotPing( Time timestamp );
296 static TQCString staticWmClientMachine(WId);
299 void checkWorkspacePosition();
301 Time userTime()
const;
302 bool hasUserTimeSupport()
const;
303 bool ignoreFocusStealing()
const;
306 static void deleteClient(
Client* c, allowed_t );
308 static bool resourceMatch(
const Client* c1,
const Client* c2 );
309 static bool belongToSameApplication(
const Client* c1,
const Client* c2,
bool active_hack =
false );
310 static void readIcons( Window win, TQPixmap* icon, TQPixmap* miniicon );
312 void minimize(
bool avoid_animation =
false );
313 void unminimize(
bool avoid_animation =
false );
316 void suspendWindow();
318 bool queryUserSuspendedResume();
319 void maximize( MaximizeMode );
322 void cancelShadeHover();
323 void cancelAutoRaise();
324 void destroyClient();
325 void checkActiveModal();
328 struct Opacity { enum : uint {
330 MouseStep = 0xCCCCCCC,
334 void setOpacity(uint opacity);
335 void setShadowSize(uint shadowSize);
336 uint defaultOpacity();
338 uint defaultOpacity(
bool active);
339 void updateOpacity();
340 void updateShadowSize();
341 bool hasCustomOpacity(){
return custom_opacity;}
342 void setCustomOpacityFlag(
bool custom =
true);
343 bool getWindowOpacity();
344 int opacityPercentage();
345 void checkAndSetInitialRuledOpacity();
346 uint ruleOpacityInactive();
347 uint ruleOpacityActive();
348 unsigned int opacity();
351 bool touches(
const Client* c);
352 void setShapable(
bool b);
353 bool hasStrut()
const;
358 void configureRequestTimeout();
359 void shortcutActivated();
360 void updateOpacityCache();
365 virtual void processMousePressEvent( TQMouseEvent* e );
371 Position mousePosition(
const TQPoint& )
const;
372 void setCursor( Position m );
373 void setCursor(
const TQCursor& c );
375 void animateMinimizeOrUnminimize(
bool minimize );
376 TQPixmap animationPixmap(
int w );
378 void drawbound(
const TQRect& geom );
380 void doDrawbound(
const TQRect& geom,
bool clear );
383 bool mapRequestEvent( XMapRequestEvent* e );
384 void unmapNotifyEvent( XUnmapEvent*e );
385 void destroyNotifyEvent( XDestroyWindowEvent*e );
386 void configureRequestEvent( XConfigureRequestEvent* e );
387 void propertyNotifyEvent( XPropertyEvent* e );
388 void clientMessageEvent( XClientMessageEvent* e );
389 void enterNotifyEvent( XCrossingEvent* e );
390 void leaveNotifyEvent( XCrossingEvent* e );
391 void focusInEvent( XFocusInEvent* e );
392 void focusOutEvent( XFocusOutEvent* e );
394 bool buttonPressEvent( Window w,
int button,
int state,
int x,
int y,
int x_root,
int y_root );
395 bool buttonReleaseEvent( Window w,
int button,
int state,
int x,
int y,
int x_root,
int y_root );
396 bool motionNotifyEvent( Window w,
int state,
int x,
int y,
int x_root,
int y_root );
399 void drawIntersectingShadows();
400 void drawOverlappingShadows(
bool waitForMe);
401 TQRegion getExposedRegion(TQRegion occludedRegion,
int x,
int y,
402 int w,
int h,
int thickness,
int xOffset,
int yOffset);
403 void imposeCachedShadow(TQPixmap &pixmap, TQRegion exposed);
404 void imposeRegionShadow(TQPixmap &pixmap, TQRegion occluded,
405 TQRegion exposed,
int thickness,
double maxOpacity = 0.75);
407 void processDecorationButtonPress(
int button,
int state,
int x,
int y,
int x_root,
int y_root );
411 void processKillerExited();
412 void processResumerExited();
413 void demandAttentionKNotify();
415 void drawShadowAfter(
Client *after);
416 void drawDelayedShadow();
425 void setMappingState(
int s );
426 int mappingState()
const;
427 bool isIconicState()
const;
428 bool isNormalState()
const;
429 bool isManaged()
const;
430 void updateAllowedActions(
bool force =
false );
431 TQSize sizeForClientSize(
const TQSize&, Sizemode mode = SizemodeAny,
bool noframe =
false )
const;
432 void changeMaximize(
bool horizontal,
bool vertical,
bool adjust );
433 void checkMaximizeGeometry();
434 int checkFullScreenHack(
const TQRect& geom )
const;
435 void updateFullScreenHack(
const TQRect& geom );
436 void getWmNormalHints();
437 void getMotifHints();
439 void getWmClientLeader();
440 void getWmClientMachine();
442 void fetchIconicName();
443 TQString readName()
const;
444 void setCaption(
const TQString& s,
bool force =
false );
445 bool hasTransientInternal(
const Client* c,
bool indirect, ConstClientList& set )
const;
446 void finishWindowRules();
447 void setShortcutInternal(
const TDEShortcut& cut );
449 void updateWorkareaDiffs();
450 void checkDirection(
int new_diff,
int old_diff, TQRect& rect,
const TQRect& area );
451 static int computeWorkareaDiff(
int left,
int right,
int a_left,
int a_right );
452 void configureRequest(
int value_mask,
int rx,
int ry,
int rw,
int rh,
int gravity,
bool from_tool );
453 NETExtendedStrut strut()
const;
454 int checkShadeGeometry(
int w,
int h );
455 void postponeGeometryUpdates(
bool postpone );
457 bool startMoveResize();
458 void finishMoveResize(
bool cancel );
459 void leaveMoveResize();
460 void checkUnrestrictedMoveResize();
461 void handleMoveResize(
int x,
int y,
int x_root,
int y_root );
462 void positionGeometryTip();
463 void grabButton(
int mod );
464 void ungrabButton(
int mod );
465 void resetMaximize();
466 void resizeDecoration(
const TQSize& s );
469 void killProcess(
bool ask, Time timestamp = CurrentTime );
470 void updateUrgency();
471 static void sendClientMessage( Window w, Atom a, Atom protocol,
472 long data1 = 0,
long data2 = 0,
long data3 = 0 );
474 void embedClient( Window w,
const XWindowAttributes &attr );
475 void detectNoBorder();
476 void detectShapable();
477 void destroyDecoration();
478 void updateFrameExtents();
483 Time readUserTimeMapTimestamp(
const TDEStartupInfoId* asn_id,
const TDEStartupInfoData* asn_data,
484 bool session )
const;
485 Time readUserCreationTime()
const;
486 static bool sameAppWindowRoleMatch(
const Client* c1,
const Client* c2,
bool active_hack );
487 void startupIdChanged();
492 KDecoration* decoration;
498 bool inhibitConfigureRequests;
499 bool move_faked_activity;
500 Window move_resize_grab_window;
501 bool unrestrictedMoveResize;
504 return moveResizeMode && mode == PositionCenter;
506 bool isResize()
const
508 return moveResizeMode && mode != PositionCenter;
513 TQPoint invertedMoveOffset;
514 TQRect moveResizeGeom;
515 TQRect initialMoveResizeGeom;
516 XSizeHints xSizeHint;
517 void sendSyntheticConfigureNotify();
519 void readTransient();
520 Window verifyTransientFor( Window transient_for,
bool set );
521 void addTransient(
Client* cl );
522 void removeTransient(
Client* cl );
523 void removeFromMainClients();
524 void cleanGrouping();
525 void checkGroupTransients();
526 void setTransient( Window new_transient_for_id );
528 Window transient_for_id;
529 Window original_transient_for_id;
530 ClientList transients_list;
531 ShadeMode shade_mode;
536 uint skip_taskbar :1;
537 uint original_skip_taskbar :1;
538 uint Pdeletewindow :1;
540 uint Ptakeactivity : 1;
541 uint Pcontexthelp : 1;
545 uint motif_noborder : 1;
546 uint motif_may_resize : 1;
547 uint motif_may_move :1;
548 uint motif_may_close : 1;
554 uint user_noborder : 1;
556 uint ignore_focus_stealing : 1;
557 uint demands_attention : 1;
558 uint user_noborder_forced : 1;
559 WindowRules client_rules;
562 void getWindowProtocols();
564 TQPixmap miniicon_pix;
568 enum FullScreenMode { FullScreenNone, FullScreenNormal, FullScreenHack };
569 FullScreenMode fullscreen_mode;
570 MaximizeMode max_mode;
572 TQRect geom_fs_restore;
573 MaximizeMode maxmode_restore;
574 int workarea_diff_x, workarea_diff_y;
576 TQTimer* autoRaiseTimer;
577 TQTimer* shadeHoverTimer;
578 TQTimer* configureRequestTimer;
580 TQCString resource_name;
581 TQCString resource_class;
582 TQCString client_machine;
583 TQString cap_normal, cap_iconic, cap_suffix;
584 WId wmClientLeaderWin;
585 TQCString window_role;
590 TDEProcess* process_killer;
591 TDEProcess* process_resumer;
594 unsigned long allowed_actions;
595 TQRect frame_geometry;
597 int postpone_geometry_updates;
598 bool pending_geometry_update;
599 bool shade_geometry_change;
600 int border_left, border_right, border_top, border_bottom;
602 Client* shadowAfterClient;
603 TQWidget* shadowWidget;
604 TQMemArray<double> activeOpacityCache;
605 TQMemArray<double> inactiveOpacityCache;
606 TQMemArray<double>* opacityCache;
607 TQRegion shapeBoundingRegion;
608 TQTimer* shadowDelayTimer;
612 static bool check_active_modal;
613 TDEShortcut _shortcut;
614 friend struct FetchNameInternalPredicate;
615 friend struct CheckIgnoreFocusStealingProcedure;
616 friend struct ResetupRulesProcedure;
617 friend class GeometryUpdatesPostponer;
618 void show() { assert(
false ); }
619 void hide() { assert(
false ); }
623 uint rule_opacity_active;
624 uint rule_opacity_inactive;
627 TQTimer* demandAttentionKNotifyTimer;
629 bool activeMaximizing;
631 ActiveMaximizingMode activeMode;
633 ActiveBorder currentActiveBorder;
635 friend bool performTransiencyCheck();
636 bool minimized_before_suspend;
640 class GeometryUpdatesPostponer
643 GeometryUpdatesPostponer(
Client* c )
644 : cl( c ) { cl->postponeGeometryUpdates(
true ); }
645 ~GeometryUpdatesPostponer()
646 { cl->postponeGeometryUpdates(
false ); }
653 class WinInfo :
public NETWinInfo
658 WinInfo( Client* c, Display * display, Window window,
659 Window rwin,
const unsigned long pr[],
int pr_size );
660 virtual void changeDesktop(
int desktop);
661 virtual void changeState(
unsigned long state,
unsigned long mask );
666 inline Window Client::window()
const
671 inline Window Client::frameId()
const
676 inline Window Client::wrapperId()
const
681 inline Window Client::decorationId()
const
683 return decoration != NULL ? decoration->widget()->winId() : None;
686 inline Workspace* Client::workspace()
const
691 inline const Client* Client::transientFor()
const
693 return transient_for;
696 inline Client* Client::transientFor()
698 return transient_for;
701 inline bool Client::groupTransient()
const
703 return transient_for_id == workspace()->rootWin();
708 inline bool Client::wasOriginallyGroupTransient()
const
710 return original_transient_for_id == workspace()->rootWin();
713 inline bool Client::isTransient()
const
715 return transient_for_id != None;
718 inline const ClientList& Client::transients()
const
720 return transients_list;
723 inline const Group* Client::group()
const
728 inline Group* Client::group()
733 inline int Client::mappingState()
const
735 return mapping_state;
738 inline TQCString Client::resourceName()
const
740 return resource_name;
743 inline TQCString Client::resourceClass()
const
745 return resource_class;
749 bool Client::isMinimized()
const
754 inline bool Client::isActive()
const
770 inline bool Client::isOnAllDesktops()
const
772 return desk == NET::OnAllDesktops;
780 return desk == d || isOnAllDesktops();
784 bool Client::isShown(
bool shaded_is_shown )
const
786 return !isMinimized() && ( !isShade() || shaded_is_shown ) && !hidden;
790 bool Client::isShade()
const
792 return shade_mode == ShadeNormal;
796 ShadeMode Client::shadeMode()
const
801 inline TQPixmap Client::icon()
const
806 inline TQPixmap Client::miniIcon()
const
811 inline TQRect Client::geometryRestore()
const
816 inline Client::MaximizeMode Client::maximizeModeRestore()
const
818 return maxmode_restore;
821 inline Client::MaximizeMode Client::maximizeMode()
const
826 inline bool Client::skipTaskbar(
bool from_outside )
const
828 return from_outside ? original_skip_taskbar : skip_taskbar;
831 inline bool Client::skipPager()
const
836 inline bool Client::keepBelow()
const
841 inline bool Client::shape()
const
847 inline bool Client::isFullScreen()
const
849 return fullscreen_mode != FullScreenNone;
852 inline bool Client::isModal()
const
857 inline bool Client::hasNETSupport()
const
859 return info->hasNETSupport();
862 inline Colormap Client::colormap()
const
867 inline pid_t Client::pid()
const
872 inline void Client::invalidateLayer()
874 in_layer = UnknownLayer;
877 inline bool Client::isIconicState()
const
879 return mapping_state == IconicState;
882 inline bool Client::isNormalState()
const
884 return mapping_state == NormalState;
887 inline bool Client::isManaged()
const
889 return mapping_state != WithdrawnState;
892 inline TQCString Client::windowRole()
const
897 inline TQRect Client::geometry()
const
899 return frame_geometry;
902 inline TQSize Client::size()
const
904 return frame_geometry.size();
907 inline TQPoint Client::pos()
const
909 return frame_geometry.topLeft();
912 inline int Client::x()
const
914 return frame_geometry.x();
917 inline int Client::y()
const
919 return frame_geometry.y();
922 inline int Client::width()
const
924 return frame_geometry.width();
927 inline int Client::height()
const
929 return frame_geometry.height();
932 inline TQRect Client::rect()
const
934 return TQRect( 0, 0, width(), height());
937 inline TQPoint Client::clientPos()
const
939 return TQPoint( border_left, border_top );
942 inline TQSize Client::clientSize()
const
949 setGeometry( r.x(), r.y(), r.width(), r.height(), force );
952 inline void Client::move(
const TQPoint & p, ForceGeometry_t force )
954 move( p.x(), p.y(), force );
957 inline void Client::plainResize(
const TQSize& s, ForceGeometry_t force )
959 plainResize( s.width(), s.height(), force );
962 inline bool Client::isShadowed()
const
967 inline Window Client::shadowId()
const
969 return shadowWidget != NULL ? shadowWidget->winId() : None;
972 inline void Client::resizeWithChecks(
const TQSize& s, ForceGeometry_t force )
974 resizeWithChecks( s.width(), s.height(), force );
977 inline bool Client::hasUserTimeSupport()
const
979 return info->userTime() != -1U;
982 inline bool Client::ignoreFocusStealing()
const
984 return ignore_focus_stealing;
987 inline const WindowRules* Client::rules()
const
989 return &client_rules;
992 KWIN_PROCEDURE( CheckIgnoreFocusStealingProcedure, cl->ignore_focus_stealing = options->checkIgnoreFocusStealing( cl ));
994 inline Window Client::moveResizeGrabWindow()
const
996 return move_resize_grab_window;
999 inline TDEShortcut Client::shortcut()
const
1004 inline bool Client::isBMP()
1009 inline void Client::setBMP(
bool b)
1014 inline void Client::removeRule( Rules* rule )
1016 client_rules.remove( rule );
1021 kndbgstream& operator<<( kndbgstream& stream,
const Client* ) {
return stream; }
1023 kndbgstream& operator<<( kndbgstream& stream,
const ClientList& ) {
return stream; }
1025 kndbgstream& operator<<( kndbgstream& stream,
const ConstClientList& ) {
return stream; }
1027 kdbgstream& operator<<( kdbgstream& stream,
const Client* );
1028 kdbgstream& operator<<( kdbgstream& stream,
const ClientList& );
1029 kdbgstream& operator<<( kdbgstream& stream,
const ConstClientList& );
1032 KWIN_COMPARE_PREDICATE( WindowMatchPredicate, Window, cl->window() == value );
1033 KWIN_COMPARE_PREDICATE( FrameIdMatchPredicate, Window, cl->frameId() == value );
1034 KWIN_COMPARE_PREDICATE( WrapperIdMatchPredicate, Window, cl->wrapperId() == value );
The Client class encapsulates a window decoration frame.
static Window staticWmClientLeader(WId)
bool providesContextHelp() const
TQRect adjustedClientArea(const TQRect &desktop, const TQRect &area) const
void setGeometry(int x, int y, int w, int h, ForceGeometry_t force=NormalGeometrySet)
bool performMouseCommand(Options::MouseCommand, TQPoint globalPos, bool handled=false)
void setActive(bool, bool updateOpacity=true)
bool isMinimizable() const
bool manage(Window w, bool isMapped)
void minimize(bool avoid_animation=false)
static TQCString staticSessionId(WId)
bool windowEvent(XEvent *e)
TQCString wmClientMachine(bool use_localhost) const
TQSize adjustedSize(const TQSize &, Sizemode mode=SizemodeAny) const
static TQCString staticWindowRole(WId)
static TQCString staticWmCommand(WId)
void updateUserTime(Time time=CurrentTime)
bool isOnDesktop(int d) const
void releaseWindow(bool on_shutdown=false)
void setMaximize(bool vertically, bool horizontally)
Window wmClientLeader() const
TQString caption(bool full=true) const
void move(int x, int y, ForceGeometry_t force=NormalGeometrySet)