1/*
2
3 Copyright (c) 2000 Troll Tech AS
4 Copyright (c) 2003 Lubos Lunak <l.lunak@kde.org>
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23
24*/
25
26#ifndef netwm_def_h
27#define netwm_def_h
28#include <kdeui_export.h>
29
30/**
31 Simple point class for NET classes.
32
33 This class is a convenience class defining a point x, y. The existence of
34 this class is to keep the implementation from being dependent on a
35 separate framework/library.
36
37 NETPoint is only used by the NET API. Usually QPoint is the
38 appropriate class for representing a point.
39
40 @author Bradley T. Hughes <bhughes@trolltech.com>
41**/
42
43struct NETPoint {
44 /**
45 Constructor to initialize this point to 0,0.
46 **/
47 NETPoint() : x(0), y(0) { }
48
49 /*
50 Public data member.
51 **/
52 int x, ///< x coordinate.
53 y; ///< y coordinate
54};
55
56
57/**
58 Simple size class for NET classes.
59
60 This class is a convenience class defining a size width by height. The
61 existence of this class is to keep the implementation from being dependent
62 on a separate framework/library.
63
64 NETSize is only used by the NET API. Usually QSize is the
65 appropriate class for representing a size.
66
67 @author Bradley T. Hughes <bhughes@trolltech.com>
68**/
69
70struct NETSize {
71 /**
72 Constructor to initialize this size to 0x0
73 **/
74 NETSize() : width(0), height(0) { }
75
76 /*
77 Public data member.
78 **/
79 int width, ///< Width.
80 height; ///< Height.
81};
82
83/**
84 Simple rectangle class for NET classes.
85
86 This class is a convenience class defining a rectangle as a point x,y with a
87 size width by height. The existence of this class is to keep the implementation
88 from being dependent on a separate framework/library;
89
90 NETRect is only used by the NET API. Usually QRect is the
91 appropriate class for representing a rectangle.
92**/
93struct NETRect {
94 /**
95 Position of the rectangle.
96
97 @see NETPoint
98 **/
99 NETPoint pos;
100
101 /**
102 Size of the rectangle.
103
104 @see NETSize
105 **/
106 NETSize size;
107};
108
109
110/**
111 Simple icon class for NET classes.
112
113 This class is a convenience class defining an icon of size width by height.
114 The existence of this class is to keep the implementation from being
115 dependent on a separate framework/library.
116
117 NETIcon is only used by the NET API. Usually QIcon is the
118 appropriate class for representing an icon.
119**/
120
121struct NETIcon {
122 /**
123 Constructor to initialize this icon to 0x0 with data=0
124 **/
125 NETIcon() : data(0) { }
126
127 /**
128 Size of the icon.
129
130 @see NETSize
131 **/
132 NETSize size;
133
134 /**
135 Image data for the icon. This is an array of 32bit packed CARDINAL ARGB
136 with high byte being A, low byte being B. First two bytes are width, height.
137 Data is in rows, left to right and top to bottom.
138 **/
139 unsigned char *data;
140};
141
142
143/**
144 Partial strut class for NET classes.
145
146 This class is a convenience class defining a strut with left, right, top and
147 bottom border values, and ranges for them. The existence of this class is to
148 keep the implementation from being dependent on a separate framework/library.
149 See the _NET_WM_STRUT_PARTIAL property in the NETWM spec.
150**/
151
152struct NETExtendedStrut {
153 /**
154 Constructor to initialize this struct to 0,0,0,0
155 **/
156 NETExtendedStrut() : left_width(0), left_start(0), left_end(0),
157 right_width(0), right_start(0), right_end(0), top_width(0), top_start(0), top_end(0),
158 bottom_width(0), bottom_start(0), bottom_end(0) {}
159
160 /**
161 Left border of the strut, width and range.
162 **/
163 int left_width, left_start, left_end;
164
165 /**
166 Right border of the strut, width and range.
167 **/
168 int right_width, right_start, right_end;
169
170 /**
171 Top border of the strut, width and range.
172 **/
173 int top_width, top_start, top_end;
174
175 /**
176 Bottom border of the strut, width and range.
177 **/
178 int bottom_width, bottom_start, bottom_end;
179
180};
181
182
183/**
184 @deprecated use NETExtendedStrut
185
186 Simple strut class for NET classes.
187
188 This class is a convenience class defining a strut with left, right, top and
189 bottom border values. The existence of this class is to keep the implementation
190 from being dependent on a separate framework/library. See the _NET_WM_STRUT
191 property in the NETWM spec.
192**/
193
194struct NETStrut {
195 /**
196 Constructor to initialize this struct to 0,0,0,0
197 **/
198 NETStrut() : left(0), right(0), top(0), bottom(0) { }
199
200 /**
201 Left border of the strut.
202 **/
203 int left;
204
205 /**
206 Right border of the strut.
207 **/
208 int right;
209
210 /**
211 Top border of the strut.
212 **/
213 int top;
214
215 /**
216 Bottom border of the strut.
217 **/
218 int bottom;
219};
220
221
222/**
223 Simple multiple monitor topology class for NET classes.
224
225 This class is a convenience class, defining a multiple monitor topology
226 for fullscreen applications that wish to be present on more than one
227 monitor/head. As per the _NET_WM_FULLSCREEN_MONITORS hint in the EWMH spec,
228 this topology consists of 4 monitor indices such that the bounding rectangle
229 is defined by the top edge of the top monitor, the bottom edge of the bottom
230 monitor, the left edge of the left monitor, and the right edge of the right
231 monitor. See the _NET_WM_FULLSCREEN_MONITORS hint in the EWMH spec.
232**/
233
234struct NETFullscreenMonitors {
235 /**
236 Constructor to initialize this struct to -1,0,0,0 (an initialized,
237 albeit invalid, topology).
238 **/
239 NETFullscreenMonitors() : top(-1), bottom(0), left(0), right(0) { }
240
241 /**
242 Monitor index whose top border defines the top edge of the topology.
243 **/
244 int top;
245
246 /**
247 Monitor index whose bottom border defines the bottom edge of the topology.
248 **/
249 int bottom;
250
251 /**
252 Monitor index whose left border defines the left edge of the topology.
253 **/
254 int left;
255
256 /**
257 Monitor index whose right border defines the right edge of the topology.
258 **/
259 int right;
260
261 /**
262 Convenience check to make sure that we are not holding the initial (invalid)
263 values. Note that we don't want to call this isValid() because we're not
264 actually validating the monitor topology here, but merely that our initial
265 values were overwritten at some point by real (non-negative) monitor indices.
266 **/
267 bool isSet() const { return (top != -1); };
268};
269
270
271/**
272 Base namespace class.
273
274 The NET API is an implementation of the NET Window Manager Specification.
275
276 This class is the base class for the NETRootInfo and NETWinInfo classes, which
277 are used to retrieve and modify the properties of windows. To keep
278 the namespace relatively clean, all enums are defined here.
279
280 @see http://www.freedesktop.org/standards/wm-spec/
281 **/
282
283class KDEUI_EXPORT NET {
284public:
285 /**
286 Application role. This is used internally to determine how several action
287 should be performed (if at all).
288 **/
289
290 enum Role {
291 /**
292 indicates that the application is a client application.
293 **/
294 Client,
295 /**
296 indicates that the application is a window manager application.
297 **/
298 WindowManager
299 };
300
301 /**
302 Window type.
303 **/
304
305 enum WindowType {
306 /**
307 indicates that the window did not define a window type.
308 **/
309 Unknown = -1,
310 /**
311 indicates that this is a normal, top-level window
312 **/
313 Normal = 0,
314 /**
315 indicates a desktop feature. This can include a single window
316 containing desktop icons with the same dimensions as the screen, allowing
317 the desktop environment to have full control of the desktop, without the
318 need for proxying root window clicks.
319 **/
320 Desktop = 1,
321 /**
322 indicates a dock or panel feature
323 **/
324 Dock = 2,
325 /**
326 indicates a toolbar window
327 **/
328 Toolbar = 3,
329 /**
330 indicates a pinnable (torn-off) menu window
331 **/
332 Menu = 4,
333 /**
334 indicates that this is a dialog window
335 **/
336 Dialog = 5,
337 /**
338 @deprecated has unclear meaning and is KDE-only
339 **/
340 Override = 6, // NON STANDARD
341 /**
342 indicates a toplevel menu (AKA macmenu). This is a KDE extension to the
343 _NET_WM_WINDOW_TYPE mechanism.
344 **/
345 TopMenu = 7, // NON STANDARD
346 /**
347 indicates a utility window
348 **/
349 Utility = 8,
350 /**
351 indicates that this window is a splash screen window.
352 **/
353 Splash = 9,
354 /**
355 indicates a dropdown menu (from a menubar typically)
356 **/
357 DropdownMenu = 10,
358 /**
359 indicates a popup menu (a context menu typically)
360 **/
361 PopupMenu = 11,
362 /**
363 indicates a tooltip window
364 **/
365 Tooltip = 12,
366 /**
367 indicates a notification window
368 **/
369 Notification = 13,
370 /**
371 indicates that the window is a list for a combobox
372 **/
373 ComboBox = 14,
374 /**
375 indicates a window that represents the dragged object during DND operation
376 **/
377 DNDIcon = 15
378 };
379
380 /**
381 Values for WindowType when they should be OR'ed together, e.g.
382 for the properties argument of the NETRootInfo constructor.
383 **/
384 enum WindowTypeMask {
385 NormalMask = 1<<0, ///< @see Normal
386 DesktopMask = 1<<1, ///< @see Desktop
387 DockMask = 1<<2, ///< @see Dock
388 ToolbarMask = 1<<3, ///< @see Toolbar
389 MenuMask = 1<<4, ///< @see Menu
390 DialogMask = 1<<5, ///< @see Dialog
391 OverrideMask = 1<<6, ///< @see Override
392 TopMenuMask = 1<<7, ///< @see TopMenu
393 UtilityMask = 1<<8, ///< @see Utility
394 SplashMask = 1<<9, ///< @see Splash
395 DropdownMenuMask = 1<<10, ///< @see DropdownMenu
396 PopupMenuMask = 1<<11, ///< @see PopupMenu
397 TooltipMask = 1<<12, ///< @see Tooltip
398 NotificationMask = 1<<13, ///< @see Notification
399 ComboBoxMask = 1<<14, ///< @see ComboBox
400 DNDIconMask = 1<<15, ///< @see DNDIcon
401 AllTypesMask = 0LU-1 ///< All window types.
402 };
403
404 /**
405 * Returns true if the given window type matches the mask given
406 * using WindowTypeMask flags.
407 */
408 static bool typeMatchesMask( WindowType type, unsigned long mask );
409
410 /**
411 Window state.
412
413 To set the state of a window, you'll typically do something like:
414 \code
415 KWindowSystem::setState( winId(), NET::SkipTaskbar | NET::SkipPager );
416 \endcode
417
418 for example to not show the window on the taskbar and desktop pager.
419 winId() is a function of QWidget()
420
421 Note that KeepAbove (StaysOnTop) and KeepBelow are meant as user preference and
422 applications should avoid setting these states themselves.
423 **/
424
425 enum State {
426 /**
427 indicates that this is a modal dialog box. The WM_TRANSIENT_FOR hint
428 MUST be set to indicate which window the dialog is a modal for, or set to
429 the root window if the dialog is a modal for its window group.
430 **/
431 Modal = 1<<0,
432 /**
433 indicates that the Window Manager SHOULD keep the window's position
434 fixed on the screen, even when the virtual desktop scrolls. Note that this is
435 different from being kept on all desktops.
436 **/
437 Sticky = 1<<1,
438 /**
439 indicates that the window is vertically maximized.
440 **/
441 MaxVert = 1<<2,
442 /**
443 indicates that the window is horizontally maximized.
444 **/
445 MaxHoriz = 1<<3,
446 /**
447 convenience value. Equal to MaxVert | MaxHoriz.
448 **/
449 Max = MaxVert | MaxHoriz,
450 /**
451 indicates that the window is shaded (rolled-up).
452 **/
453 Shaded = 1<<4,
454 /**
455 indicates that a window should not be included on a taskbar.
456 **/
457 SkipTaskbar = 1<<5,
458 /**
459 indicates that a window should on top of most windows (but below fullscreen
460 windows).
461 **/
462 KeepAbove = 1<<6,
463 /**
464 @deprecated This is an obsolete name for KeepAbove.
465 **/
466 StaysOnTop = KeepAbove, // NOT STANDARD
467 /**
468 indicates that a window should not be included on a pager.
469 **/
470 SkipPager = 1<<7,
471 /**
472 indicates that a window should not be visible on the screen (e.g. when minimised).
473 Only the window manager is allowed to change it.
474 **/
475 Hidden = 1<<8,
476 /**
477 indicates that a window should fill the entire screen and have no window
478 decorations.
479 **/
480 FullScreen = 1<<9,
481 /**
482 indicates that a window should be below most windows (but above any desktop windows).
483 **/
484 KeepBelow = 1<<10,
485 /**
486 there was an attempt to activate this window, but the window manager prevented
487 this. E.g. taskbar should mark such window specially to bring user's attention to
488 this window. Only the window manager is allowed to change it.
489 **/
490 DemandsAttention = 1<<11
491 };
492
493 /**
494 Direction for WMMoveResize.
495
496 When a client wants the Window Manager to start a WMMoveResize, it should
497 specify one of:
498
499 @li TopLeft
500 @li Top
501 @li TopRight
502 @li Right
503 @li BottomRight
504 @li Bottom
505 @li BottomLeft
506 @li Left
507 @li Move (for movement only)
508 @li KeyboardSize (resizing via keyboard)
509 @li KeyboardMove (movement via keyboard)
510 **/
511
512 enum Direction {
513 TopLeft = 0,
514 Top = 1,
515 TopRight = 2,
516 Right = 3,
517 BottomRight = 4,
518 Bottom = 5,
519 BottomLeft = 6,
520 Left = 7,
521 Move = 8, // movement only
522 KeyboardSize = 9, // size via keyboard
523 KeyboardMove = 10, // move via keyboard
524 MoveResizeCancel = 11 // to ask the WM to stop moving a window
525 };
526
527 /**
528 Client window mapping state. The class automatically watches the mapping
529 state of the client windows, and uses the mapping state to determine how
530 to set/change different properties. Note that this is very lowlevel
531 and you most probably don't want to use this state.
532 **/
533 enum MappingState {
534 /**
535 indicates the client window is visible to the user.
536 **/
537 Visible = 1, //NormalState,
538 /**
539 indicates that neither the client window nor its icon is visible.
540 **/
541 Withdrawn = 0, //WithdrawnState,
542 /**
543 indicates that the client window is not visible, but its icon is.
544 This can be when the window is minimized or when it's on a
545 different virtual desktop. See also NET::Hidden.
546 **/
547 Iconic = 3 // IconicState
548 };
549
550 /**
551 Actions that can be done with a window (_NET_WM_ALLOWED_ACTIONS).
552 **/
553 enum Action {
554 ActionMove = 1<<0,
555 ActionResize = 1<<1,
556 ActionMinimize = 1<<2,
557 ActionShade = 1<<3,
558 ActionStick = 1<<4,
559 ActionMaxVert = 1<<5,
560 ActionMaxHoriz = 1<<6,
561 ActionMax = ActionMaxVert | ActionMaxHoriz,
562 ActionFullScreen = 1<<7,
563 ActionChangeDesktop = 1<<8,
564 ActionClose = 1<<9
565 };
566
567 /**
568 Supported properties. Clients and Window Managers must define which
569 properties/protocols it wants to support.
570
571 Root/Desktop window properties and protocols:
572
573 @li Supported
574 @li ClientList
575 @li ClientListStacking
576 @li NumberOfDesktops
577 @li DesktopGeometry
578 @li DesktopViewport
579 @li CurrentDesktop
580 @li DesktopNames
581 @li ActiveWindow
582 @li WorkArea
583 @li SupportingWMCheck
584 @li VirtualRoots
585 @li CloseWindow
586 @li WMMoveResize
587
588 Client window properties and protocols:
589
590 @li WMName
591 @li WMVisibleName
592 @li WMDesktop
593 @li WMWindowType
594 @li WMState
595 @li WMStrut (obsoleted by WM2ExtendedStrut)
596 @li WMGeometry
597 @li WMFrameExtents
598 @li WMIconGeometry
599 @li WMIcon
600 @li WMIconName
601 @li WMVisibleIconName
602 @li WMHandledIcons
603 @li WMPid
604 @li WMPing
605
606 ICCCM properties (provided for convenience):
607
608 @li XAWMState
609
610 **/
611
612 enum Property {
613 // root
614 Supported = 1<<0,
615 ClientList = 1<<1,
616 ClientListStacking = 1<<2,
617 NumberOfDesktops = 1<<3,
618 DesktopGeometry = 1<<4,
619 DesktopViewport = 1<<5,
620 CurrentDesktop = 1<<6,
621 DesktopNames = 1<<7,
622 ActiveWindow = 1<<8,
623 WorkArea = 1<<9,
624 SupportingWMCheck = 1<<10,
625 VirtualRoots = 1<<11,
626 //
627 CloseWindow = 1<<13,
628 WMMoveResize = 1<<14,
629
630 // window
631 WMName = 1<<15,
632 WMVisibleName = 1<<16,
633 WMDesktop = 1<<17,
634 WMWindowType = 1<<18,
635 WMState = 1<<19,
636 WMStrut = 1<<20,
637 WMIconGeometry = 1<<21,
638 WMIcon = 1<<22,
639 WMPid = 1<<23,
640 WMHandledIcons = 1<<24,
641 WMPing = 1<<25,
642 XAWMState = 1<<27,
643 WMFrameExtents = 1<<28,
644
645 // Need to be reordered
646 WMIconName = 1<<29,
647 WMVisibleIconName = 1<<30,
648 WMGeometry = 1<<31
649 };
650
651 /**
652 Supported properties. This enum is an extension to NET::Property,
653 because them enum is limited only to 32 bits.
654
655 Client window properties and protocols:
656
657 @li WM2UserTime
658 @li WM2StartupId
659 @li WM2TransientFor mainwindow for the window (WM_TRANSIENT_FOR)
660 @li WM2GroupLeader group leader (window_group in WM_HINTS)
661 @li WM2AllowedActions
662 @li WM2RestackWindow
663 @li WM2MoveResizeWindow
664 @li WM2ExtendedStrut
665 @li WM2TemporaryRules internal, for kstart
666 @li WM2WindowClass WM_CLASS
667 @li WM2WindowRole WM_WINDOW_ROLE
668 @li WM2ClientMachine WM_CLIENT_MACHINE
669 @li WM2ShowingDesktop
670 @li WM2Opacity _NET_WM_WINDOW_OPACITY
671 @li WM2DesktopLayout _NET_DESKTOP_LAYOUT
672 @li WM2FullPlacement _NET_WM_FULL_PLACEMENT
673 @li WM2FullscreenMonitors _NET_WM_FULLSCREEN_MONITORS
674 **/
675 enum Property2 {
676 WM2UserTime = 1<<0,
677 WM2StartupId = 1<<1,
678 WM2TransientFor = 1<<2,
679 WM2GroupLeader = 1<<3,
680 WM2AllowedActions = 1<<4,
681 WM2RestackWindow = 1<<5,
682 WM2MoveResizeWindow = 1<<6,
683 WM2ExtendedStrut = 1<<7,
684 WM2TakeActivity = 1<<8,
685 WM2KDETemporaryRules = 1<<9, // NOT STANDARD
686 WM2WindowClass = 1<<10,
687 WM2WindowRole = 1<<11,
688 WM2ClientMachine = 1<<12,
689 WM2ShowingDesktop = 1<<13,
690 WM2Opacity = 1<<14,
691 WM2DesktopLayout = 1<<15,
692 WM2FullPlacement = 1<<16,
693 WM2FullscreenMonitors = 1<<17,
694 WM2FrameOverlap = 1<<18, // NOT STANDARD
695 WM2Activities = 1<<19, // NOT STANDARD @since 4.6
696 WM2BlockCompositing = 1<<20, // NOT STANDARD @since 4.7
697 WM2KDEShadow = 1<<21 // NOT Standard @since 4.7
698 };
699
700 /**
701 Sentinel value to indicate that the client wishes to be visible on
702 all desktops.
703 **/
704 enum { OnAllDesktops = -1 };
705
706 /**
707 Source of the request.
708 **/
709 // must match the values for data.l[0] field in _NET_ACTIVE_WINDOW message
710 enum RequestSource {
711 /**
712 @internal indicates that the source of the request is unknown
713 **/
714 FromUnknown = 0, // internal
715 /**
716 indicates that the request comes from a normal application
717 **/
718 FromApplication = 1,
719 /**
720 indicated that the request comes from pager or similar tool
721 **/
722 FromTool = 2
723 };
724
725 /**
726 Orientation.
727 **/
728 enum Orientation {
729 OrientationHorizontal = 0,
730 OrientationVertical = 1
731 };
732
733 /**
734 Starting corner for desktop layout.
735 **/
736 enum DesktopLayoutCorner {
737 DesktopLayoutCornerTopLeft = 0,
738 DesktopLayoutCornerTopRight = 1,
739 DesktopLayoutCornerBottomLeft = 2,
740 DesktopLayoutCornerBottomRight = 3
741 };
742
743 /**
744 Compares two X timestamps, taking into account wrapping and 64bit architectures.
745 Return value is like with strcmp(), 0 for equal, -1 for time1 < time2, 1 for time1 > time2.
746 @deprecated Moved to KXUtils namespace.
747 */
748 static int timestampCompare( unsigned long time1, unsigned long time2 );
749 /**
750 Returns a difference of two X timestamps, time2 - time1, where time2 must be later than time1,
751 as returned by timestampCompare().
752 @deprecated Moved to KXUtils namespace.
753 */
754 static int timestampDiff( unsigned long time1, unsigned long time2 );
755
756};
757
758#endif // netwm_def_h
759