summaryrefslogtreecommitdiffstats
path: root/tdecore/netwm_def.h
blob: 1f6860243e0bde50abd77633d9d0b48f23813d53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
/*

  Copyright (c) 2000 Troll Tech AS
  Copyright (c) 2003 Lubos Lunak <l.lunak@kde.org>

  Permission is hereby granted, free of charge, to any person obtaining a
  copy of this software and associated documentation files (the "Software"),
  to deal in the Software without restriction, including without limitation
  the rights to use, copy, modify, merge, publish, distribute, sublicense,
  and/or sell copies of the Software, and to permit persons to whom the
  Software is furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  DEALINGS IN THE SOFTWARE.

*/

#ifndef   __netwm_def_h
#define   __netwm_def_h

#include <kdelibs_export.h>

/**
  Simple point class for NET classes.

  This class is a convenience class defining a point x, y.  The existence of
  this class is to keep the implementation from being dependant on a
  separate framework/library.

  NETPoint is only used by the NET API. Usually TQPoint is the 
  appropriate class for representing a point.

  @author Bradley T. Hughes <bhughes@trolltech.com>
**/

struct NETPoint {
    /**
       Constructor to initialize this point to 0,0.
    **/
    NETPoint() : x(0), y(0) { }

    /*
       Public data member.
    **/
    int x, ///< x coordinate.
      y;   ///< y coordinate
};


/**
  Simple size class for NET classes.

  This class is a convenience class defining a size width by height.  The
  existence of this class is to keep the implementation from being dependant
  on a separate framework/library.

  NETSize is only used by the NET API. Usually TQSize is the 
  appropriate class for representing a size.

  @author Bradley T. Hughes <bhughes@trolltech.com>
**/

struct NETSize {
    /**
       Constructor to initialize this size to 0x0
    **/
    NETSize() : width(0), height(0) { }

    /*
       Public data member.
    **/
    int width,  ///< Width.
      height;   ///< Height.
};

/**
   Simple rectangle class for NET classes.

   This class is a convenience class defining a rectangle as a point x,y with a
   size width by height.  The existence of this class is to keep the implementation
   from being dependant on a separate framework/library;

   NETRect is only used by the NET API. Usually TQRect is the 
   appropriate class for representing a rectangle.
**/
struct NETRect {
    /**
       Position of the rectangle.

       @see NETPoint
    **/
    NETPoint pos;

    /**
       Size of the rectangle.

       @see NETSize
    **/
    NETSize size;
};


/**
   Simple icon class for NET classes.

   This class is a convenience class defining an icon of size width by height.
   The existence of this class is to keep the implementation from being
   dependant on a separate framework/library.

   NETIcon is only used by the NET API. Usually QIcon is the 
   appropriate class for representing an icon.
**/

struct NETIcon {
    /**
       Constructor to initialize this icon to 0x0 with data=0
    **/
    NETIcon() : data(0) { }

    /**
       Size of the icon.

       @see NETSize
    **/
    NETSize size;

    /**
       Image data for the icon.  This is an array of 32bit packed CARDINAL ARGB
       with high byte being A, low byte being B. First two bytes are width, height.
       Data is in rows, left to right and top to bottom.
    **/
    unsigned char *data;
};


/**
   Partial strut class for NET classes.

   This class is a convenience class defining a strut with left, right, top and
   bottom border values, and ranges for them.  The existence of this class is to
   keep the implementation from being dependant on a separate framework/library.
   See the _NET_WM_STRUT_PARTIAL property in the NETWM spec.
**/

struct NETExtendedStrut {
    /**
       Constructor to initialize this struct to 0,0,0,0
    **/
    NETExtendedStrut() : left_width(0), left_start(0), left_end(0),
        right_width(0), right_start(0), right_end(0), top_width(0), top_start(0), top_end(0),
        bottom_width(0), bottom_start(0), bottom_end(0) {}

    /**
       Left border of the strut, width and range.
           **/
    int left_width, left_start, left_end;

