00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _COMPWINDOW_H
00029 #define _COMPWINDOW_H
00030
00031 #include <boost/function.hpp>
00032
00033 #include <X11/Xlib-xcb.h>
00034 #include <X11/Xutil.h>
00035 #include <X11/Xregion.h>
00036 #include <X11/extensions/Xdamage.h>
00037 #include <X11/extensions/sync.h>
00038
00039 #include <core/action.h>
00040 #include <core/pluginclasses.h>
00041 #include <core/size.h>
00042 #include <core/point.h>
00043 #include <core/region.h>
00044
00045 #include <core/wrapsystem.h>
00046
00047 #include <map>
00048
00049 class CompWindow;
00050 class CompIcon;
00051 class PrivateWindow;
00052 struct CompStartupSequence;
00053
00054 #define ROOTPARENT(x) (((x)->frame ()) ? (x)->frame () : (x)->id ())
00055
00056 #define CompWindowProtocolDeleteMask (1 << 0)
00057 #define CompWindowProtocolTakeFocusMask (1 << 1)
00058 #define CompWindowProtocolPingMask (1 << 2)
00059 #define CompWindowProtocolSyncRequestMask (1 << 3)
00060
00061 #define CompWindowTypeDesktopMask (1 << 0)
00062 #define CompWindowTypeDockMask (1 << 1)
00063 #define CompWindowTypeToolbarMask (1 << 2)
00064 #define CompWindowTypeMenuMask (1 << 3)
00065 #define CompWindowTypeUtilMask (1 << 4)
00066 #define CompWindowTypeSplashMask (1 << 5)
00067 #define CompWindowTypeDialogMask (1 << 6)
00068 #define CompWindowTypeNormalMask (1 << 7)
00069 #define CompWindowTypeDropdownMenuMask (1 << 8)
00070 #define CompWindowTypePopupMenuMask (1 << 9)
00071 #define CompWindowTypeTooltipMask (1 << 10)
00072 #define CompWindowTypeNotificationMask (1 << 11)
00073 #define CompWindowTypeComboMask (1 << 12)
00074 #define CompWindowTypeDndMask (1 << 13)
00075 #define CompWindowTypeModalDialogMask (1 << 14)
00076 #define CompWindowTypeFullscreenMask (1 << 15)
00077 #define CompWindowTypeUnknownMask (1 << 16)
00078
00079 #define NO_FOCUS_MASK (CompWindowTypeDesktopMask | \
00080 CompWindowTypeDockMask | \
00081 CompWindowTypeSplashMask)
00082
00083 #define CompWindowStateModalMask (1 << 0)
00084 #define CompWindowStateStickyMask (1 << 1)
00085 #define CompWindowStateMaximizedVertMask (1 << 2)
00086 #define CompWindowStateMaximizedHorzMask (1 << 3)
00087 #define CompWindowStateShadedMask (1 << 4)
00088 #define CompWindowStateSkipTaskbarMask (1 << 5)
00089 #define CompWindowStateSkipPagerMask (1 << 6)
00090 #define CompWindowStateHiddenMask (1 << 7)
00091 #define CompWindowStateFullscreenMask (1 << 8)
00092 #define CompWindowStateAboveMask (1 << 9)
00093 #define CompWindowStateBelowMask (1 << 10)
00094 #define CompWindowStateDemandsAttentionMask (1 << 11)
00095 #define CompWindowStateDisplayModalMask (1 << 12)
00096
00097 #define MAXIMIZE_STATE (CompWindowStateMaximizedHorzMask | \
00098 CompWindowStateMaximizedVertMask)
00099
00100 #define CompWindowActionMoveMask (1 << 0)
00101 #define CompWindowActionResizeMask (1 << 1)
00102 #define CompWindowActionStickMask (1 << 2)
00103 #define CompWindowActionMinimizeMask (1 << 3)
00104 #define CompWindowActionMaximizeHorzMask (1 << 4)
00105 #define CompWindowActionMaximizeVertMask (1 << 5)
00106 #define CompWindowActionFullscreenMask (1 << 6)
00107 #define CompWindowActionCloseMask (1 << 7)
00108 #define CompWindowActionShadeMask (1 << 8)
00109 #define CompWindowActionChangeDesktopMask (1 << 9)
00110 #define CompWindowActionAboveMask (1 << 10)
00111 #define CompWindowActionBelowMask (1 << 11)
00112
00113 #define MwmFuncAll (1L << 0)
00114 #define MwmFuncResize (1L << 1)
00115 #define MwmFuncMove (1L << 2)
00116 #define MwmFuncIconify (1L << 3)
00117 #define MwmFuncMaximize (1L << 4)
00118 #define MwmFuncClose (1L << 5)
00119
00120 #define MwmDecorHandle (1L << 2)
00121 #define MwmDecorTitle (1L << 3)
00122 #define MwmDecorMenu (1L << 4)
00123 #define MwmDecorMinimize (1L << 5)
00124 #define MwmDecorMaximize (1L << 6)
00125
00126 #define MwmDecorAll (1L << 0)
00127 #define MwmDecorBorder (1L << 1)
00128 #define MwmDecorHandle (1L << 2)
00129 #define MwmDecorTitle (1L << 3)
00130 #define MwmDecorMenu (1L << 4)
00131 #define MwmDecorMinimize (1L << 5)
00132 #define MwmDecorMaximize (1L << 6)
00133
00134 #define WmMoveResizeSizeTopLeft 0
00135 #define WmMoveResizeSizeTop 1
00136 #define WmMoveResizeSizeTopRight 2
00137 #define WmMoveResizeSizeRight 3
00138 #define WmMoveResizeSizeBottomRight 4
00139 #define WmMoveResizeSizeBottom 5
00140 #define WmMoveResizeSizeBottomLeft 6
00141 #define WmMoveResizeSizeLeft 7
00142 #define WmMoveResizeMove 8
00143 #define WmMoveResizeSizeKeyboard 9
00144 #define WmMoveResizeMoveKeyboard 10
00145 #define WmMoveResizeCancel 11
00146
00147
00148 #define ClientTypeUnknown 0
00149 #define ClientTypeApplication 1
00150 #define ClientTypePager 2
00151
00152 #define CompWindowGrabKeyMask (1 << 0)
00153 #define CompWindowGrabButtonMask (1 << 1)
00154 #define CompWindowGrabMoveMask (1 << 2)
00155 #define CompWindowGrabResizeMask (1 << 3)
00156 #define CompWindowGrabExternalAppMask (1 << 4)
00157
00162 enum CompStackingUpdateMode {
00163 CompStackingUpdateModeNone = 0,
00164 CompStackingUpdateModeNormal,
00165 CompStackingUpdateModeAboveFullscreen,
00166 CompStackingUpdateModeInitialMap,
00167 CompStackingUpdateModeInitialMapDeniedFocus
00168 };
00169
00174 enum CompWindowNotify {
00175 CompWindowNotifyMap,
00176 CompWindowNotifyUnmap,
00177 CompWindowNotifyRestack,
00178 CompWindowNotifyHide,
00179 CompWindowNotifyShow,
00180 CompWindowNotifyAliveChanged,
00181 CompWindowNotifySyncAlarm,
00182 CompWindowNotifyReparent,
00183 CompWindowNotifyUnreparent,
00184 CompWindowNotifyFrameUpdate,
00185 CompWindowNotifyFocusChange,
00186 CompWindowNotifyBeforeUnmap,
00187 CompWindowNotifyBeforeDestroy,
00188 CompWindowNotifyClose,
00189 CompWindowNotifyMinimize,
00190 CompWindowNotifyUnminimize,
00191 CompWindowNotifyShade,
00192 CompWindowNotifyUnshade,
00193 CompWindowNotifyEnterShowDesktopMode,
00194 CompWindowNotifyLeaveShowDesktopMode,
00195 CompWindowNotifyBeforeMap
00196 };
00197
00202 struct CompWindowExtents {
00203 int left;
00204 int right;
00205 int top;
00206 int bottom;
00207 };
00208
00212 struct CompStruts {
00213 XRectangle left;
00214 XRectangle right;
00215 XRectangle top;
00216 XRectangle bottom;
00217 };
00218
00224 class WindowInterface : public WrapableInterface<CompWindow, WindowInterface>
00225 {
00226 public:
00227 virtual void getOutputExtents (CompWindowExtents& output);
00228
00229 virtual void getAllowedActions (unsigned int &setActions,
00230 unsigned int &clearActions);
00231
00232 virtual bool focus ();
00233 virtual void activate ();
00234 virtual bool place (CompPoint &pos);
00235
00236 virtual void validateResizeRequest (unsigned int &mask,
00237 XWindowChanges *xwc,
00238 unsigned int source);
00239
00240 virtual void resizeNotify (int dx, int dy, int dwidth, int dheight);
00241 virtual void moveNotify (int dx, int dy, bool immediate);
00242 virtual void windowNotify (CompWindowNotify n);
00243
00244 virtual void grabNotify (int x, int y,
00245 unsigned int state, unsigned int mask);
00246 virtual void ungrabNotify ();
00247
00248 virtual void stateChangeNotify (unsigned int lastState);
00249
00250 virtual void updateFrameRegion (CompRegion ®ion);
00251
00252 virtual bool alpha ();
00253 virtual bool isFocussable ();
00254 };
00255
00260 class CompWindow :
00261 public WrapableHandler<WindowInterface, 15>,
00262 public PluginClassStorage
00263 {
00264 public:
00265
00269 class Geometry : public CompRect
00270 {
00271 public:
00272 Geometry ();
00273 Geometry (int, int, int, int, int);
00274
00275 int border () const;
00276
00277 void set (int, int, int, int, int);
00278 void setBorder (int);
00279
00280 private:
00281 int mBorder;
00282 };
00283
00284 typedef boost::function<void (CompWindow *)> ForEach;
00285 typedef std::map<Window, CompWindow *> Map;
00286
00287 public:
00288 CompWindow *next;
00289 CompWindow *prev;
00290
00291 public:
00292 CompWindow (Window id,
00293 Window aboveId);
00294 ~CompWindow ();
00295
00300 Geometry & geometry () const;
00301
00302 int x () const;
00303 int y () const;
00304 CompPoint pos () const;
00305
00306
00307 int width () const;
00308 int height () const;
00309 CompSize size () const;
00310
00314 Geometry & serverGeometry () const;
00315
00316 int serverX () const;
00317 int serverY () const;
00318 CompPoint serverPos () const;
00319
00320
00321 int serverWidth () const;
00322 int serverHeight () const;
00323 const CompSize serverSize () const;
00324
00325
00326 CompRect inputRect () const;
00327 CompRect serverInputRect () const;
00328
00329
00330 CompRect outputRect () const;
00331 CompRect serverOutputRect () const;
00332
00333 Window id ();
00334 Window frame ();
00335
00336 CompString resName ();
00337
00338 const CompRegion & region () const;
00339
00340 const CompRegion & frameRegion () const;
00341
00342 void updateFrameRegion ();
00343 void setWindowFrameExtents (CompWindowExtents *input);
00344
00345 unsigned int & wmType ();
00346
00347 unsigned int type ();
00348
00349 unsigned int & state ();
00350
00351 unsigned int actions ();
00352
00353 unsigned int & protocols ();
00354
00355 void close (Time serverTime);
00356
00357 bool inShowDesktopMode ();
00358
00359 void setShowDesktopMode (bool);
00360
00361 bool managed ();
00362
00363 bool grabbed ();
00364
00365 int pendingMaps ();
00366
00367 unsigned int activeNum ();
00368
00369 int mapNum () const;
00370
00371 CompStruts * struts ();
00372
00373 int & saveMask ();
00374
00375 XWindowChanges & saveWc ();
00376
00377 void moveToViewportPosition (int x, int y, bool sync);
00378
00379 char * startupId ();
00380
00381 unsigned int desktop ();
00382
00383 Window clientLeader (bool checkAncestor = false);
00384
00385 void changeState (unsigned int newState);
00386
00387 void recalcActions ();
00388
00389 void recalcType ();
00390
00391 void updateWindowOutputExtents ();
00392
00393 void destroy ();
00394
00395 void sendConfigureNotify ();
00396
00397 void sendSyncRequest ();
00398
00399 XSyncAlarm syncAlarm ();
00400
00401 void map ();
00402
00403 void unmap ();
00404
00405 void incrementUnmapReference ();
00406
00407 void incrementDestroyReference ();
00408
00409 bool hasUnmapReference ();
00410
00411 bool resize (XWindowAttributes);
00412
00413 bool resize (Geometry);
00414
00415 bool resize (int x, int y, int width, int height,
00416 int border = 0);
00417
00418 void move (int dx, int dy, bool immediate = true);
00419
00420 void syncPosition ();
00421
00422 void moveInputFocusTo ();
00423
00424 void moveInputFocusToOtherWindow ();
00425
00426
00427 void configureXWindow (unsigned int valueMask,
00428 XWindowChanges *xwc);
00429
00430 void moveResize (XWindowChanges *xwc,
00431 unsigned int xwcm,
00432 int gravity,
00433 unsigned int source);
00434
00435 void raise ();
00436
00437 void lower ();
00438
00439 void restackAbove (CompWindow *sibling);
00440
00441 void restackBelow (CompWindow *sibling);
00442
00443 void updateAttributes (CompStackingUpdateMode stackingMode);
00444
00445 void hide ();
00446
00447 void show ();
00448
00449 void minimize ();
00450
00451 void unminimize ();
00452
00453 void maximize (unsigned int state = 0);
00454
00455 CompPoint defaultViewport ();
00456
00457 CompPoint & initialViewport () const;
00458
00459 CompIcon * getIcon (int width, int height);
00460
00461 const CompRect & iconGeometry () const;
00462
00463 int outputDevice ();
00464
00465 void setDesktop (unsigned int desktop);
00466
00467 bool onCurrentDesktop ();
00468
00469 bool onAllViewports ();
00470
00471 CompPoint getMovementForOffset (CompPoint offset);
00472
00473 Window transientFor ();
00474
00475 int pendingUnmaps ();
00476
00477 bool minimized ();
00478
00479 bool placed ();
00480
00481 bool shaded ();
00482
00483 CompWindowExtents & input () const;
00484
00485 CompWindowExtents & output () const;
00486
00487 XSizeHints & sizeHints () const;
00488
00489 bool destroyed ();
00490
00491 bool invisible ();
00492
00493 bool syncWait ();
00494
00495 bool alive ();
00496
00497 bool overrideRedirect ();
00498
00499 bool isMapped () const;
00500 bool isViewable () const;
00501
00502 int windowClass ();
00503
00504 unsigned int depth ();
00505
00506 unsigned int mwmDecor ();
00507 unsigned int mwmFunc ();
00508
00509 bool constrainNewWindowSize (int width,
00510 int height,
00511 int *newWidth,
00512 int *newHeight);
00513
00514 static unsigned int constrainWindowState (unsigned int state,
00515 unsigned int actions);
00516
00517 static unsigned int allocPluginClassIndex ();
00518 static void freePluginClassIndex (unsigned int index);
00519
00520 bool updateStruts ();
00521
00522 WRAPABLE_HND (0, WindowInterface, void, getOutputExtents,
00523 CompWindowExtents&);
00524 WRAPABLE_HND (1, WindowInterface, void, getAllowedActions,
00525 unsigned int &, unsigned int &);
00526
00527 WRAPABLE_HND (2, WindowInterface, bool, focus);
00528 WRAPABLE_HND (3, WindowInterface, void, activate);
00529 WRAPABLE_HND (4, WindowInterface, bool, place, CompPoint &);
00530 WRAPABLE_HND (5, WindowInterface, void, validateResizeRequest,
00531 unsigned int &, XWindowChanges *, unsigned int);
00532
00533 WRAPABLE_HND (6, WindowInterface, void, resizeNotify,
00534 int, int, int, int);
00535 WRAPABLE_HND (7, WindowInterface, void, moveNotify, int, int, bool);
00536 WRAPABLE_HND (8, WindowInterface, void, windowNotify, CompWindowNotify);
00537 WRAPABLE_HND (9, WindowInterface, void, grabNotify, int, int,
00538 unsigned int, unsigned int);
00539 WRAPABLE_HND (10, WindowInterface, void, ungrabNotify);
00540 WRAPABLE_HND (11, WindowInterface, void, stateChangeNotify,
00541 unsigned int);
00542
00543 WRAPABLE_HND (12, WindowInterface, void, updateFrameRegion,
00544 CompRegion &);
00545
00546 WRAPABLE_HND (13, WindowInterface, bool, alpha);
00547 WRAPABLE_HND (14, WindowInterface, bool, isFocussable);
00548
00549 friend class PrivateWindow;
00550 friend class CompScreen;
00551 friend class PrivateScreen;
00552
00553 private:
00554 PrivateWindow *priv;
00555 };
00556
00557 #endif