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 bool userCanSetNoBorder()
const;
155 bool noBorder()
const;
157 bool skipTaskbar(
bool from_outside =
false )
const;
158 void setSkipTaskbar(
bool set,
bool from_outside );
160 bool skipPager()
const;
161 void setSkipPager(
bool );
164 void setKeepAbove(
bool );
165 bool keepBelow()
const;
166 void setKeepBelow(
bool );
168 Layer belongsToLayer()
const;
169 void invalidateLayer();
171 void setModal(
bool modal );
172 bool isModal()
const;
175 bool wantsTabFocus()
const;
176 bool wantsInput()
const;
177 bool hasNETSupport()
const;
179 bool isDesktop()
const;
181 bool isToolbar()
const;
182 bool isTopMenu()
const;
184 bool isNormalWindow()
const;
185 bool isDialog()
const;
186 bool isSplash()
const;
187 bool isUtility()
const;
192 bool isSpecialWindow()
const;
195 bool isCloseable()
const;
197 void takeActivity(
int flags,
bool handled, allowed_t );
198 void takeFocus( allowed_t );
199 void demandAttention(
bool set =
true );
201 void setMask(
const TQRegion& r,
int mode = X::Unsorted );
202 TQRegion mask()
const;
204 void updateDecoration(
bool check_workspace_pos,
bool force =
false );
205 void checkBorderSizes();
208 bool isShadowed()
const;
209 void setShadowed(
bool shadowed);
210 Window shadowId()
const;
214 friend void Workspace::raiseClient(
Client *);
218 friend void Workspace::updateOverlappingShadows(WId);
224 void setGeometry(
int x,
int y,
int w,
int h, ForceGeometry_t force = NormalGeometrySet );
225 void setGeometry(
const TQRect& r, ForceGeometry_t force = NormalGeometrySet );
226 void move(
int x,
int y, ForceGeometry_t force = NormalGeometrySet );
227 void move(
const TQPoint & p, ForceGeometry_t force = NormalGeometrySet );
229 void plainResize(
int w,
int h, ForceGeometry_t force = NormalGeometrySet );
230 void plainResize(
const TQSize& s, ForceGeometry_t force = NormalGeometrySet );
232 void resizeWithChecks(
int w,
int h, ForceGeometry_t force = NormalGeometrySet );
233 void resizeWithChecks(
const TQSize& s, ForceGeometry_t force = NormalGeometrySet );
234 void keepInArea( TQRect area,
bool partial =
false );
235 void setActiveBorderMode( ActiveMaximizingMode mode );
236 void setActiveBorder( ActiveBorder border);
237 ActiveMaximizingMode activeBorderMode()
const;
238 ActiveBorder activeBorder()
const;
239 void setActiveBorderMaximizing(
bool maximizing);
240 void cancelActiveBorderMaximizing();
241 bool isActiveBorderMaximizing()
const;
242 TQRect activeBorderMaximizeGeometry();
243 void tileToBorder(ActiveBorder border);
245 void growHorizontal();
246 void shrinkHorizontal();
248 void shrinkVertical();
251 TDEShortcut shortcut()
const;
252 void setShortcut(
const TQString& cut );
254 bool performMouseCommand( Options::MouseCommand, TQPoint globalPos,
bool handled =
false );
256 TQCString windowRole()
const;
258 TQCString resourceName()
const;
259 TQCString resourceClass()
const;
267 Colormap colormap()
const;
270 void updateVisibility();
272 void hideClient(
bool hide );
274 TQString
caption(
bool full =
true )
const;
275 void updateCaption();
277 void keyPressEvent( uint key_code );
278 void updateMouseGrab();
279 Window moveResizeGrabWindow()
const;
281 const TQPoint calculateGravitation(
bool invert,
int gravity = 0 )
const;
283 void NETMoveResize(
int x_root,
int y_root, NET::Direction direction );
284 void NETMoveResizeWindow(
int flags,
int x,
int y,
int width,
int height );
285 void restackWindow( Window above,
int detail, NET::RequestSource source, Time timestamp,
bool send_event =
false );
287 void gotPing( Time timestamp );
292 static TQCString staticWmClientMachine(WId);
295 void checkWorkspacePosition();
297 Time userTime()
const;
298 bool hasUserTimeSupport()
const;
299 bool ignoreFocusStealing()
const;
302 static void deleteClient(
Client* c, allowed_t );
304 static bool resourceMatch(
const Client* c1,
const Client* c2 );
305 static bool belongToSameApplication(
const Client* c1,
const Client* c2,
bool active_hack =
false );
306 static void readIcons( Window win, TQPixmap* icon, TQPixmap* miniicon );
308 void minimize(
bool avoid_animation =
false );
309 void unminimize(
bool avoid_animation =
false );
312 void suspendWindow();
314 bool queryUserSuspendedResume();
315 void maximize( MaximizeMode );
318 void cancelShadeHover();
319 void cancelAutoRaise();
320 void destroyClient();
321 void checkActiveModal();
322 void setOpacity(
bool translucent, uint opacity = 0);
323 void setShadowSize(uint shadowSize);
324 void updateOpacity();
325 void updateShadowSize();
326 bool hasCustomOpacity(){
return custom_opacity;}
327 void setCustomOpacityFlag(
bool custom =
true);
328 bool getWindowOpacity();
329 int opacityPercentage();
330 void checkAndSetInitialRuledOpacity();
331 uint ruleOpacityInactive();
332 uint ruleOpacityActive();
333 unsigned int opacity();
336 bool touches(
const Client* c);
337 void setShapable(
bool b);
338 bool hasStrut()
const;
343 void configureRequestTimeout();
344 void shortcutActivated();
345 void updateOpacityCache();
350 virtual void processMousePressEvent( TQMouseEvent* e );
356 Position mousePosition(
const TQPoint& )
const;
357 void setCursor( Position m );
358 void setCursor(
const TQCursor& c );
360 void animateMinimizeOrUnminimize(
bool minimize );
361 TQPixmap animationPixmap(
int w );
363 void drawbound(
const TQRect& geom );
365 void doDrawbound(
const TQRect& geom,
bool clear );
368 bool mapRequestEvent( XMapRequestEvent* e );
369 void unmapNotifyEvent( XUnmapEvent*e );
370 void destroyNotifyEvent( XDestroyWindowEvent*e );
371 void configureRequestEvent( XConfigureRequestEvent* e );
372 void propertyNotifyEvent( XPropertyEvent* e );
373 void clientMessageEvent( XClientMessageEvent* e );
374 void enterNotifyEvent( XCrossingEvent* e );
375 void leaveNotifyEvent( XCrossingEvent* e );
376 void focusInEvent( XFocusInEvent* e );
377 void focusOutEvent( XFocusOutEvent* e );
379 bool buttonPressEvent( Window w,
int button,
int state,
int x,
int y,
int x_root,
int y_root );
380 bool buttonReleaseEvent( Window w,
int button,
int state,
int x,
int y,
int x_root,
int y_root );
381 bool motionNotifyEvent( Window w,
int state,
int x,
int y,
int x_root,
int y_root );
384 void drawIntersectingShadows();
385 void drawOverlappingShadows(
bool waitForMe);
386 TQRegion getExposedRegion(TQRegion occludedRegion,
int x,
int y,
387 int w,
int h,
int thickness,
int xOffset,
int yOffset);
388 void imposeCachedShadow(TQPixmap &pixmap, TQRegion exposed);
389 void imposeRegionShadow(TQPixmap &pixmap, TQRegion occluded,
390 TQRegion exposed,
int thickness,
double maxOpacity = 0.75);
392 void processDecorationButtonPress(
int button,
int state,
int x,
int y,
int x_root,
int y_root );
396 void processKillerExited();
397 void processResumerExited();
398 void demandAttentionKNotify();
400 void drawShadowAfter(
Client *after);
401 void drawDelayedShadow();
410 void setMappingState(
int s );
411 int mappingState()
const;
412 bool isIconicState()
const;
413 bool isNormalState()
const;
414 bool isManaged()
const;
415 void updateAllowedActions(
bool force =
false );
416 TQSize sizeForClientSize(
const TQSize&, Sizemode mode = SizemodeAny,
bool noframe =
false )
const;
417 void changeMaximize(
bool horizontal,
bool vertical,
bool adjust );
418 void checkMaximizeGeometry();
419 int checkFullScreenHack(
const TQRect& geom )
const;
420 void updateFullScreenHack(
const TQRect& geom );
421 void getWmNormalHints();
422 void getMotifHints();
424 void getWmClientLeader();
425 void getWmClientMachine();
427 void fetchIconicName();
428 TQString readName()
const;
429 void setCaption(
const TQString& s,
bool force =
false );
430 bool hasTransientInternal(
const Client* c,
bool indirect, ConstClientList& set )
const;
431 void finishWindowRules();
432 void setShortcutInternal(
const TDEShortcut& cut );
434 void updateWorkareaDiffs();
435 void checkDirection(
int new_diff,
int old_diff, TQRect& rect,
const TQRect& area );
436 static int computeWorkareaDiff(
int left,
int right,
int a_left,
int a_right );
437 void configureRequest(
int value_mask,
int rx,
int ry,
int rw,
int rh,
int gravity,
bool from_tool );
438 NETExtendedStrut strut()
const;
439 int checkShadeGeometry(
int w,
int h );
440 void postponeGeometryUpdates(
bool postpone );
442 bool startMoveResize();
443 void finishMoveResize(
bool cancel );
444 void leaveMoveResize();
445 void checkUnrestrictedMoveResize();
446 void handleMoveResize(
int x,
int y,
int x_root,
int y_root );
447 void positionGeometryTip();
448 void grabButton(
int mod );
449 void ungrabButton(
int mod );
450 void resetMaximize();
451 void resizeDecoration(
const TQSize& s );
452 void setDecoHashProperty(uint topHeight, uint rightWidth, uint bottomHeight, uint leftWidth);
453 void unsetDecoHashProperty();
456 void killProcess(
bool ask, Time timestamp = CurrentTime );
457 void updateUrgency();
458 static void sendClientMessage( Window w, Atom a, Atom protocol,
459 long data1 = 0,
long data2 = 0,
long data3 = 0 );
461 void embedClient( Window w,
const XWindowAttributes &attr );
462 void detectNoBorder();
463 void detectShapable();
464 void destroyDecoration();
465 void updateFrameExtents();
470 Time readUserTimeMapTimestamp(
const TDEStartupInfoId* asn_id,
const TDEStartupInfoData* asn_data,
471 bool session )
const;
472 Time readUserCreationTime()
const;
473 static bool sameAppWindowRoleMatch(
const Client* c1,
const Client* c2,
bool active_hack );
474 void startupIdChanged();
479 KDecoration* decoration;
485 bool inhibitConfigureRequests;
486 bool move_faked_activity;
487 Window move_resize_grab_window;
488 bool unrestrictedMoveResize;
491 return moveResizeMode && mode == PositionCenter;
493 bool isResize()
const
495 return moveResizeMode && mode != PositionCenter;
500 TQPoint invertedMoveOffset;
501 TQRect moveResizeGeom;
502 TQRect initialMoveResizeGeom;
503 XSizeHints xSizeHint;
504 void sendSyntheticConfigureNotify();
506 void readTransient();
507 Window verifyTransientFor( Window transient_for,
bool set );
508 void addTransient(
Client* cl );
509 void removeTransient(
Client* cl );
510 void removeFromMainClients();
511 void cleanGrouping();
512 void checkGroupTransients();
513 void setTransient( Window new_transient_for_id );
515 Window transient_for_id;
516 Window original_transient_for_id;
517 ClientList transients_list;
518 ShadeMode shade_mode;
523 uint skip_taskbar :1;
524 uint original_skip_taskbar :1;
525 uint Pdeletewindow :1;
527 uint Ptakeactivity : 1;
528 uint Pcontexthelp : 1;
532 uint motif_noborder : 1;
533 uint motif_may_resize : 1;
534 uint motif_may_move :1;
535 uint motif_may_close : 1;
541 uint user_noborder : 1;
543 uint ignore_focus_stealing : 1;
544 uint demands_attention : 1;
545 WindowRules client_rules;
548 void getWindowProtocols();
550 TQPixmap miniicon_pix;
554 enum FullScreenMode { FullScreenNone, FullScreenNormal, FullScreenHack };
555 FullScreenMode fullscreen_mode;
556 MaximizeMode max_mode;
558 TQRect geom_fs_restore;
559 MaximizeMode maxmode_restore;
560 int workarea_diff_x, workarea_diff_y;
562 TQTimer* autoRaiseTimer;
563 TQTimer* shadeHoverTimer;
564 TQTimer* configureRequestTimer;
566 TQCString resource_name;
567 TQCString resource_class;
568 TQCString client_machine;
569 TQString cap_normal, cap_iconic, cap_suffix;
570 WId wmClientLeaderWin;
571 TQCString window_role;
576 TDEProcess* process_killer;
577 TDEProcess* process_resumer;
580 unsigned long allowed_actions;
581 TQRect frame_geometry;
583 int postpone_geometry_updates;
584 bool pending_geometry_update;
585 bool shade_geometry_change;
586 int border_left, border_right, border_top, border_bottom;
588 Client* shadowAfterClient;
589 TQWidget* shadowWidget;
590 TQMemArray<double> activeOpacityCache;
591 TQMemArray<double> inactiveOpacityCache;
592 TQMemArray<double>* opacityCache;
593 TQRegion shapeBoundingRegion;
594 TQTimer* shadowDelayTimer;
598 static bool check_active_modal;
599 TDEShortcut _shortcut;
600 friend struct FetchNameInternalPredicate;
601 friend struct CheckIgnoreFocusStealingProcedure;
602 friend struct ResetupRulesProcedure;
603 friend class GeometryUpdatesPostponer;
604 void show() { assert(
false ); }
605 void hide() { assert(
false ); }
609 uint rule_opacity_active;
610 uint rule_opacity_inactive;
613 TQTimer* demandAttentionKNotifyTimer;
615 bool activeMaximizing;
617 TQRect activeTiledOrigGeom;
618 ActiveMaximizingMode activeMode;
619 ActiveBorder currentActiveBorder;
621 friend bool performTransiencyCheck();
622 bool minimized_before_suspend;
626 class GeometryUpdatesPostponer
629 GeometryUpdatesPostponer(
Client* c )
630 : cl( c ) { cl->postponeGeometryUpdates(
true ); }
631 ~GeometryUpdatesPostponer()
632 { cl->postponeGeometryUpdates(
false ); }
639 class WinInfo :
public NETWinInfo
644 WinInfo( Client* c, Display * display, Window window,
645 Window rwin,
const unsigned long pr[],
int pr_size );
646 virtual void changeDesktop(
int desktop);
647 virtual void changeState(
unsigned long state,
unsigned long mask );
652 inline Window Client::window()
const
657 inline Window Client::frameId()
const
662 inline Window Client::wrapperId()
const
667 inline Window Client::decorationId()
const
669 return decoration != NULL ? decoration->widget()->winId() : None;
672 inline Workspace* Client::workspace()
const
677 inline const Client* Client::transientFor()
const
679 return transient_for;
682 inline Client* Client::transientFor()
684 return transient_for;
687 inline bool Client::groupTransient()
const
689 return transient_for_id == workspace()->rootWin();
694 inline bool Client::wasOriginallyGroupTransient()
const
696 return original_transient_for_id == workspace()->rootWin();
699 inline bool Client::isTransient()
const
701 return transient_for_id != None;
704 inline const ClientList& Client::transients()
const
706 return transients_list;
709 inline const Group* Client::group()
const
714 inline Group* Client::group()
719 inline int Client::mappingState()
const
721 return mapping_state;
724 inline TQCString Client::resourceName()
const
726 return resource_name;
729 inline TQCString Client::resourceClass()
const
731 return resource_class;
735 bool Client::isMinimized()
const
740 inline bool Client::isActive()
const
756 inline bool Client::isOnAllDesktops()
const
758 return desk == NET::OnAllDesktops;
766 return desk == d || isOnAllDesktops();
770 bool Client::isShown(
bool shaded_is_shown )
const
772 return !isMinimized() && ( !isShade() || shaded_is_shown ) && !hidden;
776 bool Client::isShade()
const
778 return shade_mode == ShadeNormal;
782 ShadeMode Client::shadeMode()
const
787 inline TQPixmap Client::icon()
const
792 inline TQPixmap Client::miniIcon()
const
797 inline TQRect Client::geometryRestore()
const
802 inline Client::MaximizeMode Client::maximizeModeRestore()
const
804 return maxmode_restore;
807 inline Client::MaximizeMode Client::maximizeMode()
const
812 inline bool Client::skipTaskbar(
bool from_outside )
const
814 return from_outside ? original_skip_taskbar : skip_taskbar;
817 inline bool Client::skipPager()
const
822 inline bool Client::keepBelow()
const
827 inline bool Client::shape()
const
833 inline bool Client::isFullScreen()
const
835 return fullscreen_mode != FullScreenNone;
838 inline bool Client::isModal()
const
843 inline bool Client::hasNETSupport()
const
845 return info->hasNETSupport();
848 inline Colormap Client::colormap()
const
853 inline pid_t Client::pid()
const
858 inline void Client::invalidateLayer()
860 in_layer = UnknownLayer;
863 inline bool Client::isIconicState()
const
865 return mapping_state == IconicState;
868 inline bool Client::isNormalState()
const
870 return mapping_state == NormalState;
873 inline bool Client::isManaged()
const
875 return mapping_state != WithdrawnState;
878 inline TQCString Client::windowRole()
const
883 inline TQRect Client::geometry()
const
885 return frame_geometry;
888 inline TQSize Client::size()
const
890 return frame_geometry.size();
893 inline TQPoint Client::pos()
const
895 return frame_geometry.topLeft();
898 inline int Client::x()
const
900 return frame_geometry.x();
903 inline int Client::y()
const
905 return frame_geometry.y();
908 inline int Client::width()
const
910 return frame_geometry.width();
913 inline int Client::height()
const
915 return frame_geometry.height();
918 inline TQRect Client::rect()
const
920 return TQRect( 0, 0, width(), height());
923 inline TQPoint Client::clientPos()
const
925 return TQPoint( border_left, border_top );
928 inline TQSize Client::clientSize()
const
935 setGeometry( r.x(), r.y(), r.width(), r.height(), force );
938 inline void Client::move(
const TQPoint & p, ForceGeometry_t force )
940 move( p.x(), p.y(), force );
943 inline void Client::plainResize(
const TQSize& s, ForceGeometry_t force )
945 plainResize( s.width(), s.height(), force );
948 inline bool Client::isShadowed()
const
953 inline Window Client::shadowId()
const
955 return shadowWidget != NULL ? shadowWidget->winId() : None;
958 inline void Client::resizeWithChecks(
const TQSize& s, ForceGeometry_t force )
960 resizeWithChecks( s.width(), s.height(), force );
963 inline bool Client::hasUserTimeSupport()
const
965 return info->userTime() != -1U;
968 inline bool Client::ignoreFocusStealing()
const
970 return ignore_focus_stealing;
973 inline const WindowRules* Client::rules()
const
975 return &client_rules;
978 KWIN_PROCEDURE( CheckIgnoreFocusStealingProcedure, cl->ignore_focus_stealing = options->checkIgnoreFocusStealing( cl ));
980 inline Window Client::moveResizeGrabWindow()
const
982 return move_resize_grab_window;
985 inline TDEShortcut Client::shortcut()
const
990 inline bool Client::isBMP()
995 inline void Client::setBMP(
bool b)
1000 inline void Client::removeRule( Rules* rule )
1002 client_rules.remove( rule );
1007 kndbgstream& operator<<( kndbgstream& stream,
const Client* ) {
return stream; }
1009 kndbgstream& operator<<( kndbgstream& stream,
const ClientList& ) {
return stream; }
1011 kndbgstream& operator<<( kndbgstream& stream,
const ConstClientList& ) {
return stream; }
1013 kdbgstream& operator<<( kdbgstream& stream,
const Client* );
1014 kdbgstream& operator<<( kdbgstream& stream,
const ClientList& );
1015 kdbgstream& operator<<( kdbgstream& stream,
const ConstClientList& );
1018 KWIN_COMPARE_PREDICATE( WindowMatchPredicate, Window, cl->window() == value );
1019 KWIN_COMPARE_PREDICATE( FrameIdMatchPredicate, Window, cl->frameId() == value );
1020 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)