    /**
       Right border of the strut, width and range.
    **/
    int right_width, right_start, right_end;

    /**
       Top border of the strut, width and range.
           **/
    int top_width, top_start, top_end;

    /**
       Bottom border of the strut, width and range.
           **/
    int bottom_width, bottom_start, bottom_end;
    
};


/**
   @deprecated use NETExtendedStrut

   Simple strut class for NET classes.

   This class is a convenience class defining a strut with left, right, top and
   bottom border values.  The existence of this class is to keep the implementation
   from being dependant on a separate framework/library. See the _NET_WM_STRUT
   property in the NETWM spec.
**/

struct NETStrut {
    /**
       Constructor to initialize this struct to 0,0,0,0
    **/
    NETStrut() : left(0), right(0), top(0), bottom(0) { }

    /**
       Left border of the strut.
           **/
    int left;

    /**
       Right border of the strut.
    **/
    int right;

    /**
       Top border of the strut.
           **/
    int top;

    /**
       Bottom border of the strut.
           **/
    int bottom;
};


/**
  Base namespace class.

  The NET API is an implementation of the NET Window Manager Specification.

  This class is the base class for the NETRootInfo and NETWinInfo classes, which
  are used to retrieve and modify the properties of windows. To keep
  the namespace relatively clean, all enums are defined here.
  
  @see http://www.freedesktop.org/standards/wm-spec/
 **/

class KDECORE_EXPORT NET {
public:
    /**
       Application role.  This is used internally to determine how several action
       should be performed (if at all).

       @li Client indicates that the application is a client application.

       @li WindowManager indicates that the application is a window manager
       application.
    **/

    enum Role {
	Client,
	WindowManager
    };

    /**
       Window type.

       @li Unknown indicates that the window did not define a window type.

       @li Normal indicates that this is a normal, top-level window. Windows with
       Unknown window type or WM_TRANSIENT_FOR unset must be taken as this type.

       @li Desktop indicates a desktop feature. This can include a single window
       containing desktop icons with the same dimensions as the screen, allowing
       the desktop environment to have full control of the desktop, without the
       need for proxying root window clicks.

       @li Dock indicates a dock or panel feature. Typically a window manager would
       keep such windows on top of all other windows.

       @li Toolbar and Menu indicate toolbar and pinnable menu windows, respectively.

       @li Dialog indicates that this is a dialog window. If _NET_WM_WINDOW_TYPE is
       not set, then windows with WM_TRANSIENT_FOR set must be taken as this type.

       @li Override - deprecated, has unclear meaning and is KDE-only.
       
       @li TopMenu indicates a toplevel menu (AKA macmenu). This is a KDE extension to the
       _NET_WM_WINDOW_TYPE mechanism.

       @li DropdownMenu - dropdown menu (from a menubar typically)
       
       @li PopupMenu - a popup menu (a context menu typically)
       
       @li Tooltip - a tooltip window
       
       @li Notification - a notification window
       
       @li ComboBox - a list window for a combobox

       @li DNDIcon - a window that represents the dragged object during DND operation

       Note that some window types are typically used only on override-redirect
       windows (WX11BypassWM flag).
    **/

    enum WindowType {
	Unknown  = -1,
	Normal   = 0,
	Desktop  = 1,
	Dock     = 2,
	Toolbar  = 3,
       	Menu     = 4,
	Dialog   = 5,
	Override = 6, ///< @deprecated
        TopMenu  = 7, // NON STANDARD
	Tool     = Toolbar, // This will go away soon, COMPAT (How soon? :)
	Utility  = 8,	///< @since 3.2
	Splash   = 9,   ///< @since 3.2
        DropdownMenu = 10,  ///< @since 3.5.7
        PopupMenu    = 11,  ///< @since 3.5.7
        Tooltip      = 12,  ///< @since 3.5.7
        Notification = 13,  ///< @since 3.5.7
        ComboBox     = 14,  ///< @since 3.5.7
        DNDIcon      = 15   ///< @since 3.5.7
    };
    
