21 #include <kshortcut.h>
24 #include <X11/Xutil.h>
29 #include "workspace.h"
30 #include "kdecoration.h"
35 class KStartupInfoData;
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 );
117 void setDesktop(
int );
119 bool isOnCurrentDesktop()
const;
120 bool isOnAllDesktops()
const;
121 void setOnAllDesktops(
bool set );
123 bool isOnScreen(
int screen )
const;
127 bool isShown(
bool shaded_is_shown )
const;
129 bool isShade()
const;
130 ShadeMode shadeMode()
const;
131 void setShade( ShadeMode mode );
132 bool isShadeable()
const;
134 bool isMinimized()
const;
135 bool isMaximizable()
const;
136 TQRect geometryRestore()
const;
137 MaximizeMode maximizeModeRestore()
const;
138 MaximizeMode maximizeMode()
const;
140 void setMaximize(
bool vertically,
bool horizontally );
142 void setFullScreen(
bool set,
bool user );
143 bool isFullScreen()
const;
144 bool isFullScreenable(
bool fullscreen_hack =
false )
const;
145 bool userCanSetFullScreen()
const;
146 TQRect geometryFSRestore()
const {
return geom_fs_restore; }
147 int fullScreenMode()
const {
return fullscreen_mode; }
149 bool isUserNoBorder()
const;
150 void setUserNoBorder(
bool set );
151 bool userCanSetNoBorder()
const;
152 bool noBorder()
const;
154 bool skipTaskbar(
bool from_outside =
false )
const;
155 void setSkipTaskbar(
bool set,
bool from_outside );
157 bool skipPager()
const;
158 void setSkipPager(
bool );
161 void setKeepAbove(
bool );
162 bool keepBelow()
const;
163 void setKeepBelow(
bool );
165 Layer belongsToLayer()
const;
166 void invalidateLayer();
168 void setModal(
bool modal );
169 bool isModal()
const;
172 bool wantsTabFocus()
const;
173 bool wantsInput()
const;
174 bool hasNETSupport()
const;
176 bool isDesktop()
const;
178 bool isToolbar()
const;
179 bool isTopMenu()
const;
181 bool isNormalWindow()
const;
182 bool isDialog()
const;
183 bool isSplash()
const;
184 bool isUtility()
const;
189 bool isSpecialWindow()
const;
192 bool isCloseable()
const;
194 void takeActivity(
int flags,
bool handled, allowed_t );
195 void takeFocus( allowed_t );
196 void demandAttention(
bool set =
true );
198 void setMask(
const TQRegion& r,
int mode = X::Unsorted );
199 TQRegion mask()
const;
201 void updateDecoration(
bool check_workspace_pos,
bool force =
false );
202 void checkBorderSizes();
205 bool isShadowed()
const;
206 void setShadowed(
bool shadowed);
207 Window shadowId()
const;
211 friend void Workspace::raiseClient(
Client *);
215 friend void Workspace::updateOverlappingShadows(WId);
221 void setGeometry(
int x,
int y,
int w,
int h, ForceGeometry_t force = NormalGeometrySet );
222 void setGeometry(
const TQRect& r, ForceGeometry_t force = NormalGeometrySet );
223 void move(
int x,
int y, ForceGeometry_t force = NormalGeometrySet );
224 void move(
const TQPoint & p, ForceGeometry_t force = NormalGeometrySet );
226 void plainResize(
int w,
int h, ForceGeometry_t force = NormalGeometrySet );
227 void plainResize(
const TQSize& s, ForceGeometry_t force = NormalGeometrySet );
229 void resizeWithChecks(
int w,
int h, ForceGeometry_t force = NormalGeometrySet );
230 void resizeWithChecks(
const TQSize& s, ForceGeometry_t force = NormalGeometrySet );
231 void keepInArea( TQRect area,
bool partial =
false );
233 void growHorizontal();
234 void shrinkHorizontal();
236 void shrinkVertical();
239 KShortcut shortcut()
const;
240 void setShortcut(
const TQString& cut );
242 bool performMouseCommand( Options::MouseCommand, TQPoint globalPos,
bool handled =
false );
244 TQCString windowRole()
const;
246 TQCString resourceName()
const;
247 TQCString resourceClass()
const;
255 Colormap colormap()
const;
258 void updateVisibility();
260 void hideClient(
bool hide );
262 TQString
caption(
bool full =
true )
const;
263 void updateCaption();
265 void keyPressEvent( uint key_code );
266 void updateMouseGrab();
267 Window moveResizeGrabWindow()
const;
269 const TQPoint calculateGravitation(
bool invert,
int gravity = 0 )
const;
271 void NETMoveResize(
int x_root,
int y_root, NET::Direction direction );
272 void NETMoveResizeWindow(
int flags,
int x,
int y,
int width,
int height );
273 void restackWindow( Window above,
int detail, NET::RequestSource source, Time timestamp,
bool send_event =
false );
275 void gotPing( Time timestamp );
280 static TQCString staticWmClientMachine(WId);
283 void checkWorkspacePosition();
285 Time userTime()
const;
286 bool hasUserTimeSupport()
const;
287 bool ignoreFocusStealing()
const;
290 static void deleteClient(
Client* c, allowed_t );
292 static bool resourceMatch(
const Client* c1,
const Client* c2 );
293 static bool belongToSameApplication(
const Client* c1,
const Client* c2,
bool active_hack =
false );
294 static void readIcons( Window win, TQPixmap* icon, TQPixmap* miniicon );
296 void minimize(
bool avoid_animation =
false );
297 void unminimize(
bool avoid_animation =
false );
300 void maximize( MaximizeMode );
303 void cancelShadeHover();
304 void cancelAutoRaise();
305 void destroyClient();
306 void checkActiveModal();
307 void setOpacity(
bool translucent, uint opacity = 0);
308 void setShadowSize(uint shadowSize);
309 void updateOpacity();
310 void updateShadowSize();
311 bool hasCustomOpacity(){
return custom_opacity;}
312 void setCustomOpacityFlag(
bool custom =
true);
313 bool getWindowOpacity();
314 int opacityPercentage();
315 void checkAndSetInitialRuledOpacity();
316 uint ruleOpacityInactive();
317 uint ruleOpacityActive();
318 unsigned int opacity();
321 bool touches(
const Client* c);
322 void setShapable(
bool b);
323 bool hasStrut()
const;
328 void shortcutActivated();
329 void updateOpacityCache();
334 virtual void processMousePressEvent( TQMouseEvent* e );
340 Position mousePosition(
const TQPoint& )
const;
341 void setCursor( Position m );
342 void setCursor(
const TQCursor& c );
344 void animateMinimizeOrUnminimize(
bool minimize );
345 TQPixmap animationPixmap(
int w );
347 void drawbound(
const TQRect& geom );
349 void doDrawbound(
const TQRect& geom,
bool clear );
352 bool mapRequestEvent( XMapRequestEvent* e );
353 void unmapNotifyEvent( XUnmapEvent*e );
354 void destroyNotifyEvent( XDestroyWindowEvent*e );
355 void configureRequestEvent( XConfigureRequestEvent* e );
356 void propertyNotifyEvent( XPropertyEvent* e );
357 void clientMessageEvent( XClientMessageEvent* e );
358 void enterNotifyEvent( XCrossingEvent* e );
359 void leaveNotifyEvent( XCrossingEvent* e );
360 void focusInEvent( XFocusInEvent* e );
361 void focusOutEvent( XFocusOutEvent* e );
363 bool buttonPressEvent( Window w,
int button,
int state,
int x,
int y,
int x_root,
int y_root );
364 bool buttonReleaseEvent( Window w,
int button,
int state,
int x,
int y,
int x_root,
int y_root );
365 bool motionNotifyEvent( Window w,
int state,
int x,
int y,
int x_root,
int y_root );
368 void drawIntersectingShadows();
369 void drawOverlappingShadows(
bool waitForMe);
370 TQRegion getExposedRegion(TQRegion occludedRegion,
int x,
int y,
371 int w,
int h,
int thickness,
int xOffset,
int yOffset);
372 void imposeCachedShadow(TQPixmap &pixmap, TQRegion exposed);
373 void imposeRegionShadow(TQPixmap &pixmap, TQRegion occluded,
374 TQRegion exposed,
int thickness,
double maxOpacity = 0.75);
376 void processDecorationButtonPress(
int button,
int state,
int x,
int y,
int x_root,
int y_root );
380 void processKillerExited();
381 void demandAttentionKNotify();
383 void drawShadowAfter(
Client *after);
384 void drawDelayedShadow();
393 void setMappingState(
int s );
394 int mappingState()
const;
395 bool isIconicState()
const;
396 bool isNormalState()
const;
397 bool isManaged()
const;
398 void updateAllowedActions(
bool force =
false );
399 TQSize sizeForClientSize(
const TQSize&, Sizemode mode = SizemodeAny,
bool noframe =
false )
const;
400 void changeMaximize(
bool horizontal,
bool vertical,
bool adjust );
401 void checkMaximizeGeometry();
402 int checkFullScreenHack(
const TQRect& geom )
const;
403 void updateFullScreenHack(
const TQRect& geom );
404 void getWmNormalHints();
405 void getMotifHints();
407 void getWmClientLeader();
408 void getWmClientMachine();
410 void fetchIconicName();
411 TQString readName()
const;
412 void setCaption(
const TQString& s,
bool force =
false );
413 bool hasTransientInternal(
const Client* c,
bool indirect, ConstClientList&
set )
const;
414 void finishWindowRules();
415 void setShortcutInternal(
const KShortcut& cut );
417 void updateWorkareaDiffs();
418 void checkDirection(
int new_diff,
int old_diff, TQRect& rect,
const TQRect& area );
419 static int computeWorkareaDiff(
int left,
int right,
int a_left,
int a_right );
420 void configureRequest(
int value_mask,
int rx,
int ry,
int rw,
int rh,
int gravity,
bool from_tool );
421 NETExtendedStrut strut()
const;
422 int checkShadeGeometry(
int w,
int h );
423 void postponeGeometryUpdates(
bool postpone );
425 bool startMoveResize();
426 void finishMoveResize(
bool cancel );
427 void leaveMoveResize();
428 void checkUnrestrictedMoveResize();
429 void handleMoveResize(
int x,
int y,
int x_root,
int y_root );
430 void positionGeometryTip();
431 void grabButton(
int mod );
432 void ungrabButton(
int mod );
433 void resetMaximize();
434 void resizeDecoration(
const TQSize& s );
435 void setDecoHashProperty(uint topHeight, uint rightWidth, uint bottomHeight, uint leftWidth);
436 void unsetDecoHashProperty();
439 void killProcess(
bool ask, Time timestamp = CurrentTime );
440 void updateUrgency();
441 static void sendClientMessage( Window w, Atom a, Atom protocol,
442 long data1 = 0,
long data2 = 0,
long data3 = 0 );
444 void embedClient( Window w,
const XWindowAttributes &attr );
445 void detectNoBorder();
446 void detectShapable();
447 void destroyDecoration();
448 void updateFrameExtents();
453 Time readUserTimeMapTimestamp(
const KStartupInfoId* asn_id,
const KStartupInfoData* asn_data,
454 bool session )
const;
455 Time readUserCreationTime()
const;
456 static bool sameAppWindowRoleMatch(
const Client* c1,
const Client* c2,
bool active_hack );
457 void startupIdChanged();
462 KDecoration* decoration;
468 bool move_faked_activity;
469 Window move_resize_grab_window;
470 bool unrestrictedMoveResize;
473 return moveResizeMode && mode == PositionCenter;
475 bool isResize()
const
477 return moveResizeMode && mode != PositionCenter;
482 TQPoint invertedMoveOffset;
483 TQRect moveResizeGeom;
484 TQRect initialMoveResizeGeom;
485 XSizeHints xSizeHint;
486 void sendSyntheticConfigureNotify();
488 void readTransient();
489 Window verifyTransientFor( Window transient_for,
bool set );
490 void addTransient(
Client* cl );
491 void removeTransient(
Client* cl );
492 void removeFromMainClients();
493 void cleanGrouping();
494 void checkGroupTransients();
495 void setTransient( Window new_transient_for_id );
497 Window transient_for_id;
498 Window original_transient_for_id;
499 ClientList transients_list;
500 ShadeMode shade_mode;
505 uint skip_taskbar :1;
506 uint original_skip_taskbar :1;
507 uint Pdeletewindow :1;
509 uint Ptakeactivity : 1;
510 uint Pcontexthelp : 1;
514 uint motif_noborder : 1;
515 uint motif_may_resize : 1;
516 uint motif_may_move :1;
517 uint motif_may_close : 1;
523 uint user_noborder : 1;
525 uint ignore_focus_stealing : 1;
526 uint demands_attention : 1;
527 WindowRules client_rules;
530 void getWindowProtocols();
532 TQPixmap miniicon_pix;
536 enum FullScreenMode { FullScreenNone, FullScreenNormal, FullScreenHack };
537 FullScreenMode fullscreen_mode;
538 MaximizeMode max_mode;
540 TQRect geom_fs_restore;
541 MaximizeMode maxmode_restore;
542 int workarea_diff_x, workarea_diff_y;
544 TQTimer* autoRaiseTimer;
545 TQTimer* shadeHoverTimer;
547 TQCString resource_name;
548 TQCString resource_class;
549 TQCString client_machine;
550 TQString cap_normal, cap_iconic, cap_suffix;
551 WId wmClientLeaderWin;
552 TQCString window_role;
557 KProcess* process_killer;
560 unsigned long allowed_actions;
561 TQRect frame_geometry;
563 int postpone_geometry_updates;
564 bool pending_geometry_update;
565 bool shade_geometry_change;
566 int border_left, border_right, border_top, border_bottom;
568 Client* shadowAfterClient;
569 TQWidget* shadowWidget;
570 TQMemArray<double> activeOpacityCache;
571 TQMemArray<double> inactiveOpacityCache;
572 TQMemArray<double>* opacityCache;
573 TQRegion shapeBoundingRegion;
574 TQTimer* shadowDelayTimer;
578 static bool check_active_modal;
580 friend struct FetchNameInternalPredicate;
581 friend struct CheckIgnoreFocusStealingProcedure;
582 friend struct ResetupRulesProcedure;
583 friend class GeometryUpdatesPostponer;
584 void show() { assert(
false ); }
585 void hide() { assert(
false ); }
589 uint rule_opacity_active;
590 uint rule_opacity_inactive;
593 TQTimer* demandAttentionKNotifyTimer;
595 friend bool performTransiencyCheck();
599 class GeometryUpdatesPostponer
602 GeometryUpdatesPostponer(
Client* c )
603 : cl( c ) { cl->postponeGeometryUpdates(
true ); }
604 ~GeometryUpdatesPostponer()
605 { cl->postponeGeometryUpdates(
false ); }
612 class WinInfo :
public NETWinInfo
617 WinInfo( Client* c, Display * display, Window window,
618 Window rwin,
const unsigned long pr[],
int pr_size );
619 virtual void changeDesktop(
int desktop);
620 virtual void changeState(
unsigned long state,
unsigned long mask );
625 inline Window Client::window()
const
630 inline Window Client::frameId()
const
635 inline Window Client::wrapperId()
const
640 inline Window Client::decorationId()
const
642 return decoration != NULL ? decoration->widget()->winId() : None;
645 inline Workspace* Client::workspace()
const
650 inline const Client* Client::transientFor()
const
652 return transient_for;
655 inline Client* Client::transientFor()
657 return transient_for;
660 inline bool Client::groupTransient()
const
662 return transient_for_id == workspace()->rootWin();
667 inline bool Client::wasOriginallyGroupTransient()
const
669 return original_transient_for_id == workspace()->rootWin();
672 inline bool Client::isTransient()
const
674 return transient_for_id != None;
677 inline const ClientList& Client::transients()
const
679 return transients_list;
682 inline const Group* Client::group()
const
687 inline Group* Client::group()
692 inline int Client::mappingState()
const
694 return mapping_state;
697 inline TQCString Client::resourceName()
const
699 return resource_name;
702 inline TQCString Client::resourceClass()
const
704 return resource_class;
708 bool Client::isMinimized()
const
713 inline bool Client::isActive()
const
729 inline bool Client::isOnAllDesktops()
const
731 return desk == NET::OnAllDesktops;
739 return desk == d || isOnAllDesktops();
743 bool Client::isShown(
bool shaded_is_shown )
const
745 return !isMinimized() && ( !isShade() || shaded_is_shown ) && !hidden;
749 bool Client::isShade()
const
751 return shade_mode == ShadeNormal;
755 ShadeMode Client::shadeMode()
const
760 inline TQPixmap Client::icon()
const
765 inline TQPixmap Client::miniIcon()
const
770 inline TQRect Client::geometryRestore()
const
775 inline Client::MaximizeMode Client::maximizeModeRestore()
const
777 return maxmode_restore;
780 inline Client::MaximizeMode Client::maximizeMode()
const
785 inline bool Client::skipTaskbar(
bool from_outside )
const
787 return from_outside ? original_skip_taskbar : skip_taskbar;
790 inline bool Client::skipPager()
const
795 inline bool Client::keepBelow()
const
800 inline bool Client::shape()
const
806 inline bool Client::isFullScreen()
const
808 return fullscreen_mode != FullScreenNone;
811 inline bool Client::isModal()
const
816 inline bool Client::hasNETSupport()
const
818 return info->hasNETSupport();
821 inline Colormap Client::colormap()
const
826 inline pid_t Client::pid()
const
831 inline void Client::invalidateLayer()
833 in_layer = UnknownLayer;
836 inline bool Client::isIconicState()
const
838 return mapping_state == IconicState;
841 inline bool Client::isNormalState()
const
843 return mapping_state == NormalState;
846 inline bool Client::isManaged()
const
848 return mapping_state != WithdrawnState;
851 inline TQCString Client::windowRole()
const
856 inline TQRect Client::geometry()
const
858 return frame_geometry;
861 inline TQSize Client::size()
const
863 return frame_geometry.size();
866 inline TQPoint Client::pos()
const
868 return frame_geometry.topLeft();
871 inline int Client::x()
const
873 return frame_geometry.x();
876 inline int Client::y()
const
878 return frame_geometry.y();
881 inline int Client::width()
const
883 return frame_geometry.width();
886 inline int Client::height()
const
888 return frame_geometry.height();
891 inline TQRect Client::rect()
const
893 return TQRect( 0, 0, width(), height());
896 inline TQPoint Client::clientPos()
const
898 return TQPoint( border_left, border_top );
901 inline TQSize Client::clientSize()
const
908 setGeometry( r.x(), r.y(), r.width(), r.height(), force );
911 inline void Client::move(
const TQPoint & p, ForceGeometry_t force )
913 move( p.x(), p.y(), force );
916 inline void Client::plainResize(
const TQSize& s, ForceGeometry_t force )
918 plainResize( s.width(), s.height(), force );
921 inline bool Client::isShadowed()
const
926 inline Window Client::shadowId()
const
928 return shadowWidget != NULL ? shadowWidget->winId() : None;
931 inline void Client::resizeWithChecks(
const TQSize& s, ForceGeometry_t force )
933 resizeWithChecks( s.width(), s.height(), force );
936 inline bool Client::hasUserTimeSupport()
const
938 return info->userTime() != -1U;
941 inline bool Client::ignoreFocusStealing()
const
943 return ignore_focus_stealing;
946 inline const WindowRules* Client::rules()
const
948 return &client_rules;
951 KWIN_PROCEDURE( CheckIgnoreFocusStealingProcedure, cl->ignore_focus_stealing = options->checkIgnoreFocusStealing( cl ));
953 inline Window Client::moveResizeGrabWindow()
const
955 return move_resize_grab_window;
958 inline KShortcut Client::shortcut()
const
963 inline bool Client::isBMP()
968 inline void Client::setBMP(
bool b)
973 inline void Client::removeRule( Rules* rule )
975 client_rules.remove( rule );
980 kndbgstream& operator<<( kndbgstream& stream,
const Client* ) {
return stream; }
982 kndbgstream& operator<<( kndbgstream& stream,
const ClientList& ) {
return stream; }
984 kndbgstream& operator<<( kndbgstream& stream,
const ConstClientList& ) {
return stream; }
986 kdbgstream& operator<<( kdbgstream& stream,
const Client* );
987 kdbgstream& operator<<( kdbgstream& stream,
const ClientList& );
988 kdbgstream& operator<<( kdbgstream& stream,
const ConstClientList& );
991 KWIN_COMPARE_PREDICATE( WindowMatchPredicate, Window, cl->window() == value );
992 KWIN_COMPARE_PREDICATE( FrameIdMatchPredicate, Window, cl->frameId() == value );
993 KWIN_COMPARE_PREDICATE( WrapperIdMatchPredicate, Window, cl->wrapperId() == value );