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 );
236 void growHorizontal();
237 void shrinkHorizontal();
239 void shrinkVertical();
242 TDEShortcut shortcut()
const;
243 void setShortcut(
const TQString& cut );
245 bool performMouseCommand( Options::MouseCommand, TQPoint globalPos,
bool handled =
false );
247 TQCString windowRole()
const;
249 TQCString resourceName()
const;
250 TQCString resourceClass()
const;
258 Colormap colormap()
const;
261 void updateVisibility();
263 void hideClient(
bool hide );
265 TQString
caption(
bool full =
true )
const;
266 void updateCaption();
268 void keyPressEvent( uint key_code );
269 void updateMouseGrab();
270 Window moveResizeGrabWindow()
const;
272 const TQPoint calculateGravitation(
bool invert,
int gravity = 0 )
const;
274 void NETMoveResize(
int x_root,
int y_root, NET::Direction direction );
275 void NETMoveResizeWindow(
int flags,
int x,
int y,
int width,
int height );
276 void restackWindow( Window above,
int detail, NET::RequestSource source, Time timestamp,
bool send_event =
false );
278 void gotPing( Time timestamp );
283 static TQCString staticWmClientMachine(WId);
286 void checkWorkspacePosition();
288 Time userTime()
const;
289 bool hasUserTimeSupport()
const;
290 bool ignoreFocusStealing()
const;
293 static void deleteClient(
Client* c, allowed_t );
295 static bool resourceMatch(
const Client* c1,
const Client* c2 );
296 static bool belongToSameApplication(
const Client* c1,
const Client* c2,
bool active_hack =
false );
297 static void readIcons( Window win, TQPixmap* icon, TQPixmap* miniicon );
299 void minimize(
bool avoid_animation =
false );
300 void unminimize(
bool avoid_animation =
false );
303 void suspendWindow();
305 bool queryUserSuspendedResume();
306 void maximize( MaximizeMode );
309 void cancelShadeHover();
310 void cancelAutoRaise();
311 void destroyClient();
312 void checkActiveModal();
313 void setOpacity(
bool translucent, uint opacity = 0);
314 void setShadowSize(uint shadowSize);
315 void updateOpacity();
316 void updateShadowSize();
317 bool hasCustomOpacity(){
return custom_opacity;}
318 void setCustomOpacityFlag(
bool custom =
true);
319 bool getWindowOpacity();
320 int opacityPercentage();
321 void checkAndSetInitialRuledOpacity();
322 uint ruleOpacityInactive();
323 uint ruleOpacityActive();
324 unsigned int opacity();
327 bool touches(
const Client* c);
328 void setShapable(
bool b);
329 bool hasStrut()
const;
334 void shortcutActivated();
335 void updateOpacityCache();
340 virtual void processMousePressEvent( TQMouseEvent* e );
346 Position mousePosition(
const TQPoint& )
const;
347 void setCursor( Position m );
348 void setCursor(
const TQCursor& c );
350 void animateMinimizeOrUnminimize(
bool minimize );
351 TQPixmap animationPixmap(
int w );
353 void drawbound(
const TQRect& geom );
355 void doDrawbound(
const TQRect& geom,
bool clear );
358 bool mapRequestEvent( XMapRequestEvent* e );
359 void unmapNotifyEvent( XUnmapEvent*e );
360 void destroyNotifyEvent( XDestroyWindowEvent*e );
361 void configureRequestEvent( XConfigureRequestEvent* e );
362 void propertyNotifyEvent( XPropertyEvent* e );
363 void clientMessageEvent( XClientMessageEvent* e );
364 void enterNotifyEvent( XCrossingEvent* e );
365 void leaveNotifyEvent( XCrossingEvent* e );
366 void focusInEvent( XFocusInEvent* e );
367 void focusOutEvent( XFocusOutEvent* e );
369 bool buttonPressEvent( Window w,
int button,
int state,
int x,
int y,
int x_root,
int y_root );
370 bool buttonReleaseEvent( Window w,
int button,
int state,
int x,
int y,
int x_root,
int y_root );
371 bool motionNotifyEvent( Window w,
int state,
int x,
int y,
int x_root,
int y_root );
374 void drawIntersectingShadows();
375 void drawOverlappingShadows(
bool waitForMe);
376 TQRegion getExposedRegion(TQRegion occludedRegion,
int x,
int y,
377 int w,
int h,
int thickness,
int xOffset,
int yOffset);
378 void imposeCachedShadow(TQPixmap &pixmap, TQRegion exposed);
379 void imposeRegionShadow(TQPixmap &pixmap, TQRegion occluded,
380 TQRegion exposed,
int thickness,
double maxOpacity = 0.75);
382 void processDecorationButtonPress(
int button,
int state,
int x,
int y,
int x_root,
int y_root );
386 void processKillerExited();
387 void processResumerExited();
388 void demandAttentionKNotify();
390 void drawShadowAfter(
Client *after);
391 void drawDelayedShadow();
400 void setMappingState(
int s );
401 int mappingState()
const;
402 bool isIconicState()
const;
403 bool isNormalState()
const;
404 bool isManaged()
const;
405 void updateAllowedActions(
bool force =
false );
406 TQSize sizeForClientSize(
const TQSize&, Sizemode mode = SizemodeAny,
bool noframe =
false )
const;
407 void changeMaximize(
bool horizontal,
bool vertical,
bool adjust );
408 void checkMaximizeGeometry();
409 int checkFullScreenHack(
const TQRect& geom )
const;
410 void updateFullScreenHack(
const TQRect& geom );
411 void getWmNormalHints();
412 void getMotifHints();
414 void getWmClientLeader();
415 void getWmClientMachine();
417 void fetchIconicName();
418 TQString readName()
const;
419 void setCaption(
const TQString& s,
bool force =
false );
420 bool hasTransientInternal(
const Client* c,
bool indirect, ConstClientList&
set )
const;
421 void finishWindowRules();
422 void setShortcutInternal(
const TDEShortcut& cut );
424 void updateWorkareaDiffs();
425 void checkDirection(
int new_diff,
int old_diff, TQRect& rect,
const TQRect& area );
426 static int computeWorkareaDiff(
int left,
int right,
int a_left,
int a_right );
427 void configureRequest(
int value_mask,
int rx,
int ry,
int rw,
int rh,
int gravity,
bool from_tool );
428 NETExtendedStrut strut()
const;
429 int checkShadeGeometry(
int w,
int h );
430 void postponeGeometryUpdates(
bool postpone );
432 bool startMoveResize();
433 void finishMoveResize(
bool cancel );
434 void leaveMoveResize();
435 void checkUnrestrictedMoveResize();
436 void handleMoveResize(
int x,
int y,
int x_root,
int y_root );
437 void positionGeometryTip();
438 void grabButton(
int mod );
439 void ungrabButton(
int mod );
440 void resetMaximize();
441 void resizeDecoration(
const TQSize& s );
442 void setDecoHashProperty(uint topHeight, uint rightWidth, uint bottomHeight, uint leftWidth);
443 void unsetDecoHashProperty();
446 void killProcess(
bool ask, Time timestamp = CurrentTime );
447 void updateUrgency();
448 static void sendClientMessage( Window w, Atom a, Atom protocol,
449 long data1 = 0,
long data2 = 0,
long data3 = 0 );
451 void embedClient( Window w,
const XWindowAttributes &attr );
452 void detectNoBorder();
453 void detectShapable();
454 void destroyDecoration();
455 void updateFrameExtents();
460 Time readUserTimeMapTimestamp(
const TDEStartupInfoId* asn_id,
const TDEStartupInfoData* asn_data,
461 bool session )
const;
462 Time readUserCreationTime()
const;
463 static bool sameAppWindowRoleMatch(
const Client* c1,
const Client* c2,
bool active_hack );
464 void startupIdChanged();
469 KDecoration* decoration;
475 bool move_faked_activity;
476 Window move_resize_grab_window;
477 bool unrestrictedMoveResize;
480 return moveResizeMode && mode == PositionCenter;
482 bool isResize()
const
484 return moveResizeMode && mode != PositionCenter;
489 TQPoint invertedMoveOffset;
490 TQRect moveResizeGeom;
491 TQRect initialMoveResizeGeom;
492 XSizeHints xSizeHint;
493 void sendSyntheticConfigureNotify();
495 void readTransient();
496 Window verifyTransientFor( Window transient_for,
bool set );
497 void addTransient(
Client* cl );
498 void removeTransient(
Client* cl );
499 void removeFromMainClients();
500 void cleanGrouping();
501 void checkGroupTransients();
502 void setTransient( Window new_transient_for_id );
504 Window transient_for_id;
505 Window original_transient_for_id;
506 ClientList transients_list;
507 ShadeMode shade_mode;
512 uint skip_taskbar :1;
513 uint original_skip_taskbar :1;
514 uint Pdeletewindow :1;
516 uint Ptakeactivity : 1;
517 uint Pcontexthelp : 1;
521 uint motif_noborder : 1;
522 uint motif_may_resize : 1;
523 uint motif_may_move :1;
524 uint motif_may_close : 1;
530 uint user_noborder : 1;
532 uint ignore_focus_stealing : 1;
533 uint demands_attention : 1;
534 WindowRules client_rules;
537 void getWindowProtocols();
539 TQPixmap miniicon_pix;
543 enum FullScreenMode { FullScreenNone, FullScreenNormal, FullScreenHack };
544 FullScreenMode fullscreen_mode;
545 MaximizeMode max_mode;
547 TQRect geom_fs_restore;
548 MaximizeMode maxmode_restore;
549 int workarea_diff_x, workarea_diff_y;
551 TQTimer* autoRaiseTimer;
552 TQTimer* shadeHoverTimer;
554 TQCString resource_name;
555 TQCString resource_class;
556 TQCString client_machine;
557 TQString cap_normal, cap_iconic, cap_suffix;
558 WId wmClientLeaderWin;
559 TQCString window_role;
564 TDEProcess* process_killer;
565 TDEProcess* process_resumer;
568 unsigned long allowed_actions;
569 TQRect frame_geometry;
571 int postpone_geometry_updates;
572 bool pending_geometry_update;
573 bool shade_geometry_change;
574 int border_left, border_right, border_top, border_bottom;
576 Client* shadowAfterClient;
577 TQWidget* shadowWidget;
578 TQMemArray<double> activeOpacityCache;
579 TQMemArray<double> inactiveOpacityCache;
580 TQMemArray<double>* opacityCache;
581 TQRegion shapeBoundingRegion;
582 TQTimer* shadowDelayTimer;
586 static bool check_active_modal;
587 TDEShortcut _shortcut;
588 friend struct FetchNameInternalPredicate;
589 friend struct CheckIgnoreFocusStealingProcedure;
590 friend struct ResetupRulesProcedure;
591 friend class GeometryUpdatesPostponer;
592 void show() { assert(
false ); }
593 void hide() { assert(
false ); }
597 uint rule_opacity_active;
598 uint rule_opacity_inactive;
601 TQTimer* demandAttentionKNotifyTimer;
603 friend bool performTransiencyCheck();
604 bool minimized_before_suspend;
608 class GeometryUpdatesPostponer
611 GeometryUpdatesPostponer(
Client* c )
612 : cl( c ) { cl->postponeGeometryUpdates(
true ); }
613 ~GeometryUpdatesPostponer()
614 { cl->postponeGeometryUpdates(
false ); }
621 class WinInfo :
public NETWinInfo
626 WinInfo( Client* c, Display * display, Window window,
627 Window rwin,
const unsigned long pr[],
int pr_size );
628 virtual void changeDesktop(
int desktop);
629 virtual void changeState(
unsigned long state,
unsigned long mask );
634 inline Window Client::window()
const
639 inline Window Client::frameId()
const
644 inline Window Client::wrapperId()
const
649 inline Window Client::decorationId()
const
651 return decoration != NULL ? decoration->widget()->winId() : None;
654 inline Workspace* Client::workspace()
const
659 inline const Client* Client::transientFor()
const
661 return transient_for;
664 inline Client* Client::transientFor()
666 return transient_for;
669 inline bool Client::groupTransient()
const
671 return transient_for_id == workspace()->rootWin();
676 inline bool Client::wasOriginallyGroupTransient()
const
678 return original_transient_for_id == workspace()->rootWin();
681 inline bool Client::isTransient()
const
683 return transient_for_id != None;
686 inline const ClientList& Client::transients()
const
688 return transients_list;
691 inline const Group* Client::group()
const
696 inline Group* Client::group()
701 inline int Client::mappingState()
const
703 return mapping_state;
706 inline TQCString Client::resourceName()
const
708 return resource_name;
711 inline TQCString Client::resourceClass()
const
713 return resource_class;
717 bool Client::isMinimized()
const
722 inline bool Client::isActive()
const
738 inline bool Client::isOnAllDesktops()
const
740 return desk == NET::OnAllDesktops;
748 return desk == d || isOnAllDesktops();
752 bool Client::isShown(
bool shaded_is_shown )
const
754 return !isMinimized() && ( !isShade() || shaded_is_shown ) && !hidden;
758 bool Client::isShade()
const
760 return shade_mode == ShadeNormal;
764 ShadeMode Client::shadeMode()
const
769 inline TQPixmap Client::icon()
const
774 inline TQPixmap Client::miniIcon()
const
779 inline TQRect Client::geometryRestore()
const
784 inline Client::MaximizeMode Client::maximizeModeRestore()
const
786 return maxmode_restore;
789 inline Client::MaximizeMode Client::maximizeMode()
const
794 inline bool Client::skipTaskbar(
bool from_outside )
const
796 return from_outside ? original_skip_taskbar : skip_taskbar;
799 inline bool Client::skipPager()
const
804 inline bool Client::keepBelow()
const
809 inline bool Client::shape()
const
815 inline bool Client::isFullScreen()
const
817 return fullscreen_mode != FullScreenNone;
820 inline bool Client::isModal()
const
825 inline bool Client::hasNETSupport()
const
827 return info->hasNETSupport();
830 inline Colormap Client::colormap()
const
835 inline pid_t Client::pid()
const
840 inline void Client::invalidateLayer()
842 in_layer = UnknownLayer;
845 inline bool Client::isIconicState()
const
847 return mapping_state == IconicState;
850 inline bool Client::isNormalState()
const
852 return mapping_state == NormalState;
855 inline bool Client::isManaged()
const
857 return mapping_state != WithdrawnState;
860 inline TQCString Client::windowRole()
const
865 inline TQRect Client::geometry()
const
867 return frame_geometry;
870 inline TQSize Client::size()
const
872 return frame_geometry.size();
875 inline TQPoint Client::pos()
const
877 return frame_geometry.topLeft();
880 inline int Client::x()
const
882 return frame_geometry.x();
885 inline int Client::y()
const
887 return frame_geometry.y();
890 inline int Client::width()
const
892 return frame_geometry.width();
895 inline int Client::height()
const
897 return frame_geometry.height();
900 inline TQRect Client::rect()
const
902 return TQRect( 0, 0, width(), height());
905 inline TQPoint Client::clientPos()
const
907 return TQPoint( border_left, border_top );
910 inline TQSize Client::clientSize()
const
917 setGeometry( r.x(), r.y(), r.width(), r.height(), force );
920 inline void Client::move(
const TQPoint & p, ForceGeometry_t force )
922 move( p.x(), p.y(), force );
925 inline void Client::plainResize(
const TQSize& s, ForceGeometry_t force )
927 plainResize( s.width(), s.height(), force );
930 inline bool Client::isShadowed()
const
935 inline Window Client::shadowId()
const
937 return shadowWidget != NULL ? shadowWidget->winId() : None;
940 inline void Client::resizeWithChecks(
const TQSize& s, ForceGeometry_t force )
942 resizeWithChecks( s.width(), s.height(), force );
945 inline bool Client::hasUserTimeSupport()
const
947 return info->userTime() != -1U;
950 inline bool Client::ignoreFocusStealing()
const
952 return ignore_focus_stealing;
955 inline const WindowRules* Client::rules()
const
957 return &client_rules;
960 KWIN_PROCEDURE( CheckIgnoreFocusStealingProcedure, cl->ignore_focus_stealing = options->checkIgnoreFocusStealing( cl ));
962 inline Window Client::moveResizeGrabWindow()
const
964 return move_resize_grab_window;
967 inline TDEShortcut Client::shortcut()
const
972 inline bool Client::isBMP()
977 inline void Client::setBMP(
bool b)
982 inline void Client::removeRule( Rules* rule )
984 client_rules.remove( rule );
989 kndbgstream& operator<<( kndbgstream& stream,
const Client* ) {
return stream; }
991 kndbgstream& operator<<( kndbgstream& stream,
const ClientList& ) {
return stream; }
993 kndbgstream& operator<<( kndbgstream& stream,
const ConstClientList& ) {
return stream; }
995 kdbgstream& operator<<( kdbgstream& stream,
const Client* );
996 kdbgstream& operator<<( kdbgstream& stream,
const ClientList& );
997 kdbgstream& operator<<( kdbgstream& stream,
const ConstClientList& );
1000 KWIN_COMPARE_PREDICATE( WindowMatchPredicate, Window, cl->window() == value );
1001 KWIN_COMPARE_PREDICATE( FrameIdMatchPredicate, Window, cl->frameId() == value );
1002 KWIN_COMPARE_PREDICATE( WrapperIdMatchPredicate, Window, cl->wrapperId() == value );