    /**
        Values for WindowType when they should be OR'ed together, e.g.
        for the properties argument of the NETRootInfo constructor.
        @since 3.2
    **/
    enum WindowTypeMask {
	NormalMask   = 1<<0,
	DesktopMask  = 1<<1,
	DockMask     = 1<<2,
	ToolbarMask  = 1<<3,
	MenuMask     = 1<<4,
	DialogMask   = 1<<5,
	OverrideMask = 1<<6,
        TopMenuMask  = 1<<7,
	UtilityMask  = 1<<8,
	SplashMask   = 1<<9,
        DropdownMenuMask = 1<<10,  ///< @since 3.5.7
        PopupMenuMask    = 1<<11,  ///< @since 3.5.7
        TooltipMask      = 1<<12,  ///< @since 3.5.7
        NotificationMask = 1<<13,  ///< @since 3.5.7
        ComboBoxMask     = 1<<14,  ///< @since 3.5.7
        DNDIconMask      = 1<<15   ///< @since 3.5.7
    };

    // KDE4 move to WindowTypeMask
    enum { AllTypesMask = 0LU-1 };

    /**
     * Returns true if the given window type matches the mask given
     * using WindowTypeMask flags.
     */    
    static bool typeMatchesMask( WindowType type, unsigned long mask );

    /**
       Window state.

       @li Modal ndicates that this is a modal dialog box. The WM_TRANSIENT_FOR hint
       MUST be set to indicate which window the dialog is a modal for, or set to
       the root window if the dialog is a modal for its window group.

       @li Sticky indicates that the Window Manager SHOULD keep the window's position
       fixed on the screen, even when the virtual desktop scrolls. Note that this is
       different from being kept on all desktops.

       @li Max{Vert,Horiz} indicates that the window is {vertically,horizontally}
       maximized.

       @li Max is more convenient than MaxVert | MaxHoriz.

       @li Shaded indicates that the window is shaded (rolled-up).

       @li SkipTaskbar indicates that a window should not be included on a taskbar.

       @li SkipPager indicates that a window should not be included on a pager.

       @li Hidden indicates that a window should not be visible on the screen (e.g. when minimised).
           Only the window manager is allowed to change it.

       @li FullScreen indicates that a window should fill the entire screen and have no window decorations.

       @li KeepAbove indicates that a window should on top of most windows (but below fullscreen windows).

       @li KeepBelow indicates that a window should be below most windows (but above any desktop windows).

       @li StaysOnTop is an obsolete name for KeepAbove.
       
       @li DemandsAttention there was an attempt to activate this window, but the window manager prevented
           this. E.g. taskbar should mark such window specially to bring user's attention to this window.
           Only the window manager is allowed to change it.

       Note that KeepAbove (StaysOnTop) and KeepBelow are meant as user preference and applications
       should avoid setting these states themselves.
    **/

    enum State {
	Modal        = 1<<0,
	Sticky       = 1<<1,
	MaxVert      = 1<<2,
	MaxHoriz     = 1<<3,
	Max = MaxVert | MaxHoriz,
	Shaded       = 1<<4,
	SkipTaskbar  = 1<<5,
	KeepAbove    = 1<<6,	///< @since 3.2
	StaysOnTop   = KeepAbove,	// NOT STANDARD
	SkipPager    = 1<<7,
	Hidden       = 1<<8,	///< @since 3.2
	FullScreen   = 1<<9,	///< @since 3.2
	KeepBelow    = 1<<10,	///< @since 3.2
        DemandsAttention = 1<<11  ///< @since 3.2
    };

    /**
       Direction for WMMoveResize.

       When a client wants the Window Manager to start a WMMoveResize, it should
       specify one of:

       @li TopLeft
       @li Top
       @li TopRight
       @li Right
       @li BottomRight
       @li Bottom
       @li BottomLeft
       @li Left
       @li Move (for movement only)
       @li KeyboardSize (resizing via keyboard)
       @li KeyboardMove (movement via keyboard)
    **/

