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
27#ifndef netwm_h
28#define netwm_h
29
30#include <kdeui_export.h>
31#include <QtGui/QWidget>
32#ifdef Q_WS_X11
33#include <X11/Xlib.h>
34#include <X11/Xutil.h>
35#include <X11/Xatom.h>
36#include <fixx11h.h>
37
38#include "netwm_def.h"
39
40// forward declaration
41struct NETRootInfoPrivate;
42struct NETWinInfoPrivate;
43template <class Z> class NETRArray;
44
45
46/**
47 Common API for root window properties/protocols.
48
49 The NETRootInfo class provides a common API for clients and window managers
50 to set/read/change properties on the root window as defined by the NET Window
51 Manager Specification..
52
53 @author Bradley T. Hughes <bhughes@trolltech.com>
54 @see NET
55 @see NETWinInfo
56 **/
57
58class KDEUI_EXPORT NETRootInfo : public NET {
59public:
60 /**
61 Indexes for the properties array.
62 **/
63 // update also NETRootInfoPrivate::properties[] size when extending this
64 enum { PROTOCOLS, WINDOW_TYPES, STATES, PROTOCOLS2, ACTIONS,
65 PROPERTIES_SIZE };
66
67 /**
68 Window Managers should use this constructor to create a NETRootInfo object,
69 which will be used to set/update information stored on the rootWindow.
70 The application role is automatically set to WindowManager
71 when using this constructor.
72
73 @param display An X11 Display struct.
74
75 @param supportWindow The Window id of the supportWindow. The supportWindow
76 must be created by the window manager as a child of the rootWindow. The
77 supportWindow must not be destroyed until the Window Manager exits.
78
79 @param wmName A string which should be the window manager's name (ie. "KWin"
80 or "Blackbox").
81
82 @param properties An array of elements listing all properties and protocols
83 the window manager supports. The elements contain OR'ed values of constants
84 from the NET base class, in the following order: [0]= NET::Property,
85 [1]= NET::WindowTypeMask (not NET::WindowType!), [2]= NET::State,
86 [3]= NET::Property2, [4]= NET::Action.
87 In future versions, the list may be extended. In case you pass less elements,
88 the missing ones will be replaced with default values.
89
90 @param properties_size The number of elements in the properties array.
91
92 @param screen For Window Managers that support multiple screen (ie.
93 "multiheaded") displays, the screen number may be explicitly defined. If
94 this argument is omitted, the default screen will be used.
95
96 @param doActivate true to activate the window
97 **/
98 NETRootInfo(Display *display, Window supportWindow, const char *wmName,
99 const unsigned long properties[], int properties_size,
100 int screen = -1, bool doActivate = true);
101
102
103 /**
104 Clients should use this constructor to create a NETRootInfo object, which
105 will be used to query information set on the root window. The application
106 role is automatically set to Client when using this constructor.
107
108 @param display An X11 Display struct.
109
110 @param properties An array of elements listing all protocols the client
111 is interested in. The elements contain OR'ed values of constants
112 from the NET base class, in the following order: [0]= NET::Property,
113 [1]= NET::Property2.
114
115 @param properties_size The number of elements in the properties array.
116
117 @param screen For Clients that support multiple screen (ie. "multiheaded")
118 displays, the screen number may be explicitly defined. If this argument is
119 omitted, the default screen will be used.
120
121 @param doActivate true to call activate() to do an initial data read/update
122 of the query information.
123 **/
124 NETRootInfo(Display *display, const unsigned long properties[], int properties_size,
125 int screen = -1, bool doActivate = true);
126
127 /**
128 This constructor differs from the above one only in the way it accepts
129 the list of supported properties. The properties argument is equivalent
130 to the first element of the properties array in the above constructor,
131 and therefore you cannot read all root window properties using it.
132 **/
133 NETRootInfo(Display *display, unsigned long properties, int screen = -1,
134 bool doActivate = true);
135
136 /**
137 Creates a shared copy of the specified NETRootInfo object.
138
139 @param rootinfo the NETRootInfo object to copy
140 **/
141 NETRootInfo(const NETRootInfo &rootinfo);
142
143 /**
144 Destroys the NETRootInfo object.
145 **/
146 virtual ~NETRootInfo();
147
148 /**
149 Returns the X11 Display struct used.
150
151 @return the X11 Display
152 **/
153 Display *x11Display() const;
154
155 /**
156 Returns the Window id of the rootWindow.
157
158 @return the id of the root window
159 **/
160 Window rootWindow() const;
161
162 /**
163 Returns the Window id of the supportWindow.
164
165 @return the id of the support window
166 **/
167 Window supportWindow() const;
168
169 /**
170 Returns the name of the Window Manager.
171
172 @return the name of the window manager
173 **/
174 const char *wmName() const;
175
176 /**
177 Returns the screenNumber.
178
179 @return the screen number
180 **/
181 int screenNumber() const;
182
183 /**
184 Sets the given property if on is true, and clears the property otherwise.
185 In WindowManager mode this function updates _NET_SUPPORTED.
186 In Client mode this function does nothing.
187
188 @since 4.4
189 **/
190 void setSupported( NET::Property property, bool on = true );
191
192 /**
193 @overload
194 @since 4.4
195 **/
196 void setSupported( NET::Property2 property, bool on = true );
197
198 /**
199 @overload
200 @since 4.4
201 **/
202 void setSupported( NET::WindowType property, bool on = true );
203
204 /**
205 @overload
206 @since 4.4
207 **/
208 void setSupported( NET::State property, bool on = true );
209
210 /**
211 @overload
212 @since 4.4
213 **/
214 void setSupported( NET::Action property, bool on = true );
215
216 /**
217 Returns true if the given property is supported by the window
218 manager. Note that for Client mode, NET::Supported needs
219 to be passed in the properties argument for this to work.
220 **/
221 bool isSupported( NET::Property property ) const;
222 /**
223 @overload
224 **/
225 bool isSupported( NET::Property2 property ) const;
226 /**
227 @overload
228 **/
229 bool isSupported( NET::WindowType type ) const;
230 /**
231 @overload
232 **/
233 bool isSupported( NET::State state ) const;
234
235 /**
236 @overload
237 **/
238 bool isSupported( NET::Action action ) const;
239
240 /**
241 In the Window Manager mode, this is equivalent to the properties
242 argument passed to the constructor. In the Client mode, if
243 NET::Supported was passed in the properties argument, the returned
244 value is array of all protocols and properties supported
245 by the Window Manager. The elements of the array are the same
246 as they would be passed to the Window Manager mode constructor,
247 the size is the maximum array size the constructor accepts.
248 **/
249 const unsigned long* supportedProperties() const;
250
251 /**
252 Returns the properties argument passed to the constructor.
253 The size is the maximum array size the constructor accepts.
254 **/
255 const unsigned long* passedProperties() const;
256
257 /**
258 Returns an array of Window id's, which contain all managed windows.
259
260 @return the array of Window id's
261
262 @see clientListCount()
263 **/
264 const Window *clientList() const;
265
266 /**
267 Returns the number of managed windows in clientList array.
268
269 @return the number of managed windows in the clientList array
270
271 @see clientList()
272 **/
273 int clientListCount() const;
274
275 /**
276 Returns an array of Window id's, which contain all managed windows in
277 stacking order.
278
279 @return the array of Window id's in stacking order
280
281 @see clientListStackingCount()
282 **/
283 const Window *clientListStacking() const;
284
285 /**
286 Returns the number of managed windows in the clientListStacking array.
287
288 @return the number of Window id's in the client list
289
290 @see clientListStacking()
291 **/
292 int clientListStackingCount() const;
293
294 /**
295 Returns the desktop geometry size.
296
297 The desktop argument is ignored. Early drafts of the NET WM
298 Specification were unclear about the semantics of this property.
299
300 NOTE: KDE uses virtual desktops and does not directly support
301 viewport in any way. You should use calls for virtual desktops,
302 viewport is mapped to them if needed.
303
304 @param desktop the number of the desktop
305
306 @return the size of the desktop
307 **/
308 NETSize desktopGeometry(int desktop) const;
309
310 /**
311 Returns the viewport of the specified desktop.
312
313 NOTE: KDE uses virtual desktops and does not directly support
314 viewport in any way. You should use calls for virtual desktops,
315 viewport is mapped to them if needed.
316
317 @param desktop the number of the desktop
318
319 @return the position of the desktop's viewport
320 **/
321 NETPoint desktopViewport(int desktop) const;
322
323 /**
324 Returns the workArea for the specified desktop.
325
326 @param desktop the number of the desktop
327
328 @return the size of the work area
329 **/
330 NETRect workArea(int desktop) const;
331
332 /**
333 Returns the name for the specified desktop.
334
335 @param desktop the number of the desktop
336
337 @return the name of the desktop
338 **/
339 const char *desktopName(int desktop) const;
340
341 /**
342 Returns an array of Window id's, which contain the virtual root windows.
343
344 @return the array of Window id's
345
346 @see virtualRootsCount()
347 **/
348 const Window *virtualRoots( ) const;
349
350 /**
351 Returns the number of window in the virtualRoots array.
352
353 @return the number of Window id's in the virtual root array
354
355 @see virtualRoots()
356 **/
357 int virtualRootsCount() const;
358
359 /**
360 Returns the desktop layout orientation.
361 **/
362 NET::Orientation desktopLayoutOrientation() const;
363
364 /**
365 Returns the desktop layout number of columns and rows. Note that
366 either may be 0 (see _NET_DESKTOP_LAYOUT).
367 **/
368 QSize desktopLayoutColumnsRows() const;
369
370 /**
371 Returns the desktop layout starting corner.
372 **/
373 NET::DesktopLayoutCorner desktopLayoutCorner() const;
374
375 /**
376 Returns the number of desktops.
377
378 NOTE: KDE uses virtual desktops and does not directly support
379 viewport in any way. They are however mapped to virtual desktops
380 if needed.
381
382 @param ignore_viewport if false, viewport is mapped to virtual desktops
383
384 @return the number of desktops
385 **/
386 int numberOfDesktops( bool ignore_viewport = false ) const;
387
388 /**
389 Returns the current desktop.
390
391 NOTE: KDE uses virtual desktops and does not directly support
392 viewport in any way. They are however mapped to virtual desktops
393 if needed.
394
395 @param ignore_viewport if false, viewport is mapped to virtual desktops
396
397 @return the number of the current desktop
398 **/
399 int currentDesktop( bool ignore_viewport = false ) const;
400
401 /**
402 Returns the active (focused) window.
403
404 @return the id of the active window
405 **/
406 Window activeWindow() const;
407
408 /**
409 Window Managers must call this after creating the NETRootInfo object, and
410 before using any other method in the class. This method sets initial data
411 on the root window and does other post-construction duties.
412
413 Clients must also call this after creating the object to do an initial
414 data read/update.
415 **/
416 void activate();
417
418 /**
419 Sets the list of managed windows on the Root/Desktop window.
420
421 @param windows The array of Window id's
422
423 @param count The number of windows in the array
424 **/
425 void setClientList(const Window *windows, unsigned int count);
426
427 /**
428 Sets the list of managed windows in stacking order on the Root/Desktop
429 window.
430
431 @param windows The array of Window id's
432
433 @param count The number of windows in the array.
434 **/
435 void setClientListStacking(const Window *windows, unsigned int count);
436
437 /**
438 Sets the current desktop to the specified desktop.
439
440 NOTE: KDE uses virtual desktops and does not directly support
441 viewport in any way. It is however mapped to virtual desktops
442 if needed.
443
444 @param desktop the number of the desktop
445 @param ignore_viewport if false, viewport is mapped to virtual desktops
446 **/
447 void setCurrentDesktop(int desktop, bool ignore_viewport = false);
448
449 /**
450 Sets the desktop geometry to the specified geometry.
451
452 The desktop argument is ignored. Early drafts of the NET WM
453 Specification were unclear about the semantics of this property.
454
455 NOTE: KDE uses virtual desktops and does not directly support
456 viewport in any way. You should use calls for virtual desktops,
457 viewport is mapped to them if needed.
458
459 @param desktop the number of the desktop
460
461 @param geometry the new size of the desktop
462 **/
463 void setDesktopGeometry(int desktop, const NETSize &geometry);
464
465 /**
466 Sets the viewport for the current desktop to the specified point.
467
468 NOTE: KDE uses virtual desktops and does not directly support
469 viewport in any way. You should use calls for virtual desktops,
470 viewport is mapped to them if needed.
471
472 @param desktop the number of the desktop
473
474 @param viewport the new position of the desktop's viewport
475 **/
476 void setDesktopViewport(int desktop, const NETPoint &viewport);
477
478 /**
479 Sets the number of desktops to the specified number.
480
481 NOTE: KDE uses virtual desktops and does not directly support
482 viewport in any way. Viewport is mapped to virtual desktops
483 if needed, but not for this call.
484
485 @param numberOfDesktops the number of desktops
486 **/
487 void setNumberOfDesktops(int numberOfDesktops);
488
489 /**
490 Sets the name of the specified desktop.
491
492 NOTE: KDE uses virtual desktops and does not directly support
493 viewport in any way. Viewport is mapped to virtual desktops
494 if needed, but not for this call.
495
496 @param desktop the number of the desktop
497
498 @param desktopName the new name of the desktop
499 **/
500 void setDesktopName(int desktop, const char *desktopName);
501
502 /**
503 Requests that the specified window becomes the active (focused) one.
504
505 @param window the id of the new active window
506 @param src whether the request comes from normal application
507 or from a pager or similar tool
508 @param timestamp X server timestamp of the user action that
509 caused the request
510 @param active_window active window of the requesting application, if any
511 **/
512 void setActiveWindow(Window window, NET::RequestSource src,
513 Time timestamp, Window active_window);
514
515 /**
516 Sets the active (focused) window the specified window. This should
517 be used only in the window manager mode.
518
519 @param window the if of the new active window
520 **/
521 void setActiveWindow(Window window);
522
523 /**
524 Sets the workarea for the specified desktop
525
526 @param desktop the number of the desktop
527
528 @param workArea the new work area of the desktop
529 **/
530 void setWorkArea(int desktop, const NETRect &workArea);
531
532 /**
533 Sets the list of virtual root windows on the root window.
534
535 @param windows The array of Window id's
536
537 @param count The number of windows in the array.
538 **/
539 void setVirtualRoots(const Window *windows, unsigned int count);
540
541 /**
542 Sets the desktop layout. This is set by the pager. When setting, the pager must
543 own the _NET_DESKTOP_LAYOUT_Sn manager selection. See _NET_DESKTOP_LAYOUT for details.
544 **/
545 void setDesktopLayout(NET::Orientation orientation, int columns, int rows,
546 NET::DesktopLayoutCorner corner);
547
548 /**
549 * Sets the _NET_SHOWING_DESKTOP status (whether desktop is being shown).
550 */
551 void setShowingDesktop( bool showing );
552 /**
553 * Returns the status of _NET_SHOWING_DESKTOP.
554 */
555 bool showingDesktop() const;
556
557 /**
558 Assignment operator. Ensures that the shared data reference counts are
559 correct.
560 **/
561 const NETRootInfo &operator=(const NETRootInfo &rootinfo);
562
563 /**
564 Clients (such as pagers/taskbars) that wish to close a window should call
565 this function. This will send a request to the Window Manager, which
566 usually can usually decide how to react to such requests.
567
568 @param window the id of the window to close
569 **/
570 void closeWindowRequest(Window window);
571
572 /**
573 Clients (such as pagers/taskbars) that wish to start a WMMoveResize
574 (where the window manager controls the resize/movement,
575 i.e. _NET_WM_MOVERESIZE) should call this function.
576 This will send a request to the Window Manager.
577
578 @param window The client window that would be resized/moved.
579
580 @param x_root X position of the cursor relative to the root window.
581
582 @param y_root Y position of the cursor relative to the root window.
583
584 @param direction One of NET::Direction (see base class documentation for
585 a description of the different directions).
586 **/
587 void moveResizeRequest(Window window, int x_root, int y_root,
588 Direction direction);
589
590 /**
591 Clients (such as pagers/taskbars) that wish to move/resize a window
592 using WM2MoveResizeWindow (_NET_MOVERESIZE_WINDOW) should call this function.
593 This will send a request to the Window Manager. See _NET_MOVERESIZE_WINDOW
594 description for details.
595
596 @param window The client window that would be resized/moved.
597 @param flags Flags specifying the operation (see _NET_MOVERESIZE_WINDOW description)
598 @param x Requested X position for the window
599 @param y Requested Y position for the window
600 @param width Requested width for the window
601 @param height Requested height for the window
602 **/
603 void moveResizeWindowRequest(Window window, int flags, int x, int y, int width, int height );
604
605 /**
606 Sends the _NET_RESTACK_WINDOW request.
607 **/
608 void restackRequest(Window window, RequestSource source, Window above, int detail, Time timestamp);
609
610 /**
611 Sends a ping with the given timestamp to the window, using
612 the _NET_WM_PING protocol.
613 */
614 void sendPing( Window window, Time timestamp );
615
616 /**
617 Sends a take activity message with the given timestamp to the window, using
618 the _NET_WM_TAKE_ACTIVITY protocol (see the WM spec for details).
619 @param window the window to which the message should be sent
620 @param timestamp timestamp of the message
621 @param flags arbitrary flags
622 */
623 void takeActivity( Window window, Time timestamp, long flags );
624
625 /**
626 This function takes the passed XEvent and returns an OR'ed list of
627 NETRootInfo properties that have changed in the properties argument.
628 The new information will be read immediately by the class.
629 The elements of the properties argument are as they would be passed
630 to the constructor, if the array is not large enough,
631 changed properties that don't fit in it won't be listed there
632 (they'll be updated in the class though).
633
634 @param event the event
635 @param properties properties that changed
636 @param properties_size size of the passed properties array
637
638 **/
639 void event( XEvent* event, unsigned long* properties, int properties_size );
640
641 /**
642 This function takes the passed XEvent and returns an OR'ed list of
643 NETRootInfo properties that have changed. The new information will be
644 read immediately by the class. This overloaded version returns
645 only a single mask, and therefore cannot check state of all properties
646 like the other variant.
647
648 @param event the event
649
650 @return the properties
651 **/
652 unsigned long event(XEvent *event);
653
654
655protected:
656 /**
657 A Client should subclass NETRootInfo and reimplement this function when
658 it wants to know when a window has been added.
659
660 @param window the id of the window to add
661 **/
662 virtual void addClient(Window window) { Q_UNUSED(window); }
663
664 /**
665 A Client should subclass NETRootInfo and reimplement this function when
666 it wants to know when a window has been removed.
667
668 @param window the id of the window to remove
669 **/
670 virtual void removeClient(Window window) { Q_UNUSED(window); }
671
672 /**
673 A Window Manager should subclass NETRootInfo and reimplement this function
674 when it wants to know when a Client made a request to change the number
675 of desktops.
676
677 @param numberOfDesktops the new number of desktops
678 **/
679 virtual void changeNumberOfDesktops(int numberOfDesktops) { Q_UNUSED(numberOfDesktops); }
680
681 /**
682 A Window Manager should subclass NETRootInfo and reimplement this function
683 when it wants to know when a Client made a request to change the specified
684 desktop geometry.
685
686 @param desktop the number of the desktop
687
688 @param geom the new size
689 **/
690 virtual void changeDesktopGeometry(int desktop, const NETSize &geom) { Q_UNUSED(desktop); Q_UNUSED(geom); }
691
692 /**
693 A Window Manager should subclass NETRootInfo and reimplement this function
694 when it wants to know when a Client made a request to change the specified
695 desktop viewport.
696
697 @param desktop the number of the desktop
698
699 @param viewport the new position of the viewport
700 **/
701 virtual void changeDesktopViewport(int desktop, const NETPoint &viewport) { Q_UNUSED(desktop); Q_UNUSED(viewport); }
702
703 /**
704 A Window Manager should subclass NETRootInfo and reimplement this function
705 when it wants to know when a Client made a request to change the current
706 desktop.
707
708 @param desktop the number of the desktop
709 **/
710 virtual void changeCurrentDesktop(int desktop) { Q_UNUSED(desktop); }
711
712 /**
713 A Window Manager should subclass NETRootInfo and reimplement this function
714 when it wants to know when a Client made a request to close a window.
715
716 @param window the id of the window to close
717 **/
718 virtual void closeWindow(Window window) { Q_UNUSED(window); }
719
720 /**
721 A Window Manager should subclass NETRootInfo and reimplement this function
722 when it wants to know when a Client made a request to start a move/resize.
723
724 @param window The window that wants to move/resize
725
726 @param x_root X position of the cursor relative to the root window.
727
728 @param y_root Y position of the cursor relative to the root window.
729
730 @param direction One of NET::Direction (see base class documentation for
731 a description of the different directions).
732 **/
733 virtual void moveResize(Window window, int x_root, int y_root,
734 unsigned long direction) { Q_UNUSED(window); Q_UNUSED(x_root); Q_UNUSED(y_root); Q_UNUSED(direction); }
735
736 /**
737 A Window Manager should subclass NETRootInfo and reimplement this function
738 when it wants to receive replies to the _NET_WM_PING protocol.
739 @param window the window from which the reply came
740 @param timestamp timestamp of the ping
741 */
742 virtual void gotPing( Window window, Time timestamp ) { Q_UNUSED(window); Q_UNUSED(timestamp); }
743 /**
744 A Window Manager should subclass NETRootInfo and reimplement this function
745 when it wants to know when a Client made a request to change the active
746 (focused) window.
747
748 @param window the id of the window to activate
749 @param src the source from which the request came
750 @param timestamp the timestamp of the user action causing this request
751 @param active_window active window of the requesting application, if any
752 **/
753 virtual void changeActiveWindow(Window window,NET::RequestSource src,
754 Time timestamp, Window active_window ) { Q_UNUSED(window); Q_UNUSED(src); Q_UNUSED(timestamp); Q_UNUSED(active_window);}
755
756 /**
757 A Window Manager should subclass NETRootInfo and reimplement this function
758 when it wants to know when a pager made a request to move/resize a window.
759 See _NET_MOVERESIZE_WINDOW for details.
760
761 @param window the id of the window to more/resize
762 @param flags Flags specifying the operation (see _NET_MOVERESIZE_WINDOW description)
763 @param x Requested X position for the window
764 @param y Requested Y position for the window
765 @param width Requested width for the window
766 @param height Requested height for the window
767 **/
768 virtual void moveResizeWindow(Window window, int flags, int x, int y, int width, int height) { Q_UNUSED(window); Q_UNUSED(flags); Q_UNUSED(x); Q_UNUSED(y); Q_UNUSED(width); Q_UNUSED(height); }
769
770 /**
771 A Window Manager should subclass NETRootInfo and reimplement this function
772 when it wants to know when a Client made a request to restack a window.
773 See _NET_RESTACK_WINDOW for details.
774
775 @param window the id of the window to restack
776 @param source the source of the request
777 @param above other window in the restack request
778 @param detail restack detail
779 @param timestamp the timestamp of the request
780 **/
781 virtual void restackWindow(Window window, RequestSource source,
782 Window above, int detail, Time timestamp) { Q_UNUSED(window); Q_UNUSED(source); Q_UNUSED(above); Q_UNUSED(detail); Q_UNUSED(timestamp); }
783 /**
784 A Window Manager should subclass NETRootInfo and reimplement this function
785 when it wants to receive replies to the _NET_WM_TAKE_ACTIVITY protocol.
786 @param window the window from which the reply came
787 @param timestamp timestamp of the ping
788 @param flags flags passed in the original message
789 */
790 virtual void gotTakeActivity(Window window, Time timestamp, long flags ) { Q_UNUSED(window); Q_UNUSED(timestamp); Q_UNUSED(flags); }
791
792 /**
793 A Window Manager should subclass NETRootInfo and reimplement this function
794 when it wants to know when a pager made a request to change showing the desktop.
795 See _NET_SHOWING_DESKTOP for details.
796
797 @param showing whether to activate the showing desktop mode
798 **/
799 virtual void changeShowingDesktop(bool showing) { Q_UNUSED(showing); }
800
801private:
802 void update( const unsigned long[] );
803 void setSupported();
804 void setDefaultProperties();
805 void updateSupportedProperties( Atom atom );
806
807protected:
808 /** Virtual hook, used to add new "virtual" functions while maintaining
809 binary compatibility. Unused in this class.
810 */
811 virtual void virtual_hook( int id, void* data );
812private:
813 NETRootInfoPrivate *p; // krazy:exclude=dpointer (implicitly shared)
814};
815
816/**
817 Common API for application window properties/protocols.
818
819 The NETWinInfo class provides a common API for clients and window managers to
820 set/read/change properties on an application window as defined by the NET
821 Window Manager Specification.
822
823 @author Bradley T. Hughes <bhughes@trolltech.com>
824 @see NET
825 @see NETRootInfo
826 @see http://www.freedesktop.org/standards/wm-spec/
827 **/
828
829class KDEUI_EXPORT NETWinInfo : public NET {
830public:
831 /**
832 Indexes for the properties array.
833 **/
834 // update also NETWinInfoPrivate::properties[] size when extending this
835 enum { PROTOCOLS, PROTOCOLS2,
836 PROPERTIES_SIZE };
837 /**
838 Create a NETWinInfo object, which will be used to set/read/change
839 information stored on an application window.
840
841 @param display An X11 Display struct.
842
843 @param window The Window id of the application window.
844
845 @param rootWindow The Window id of the root window.
846
847 @param properties An array of elements listing all properties the client
848 is interested in.The elements contain OR'ed values of constants
849 from the NET base class, in the following order: [0]= NET::Property,
850 [1]= NET::Property2.
851 In future versions, the list may be extended. In case you pass less elements,
852 the missing ones will be replaced with default values.
853
854 @param properties_size The number of elements in the properties array.
855
856 @param role Select the application role. If this argument is omitted,
857 the role will default to Client.
858 **/
859 NETWinInfo(Display *display, Window window, Window rootWindow,
860 const unsigned long properties[], int properties_size,
861 Role role = Client);
862
863 /**
864 This constructor differs from the above one only in the way it accepts
865 the list of properties the client is interested in. The properties argument
866 is equivalent to the first element of the properties array
867 in the above constructor.
868 **/
869 NETWinInfo(Display *display, Window window,
870 Window rootWindow, unsigned long properties,
871 Role role = Client);
872
873 /**
874 Creates a shared copy of the specified NETWinInfo object.
875
876 @param wininfo the NETWinInfo to copy
877 **/
878 NETWinInfo(const NETWinInfo & wininfo);
879
880 /**
881 Destroys the NETWinInfo object.
882 **/
883 virtual ~NETWinInfo();
884
885 /**
886 Assignment operator. Ensures that the shared data reference counts are
887 correct.
888 **/
889 const NETWinInfo &operator=(const NETWinInfo &wintinfo);
890
891 /**
892 Returns true if the window has any window type set, even if the type
893 itself is not known to this implementation. Presence of a window type
894 as specified by the NETWM spec is considered as the window supporting
895 this specification.
896 @return true if the window has support for the NETWM spec
897 **/
898 bool hasNETSupport() const;
899
900 /**
901 Returns the properties argument passed to the constructor.
902 The size is the maximum array size the constructor accepts.
903 **/
904 const unsigned long* passedProperties() const;
905
906 /**
907 Returns the icon geometry.
908
909 @return the geometry of the icon
910 **/
911 NETRect iconGeometry() const;
912
913 /**
914 Returns the state of the window (see the NET base class documentation for a
915 description of the various states).
916
917 @return the state of the window
918 **/
919 unsigned long state() const;
920
921 /**
922 Returns the extended (partial) strut specified by this client.
923 See _NET_WM_STRUT_PARTIAL in the spec.
924 **/
925 NETExtendedStrut extendedStrut() const;
926
927 /**
928 @deprecated use strutPartial()
929 Returns the strut specified by this client.
930
931 @return the strut of the window
932 **/
933 NETStrut strut() const;
934
935 /**
936 Returns the window type for this client (see the NET base class
937 documentation for a description of the various window types).
938 Since clients may specify several windows types for a window
939 in order to support backwards compatibility and extensions
940 not available in the NETWM spec, you should specify all
941 window types you application supports (see the NET::WindowTypeMask
942 mask values for various window types). This method will
943 return the first window type that is listed in the supported types,
944 or NET::Unknown if none of the window types is supported.
945
946 @return the type of the window
947 **/
948 WindowType windowType( unsigned long supported_types ) const;
949
950 /**
951 This function returns false if the window has not window type
952 specified at all. Used by KWindowInfo::windowType() to return either
953 NET::Normal or NET::Dialog as appropriate as a fallback.
954 **/
955 bool hasWindowType() const;
956
957 /**
958 Returns the name of the window in UTF-8 format.
959
960 @return the name of the window
961 **/
962 const char *name() const;
963
964 /**
965 Returns the visible name as set by the window manager in UTF-8 format.
966
967 @return the visible name of the window
968 **/
969 const char *visibleName() const;
970
971 /**
972 Returns the iconic name of the window in UTF-8 format. Note that this has
973 nothing to do with icons, but it's for "iconic"
974 representations of the window (taskbars etc.), that should be shown
975 when the window is in iconic state. See description of _NET_WM_ICON_NAME
976 for details.
977
978 @return the iconic name
979 **/
980 const char *iconName() const;
981
982 /**
983 Returns the visible iconic name as set by the window manager in UTF-8 format.
984 Note that this has nothing to do with icons, but it's for "iconic"
985 representations of the window (taskbars etc.), that should be shown
986 when the window is in iconic state. See description of _NET_WM_VISIBLE_ICON_NAME
987 for details.
988
989 @return the visible iconic name
990 **/
991 const char *visibleIconName() const;
992
993 /**
994 Returns the desktop where the window is residing.
995
996 NOTE: KDE uses virtual desktops and does not directly support
997 viewport in any way. It is however mapped to virtual desktops
998 if needed.
999
1000 @param ignore_viewport if false, viewport is mapped to virtual desktops
1001
1002 @return the number of the window's desktop
1003
1004 @see OnAllDesktops()
1005 **/
1006 int desktop( bool ignore_viewport = false ) const;
1007
1008 /**
1009 Returns the process id for the client window.
1010
1011 @return the process id of the window
1012 **/
1013 int pid() const;
1014
1015 /**
1016 Returns whether or not this client handles icons.
1017
1018 @return true if this client handles icons, false otherwise
1019 **/
1020 Bool handledIcons() const;
1021
1022 /**
1023 Returns the mapping state for the window (see the NET base class
1024 documentation for a description of mapping state).
1025
1026 @return the mapping state
1027 **/
1028 MappingState mappingState() const;
1029
1030 /**
1031 Set icons for the application window. If replace is True, then
1032 the specified icon is defined to be the only icon. If replace is False,
1033 then the specified icon is added to a list of icons.
1034
1035 @param icon the new icon
1036
1037 @param replace true to replace, false to append to the list of icons
1038 **/
1039 void setIcon(NETIcon icon, Bool replace = True);
1040
1041 /**
1042 Set the icon geometry for the application window.
1043
1044 @param geometry the new icon geometry
1045 **/
1046 void setIconGeometry(NETRect geometry);
1047
1048 /**
1049 Set the extended (partial) strut for the application window.
1050
1051 @param extended_strut the new strut
1052 **/
1053 void setExtendedStrut(const NETExtendedStrut& extended_strut );
1054
1055 /**
1056 @deprecated use setExtendedStrut()
1057 Set the strut for the application window.
1058
1059 @param strut the new strut
1060 **/
1061 void setStrut(NETStrut strut);
1062
1063 /**
1064 Set the state for the application window (see the NET base class documentation
1065 for a description of window state).
1066
1067 @param state the name state
1068
1069 @param mask the mask for the state
1070 **/
1071 void setState(unsigned long state, unsigned long mask);
1072
1073 /**
1074 Sets the window type for this client (see the NET base class
1075 documentation for a description of the various window types).
1076
1077 @param type the window type
1078 **/
1079 void setWindowType(WindowType type);
1080
1081 /**
1082 Sets the name for the application window.
1083
1084 @param name the new name of the window
1085 **/
1086 void setName(const char *name);
1087
1088 /**
1089 For Window Managers only: set the visible name ( i.e. xterm, xterm <2>,
1090 xterm <3>, ... )
1091
1092 @param visibleName the new visible name
1093 **/
1094 void setVisibleName(const char *visibleName);
1095
1096 /**
1097 Sets the iconic name for the application window.
1098
1099 @param name the new iconic name
1100 **/
1101 void setIconName(const char *name);
1102
1103 /**
1104 For Window Managers only: set the visible iconic name ( i.e. xterm, xterm <2>,
1105 xterm <3>, ... )
1106
1107 @param name the new visible iconic name
1108 **/
1109 void setVisibleIconName(const char *name);
1110
1111 /**
1112 Set which window the desktop is (should be) on.
1113
1114 NOTE: KDE uses virtual desktops and does not directly support
1115 viewport in any way. It is however mapped to virtual desktops
1116 if needed.
1117
1118 @param desktop the number of the new desktop
1119 @param ignore_viewport if false, viewport is mapped to virtual desktops
1120
1121 @see OnAllDesktops()
1122 **/
1123 void setDesktop(int desktop, bool ignore_viewport = false);
1124
1125 /**
1126 Set the application window's process id.
1127
1128 @param pid the window's process id
1129 **/
1130 void setPid(int pid);
1131
1132 /**
1133 Set whether this application window handles icons.
1134
1135 @param handled true if the window handles icons, false otherwise
1136 **/
1137 void setHandledIcons(Bool handled);
1138
1139 /**
1140 Set the frame decoration strut, i.e. the width of the decoration borders.
1141
1142 @param strut the new strut
1143 **/
1144 void setFrameExtents(NETStrut strut);
1145
1146 /**
1147 Returns the frame decoration strut, i.e. the width of the decoration borders.
1148
1149 @since 4.3
1150 **/
1151 NETStrut frameExtents() const;
1152
1153 /**
1154 Sets the window frame overlap strut, i.e. how far the window frame extends
1155 behind the client area on each side.
1156
1157 Set the strut values to -1 if you want the window frame to cover the whole
1158 client area.
1159
1160 The default values are 0.
1161
1162 @since 4.4
1163 **/
1164 void setFrameOverlap(NETStrut strut);
1165
1166 /**
1167 Returns the frame overlap strut, i.e. how far the window frame extends
1168 behind the client area on each side.
1169
1170 @since 4.4
1171 **/
1172 NETStrut frameOverlap() const;
1173
1174 /**
1175 Returns an icon. If width and height are passed, the icon returned will be
1176 the closest it can find (the next biggest). If width and height are omitted,
1177 then the largest icon in the list is returned.
1178
1179 @param width the preferred width for the icon, -1 to ignore
1180
1181 @param height the preferred height for the icon, -1 to ignore
1182
1183 @return the icon
1184 **/
1185 NETIcon icon(int width = -1, int height = -1) const;
1186
1187 /**
1188 Returns a list of provided icon sizes. Each size is pair width,height, terminated
1189 with pair 0,0.
1190 @since 4.3
1191 **/
1192 const int* iconSizes() const;
1193
1194 /**
1195 * Sets user timestamp @p time on the window (property _NET_WM_USER_TIME).
1196 * The timestamp is expressed as XServer time. If a window
1197 * is shown with user timestamp older than the time of the last
1198 * user action, it won't be activated after being shown, with the special
1199 * value 0 meaning not to activate the window after being shown.
1200 */
1201 void setUserTime( Time time );
1202
1203 /**
1204 * Returns the time of last user action on the window, or -1 if not set.
1205 */
1206 Time userTime() const;
1207
1208 /**
1209 * Sets the startup notification id @p id on the window.
1210 */
1211 void setStartupId( const char* startup_id );
1212
1213 /**
1214 * Returns the startup notification id of the window.
1215 */
1216 const char* startupId() const;
1217
1218 /**
1219 * Sets opacity (0 = transparent, 0xffffffff = opaque ) on the window.
1220 */
1221 void setOpacity( unsigned long opacity );
1222
1223 /**
1224 * Returns the opacity of the window.
1225 */
1226 unsigned long opacity() const;
1227
1228 /**
1229 * Sets actions that the window manager allows for the window.
1230 */
1231 void setAllowedActions( unsigned long actions );
1232
1233 /**
1234 * Returns actions that the window manager allows for the window.
1235 */
1236 unsigned long allowedActions() const;
1237
1238 /**
1239 * Returns the WM_TRANSIENT_FOR property for the window, i.e. the mainwindow
1240 * for this window.
1241 */
1242 Window transientFor() const;
1243
1244 /**
1245 * Returns the leader window for the group the window is in, if any.
1246 */
1247 Window groupLeader() const;
1248
1249 /**
1250 * Returns the class component of the window class for the window
1251 * (i.e. WM_CLASS property).
1252 */
1253 const char* windowClassClass() const;
1254
1255 /**
1256 * Returns the name component of the window class for the window
1257 * (i.e. WM_CLASS property).
1258 */
1259 const char* windowClassName() const;
1260
1261 /**
1262 * Returns the window role for the window (i.e. WM_WINDOW_ROLE property).
1263 */
1264 const char* windowRole() const;
1265
1266 /**
1267 * Returns the client machine for the window (i.e. WM_CLIENT_MACHINE property).
1268 */
1269 const char* clientMachine() const;
1270
1271 /**
1272 * returns a comma-separated list of the activities the window is associated with.
1273 * FIXME this might be better as a NETRArray ?
1274 * @since 4.6
1275 */
1276 const char* activities() const;
1277
1278
1279 /**
1280 * Sets whether the client wishes to block compositing (for better performance)
1281 * @since 4.7
1282 */
1283 void setBlockingCompositing(bool active);
1284
1285 /**
1286 * Returns whether the client wishes to block compositing (for better performance)
1287 * @since 4.7
1288 */
1289 bool isBlockingCompositing() const;
1290
1291 /**
1292 Places the window frame geometry in frame, and the application window
1293 geometry in window. Both geometries are relative to the root window.
1294
1295 @param frame the geometry for the frame
1296
1297 @param window the geometry for the window
1298 **/
1299 void kdeGeometry(NETRect &frame, NETRect &window);
1300
1301 /**
1302 This function takes the passed XEvent and returns an OR'ed list of
1303 NETWinInfo properties that have changed in the properties argument.
1304 The new information will be read immediately by the class.
1305 The elements of the properties argument are as they would be passed
1306 to the constructor, if the array is not large enough,
1307 changed properties that don't fit in it won't be listed there
1308 (they'll be updated in the class though).
1309
1310 @param event the event
1311 @param properties properties that changed
1312 @param properties_size size of the passed properties array
1313 **/
1314 void event( XEvent* event, unsigned long* properties, int properties_size );
1315
1316 /**
1317 This function takes the pass XEvent and returns an OR'ed list of NETWinInfo
1318 properties that have changed. The new information will be read
1319 immediately by the class. This overloaded version returns
1320 only a single mask, and therefore cannot check state of all properties
1321 like the other variant.
1322
1323 @param event the event
1324
1325 @return the properties
1326 **/
1327 unsigned long event(XEvent *event);
1328
1329 /**
1330 Sentinel value to indicate that the client wishes to be visible on
1331 all desktops.
1332
1333 @return the value to be on all desktops
1334 **/
1335 static const int OnAllDesktops;
1336
1337protected:
1338 /**
1339 A Window Manager should subclass NETWinInfo and reimplement this function when
1340 it wants to know when a Client made a request to change desktops (ie. move to
1341 another desktop).
1342
1343 @param desktop the number of the desktop
1344 **/
1345 virtual void changeDesktop(int desktop) { Q_UNUSED(desktop); }
1346
1347 /**
1348 A Window Manager should subclass NETWinInfo and reimplement this function when
1349 it wants to know when a Client made a request to change state (ie. to
1350 Shade / Unshade).
1351
1352 @param state the new state
1353
1354 @param mask the mask for the state
1355 **/
1356 virtual void changeState(unsigned long state, unsigned long mask) { Q_UNUSED(state); Q_UNUSED(mask); }
1357
1358private:
1359 void update( const unsigned long[] );
1360 void updateWMState();
1361 void setIconInternal(NETRArray<NETIcon>& icons, int& icon_count, Atom property, NETIcon icon, Bool replace);
1362 NETIcon iconInternal(NETRArray<NETIcon>& icons, int icon_count, int width, int height) const;
1363
1364protected:
1365 /** Virtual hook, used to add new "virtual" functions while maintaining
1366 binary compatibility. Unused in this class.
1367 */
1368 virtual void virtual_hook( int id, void* data );
1369private:
1370 NETWinInfoPrivate *p; // krazy:exclude=dpointer (implicitly shared)
1371 friend class NETWinInfo2;
1372};
1373
1374
1375/**
1376 This class is an extension of the NETWinInfo class, and exists solely
1377 for binary compatibility reasons (adds new virtual methods) until KDE5. Simply
1378 use it instead of NETWinInfo and override also the added virtual methods.
1379 @since 4.2
1380*/
1381class KDEUI_EXPORT NETWinInfo2 : public NETWinInfo {
1382public:
1383 NETWinInfo2(Display *display, Window window, Window rootWindow,
1384 const unsigned long properties[], int properties_size,
1385 Role role = Client);
1386
1387 NETWinInfo2(Display *display, Window window,
1388 Window rootWindow, unsigned long properties,
1389 Role role = Client);
1390
1391 /**
1392 Sets the desired multiple-monitor topology (4 monitor indices indicating
1393 the top, bottom, left, and right edges of the window) when the fullscreen
1394 state is enabled. The indices are from the set returned by the Xinerama
1395 extension.
1396 See _NET_WM_FULLSCREEN_MONITORS for details.
1397
1398 @param topology A struct that models the desired monitor topology, namely:
1399 top is the monitor whose top edge defines the top edge of the
1400 fullscreen window, bottom is the monitor whose bottom edge defines
1401 the bottom edge of the fullscreen window, left is the monitor whose
1402 left edge defines the left edge of the fullscreen window, and right
1403 is the monitor whose right edge defines the right edge of the fullscreen
1404 window.
1405
1406 **/
1407 void setFullscreenMonitors(NETFullscreenMonitors topology);
1408
1409 /**
1410 Returns the desired fullscreen monitor topology for this client, should
1411 it be in fullscreen state.
1412 See _NET_WM_FULLSCREEN_MONITORS in the spec.
1413 **/
1414 NETFullscreenMonitors fullscreenMonitors() const;
1415
1416protected:
1417 friend class NETWinInfo;
1418 /**
1419 A Window Manager should subclass NETWinInfo2 and reimplement this function
1420 when it wants to know when a Client made a request to change the
1421 fullscreen monitor topology for its fullscreen state.
1422
1423 @param topology A structure (top, bottom, left, right) representing the
1424 fullscreen monitor topology.
1425 **/
1426 virtual void changeFullscreenMonitors(NETFullscreenMonitors topology) { Q_UNUSED(topology); }
1427};
1428
1429//#define KWIN_FOCUS
1430
1431#endif
1432#endif // netwm_h
1433