    enum Direction {
	TopLeft      = 0,
	Top          = 1,
	TopRight     = 2,
	Right        = 3,
	BottomRight  = 4,
	Bottom       = 5,
	BottomLeft   = 6,
	Left         = 7,
	Move         = 8,  // movement only
    /**
       @since 3.2
    **/
	KeyboardSize = 9,  // size via keyboard
    /**
       @since 3.2
    **/
	KeyboardMove = 10, // move via keyboard
    /**
      @since 3.5.1
    **/
	MoveResizeCancel = 11 // to ask the WM to stop moving a window
    };

    /**
       Client window mapping state.  The class automatically watches the mapping
       state of the client windows, and uses the mapping state to determine how
       to set/change different properties.

       @li Visible indicates the client window is visible to the user.

       @li Withdrawn indicates that neither the client window nor its icon is visible.

       @li Iconic indicates that the client window is not visible, but its icon is.
           This can be when the window is minimized or when it's on a different
           virtual desktop. See also NET::Hidden.
    **/

    // KDE4 aaarghl, this doesn't map correctly to Xlib #defines
    enum MappingState {
	Visible, // ie. NormalState
	Withdrawn,
	Iconic
    };

    /**
      Actions that can be done with a window (_NET_WM_ALLOWED_ACTIONS).
      @since 3.2
    **/
    enum Action {
        ActionMove           = 1<<0,
        ActionResize         = 1<<1,
        ActionMinimize       = 1<<2,
        ActionShade          = 1<<3,
        ActionStick          = 1<<4,
        ActionMaxVert        = 1<<5,
        ActionMaxHoriz       = 1<<6,
        ActionMax            = ActionMaxVert | ActionMaxHoriz,
        ActionFullScreen     = 1<<7,
        ActionChangeDesktop  = 1<<8,
        ActionClose          = 1<<9
    };
    
    /**
       Supported properties.  Clients and Window Managers must define which
       properties/protocols it wants to support.

       Root/Desktop window properties and protocols:

       @li Supported
       @li ClientList
       @li ClientListStacking
       @li NumberOfDesktops
       @li DesktopGeometry
       @li DesktopViewport
       @li CurrentDesktop
       @li DesktopNames
       @li ActiveWindow
       @li WorkArea
       @li SupportingWMCheck
       @li VirtualRoots
       @li CloseWindow
       @li WMMoveResize

       Client window properties and protocols:

       @li WMName
       @li WMVisibleName
       @li WMDesktop
       @li WMWindowType
       @li WMState
       @li WMStrut  (obsoleted by WM2ExtendedStrut)
       @li WMIconGeometry
       @li WMIcon
       @li WMPid
       @li WMVisibleIconName
       @li WMIconName

       ICCCM properties (provided for convenience):

       @li XAWMState

       Extended KDE protocols and properties (NOT STANDARD):

       @li KDESystemTrayWindows
       @li WMKDESystemTrayWinFor
       @li WMKDEFrameStrut
    **/

    enum Property {
	// root
	Supported             = 1<<0,
	ClientList            = 1<<1,
	ClientListStacking    = 1<<2,
	NumberOfDesktops      = 1<<3,
	DesktopGeometry       = 1<<4,
	DesktopViewport       = 1<<5,
	CurrentDesktop        = 1<<6,
	DesktopNames          = 1<<7,
	ActiveWindow          = 1<<8,
	WorkArea              = 1<<9,
	SupportingWMCheck     = 1<<10,
	VirtualRoots          = 1<<11,
	KDESystemTrayWindows  = 1<<12, // NOT STANDARD
	CloseWindow           = 1<<13,
	WMMoveResize          = 1<<14,

	// window
	WMName                = 1<<15,
	WMVisibleName         = 1<<16,
	WMDesktop             = 1<<17,
	WMWindowType          = 1<<18,
	WMState               = 1<<19,
	WMStrut               = 1<<20,
	WMIconGeometry        = 1<<21,
	WMIcon                = 1<<22,
	WMPid                 = 1<<23,
	WMHandledIcons        = 1<<24,
	WMPing                = 1<<25,
	WMKDESystemTrayWinFor = 1<<26, // NOT STANDARD
	XAWMState             = 1<<27, // NOT STANDARD
        WMFrameExtents        = 1<<28, ///< @since 3.5
	WMKDEFrameStrut       = WMFrameExtents, // NOT STANDARD

	// Need to be reordered
	WMIconName            = 1<<29,
	WMVisibleIconName     = 1<<30,
	WMGeometry	      = 1<<31
    };
    
    /**
        Supported properties. This enum is an extension to NET::Property,
        because them enum is limited only to 32 bits.

        Client window properties and protocols:

        @li WM2UserTime
        @li WM2StartupId
        @li WM2TransientFor mainwindow for the window (WM_TRANSIENT_FOR)
        @li WM2GroupLeader  group leader (window_group in WM_HINTS)
        @li WM2AllowedActions
        @li WM2RestackWindow
        @li WM2MoveResizeWindow
        @li WM2ExtendedStrut
        @li WM2TemporaryRules internal, for kstart
        @li WM2WindowClass  WM_CLASS
        @li WM2WindowRole   WM_WINDOW_ROLE
        @li WM2ClientMachine WM_CLIENT_MACHINE
        @li WM2DesktopLayout _NET_DESKTOP_LAYOUT
        
        @since 3.2

    **/
    enum Property2 {
        WM2UserTime            = 1<<0,
        WM2StartupId           = 1<<1,
        WM2TransientFor        = 1<<2,
        WM2GroupLeader         = 1<<3,
        WM2AllowedActions      = 1<<4,
        WM2RestackWindow       = 1<<5,
        WM2MoveResizeWindow    = 1<<6,
        WM2ExtendedStrut       = 1<<7,
        WM2TakeActivity        = 1<<8,
        WM2KDETemporaryRules   = 1<<9,  // NOT STANDARD
        WM2WindowClass         = 1<<10, ///< @since 3.3
        WM2WindowRole          = 1<<11, ///< @since 3.3
        WM2ClientMachine       = 1<<12, ///< @since 3.3
        WM2ShowingDesktop      = 1<<13, ///< @since 3.5
        WM2FullPlacement       = 1<<14,
        WM2DesktopLayout       = 1<<15  ///< @since 3.5.8
    };

    /**
       Sentinel value to indicate that the client wishes to be visible on
       all desktops.
       @since 3.2
     **/ 
    enum { OnAllDesktops = -1 };
    
    /**
       Source of the request.
       @li FromApplication the request comes from a normal application
       @li FromTool the request comes from pager or similar tool
       @since 3.2
    **/
    // must match the values for data.l[0] field in _NET_ACTIVE_WINDOW message
    enum RequestSource {
        FromUnknown, // internal
        FromApplication,
        FromTool
    };
    
    /**
      Orientation.
    **/
    enum Orientation {
        OrientationHorizontal = 0,
        OrientationVertical = 1
    };
    
    /**
     Starting corner for desktop layout.
    **/
    enum DesktopLayoutCorner {
        DesktopLayoutCornerTopLeft = 0,
        DesktopLayoutCornerTopRight = 1,
        DesktopLayoutCornerBottomLeft = 2,
        DesktopLayoutCornerBottomRight = 3
    };
    
    /**
     Compares two X timestamps, taking into account wrapping and 64bit architectures.
     Return value is like with strcmp(), 0 for equal, -1 for time1 < time2, 1 for time1 > time2.
     @since 3.5.3
    */
    static int timestampCompare( unsigned long time1, unsigned long time2 );
    /**
     Returns a difference of two X timestamps, time2 - time1, where time2 must be later than time1,
     as returned by timestampCompare().
     @since 3.5.3
    */
    static int timestampDiff( unsigned long time1_, unsigned long time2_ );

};


#endif // __netwm_def_h