• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDEUI

  • kdeui
  • windowmanagement
netwm.cpp
Go to the documentation of this file.
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//#define NETWMDEBUG
27
28#include "netwm.h"
29#include "netwm_p.h"
30
31#include <QtGui/QWidget>
32#ifdef Q_WS_X11 //FIXME
33
34#include <QtGui/qx11info_x11.h>
35
36#include <kwindowsystem.h>
37#include <kxutils.h>
38
39#include <string.h>
40#include <stdio.h>
41#include <assert.h>
42#include <stdlib.h>
43
44#include <X11/Xmd.h>
45
46// UTF-8 string
47static Atom UTF8_STRING = 0;
48
49// root window properties
50static Atom net_supported = 0;
51static Atom net_client_list = 0;
52static Atom net_client_list_stacking = 0;
53static Atom net_desktop_geometry = 0;
54static Atom net_desktop_viewport = 0;
55static Atom net_current_desktop = 0;
56static Atom net_desktop_names = 0;
57static Atom net_number_of_desktops = 0;
58static Atom net_active_window = 0;
59static Atom net_workarea = 0;
60static Atom net_supporting_wm_check = 0;
61static Atom net_virtual_roots = 0;
62static Atom net_showing_desktop = 0;
63static Atom net_desktop_layout = 0;
64
65// root window messages
66static Atom net_close_window = 0;
67static Atom net_restack_window = 0;
68static Atom net_wm_moveresize = 0;
69static Atom net_moveresize_window = 0;
70
71// application window properties
72static Atom net_wm_name = 0;
73static Atom net_wm_visible_name = 0;
74static Atom net_wm_icon_name = 0;
75static Atom net_wm_visible_icon_name = 0;
76static Atom net_wm_desktop = 0;
77static Atom net_wm_window_type = 0;
78static Atom net_wm_state = 0;
79static Atom net_wm_strut = 0;
80static Atom net_wm_extended_strut = 0; // the atom is called _NET_WM_STRUT_PARTIAL
81static Atom net_wm_icon_geometry = 0;
82static Atom net_wm_icon = 0;
83static Atom net_wm_pid = 0;
84static Atom net_wm_user_time = 0;
85static Atom net_wm_handled_icons = 0;
86static Atom net_startup_id = 0;
87static Atom net_wm_allowed_actions = 0;
88static Atom wm_window_role = 0;
89static Atom net_frame_extents = 0;
90static Atom net_wm_window_opacity = 0;
91static Atom kde_net_wm_frame_strut = 0;
92static Atom net_wm_fullscreen_monitors = 0;
93
94// KDE extensions
95static Atom kde_net_wm_window_type_override = 0;
96static Atom kde_net_wm_window_type_topmenu = 0;
97static Atom kde_net_wm_temporary_rules = 0;
98static Atom kde_net_wm_frame_overlap = 0;
99static Atom kde_net_wm_activities = 0;
100static Atom kde_net_wm_block_compositing = 0;
101static Atom kde_net_wm_shadow = 0;
102
103// application protocols
104static Atom wm_protocols = 0;
105static Atom net_wm_ping = 0;
106static Atom net_wm_take_activity = 0;
107
108// application window types
109static Atom net_wm_window_type_normal = 0;
110static Atom net_wm_window_type_desktop = 0;
111static Atom net_wm_window_type_dock = 0;
112static Atom net_wm_window_type_toolbar = 0;
113static Atom net_wm_window_type_menu = 0;
114static Atom net_wm_window_type_dialog = 0;
115static Atom net_wm_window_type_utility = 0;
116static Atom net_wm_window_type_splash = 0;
117static Atom net_wm_window_type_dropdown_menu = 0;
118static Atom net_wm_window_type_popup_menu = 0;
119static Atom net_wm_window_type_tooltip = 0;
120static Atom net_wm_window_type_notification = 0;
121static Atom net_wm_window_type_combobox = 0;
122static Atom net_wm_window_type_dnd = 0;
123
124// application window state
125static Atom net_wm_state_modal = 0;
126static Atom net_wm_state_sticky = 0;
127static Atom net_wm_state_max_vert = 0;
128static Atom net_wm_state_max_horiz = 0;
129static Atom net_wm_state_shaded = 0;
130static Atom net_wm_state_skip_taskbar = 0;
131static Atom net_wm_state_skip_pager = 0;
132static Atom net_wm_state_hidden = 0;
133static Atom net_wm_state_fullscreen = 0;
134static Atom net_wm_state_above = 0;
135static Atom net_wm_state_below = 0;
136static Atom net_wm_state_demands_attention = 0;
137
138// allowed actions
139static Atom net_wm_action_move = 0;
140static Atom net_wm_action_resize = 0;
141static Atom net_wm_action_minimize = 0;
142static Atom net_wm_action_shade = 0;
143static Atom net_wm_action_stick = 0;
144static Atom net_wm_action_max_vert = 0;
145static Atom net_wm_action_max_horiz = 0;
146static Atom net_wm_action_fullscreen = 0;
147static Atom net_wm_action_change_desk = 0;
148static Atom net_wm_action_close = 0;
149
150// KDE extension that's not in the specs - Replaced by state_above now?
151static Atom net_wm_state_stays_on_top = 0;
152
153// used to determine whether application window is managed or not
154static Atom xa_wm_state = 0;
155
156// ability flags
157static Atom net_wm_full_placement = 0;
158
159static Bool netwm_atoms_created = False;
160const unsigned long netwm_sendevent_mask = (SubstructureRedirectMask|
161 SubstructureNotifyMask);
162
163
164const long MAX_PROP_SIZE = 100000;
165
166static char *nstrdup(const char *s1) {
167 if (! s1) return (char *) 0;
168
169 int l = strlen(s1) + 1;
170 char *s2 = new char[l];
171 strncpy(s2, s1, l);
172 return s2;
173}
174
175
176static char *nstrndup(const char *s1, int l) {
177 if (! s1 || l == 0) return (char *) 0;
178
179 char *s2 = new char[l+1];
180 strncpy(s2, s1, l);
181 s2[l] = '\0';
182 return s2;
183}
184
185
186static Window *nwindup(const Window *w1, int n) {
187 if (! w1 || n == 0) return (Window *) 0;
188
189 Window *w2 = new Window[n];
190 while (n--) w2[n] = w1[n];
191 return w2;
192}
193
194
195static void refdec_nri(NETRootInfoPrivate *p) {
196
197#ifdef NETWMDEBUG
198 fprintf(stderr, "NET: decrementing NETRootInfoPrivate::ref (%d)\n", p->ref - 1);
199#endif
200
201 if (! --p->ref) {
202
203#ifdef NETWMDEBUG
204 fprintf(stderr, "NET: \tno more references, deleting\n");
205#endif
206
207 delete [] p->name;
208 delete [] p->stacking;
209 delete [] p->clients;
210 delete [] p->virtual_roots;
211
212 int i;
213 for (i = 0; i < p->desktop_names.size(); i++)
214 delete [] p->desktop_names[i];
215 }
216}
217
218
219static void refdec_nwi(NETWinInfoPrivate *p) {
220
221#ifdef NETWMDEBUG
222 fprintf(stderr, "NET: decrementing NETWinInfoPrivate::ref (%d)\n", p->ref - 1);
223#endif
224
225 if (! --p->ref) {
226
227#ifdef NETWMDEBUG
228 fprintf(stderr, "NET: \tno more references, deleting\n");
229#endif
230
231 delete [] p->name;
232 delete [] p->visible_name;
233 delete [] p->window_role;
234 delete [] p->icon_name;
235 delete [] p->visible_icon_name;
236 delete [] p->startup_id;
237 delete [] p->class_class;
238 delete [] p->class_name;
239 delete [] p->activities;
240
241 int i;
242 for (i = 0; i < p->icons.size(); i++)
243 delete [] p->icons[i].data;
244 delete [] p->icon_sizes;
245 }
246}
247
248
249static int wcmp(const void *a, const void *b) {
250 if (*((Window *) a) < *((Window *) b))
251 return -1;
252 else if (*((Window *) a) > *((Window *) b))
253 return 1;
254 else
255 return 0;
256}
257
258
259static const int netAtomCount = 89;
260static void create_netwm_atoms(Display *d) {
261 static const char * const names[netAtomCount] =
262 {
263 "UTF8_STRING",
264 "_NET_SUPPORTED",
265 "_NET_SUPPORTING_WM_CHECK",
266 "_NET_CLIENT_LIST",
267 "_NET_CLIENT_LIST_STACKING",
268 "_NET_NUMBER_OF_DESKTOPS",
269 "_NET_DESKTOP_GEOMETRY",
270 "_NET_DESKTOP_VIEWPORT",
271 "_NET_CURRENT_DESKTOP",
272 "_NET_DESKTOP_NAMES",
273 "_NET_ACTIVE_WINDOW",
274 "_NET_WORKAREA",
275 "_NET_VIRTUAL_ROOTS",
276 "_NET_DESKTOP_LAYOUT",
277 "_NET_SHOWING_DESKTOP",
278 "_NET_CLOSE_WINDOW",
279 "_NET_RESTACK_WINDOW",
280
281 "_NET_WM_MOVERESIZE",
282 "_NET_MOVERESIZE_WINDOW",
283 "_NET_WM_NAME",
284 "_NET_WM_VISIBLE_NAME",
285 "_NET_WM_ICON_NAME",
286 "_NET_WM_VISIBLE_ICON_NAME",
287 "_NET_WM_DESKTOP",
288 "_NET_WM_WINDOW_TYPE",
289 "_NET_WM_STATE",
290 "_NET_WM_STRUT",
291 "_NET_WM_STRUT_PARTIAL",
292 "_NET_WM_ICON_GEOMETRY",
293 "_NET_WM_ICON",
294 "_NET_WM_PID",
295 "_NET_WM_USER_TIME",
296 "_NET_WM_HANDLED_ICONS",
297 "_NET_STARTUP_ID",
298 "_NET_WM_ALLOWED_ACTIONS",
299 "_NET_WM_PING",
300 "_NET_WM_TAKE_ACTIVITY",
301 "WM_WINDOW_ROLE",
302 "_NET_FRAME_EXTENTS",
303 "_NET_WM_WINDOW_OPACITY",
304 "_NET_WM_FULLSCREEN_MONITORS",
305
306 "_NET_WM_WINDOW_TYPE_NORMAL",
307 "_NET_WM_WINDOW_TYPE_DESKTOP",
308 "_NET_WM_WINDOW_TYPE_DOCK",
309 "_NET_WM_WINDOW_TYPE_TOOLBAR",
310 "_NET_WM_WINDOW_TYPE_MENU",
311 "_NET_WM_WINDOW_TYPE_DIALOG",
312 "_NET_WM_WINDOW_TYPE_UTILITY",
313 "_NET_WM_WINDOW_TYPE_SPLASH",
314 "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU",
315 "_NET_WM_WINDOW_TYPE_POPUP_MENU",
316 "_NET_WM_WINDOW_TYPE_TOOLTIP",
317 "_NET_WM_WINDOW_TYPE_NOTIFICATION",
318 "_NET_WM_WINDOW_TYPE_COMBOBOX",
319 "_NET_WM_WINDOW_TYPE_DND",
320
321 "_NET_WM_STATE_MODAL",
322 "_NET_WM_STATE_STICKY",
323 "_NET_WM_STATE_MAXIMIZED_VERT",
324 "_NET_WM_STATE_MAXIMIZED_HORZ",
325 "_NET_WM_STATE_SHADED",
326 "_NET_WM_STATE_SKIP_TASKBAR",
327 "_NET_WM_STATE_SKIP_PAGER",
328 "_NET_WM_STATE_HIDDEN",
329 "_NET_WM_STATE_FULLSCREEN",
330 "_NET_WM_STATE_ABOVE",
331 "_NET_WM_STATE_BELOW",
332 "_NET_WM_STATE_DEMANDS_ATTENTION",
333
334 "_NET_WM_ACTION_MOVE",
335 "_NET_WM_ACTION_RESIZE",
336 "_NET_WM_ACTION_MINIMIZE",
337 "_NET_WM_ACTION_SHADE",
338 "_NET_WM_ACTION_STICK",
339 "_NET_WM_ACTION_MAXIMIZE_VERT",
340 "_NET_WM_ACTION_MAXIMIZE_HORZ",
341 "_NET_WM_ACTION_FULLSCREEN",
342 "_NET_WM_ACTION_CHANGE_DESKTOP",
343 "_NET_WM_ACTION_CLOSE",
344
345 "_NET_WM_STATE_STAYS_ON_TOP",
346
347 "_KDE_NET_WM_FRAME_STRUT",
348 "_KDE_NET_WM_WINDOW_TYPE_OVERRIDE",
349 "_KDE_NET_WM_WINDOW_TYPE_TOPMENU",
350 "_KDE_NET_WM_TEMPORARY_RULES",
351 "_NET_WM_FRAME_OVERLAP",
352
353 "WM_STATE",
354 "WM_PROTOCOLS",
355
356 "_NET_WM_FULL_PLACEMENT",
357 "_KDE_NET_WM_ACTIVITIES",
358 "_KDE_NET_WM_BLOCK_COMPOSITING",
359 "_KDE_NET_WM_SHADOW"
360 };
361
362 Atom atoms[netAtomCount], *atomsp[netAtomCount] =
363 {
364 &UTF8_STRING,
365 &net_supported,
366 &net_supporting_wm_check,
367 &net_client_list,
368 &net_client_list_stacking,
369 &net_number_of_desktops,
370 &net_desktop_geometry,
371 &net_desktop_viewport,
372 &net_current_desktop,
373 &net_desktop_names,
374 &net_active_window,
375 &net_workarea,
376 &net_virtual_roots,
377 &net_desktop_layout,
378 &net_showing_desktop,
379 &net_close_window,
380 &net_restack_window,
381
382 &net_wm_moveresize,
383 &net_moveresize_window,
384 &net_wm_name,
385 &net_wm_visible_name,
386 &net_wm_icon_name,
387 &net_wm_visible_icon_name,
388 &net_wm_desktop,
389 &net_wm_window_type,
390 &net_wm_state,
391 &net_wm_strut,
392 &net_wm_extended_strut,
393 &net_wm_icon_geometry,
394 &net_wm_icon,
395 &net_wm_pid,
396 &net_wm_user_time,
397 &net_wm_handled_icons,
398 &net_startup_id,
399 &net_wm_allowed_actions,
400 &net_wm_ping,
401 &net_wm_take_activity,
402 &wm_window_role,
403 &net_frame_extents,
404 &net_wm_window_opacity,
405 &net_wm_fullscreen_monitors,
406
407 &net_wm_window_type_normal,
408 &net_wm_window_type_desktop,
409 &net_wm_window_type_dock,
410 &net_wm_window_type_toolbar,
411 &net_wm_window_type_menu,
412 &net_wm_window_type_dialog,
413 &net_wm_window_type_utility,
414 &net_wm_window_type_splash,
415 &net_wm_window_type_dropdown_menu,
416 &net_wm_window_type_popup_menu,
417 &net_wm_window_type_tooltip,
418 &net_wm_window_type_notification,
419 &net_wm_window_type_combobox,
420 &net_wm_window_type_dnd,
421
422 &net_wm_state_modal,
423 &net_wm_state_sticky,
424 &net_wm_state_max_vert,
425 &net_wm_state_max_horiz,
426 &net_wm_state_shaded,
427 &net_wm_state_skip_taskbar,
428 &net_wm_state_skip_pager,
429 &net_wm_state_hidden,
430 &net_wm_state_fullscreen,
431 &net_wm_state_above,
432 &net_wm_state_below,
433 &net_wm_state_demands_attention,
434
435 &net_wm_action_move,
436 &net_wm_action_resize,
437 &net_wm_action_minimize,
438 &net_wm_action_shade,
439 &net_wm_action_stick,
440 &net_wm_action_max_vert,
441 &net_wm_action_max_horiz,
442 &net_wm_action_fullscreen,
443 &net_wm_action_change_desk,
444 &net_wm_action_close,
445
446 &net_wm_state_stays_on_top,
447
448 &kde_net_wm_frame_strut,
449 &kde_net_wm_window_type_override,
450 &kde_net_wm_window_type_topmenu,
451 &kde_net_wm_temporary_rules,
452 &kde_net_wm_frame_overlap,
453
454 &xa_wm_state,
455 &wm_protocols,
456
457 &net_wm_full_placement,
458 &kde_net_wm_activities,
459 &kde_net_wm_block_compositing,
460 &kde_net_wm_shadow
461 };
462
463 assert( !netwm_atoms_created );
464
465 int i = netAtomCount;
466 while (i--)
467 atoms[i] = 0;
468
469 XInternAtoms(d, (char **) names, netAtomCount, False, atoms);
470
471 i = netAtomCount;
472 while (i--)
473 *atomsp[i] = atoms[i];
474
475 netwm_atoms_created = True;
476}
477
478
479static void readIcon(Display* display, Window window, Atom property, NETRArray<NETIcon>& icons, int& icon_count) {
480
481#ifdef NETWMDEBUG
482 fprintf(stderr, "NET: readIcon\n");
483#endif
484
485 Atom type_ret;
486 int format_ret;
487 unsigned long nitems_ret = 0, after_ret = 0;
488 unsigned char *data_ret = 0;
489
490 // reset
491 for (int i = 0; i < icons.size(); i++)
492 delete [] icons[i].data;
493 icons.reset();
494 icon_count = 0;
495
496 // allocate buffers
497 unsigned char *buffer = 0;
498 unsigned long offset = 0;
499 unsigned long buffer_offset = 0;
500 unsigned long bufsize = 0;
501
502 // read data
503 do {
504 if (XGetWindowProperty(display, window, property, offset,
505 MAX_PROP_SIZE, False, XA_CARDINAL, &type_ret,
506 &format_ret, &nitems_ret, &after_ret, &data_ret)
507 == Success) {
508 if (!bufsize)
509 {
510 if (nitems_ret < 3 || type_ret != XA_CARDINAL ||
511 format_ret != 32) {
512 // either we didn't get the property, or the property has less than
513 // 3 elements in it
514 // NOTE: 3 is the ABSOLUTE minimum:
515 // width = 1, height = 1, length(data) = 1 (width * height)
516 if ( data_ret )
517 XFree(data_ret);
518 return;
519 }
520
521 bufsize = nitems_ret * sizeof(long) + after_ret;
522 buffer = (unsigned char *) malloc(bufsize);
523 }
524 else if (buffer_offset + nitems_ret*sizeof(long) > bufsize)
525 {
526fprintf(stderr, "NETWM: Warning readIcon() needs buffer adjustment!\n");
527 bufsize = buffer_offset + nitems_ret * sizeof(long) + after_ret;
528 buffer = (unsigned char *) realloc(buffer, bufsize);
529 }
530 memcpy((buffer + buffer_offset), data_ret, nitems_ret * sizeof(long));
531 buffer_offset += nitems_ret * sizeof(long);
532 offset += nitems_ret;
533
534 if ( data_ret )
535 XFree(data_ret);
536 } else {
537 if (buffer)
538 free(buffer);
539 return; // Some error occurred cq. property didn't exist.
540 }
541 }
542 while (after_ret > 0);
543
544 CARD32 *data32;
545 unsigned long i, j, k, sz, s;
546 unsigned long *d = (unsigned long *) buffer;
547 for (i = 0, j = 0; i < bufsize;) {
548 icons[j].size.width = *d++;
549 i += sizeof(long);
550 icons[j].size.height = *d++;
551 i += sizeof(long);
552
553 sz = icons[j].size.width * icons[j].size.height;
554 s = sz * sizeof(long);
555
556 if ( i + s - 1 > bufsize || sz == 0 || sz > 1024 * 1024 ) {
557 break;
558 }
559
560 delete [] icons[j].data;
561 data32 = new CARD32[sz];
562 icons[j].data = (unsigned char *) data32;
563 for (k = 0; k < sz; k++, i += sizeof(long)) {
564 *data32++ = (CARD32) *d++;
565 }
566 j++;
567 icon_count++;
568 }
569
570#ifdef NETWMDEBUG
571 fprintf(stderr, "NET: readIcon got %d icons\n", icon_count);
572#endif
573
574 free(buffer);
575}
576
577
578template <class Z>
579NETRArray<Z>::NETRArray()
580 : sz(0), capacity(2)
581{
582 d = (Z*) calloc(capacity, sizeof(Z)); // allocate 2 elts and set to zero
583}
584
585
586template <class Z>
587NETRArray<Z>::~NETRArray() {
588 free(d);
589}
590
591
592template <class Z>
593void NETRArray<Z>::reset() {
594 sz = 0;
595 capacity = 2;
596 d = (Z*) realloc(d, sizeof(Z)*capacity);
597 memset( (void*) d, 0, sizeof(Z)*capacity );
598}
599
600template <class Z>
601Z &NETRArray<Z>::operator[](int index) {
602 if (index >= capacity) {
603 // allocate space for the new data
604 // open table has amortized O(1) access time
605 // when N elements appended consecutively -- exa
606 int newcapacity = 2*capacity > index+1 ? 2*capacity : index+1; // max
607 // copy into new larger memory block using realloc
608 d = (Z*) realloc(d, sizeof(Z)*newcapacity);
609 memset( (void*) &d[capacity], 0, sizeof(Z)*(newcapacity-capacity) );
610 capacity = newcapacity;
611 }
612 if (index >= sz) // at this point capacity>index
613 sz = index + 1;
614
615 return d[index];
616}
617
618/*
619 The viewport<->desktop matching is a bit backwards, since NET* classes are the base
620 (and were originally even created with the intention of being the reference WM spec
621 implementation) and KWindowSystem builds on top of it. However it's simpler to add watching
622 whether the WM uses viewport is simpler to KWindowSystem and not having this mapping
623 in NET* classes could result in some code using it directly and not supporting viewport.
624 So NET* classes check if mapping is needed and if yes they forward to KWindowSystem,
625 which will forward again back to NET* classes, but to viewport calls instead of desktop calls.
626*/
627
628// Construct a new NETRootInfo object.
629
630NETRootInfo::NETRootInfo(Display *display, Window supportWindow, const char *wmName,
631 const unsigned long properties[], int properties_size,
632 int screen, bool doActivate)
633{
634
635#ifdef NETWMDEBUG
636 fprintf(stderr, "NETRootInfo::NETRootInfo: using window manager constructor\n");
637#endif
638
639 p = new NETRootInfoPrivate;
640 p->ref = 1;
641
642 p->display = display;
643 p->name = nstrdup(wmName);
644
645 if (screen != -1) {
646 p->screen = screen;
647 } else {
648 p->screen = DefaultScreen(p->display);
649 }
650
651 p->root = RootWindow(p->display, p->screen);
652 p->supportwindow = supportWindow;
653 p->number_of_desktops = p->current_desktop = 0;
654 p->active = None;
655 p->clients = p->stacking = p->virtual_roots = (Window *) 0;
656 p->clients_count = p->stacking_count = p->virtual_roots_count = 0;
657 p->showing_desktop = false;
658 p->desktop_layout_orientation = OrientationHorizontal;
659 p->desktop_layout_corner = DesktopLayoutCornerTopLeft;
660 p->desktop_layout_columns = p->desktop_layout_rows = 0;
661 setDefaultProperties();
662 if( properties_size > PROPERTIES_SIZE ) {
663 fprintf( stderr, "NETRootInfo::NETRootInfo(): properties array too large\n");
664 properties_size = PROPERTIES_SIZE;
665 }
666 for( int i = 0; i < properties_size; ++i )
667 p->properties[ i ] = properties[ i ];
668 // force support for Supported and SupportingWMCheck for window managers
669 p->properties[ PROTOCOLS ] |= ( Supported | SupportingWMCheck );
670 p->client_properties[ PROTOCOLS ] = DesktopNames // the only thing that can be changed by clients
671 | WMPing; // or they can reply to this
672 p->client_properties[ PROTOCOLS2 ] = WM2TakeActivity | WM2DesktopLayout;
673
674 p->role = WindowManager;
675
676 if (! netwm_atoms_created) create_netwm_atoms(p->display);
677
678 if (doActivate) activate();
679}
680
681
682NETRootInfo::NETRootInfo(Display *display, const unsigned long properties[], int properties_size,
683 int screen, bool doActivate)
684{
685
686#ifdef NETWMDEBUG
687 fprintf(stderr, "NETRootInfo::NETRootInfo: using Client constructor\n");
688#endif
689
690 p = new NETRootInfoPrivate;
691 p->ref = 1;
692
693 p->name = 0;
694
695 p->display = display;
696
697 if (screen != -1) {
698 p->screen = screen;
699 } else {
700 p->screen = DefaultScreen(p->display);
701 }
702
703 p->root = RootWindow(p->display, p->screen);
704 p->rootSize.width = WidthOfScreen(ScreenOfDisplay(p->display, p->screen));
705 p->rootSize.height = HeightOfScreen(ScreenOfDisplay(p->display, p->screen));
706
707 p->supportwindow = None;
708 p->number_of_desktops = p->current_desktop = 0;
709 p->active = None;
710 p->clients = p->stacking = p->virtual_roots = (Window *) 0;
711 p->clients_count = p->stacking_count = p->virtual_roots_count = 0;
712 p->showing_desktop = false;
713 p->desktop_layout_orientation = OrientationHorizontal;
714 p->desktop_layout_corner = DesktopLayoutCornerTopLeft;
715 p->desktop_layout_columns = p->desktop_layout_rows = 0;
716 setDefaultProperties();
717 if( properties_size > 2 ) {
718 fprintf( stderr, "NETWinInfo::NETWinInfo(): properties array too large\n");
719 properties_size = 2;
720 }
721 for( int i = 0; i < properties_size; ++i )
722 // remap from [0]=NET::Property,[1]=NET::Property2
723 switch( i ) {
724 case 0:
725 p->client_properties[ PROTOCOLS ] = properties[ i ];
726 break;
727 case 1:
728 p->client_properties[ PROTOCOLS2 ] = properties[ i ];
729 break;
730 }
731 for( int i = 0; i < PROPERTIES_SIZE; ++i )
732 p->properties[ i ] = 0;
733
734 p->role = Client;
735
736 if (! netwm_atoms_created) create_netwm_atoms(p->display);
737
738 if (doActivate) activate();
739}
740
741NETRootInfo::NETRootInfo(Display *display, unsigned long properties, int screen,
742 bool doActivate)
743{
744
745#ifdef NETWMDEBUG
746 fprintf(stderr, "NETRootInfo::NETRootInfo: using Client constructor\n");
747#endif
748
749 p = new NETRootInfoPrivate;
750 p->ref = 1;
751
752 p->name = 0;
753
754 p->display = display;
755
756 if (screen != -1) {
757 p->screen = screen;
758 } else {
759 p->screen = DefaultScreen(p->display);
760 }
761
762 p->root = RootWindow(p->display, p->screen);
763 p->rootSize.width = WidthOfScreen(ScreenOfDisplay(p->display, p->screen));
764 p->rootSize.height = HeightOfScreen(ScreenOfDisplay(p->display, p->screen));
765
766 p->supportwindow = None;
767 p->number_of_desktops = p->current_desktop = 0;
768 p->active = None;
769 p->clients = p->stacking = p->virtual_roots = (Window *) 0;
770 p->clients_count = p->stacking_count = p->virtual_roots_count = 0;
771 p->showing_desktop = false;
772 p->desktop_layout_orientation = OrientationHorizontal;
773 p->desktop_layout_corner = DesktopLayoutCornerTopLeft;
774 p->desktop_layout_columns = p->desktop_layout_rows = 0;
775 setDefaultProperties();
776 p->client_properties[ PROTOCOLS ] = properties;
777 for( int i = 0; i < PROPERTIES_SIZE; ++i )
778 p->properties[ i ] = 0;
779
780 p->role = Client;
781
782 if (! netwm_atoms_created) create_netwm_atoms(p->display);
783
784 if (doActivate) activate();
785}
786
787
788// Copy an existing NETRootInfo object.
789
790NETRootInfo::NETRootInfo(const NETRootInfo &rootinfo) {
791
792#ifdef NETWMDEBUG
793 fprintf(stderr, "NETRootInfo::NETRootInfo: using copy constructor\n");
794#endif
795
796 p = rootinfo.p;
797
798 p->ref++;
799}
800
801
802// Be gone with our NETRootInfo.
803
804NETRootInfo::~NETRootInfo() {
805 refdec_nri(p);
806
807 if (! p->ref) delete p;
808}
809
810
811void NETRootInfo::setDefaultProperties()
812{
813 p->properties[ PROTOCOLS ] = Supported | SupportingWMCheck;
814 p->properties[ WINDOW_TYPES ] = NormalMask | DesktopMask | DockMask
815 | ToolbarMask | MenuMask | DialogMask;
816 p->properties[ STATES ] = Modal | Sticky | MaxVert | MaxHoriz | Shaded
817 | SkipTaskbar | StaysOnTop;
818 p->properties[ PROTOCOLS2 ] = 0;
819 p->properties[ ACTIONS ] = 0;
820 p->client_properties[ PROTOCOLS ] = 0;
821 p->client_properties[ WINDOW_TYPES ] = 0; // these two actually don't
822 p->client_properties[ STATES ] = 0; // make sense in client_properties
823 p->client_properties[ PROTOCOLS2 ] = 0;
824 p->client_properties[ ACTIONS ] = 0;
825}
826
827void NETRootInfo::activate() {
828 if (p->role == WindowManager) {
829
830#ifdef NETWMDEBUG
831 fprintf(stderr,
832 "NETRootInfo::activate: setting supported properties on root\n");
833#endif
834
835 setSupported();
836 update(p->client_properties);
837 } else {
838
839#ifdef NETWMDEBUG
840 fprintf(stderr, "NETRootInfo::activate: updating client information\n");
841#endif
842
843 update(p->client_properties);
844 }
845}
846
847
848void NETRootInfo::setClientList(const Window *windows, unsigned int count) {
849 if (p->role != WindowManager) return;
850
851 p->clients_count = count;
852
853 delete [] p->clients;
854 p->clients = nwindup(windows, count);
855
856#ifdef NETWMDEBUG
857 fprintf(stderr, "NETRootInfo::setClientList: setting list with %ld windows\n",
858 p->clients_count);
859#endif
860
861 XChangeProperty(p->display, p->root, net_client_list, XA_WINDOW, 32,
862 PropModeReplace, (unsigned char *)p->clients,
863 p->clients_count);
864}
865
866
867void NETRootInfo::setClientListStacking(const Window *windows, unsigned int count) {
868 if (p->role != WindowManager) return;
869
870 p->stacking_count = count;
871 delete [] p->stacking;
872 p->stacking = nwindup(windows, count);
873
874#ifdef NETWMDEBUG
875 fprintf(stderr,
876 "NETRootInfo::setClientListStacking: setting list with %ld windows\n",
877 p->clients_count);
878#endif
879
880 XChangeProperty(p->display, p->root, net_client_list_stacking, XA_WINDOW, 32,
881 PropModeReplace, (unsigned char *) p->stacking,
882 p->stacking_count);
883}
884
885
886void NETRootInfo::setNumberOfDesktops(int numberOfDesktops) {
887
888#ifdef NETWMDEBUG
889 fprintf(stderr,
890 "NETRootInfo::setNumberOfDesktops: setting desktop count to %d (%s)\n",
891 numberOfDesktops, (p->role == WindowManager) ? "WM" : "Client");
892#endif
893
894 if (p->role == WindowManager) {
895 p->number_of_desktops = numberOfDesktops;
896 long d = numberOfDesktops;
897 XChangeProperty(p->display, p->root, net_number_of_desktops, XA_CARDINAL, 32,
898 PropModeReplace, (unsigned char *) &d, 1);
899 } else {
900 XEvent e;
901
902 e.xclient.type = ClientMessage;
903 e.xclient.message_type = net_number_of_desktops;
904 e.xclient.display = p->display;
905 e.xclient.window = p->root;
906 e.xclient.format = 32;
907 e.xclient.data.l[0] = numberOfDesktops;
908 e.xclient.data.l[1] = 0l;
909 e.xclient.data.l[2] = 0l;
910 e.xclient.data.l[3] = 0l;
911 e.xclient.data.l[4] = 0l;
912
913 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
914 }
915}
916
917
918void NETRootInfo::setCurrentDesktop(int desktop, bool ignore_viewport) {
919
920#ifdef NETWMDEBUG
921 fprintf(stderr,
922 "NETRootInfo::setCurrentDesktop: setting current desktop = %d (%s)\n",
923 desktop, (p->role == WindowManager) ? "WM" : "Client");
924#endif
925
926 if (p->role == WindowManager) {
927 p->current_desktop = desktop;
928 long d = p->current_desktop - 1;
929 XChangeProperty(p->display, p->root, net_current_desktop, XA_CARDINAL, 32,
930 PropModeReplace, (unsigned char *) &d, 1);
931 } else {
932
933 if( !ignore_viewport && KWindowSystem::mapViewport()) {
934 KWindowSystem::setCurrentDesktop( desktop );
935 return;
936 }
937
938 XEvent e;
939 e.xclient.type = ClientMessage;
940 e.xclient.message_type = net_current_desktop;
941 e.xclient.display = p->display;
942 e.xclient.window = p->root;
943 e.xclient.format = 32;
944 e.xclient.data.l[0] = desktop - 1;
945 e.xclient.data.l[1] = 0l;
946 e.xclient.data.l[2] = 0l;
947 e.xclient.data.l[3] = 0l;
948 e.xclient.data.l[4] = 0l;
949
950 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
951 }
952}
953
954
955void NETRootInfo::setDesktopName(int desktop, const char *desktopName) {
956 // allow setting desktop names even for non-existent desktops, see the spec, sect.3.7.
957 if (desktop < 1) return;
958
959 delete [] p->desktop_names[desktop - 1];
960 p->desktop_names[desktop - 1] = nstrdup(desktopName);
961
962 unsigned int i, proplen,
963 num = ((p->number_of_desktops > p->desktop_names.size()) ?
964 p->number_of_desktops : p->desktop_names.size());
965 for (i = 0, proplen = 0; i < num; i++)
966 proplen += (p->desktop_names[i] != 0 ? strlen(p->desktop_names[i])+1 : 1 );
967
968 char *prop = new char[proplen], *propp = prop;
969
970 for (i = 0; i < num; i++)
971 if (p->desktop_names[i]) {
972 strcpy(propp, p->desktop_names[i]);
973 propp += strlen(p->desktop_names[i]) + 1;
974 } else
975 *propp++ = '\0';
976
977#ifdef NETWMDEBUG
978 fprintf(stderr,
979 "NETRootInfo::setDesktopName(%d, '%s')\n"
980 "NETRootInfo::setDesktopName: total property length = %d",
981 desktop, desktopName, proplen);
982#endif
983
984 XChangeProperty(p->display, p->root, net_desktop_names, UTF8_STRING, 8,
985 PropModeReplace, (unsigned char *) prop, proplen);
986
987 delete [] prop;
988}
989
990
991void NETRootInfo::setDesktopGeometry(int , const NETSize &geometry) {
992
993#ifdef NETWMDEBUG
994 fprintf(stderr, "NETRootInfo::setDesktopGeometry( -- , { %d, %d }) (%s)\n",
995 geometry.width, geometry.height, (p->role == WindowManager) ? "WM" : "Client");
996#endif
997
998 if (p->role == WindowManager) {
999 p->geometry = geometry;
1000
1001 long data[2];
1002 data[0] = p->geometry.width;
1003 data[1] = p->geometry.height;
1004
1005 XChangeProperty(p->display, p->root, net_desktop_geometry, XA_CARDINAL, 32,
1006 PropModeReplace, (unsigned char *) data, 2);
1007 } else {
1008 XEvent e;
1009
1010 e.xclient.type = ClientMessage;
1011 e.xclient.message_type = net_desktop_geometry;
1012 e.xclient.display = p->display;
1013 e.xclient.window = p->root;
1014 e.xclient.format = 32;
1015 e.xclient.data.l[0] = geometry.width;
1016 e.xclient.data.l[1] = geometry.height;
1017 e.xclient.data.l[2] = 0l;
1018 e.xclient.data.l[3] = 0l;
1019 e.xclient.data.l[4] = 0l;
1020
1021 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
1022 }
1023}
1024
1025
1026void NETRootInfo::setDesktopViewport(int desktop, const NETPoint &viewport) {
1027
1028#ifdef NETWMDEBUG
1029 fprintf(stderr, "NETRootInfo::setDesktopViewport(%d, { %d, %d }) (%s)\n",
1030 desktop, viewport.x, viewport.y, (p->role == WindowManager) ? "WM" : "Client");
1031#endif
1032
1033 if (desktop < 1) return;
1034
1035 if (p->role == WindowManager) {
1036 p->viewport[desktop - 1] = viewport;
1037
1038 int d, i, l;
1039 l = p->number_of_desktops * 2;
1040 long *data = new long[l];
1041 for (d = 0, i = 0; d < p->number_of_desktops; d++) {
1042 data[i++] = p->viewport[d].x;
1043 data[i++] = p->viewport[d].y;
1044 }
1045
1046 XChangeProperty(p->display, p->root, net_desktop_viewport, XA_CARDINAL, 32,
1047 PropModeReplace, (unsigned char *) data, l);
1048
1049 delete [] data;
1050 } else {
1051 XEvent e;
1052
1053 e.xclient.type = ClientMessage;
1054 e.xclient.message_type = net_desktop_viewport;
1055 e.xclient.display = p->display;
1056 e.xclient.window = p->root;
1057 e.xclient.format = 32;
1058 e.xclient.data.l[0] = viewport.x;
1059 e.xclient.data.l[1] = viewport.y;
1060 e.xclient.data.l[2] = 0l;
1061 e.xclient.data.l[3] = 0l;
1062 e.xclient.data.l[4] = 0l;
1063
1064 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
1065 }
1066}
1067
1068
1069void NETRootInfo::setSupported() {
1070 if (p->role != WindowManager) {
1071#ifdef NETWMDEBUG
1072 fprintf(stderr, "NETRootInfo::setSupported - role != WindowManager\n");
1073#endif
1074
1075 return;
1076 }
1077
1078 Atom atoms[netAtomCount];
1079 int pnum = 2;
1080
1081 // Root window properties/messages
1082 atoms[0] = net_supported;
1083 atoms[1] = net_supporting_wm_check;
1084
1085 if (p->properties[ PROTOCOLS ] & ClientList)
1086 atoms[pnum++] = net_client_list;
1087
1088 if (p->properties[ PROTOCOLS ] & ClientListStacking)
1089 atoms[pnum++] = net_client_list_stacking;
1090
1091 if (p->properties[ PROTOCOLS ] & NumberOfDesktops)
1092 atoms[pnum++] = net_number_of_desktops;
1093
1094 if (p->properties[ PROTOCOLS ] & DesktopGeometry)
1095 atoms[pnum++] = net_desktop_geometry;
1096
1097 if (p->properties[ PROTOCOLS ] & DesktopViewport)
1098 atoms[pnum++] = net_desktop_viewport;
1099
1100 if (p->properties[ PROTOCOLS ] & CurrentDesktop)
1101 atoms[pnum++] = net_current_desktop;
1102
1103 if (p->properties[ PROTOCOLS ] & DesktopNames)
1104 atoms[pnum++] = net_desktop_names;
1105
1106 if (p->properties[ PROTOCOLS ] & ActiveWindow)
1107 atoms[pnum++] = net_active_window;
1108
1109 if (p->properties[ PROTOCOLS ] & WorkArea)
1110 atoms[pnum++] = net_workarea;
1111
1112 if (p->properties[ PROTOCOLS ] & VirtualRoots)
1113 atoms[pnum++] = net_virtual_roots;
1114
1115 if (p->properties[ PROTOCOLS2 ] & WM2DesktopLayout)
1116 atoms[pnum++] = net_desktop_layout;
1117
1118 if (p->properties[ PROTOCOLS ] & CloseWindow)
1119 atoms[pnum++] = net_close_window;
1120
1121 if (p->properties[ PROTOCOLS2 ] & WM2RestackWindow)
1122 atoms[pnum++] = net_restack_window;
1123
1124 if (p->properties[ PROTOCOLS2 ] & WM2ShowingDesktop)
1125 atoms[pnum++] = net_showing_desktop;
1126
1127 // Application window properties/messages
1128 if (p->properties[ PROTOCOLS ] & WMMoveResize)
1129 atoms[pnum++] = net_wm_moveresize;
1130
1131 if (p->properties[ PROTOCOLS2 ] & WM2MoveResizeWindow)
1132 atoms[pnum++] = net_moveresize_window;
1133
1134 if (p->properties[ PROTOCOLS ] & WMName)
1135 atoms[pnum++] = net_wm_name;
1136
1137 if (p->properties[ PROTOCOLS ] & WMVisibleName)
1138 atoms[pnum++] = net_wm_visible_name;
1139
1140 if (p->properties[ PROTOCOLS ] & WMIconName)
1141 atoms[pnum++] = net_wm_icon_name;
1142
1143 if (p->properties[ PROTOCOLS ] & WMVisibleIconName)
1144 atoms[pnum++] = net_wm_visible_icon_name;
1145
1146 if (p->properties[ PROTOCOLS ] & WMDesktop)
1147 atoms[pnum++] = net_wm_desktop;
1148
1149 if (p->properties[ PROTOCOLS ] & WMWindowType) {
1150 atoms[pnum++] = net_wm_window_type;
1151
1152 // Application window types
1153 if (p->properties[ WINDOW_TYPES ] & NormalMask)
1154 atoms[pnum++] = net_wm_window_type_normal;
1155 if (p->properties[ WINDOW_TYPES ] & DesktopMask)
1156 atoms[pnum++] = net_wm_window_type_desktop;
1157 if (p->properties[ WINDOW_TYPES ] & DockMask)
1158 atoms[pnum++] = net_wm_window_type_dock;
1159 if (p->properties[ WINDOW_TYPES ] & ToolbarMask)
1160 atoms[pnum++] = net_wm_window_type_toolbar;
1161 if (p->properties[ WINDOW_TYPES ] & MenuMask)
1162 atoms[pnum++] = net_wm_window_type_menu;
1163 if (p->properties[ WINDOW_TYPES ] & DialogMask)
1164 atoms[pnum++] = net_wm_window_type_dialog;
1165 if (p->properties[ WINDOW_TYPES ] & UtilityMask)
1166 atoms[pnum++] = net_wm_window_type_utility;
1167 if (p->properties[ WINDOW_TYPES ] & SplashMask)
1168 atoms[pnum++] = net_wm_window_type_splash;
1169 if (p->properties[ WINDOW_TYPES ] & DropdownMenuMask)
1170 atoms[pnum++] = net_wm_window_type_dropdown_menu;
1171 if (p->properties[ WINDOW_TYPES ] & PopupMenuMask)
1172 atoms[pnum++] = net_wm_window_type_popup_menu;
1173 if (p->properties[ WINDOW_TYPES ] & TooltipMask)
1174 atoms[pnum++] = net_wm_window_type_tooltip;
1175 if (p->properties[ WINDOW_TYPES ] & NotificationMask)
1176 atoms[pnum++] = net_wm_window_type_notification;
1177 if (p->properties[ WINDOW_TYPES ] & ComboBoxMask)
1178 atoms[pnum++] = net_wm_window_type_combobox;
1179 if (p->properties[ WINDOW_TYPES ] & DNDIconMask)
1180 atoms[pnum++] = net_wm_window_type_dnd;
1181 // KDE extensions
1182 if (p->properties[ WINDOW_TYPES ] & OverrideMask)
1183 atoms[pnum++] = kde_net_wm_window_type_override;
1184 if (p->properties[ WINDOW_TYPES ] & TopMenuMask)
1185 atoms[pnum++] = kde_net_wm_window_type_topmenu;
1186 }
1187
1188 if (p->properties[ PROTOCOLS ] & WMState) {
1189 atoms[pnum++] = net_wm_state;
1190
1191 // Application window states
1192 if (p->properties[ STATES ] & Modal)
1193 atoms[pnum++] = net_wm_state_modal;
1194 if (p->properties[ STATES ] & Sticky)
1195 atoms[pnum++] = net_wm_state_sticky;
1196 if (p->properties[ STATES ] & MaxVert)
1197 atoms[pnum++] = net_wm_state_max_vert;
1198 if (p->properties[ STATES ] & MaxHoriz)
1199 atoms[pnum++] = net_wm_state_max_horiz;
1200 if (p->properties[ STATES ] & Shaded)
1201 atoms[pnum++] = net_wm_state_shaded;
1202 if (p->properties[ STATES ] & SkipTaskbar)
1203 atoms[pnum++] = net_wm_state_skip_taskbar;
1204 if (p->properties[ STATES ] & SkipPager)
1205 atoms[pnum++] = net_wm_state_skip_pager;
1206 if (p->properties[ STATES ] & Hidden)
1207 atoms[pnum++] = net_wm_state_hidden;
1208 if (p->properties[ STATES ] & FullScreen)
1209 atoms[pnum++] = net_wm_state_fullscreen;
1210 if (p->properties[ STATES ] & KeepAbove)
1211 atoms[pnum++] = net_wm_state_above;
1212 if (p->properties[ STATES ] & KeepBelow)
1213 atoms[pnum++] = net_wm_state_below;
1214 if (p->properties[ STATES ] & DemandsAttention)
1215 atoms[pnum++] = net_wm_state_demands_attention;
1216
1217 if (p->properties[ STATES ] & StaysOnTop)
1218 atoms[pnum++] = net_wm_state_stays_on_top;
1219 }
1220
1221 if (p->properties[ PROTOCOLS ] & WMStrut)
1222 atoms[pnum++] = net_wm_strut;
1223
1224 if (p->properties[ PROTOCOLS2 ] & WM2ExtendedStrut)
1225 atoms[pnum++] = net_wm_extended_strut;
1226
1227 if (p->properties[ PROTOCOLS ] & WMIconGeometry)
1228 atoms[pnum++] = net_wm_icon_geometry;
1229
1230 if (p->properties[ PROTOCOLS ] & WMIcon)
1231 atoms[pnum++] = net_wm_icon;
1232
1233 if (p->properties[ PROTOCOLS ] & WMPid)
1234 atoms[pnum++] = net_wm_pid;
1235
1236 if (p->properties[ PROTOCOLS ] & WMHandledIcons)
1237 atoms[pnum++] = net_wm_handled_icons;
1238
1239 if (p->properties[ PROTOCOLS ] & WMPing)
1240 atoms[pnum++] = net_wm_ping;
1241
1242 if (p->properties[ PROTOCOLS2 ] & WM2TakeActivity)
1243 atoms[pnum++] = net_wm_take_activity;
1244
1245 if (p->properties[ PROTOCOLS2 ] & WM2UserTime)
1246 atoms[pnum++] = net_wm_user_time;
1247
1248 if (p->properties[ PROTOCOLS2 ] & WM2StartupId)
1249 atoms[pnum++] = net_startup_id;
1250
1251 if (p->properties[ PROTOCOLS2 ] & WM2Opacity)
1252 atoms[pnum++] = net_wm_window_opacity;
1253
1254 if (p->properties[ PROTOCOLS2 ] & WM2FullscreenMonitors)
1255 atoms[pnum++] = net_wm_fullscreen_monitors;
1256
1257 if (p->properties[ PROTOCOLS2 ] & WM2AllowedActions) {
1258 atoms[pnum++] = net_wm_allowed_actions;
1259
1260 // Actions
1261 if (p->properties[ ACTIONS ] & ActionMove)
1262 atoms[pnum++] = net_wm_action_move;
1263 if (p->properties[ ACTIONS ] & ActionResize)
1264 atoms[pnum++] = net_wm_action_resize;
1265 if (p->properties[ ACTIONS ] & ActionMinimize)
1266 atoms[pnum++] = net_wm_action_minimize;
1267 if (p->properties[ ACTIONS ] & ActionShade)
1268 atoms[pnum++] = net_wm_action_shade;
1269 if (p->properties[ ACTIONS ] & ActionStick)
1270 atoms[pnum++] = net_wm_action_stick;
1271 if (p->properties[ ACTIONS ] & ActionMaxVert)
1272 atoms[pnum++] = net_wm_action_max_vert;
1273 if (p->properties[ ACTIONS ] & ActionMaxHoriz)
1274 atoms[pnum++] = net_wm_action_max_horiz;
1275 if (p->properties[ ACTIONS ] & ActionFullScreen)
1276 atoms[pnum++] = net_wm_action_fullscreen;
1277 if (p->properties[ ACTIONS ] & ActionChangeDesktop)
1278 atoms[pnum++] = net_wm_action_change_desk;
1279 if (p->properties[ ACTIONS ] & ActionClose)
1280 atoms[pnum++] = net_wm_action_close;
1281 }
1282
1283 if (p->properties[ PROTOCOLS ] & WMFrameExtents) {
1284 atoms[pnum++] = net_frame_extents;
1285 atoms[pnum++] = kde_net_wm_frame_strut;
1286 }
1287
1288 if (p->properties[ PROTOCOLS2 ] & WM2FrameOverlap) {
1289 atoms[pnum++] = kde_net_wm_frame_overlap;
1290 }
1291
1292 if (p->properties[ PROTOCOLS2 ] & WM2KDETemporaryRules)
1293 atoms[pnum++] = kde_net_wm_temporary_rules;
1294 if (p->properties[ PROTOCOLS2 ] & WM2FullPlacement)
1295 atoms[pnum++] = net_wm_full_placement;
1296
1297 if (p->properties[ PROTOCOLS2 ] & WM2Activities)
1298 atoms[pnum++] = kde_net_wm_activities;
1299
1300 if (p->properties[ PROTOCOLS2 ] & WM2BlockCompositing)
1301 atoms[pnum++] = kde_net_wm_block_compositing;
1302
1303 if (p->properties[ PROTOCOLS2 ] & WM2KDEShadow ) {
1304 atoms[pnum++] = kde_net_wm_shadow;
1305 }
1306
1307 XChangeProperty(p->display, p->root, net_supported, XA_ATOM, 32,
1308 PropModeReplace, (unsigned char *) atoms, pnum);
1309 XChangeProperty(p->display, p->root, net_supporting_wm_check, XA_WINDOW, 32,
1310 PropModeReplace, (unsigned char *) &(p->supportwindow), 1);
1311
1312#ifdef NETWMDEBUG
1313 fprintf(stderr,
1314 "NETRootInfo::setSupported: _NET_SUPPORTING_WM_CHECK = 0x%lx on 0x%lx\n"
1315 " : _NET_WM_NAME = '%s' on 0x%lx\n",
1316 p->supportwindow, p->supportwindow, p->name, p->supportwindow);
1317#endif
1318
1319 XChangeProperty(p->display, p->supportwindow, net_supporting_wm_check,
1320 XA_WINDOW, 32, PropModeReplace,
1321 (unsigned char *) &(p->supportwindow), 1);
1322 XChangeProperty(p->display, p->supportwindow, net_wm_name, UTF8_STRING, 8,
1323 PropModeReplace, (unsigned char *) p->name,
1324 strlen(p->name));
1325}
1326
1327void NETRootInfo::updateSupportedProperties( Atom atom )
1328{
1329 if( atom == net_supported )
1330 p->properties[ PROTOCOLS ] |= Supported;
1331
1332 else if( atom == net_supporting_wm_check )
1333 p->properties[ PROTOCOLS ] |= SupportingWMCheck;
1334
1335 else if( atom == net_client_list )
1336 p->properties[ PROTOCOLS ] |= ClientList;
1337
1338 else if( atom == net_client_list_stacking )
1339 p->properties[ PROTOCOLS ] |= ClientListStacking;
1340
1341 else if( atom == net_number_of_desktops )
1342 p->properties[ PROTOCOLS ] |= NumberOfDesktops;
1343
1344 else if( atom == net_desktop_geometry )
1345 p->properties[ PROTOCOLS ] |= DesktopGeometry;
1346
1347 else if( atom == net_desktop_viewport )
1348 p->properties[ PROTOCOLS ] |= DesktopViewport;
1349
1350 else if( atom == net_current_desktop )
1351 p->properties[ PROTOCOLS ] |= CurrentDesktop;
1352
1353 else if( atom == net_desktop_names )
1354 p->properties[ PROTOCOLS ] |= DesktopNames;
1355
1356 else if( atom == net_active_window )
1357 p->properties[ PROTOCOLS ] |= ActiveWindow;
1358
1359 else if( atom == net_workarea )
1360 p->properties[ PROTOCOLS ] |= WorkArea;
1361
1362 else if( atom == net_virtual_roots )
1363 p->properties[ PROTOCOLS ] |= VirtualRoots;
1364
1365 else if( atom == net_desktop_layout )
1366 p->properties[ PROTOCOLS2 ] |= WM2DesktopLayout;
1367
1368 else if( atom == net_close_window )
1369 p->properties[ PROTOCOLS ] |= CloseWindow;
1370
1371 else if( atom == net_restack_window )
1372 p->properties[ PROTOCOLS2 ] |= WM2RestackWindow;
1373
1374 else if( atom == net_showing_desktop )
1375 p->properties[ PROTOCOLS2 ] |= WM2ShowingDesktop;
1376
1377 // Application window properties/messages
1378 else if( atom == net_wm_moveresize )
1379 p->properties[ PROTOCOLS ] |= WMMoveResize;
1380
1381 else if( atom == net_moveresize_window )
1382 p->properties[ PROTOCOLS2 ] |= WM2MoveResizeWindow;
1383
1384 else if( atom == net_wm_name )
1385 p->properties[ PROTOCOLS ] |= WMName;
1386
1387 else if( atom == net_wm_visible_name )
1388 p->properties[ PROTOCOLS ] |= WMVisibleName;
1389
1390 else if( atom == net_wm_icon_name )
1391 p->properties[ PROTOCOLS ] |= WMIconName;
1392
1393 else if( atom == net_wm_visible_icon_name )
1394 p->properties[ PROTOCOLS ] |= WMVisibleIconName;
1395
1396 else if( atom == net_wm_desktop )
1397 p->properties[ PROTOCOLS ] |= WMDesktop;
1398
1399 else if( atom == net_wm_window_type )
1400 p->properties[ PROTOCOLS ] |= WMWindowType;
1401
1402 // Application window types
1403 else if( atom == net_wm_window_type_normal )
1404 p->properties[ WINDOW_TYPES ] |= NormalMask;
1405 else if( atom == net_wm_window_type_desktop )
1406 p->properties[ WINDOW_TYPES ] |= DesktopMask;
1407 else if( atom == net_wm_window_type_dock )
1408 p->properties[ WINDOW_TYPES ] |= DockMask;
1409 else if( atom == net_wm_window_type_toolbar )
1410 p->properties[ WINDOW_TYPES ] |= ToolbarMask;
1411 else if( atom == net_wm_window_type_menu )
1412 p->properties[ WINDOW_TYPES ] |= MenuMask;
1413 else if( atom == net_wm_window_type_dialog )
1414 p->properties[ WINDOW_TYPES ] |= DialogMask;
1415 else if( atom == net_wm_window_type_utility )
1416 p->properties[ WINDOW_TYPES ] |= UtilityMask;
1417 else if( atom == net_wm_window_type_splash )
1418 p->properties[ WINDOW_TYPES ] |= SplashMask;
1419 else if( atom == net_wm_window_type_dropdown_menu )
1420 p->properties[ WINDOW_TYPES ] |= DropdownMenuMask;
1421 else if( atom == net_wm_window_type_popup_menu )
1422 p->properties[ WINDOW_TYPES ] |= PopupMenuMask;
1423 else if( atom == net_wm_window_type_tooltip )
1424 p->properties[ WINDOW_TYPES ] |= TooltipMask;
1425 else if( atom == net_wm_window_type_notification )
1426 p->properties[ WINDOW_TYPES ] |= NotificationMask;
1427 else if( atom == net_wm_window_type_combobox )
1428 p->properties[ WINDOW_TYPES ] |= ComboBoxMask;
1429 else if( atom == net_wm_window_type_dnd )
1430 p->properties[ WINDOW_TYPES ] |= DNDIconMask;
1431 // KDE extensions
1432 else if( atom == kde_net_wm_window_type_override )
1433 p->properties[ WINDOW_TYPES ] |= OverrideMask;
1434 else if( atom == kde_net_wm_window_type_topmenu )
1435 p->properties[ WINDOW_TYPES ] |= TopMenuMask;
1436
1437 else if( atom == net_wm_state )
1438 p->properties[ PROTOCOLS ] |= WMState;
1439
1440 // Application window states
1441 else if( atom == net_wm_state_modal )
1442 p->properties[ STATES ] |= Modal;
1443 else if( atom == net_wm_state_sticky )
1444 p->properties[ STATES ] |= Sticky;
1445 else if( atom == net_wm_state_max_vert )
1446 p->properties[ STATES ] |= MaxVert;
1447 else if( atom == net_wm_state_max_horiz )
1448 p->properties[ STATES ] |= MaxHoriz;
1449 else if( atom == net_wm_state_shaded )
1450 p->properties[ STATES ] |= Shaded;
1451 else if( atom == net_wm_state_skip_taskbar )
1452 p->properties[ STATES ] |= SkipTaskbar;
1453 else if( atom == net_wm_state_skip_pager )
1454 p->properties[ STATES ] |= SkipPager;
1455 else if( atom == net_wm_state_hidden )
1456 p->properties[ STATES ] |= Hidden;
1457 else if( atom == net_wm_state_fullscreen )
1458 p->properties[ STATES ] |= FullScreen;
1459 else if( atom == net_wm_state_above )
1460 p->properties[ STATES ] |= KeepAbove;
1461 else if( atom == net_wm_state_below )
1462 p->properties[ STATES ] |= KeepBelow;
1463 else if( atom == net_wm_state_demands_attention )
1464 p->properties[ STATES ] |= DemandsAttention;
1465
1466 else if( atom == net_wm_state_stays_on_top )
1467 p->properties[ STATES ] |= StaysOnTop;
1468
1469 else if( atom == net_wm_strut )
1470 p->properties[ PROTOCOLS ] |= WMStrut;
1471
1472 else if( atom == net_wm_extended_strut )
1473 p->properties[ PROTOCOLS2 ] |= WM2ExtendedStrut;
1474
1475 else if( atom == net_wm_icon_geometry )
1476 p->properties[ PROTOCOLS ] |= WMIconGeometry;
1477
1478 else if( atom == net_wm_icon )
1479 p->properties[ PROTOCOLS ] |= WMIcon;
1480
1481 else if( atom == net_wm_pid )
1482 p->properties[ PROTOCOLS ] |= WMPid;
1483
1484 else if( atom == net_wm_handled_icons )
1485 p->properties[ PROTOCOLS ] |= WMHandledIcons;
1486
1487 else if( atom == net_wm_ping )
1488 p->properties[ PROTOCOLS ] |= WMPing;
1489
1490 else if( atom == net_wm_take_activity )
1491 p->properties[ PROTOCOLS2 ] |= WM2TakeActivity;
1492
1493 else if( atom == net_wm_user_time )
1494 p->properties[ PROTOCOLS2 ] |= WM2UserTime;
1495
1496 else if( atom == net_startup_id )
1497 p->properties[ PROTOCOLS2 ] |= WM2StartupId;
1498
1499 else if( atom == net_wm_window_opacity )
1500 p->properties[ PROTOCOLS2 ] |= WM2Opacity;
1501
1502 else if( atom == net_wm_fullscreen_monitors )
1503 p->properties[ PROTOCOLS2 ] |= WM2FullscreenMonitors;
1504
1505 else if( atom == net_wm_allowed_actions )
1506 p->properties[ PROTOCOLS2 ] |= WM2AllowedActions;
1507
1508 // Actions
1509 else if( atom == net_wm_action_move )
1510 p->properties[ ACTIONS ] |= ActionMove;
1511 else if( atom == net_wm_action_resize )
1512 p->properties[ ACTIONS ] |= ActionResize;
1513 else if( atom == net_wm_action_minimize )
1514 p->properties[ ACTIONS ] |= ActionMinimize;
1515 else if( atom == net_wm_action_shade )
1516 p->properties[ ACTIONS ] |= ActionShade;
1517 else if( atom == net_wm_action_stick )
1518 p->properties[ ACTIONS ] |= ActionStick;
1519 else if( atom == net_wm_action_max_vert )
1520 p->properties[ ACTIONS ] |= ActionMaxVert;
1521 else if( atom == net_wm_action_max_horiz )
1522 p->properties[ ACTIONS ] |= ActionMaxHoriz;
1523 else if( atom == net_wm_action_fullscreen )
1524 p->properties[ ACTIONS ] |= ActionFullScreen;
1525 else if( atom == net_wm_action_change_desk )
1526 p->properties[ ACTIONS ] |= ActionChangeDesktop;
1527 else if( atom == net_wm_action_close )
1528 p->properties[ ACTIONS ] |= ActionClose;
1529
1530 else if( atom == net_frame_extents )
1531 p->properties[ PROTOCOLS ] |= WMFrameExtents;
1532 else if( atom == kde_net_wm_frame_strut )
1533 p->properties[ PROTOCOLS ] |= WMFrameExtents;
1534 else if( atom == kde_net_wm_frame_overlap )
1535 p->properties[ PROTOCOLS2 ] |= WM2FrameOverlap;
1536
1537 else if( atom == kde_net_wm_temporary_rules )
1538 p->properties[ PROTOCOLS2 ] |= WM2KDETemporaryRules;
1539 else if( atom == net_wm_full_placement )
1540 p->properties[ PROTOCOLS2 ] |= WM2FullPlacement;
1541
1542 else if( atom == kde_net_wm_activities )
1543 p->properties[ PROTOCOLS2 ] |= WM2Activities;
1544
1545 else if( atom == kde_net_wm_block_compositing )
1546 p->properties[ PROTOCOLS2 ] |= WM2BlockCompositing;
1547
1548 else if( atom == kde_net_wm_shadow )
1549 p->properties[ PROTOCOLS2 ] |= WM2KDEShadow;
1550}
1551
1552void NETRootInfo::setActiveWindow(Window window) {
1553 setActiveWindow( window, FromUnknown, QX11Info::appUserTime(), None );
1554}
1555
1556void NETRootInfo::setActiveWindow(Window window, NET::RequestSource src,
1557 Time timestamp, Window active_window ) {
1558
1559#ifdef NETWMDEBUG
1560 fprintf(stderr, "NETRootInfo::setActiveWindow(0x%lx) (%s)\n",
1561 window, (p->role == WindowManager) ? "WM" : "Client");
1562#endif
1563
1564 if (p->role == WindowManager) {
1565 p->active = window;
1566 XChangeProperty(p->display, p->root, net_active_window, XA_WINDOW, 32,
1567 PropModeReplace, (unsigned char *) &(p->active), 1);
1568 } else {
1569 XEvent e;
1570
1571 e.xclient.type = ClientMessage;
1572 e.xclient.message_type = net_active_window;
1573 e.xclient.display = p->display;
1574 e.xclient.window = window;
1575 e.xclient.format = 32;
1576 e.xclient.data.l[0] = src;
1577 e.xclient.data.l[1] = timestamp;
1578 e.xclient.data.l[2] = active_window;
1579 e.xclient.data.l[3] = 0l;
1580 e.xclient.data.l[4] = 0l;
1581
1582 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
1583 }
1584}
1585
1586
1587void NETRootInfo::setWorkArea(int desktop, const NETRect &workarea) {
1588
1589#ifdef NETWMDEBUG
1590 fprintf(stderr, "NETRootInfo::setWorkArea(%d, { %d, %d, %d, %d }) (%s)\n",
1591 desktop, workarea.pos.x, workarea.pos.y, workarea.size.width, workarea.size.height,
1592 (p->role == WindowManager) ? "WM" : "Client");
1593#endif
1594
1595 if (p->role != WindowManager || desktop < 1) return;
1596
1597 p->workarea[desktop - 1] = workarea;
1598
1599 long *wa = new long[p->number_of_desktops * 4];
1600 int i, o;
1601 for (i = 0, o = 0; i < p->number_of_desktops; i++) {
1602 wa[o++] = p->workarea[i].pos.x;
1603 wa[o++] = p->workarea[i].pos.y;
1604 wa[o++] = p->workarea[i].size.width;
1605 wa[o++] = p->workarea[i].size.height;
1606 }
1607
1608 XChangeProperty(p->display, p->root, net_workarea, XA_CARDINAL, 32,
1609 PropModeReplace, (unsigned char *) wa,
1610 p->number_of_desktops * 4);
1611
1612 delete [] wa;
1613}
1614
1615
1616void NETRootInfo::setVirtualRoots(const Window *windows, unsigned int count) {
1617 if (p->role != WindowManager) return;
1618
1619 p->virtual_roots_count = count;
1620 delete[] p->virtual_roots;
1621 p->virtual_roots = nwindup(windows,count);;
1622
1623#ifdef NETWMDEBUG
1624 fprintf(stderr, "NETRootInfo::setVirtualRoots: setting list with %ld windows\n",
1625 p->virtual_roots_count);
1626#endif
1627
1628 XChangeProperty(p->display, p->root, net_virtual_roots, XA_WINDOW, 32,
1629 PropModeReplace, (unsigned char *) p->virtual_roots,
1630 p->virtual_roots_count);
1631}
1632
1633
1634void NETRootInfo::setDesktopLayout(NET::Orientation orientation, int columns, int rows,
1635 NET::DesktopLayoutCorner corner)
1636{
1637 p->desktop_layout_orientation = orientation;
1638 p->desktop_layout_columns = columns;
1639 p->desktop_layout_rows = rows;
1640 p->desktop_layout_corner = corner;
1641
1642#ifdef NETWMDEBUG
1643 fprintf(stderr, "NETRootInfo::setDesktopLayout: %d %d %d %d\n",
1644 orientation, columns, rows, corner);
1645#endif
1646
1647 long data[ 4 ];
1648 data[ 0 ] = orientation;
1649 data[ 1 ] = columns;
1650 data[ 2 ] = rows;
1651 data[ 3 ] = corner;
1652 XChangeProperty(p->display, p->root, net_desktop_layout, XA_CARDINAL, 32,
1653 PropModeReplace, (unsigned char *) &data, 4);
1654}
1655
1656
1657void NETRootInfo::setShowingDesktop( bool showing ) {
1658 if (p->role == WindowManager) {
1659 long d = p->showing_desktop = showing;
1660 XChangeProperty(p->display, p->root, net_showing_desktop, XA_CARDINAL, 32,
1661 PropModeReplace, (unsigned char *) &d, 1);
1662 } else {
1663 XEvent e;
1664
1665 e.xclient.type = ClientMessage;
1666 e.xclient.message_type = net_showing_desktop;
1667 e.xclient.display = p->display;
1668 e.xclient.window = 0;
1669 e.xclient.format = 32;
1670 e.xclient.data.l[0] = showing ? 1 : 0;
1671 e.xclient.data.l[1] = 0;
1672 e.xclient.data.l[2] = 0;
1673 e.xclient.data.l[3] = 0;
1674 e.xclient.data.l[4] = 0;
1675
1676 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
1677 }
1678}
1679
1680
1681bool NETRootInfo::showingDesktop() const {
1682 return p->showing_desktop;
1683}
1684
1685
1686void NETRootInfo::closeWindowRequest(Window window) {
1687
1688#ifdef NETWMDEBUG
1689 fprintf(stderr, "NETRootInfo::closeWindowRequest: requesting close for 0x%lx\n",
1690 window);
1691#endif
1692
1693 XEvent e;
1694
1695 e.xclient.type = ClientMessage;
1696 e.xclient.message_type = net_close_window;
1697 e.xclient.display = p->display;
1698 e.xclient.window = window;
1699 e.xclient.format = 32;
1700 e.xclient.data.l[0] = 0l;
1701 e.xclient.data.l[1] = 0l;
1702 e.xclient.data.l[2] = 0l;
1703 e.xclient.data.l[3] = 0l;
1704 e.xclient.data.l[4] = 0l;
1705
1706 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
1707}
1708
1709
1710void NETRootInfo::moveResizeRequest(Window window, int x_root, int y_root,
1711 Direction direction)
1712{
1713
1714#ifdef NETWMDEBUG
1715 fprintf(stderr,
1716 "NETRootInfo::moveResizeRequest: requesting resize/move for 0x%lx (%d, %d, %d)\n",
1717 window, x_root, y_root, direction);
1718#endif
1719
1720 XEvent e;
1721
1722 e.xclient.type = ClientMessage;
1723 e.xclient.message_type = net_wm_moveresize;
1724 e.xclient.display = p->display;
1725 e.xclient.window = window,
1726 e.xclient.format = 32;
1727 e.xclient.data.l[0] = x_root;
1728 e.xclient.data.l[1] = y_root;
1729 e.xclient.data.l[2] = direction;
1730 e.xclient.data.l[3] = 0l;
1731 e.xclient.data.l[4] = 0l;
1732
1733 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
1734}
1735
1736void NETRootInfo::moveResizeWindowRequest(Window window, int flags, int x, int y, int width, int height )
1737{
1738
1739#ifdef NETWMDEBUG
1740 fprintf(stderr,
1741 "NETRootInfo::moveResizeWindowRequest: resizing/moving 0x%lx (%d, %d, %d, %d, %d)\n",
1742 window, flags, x, y, width, height);
1743#endif
1744
1745 XEvent e;
1746
1747 e.xclient.type = ClientMessage;
1748 e.xclient.message_type = net_moveresize_window;
1749 e.xclient.display = p->display;
1750 e.xclient.window = window,
1751 e.xclient.format = 32;
1752 e.xclient.data.l[0] = flags;
1753 e.xclient.data.l[1] = x;
1754 e.xclient.data.l[2] = y;
1755 e.xclient.data.l[3] = width;
1756 e.xclient.data.l[4] = height;
1757
1758 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
1759}
1760
1761void NETRootInfo::restackRequest(Window window, RequestSource src, Window above, int detail, Time timestamp )
1762{
1763#ifdef NETWMDEBUG
1764 fprintf(stderr,
1765 "NETRootInfo::restackRequest: requesting restack for 0x%lx (%lx, %d)\n",
1766 window, above, detail);
1767#endif
1768
1769 XEvent e;
1770
1771 e.xclient.type = ClientMessage;
1772 e.xclient.message_type = net_restack_window;
1773 e.xclient.display = p->display;
1774 e.xclient.window = window,
1775 e.xclient.format = 32;
1776 e.xclient.data.l[0] = src;
1777 e.xclient.data.l[1] = above;
1778 e.xclient.data.l[2] = detail;
1779 e.xclient.data.l[3] = timestamp;
1780 e.xclient.data.l[4] = 0l;
1781
1782 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
1783}
1784
1785void NETRootInfo::sendPing( Window window, Time timestamp )
1786{
1787 if (p->role != WindowManager) return;
1788#ifdef NETWMDEBUG
1789 fprintf(stderr, "NETRootInfo::setPing: window 0x%lx, timestamp %lu\n",
1790 window, timestamp );
1791#endif
1792 XEvent e;
1793 e.xclient.type = ClientMessage;
1794 e.xclient.message_type = wm_protocols;
1795 e.xclient.display = p->display;
1796 e.xclient.window = window,
1797 e.xclient.format = 32;
1798 e.xclient.data.l[0] = net_wm_ping;
1799 e.xclient.data.l[1] = timestamp;
1800 e.xclient.data.l[2] = window;
1801 e.xclient.data.l[3] = 0;
1802 e.xclient.data.l[4] = 0;
1803
1804 XSendEvent(p->display, window, False, 0, &e);
1805}
1806
1807void NETRootInfo::takeActivity( Window window, Time timestamp, long flags )
1808{
1809 if (p->role != WindowManager) return;
1810#ifdef NETWMDEBUG
1811 fprintf(stderr, "NETRootInfo::takeActivity: window 0x%lx, timestamp %lu, flags 0x%lx\n",
1812 window, timestamp, flags );
1813#endif
1814 XEvent e;
1815 e.xclient.type = ClientMessage;
1816 e.xclient.message_type = wm_protocols;
1817 e.xclient.display = p->display;
1818 e.xclient.window = window,
1819 e.xclient.format = 32;
1820 e.xclient.data.l[0] = net_wm_take_activity;
1821 e.xclient.data.l[1] = timestamp;
1822 e.xclient.data.l[2] = window;
1823 e.xclient.data.l[3] = flags;
1824 e.xclient.data.l[4] = 0;
1825
1826 XSendEvent(p->display, window, False, 0, &e);
1827}
1828
1829
1830
1831// assignment operator
1832
1833const NETRootInfo &NETRootInfo::operator=(const NETRootInfo &rootinfo) {
1834
1835#ifdef NETWMDEBUG
1836 fprintf(stderr, "NETRootInfo::operator=()\n");
1837#endif
1838
1839 if (p != rootinfo.p) {
1840 refdec_nri(p);
1841
1842 if (! p->ref) delete p;
1843 }
1844
1845 p = rootinfo.p;
1846 p->ref++;
1847
1848 return *this;
1849}
1850
1851unsigned long NETRootInfo::event(XEvent *ev )
1852{
1853 unsigned long props[ 1 ];
1854 event( ev, props, 1 );
1855 return props[ 0 ];
1856}
1857
1858void NETRootInfo::event(XEvent *event, unsigned long* properties, int properties_size )
1859{
1860 unsigned long props[ PROPERTIES_SIZE ] = { 0, 0, 0, 0, 0 };
1861 assert( PROPERTIES_SIZE == 5 ); // add elements above
1862 unsigned long& dirty = props[ PROTOCOLS ];
1863 unsigned long& dirty2 = props[ PROTOCOLS2 ];
1864 bool do_update = false;
1865
1866 // the window manager will be interested in client messages... no other
1867 // client should get these messages
1868 if (p->role == WindowManager && event->type == ClientMessage &&
1869 event->xclient.format == 32) {
1870#ifdef NETWMDEBUG
1871 fprintf(stderr, "NETRootInfo::event: handling ClientMessage event\n");
1872#endif
1873
1874 if (event->xclient.message_type == net_number_of_desktops) {
1875 dirty = NumberOfDesktops;
1876
1877#ifdef NETWMDEBUG
1878 fprintf(stderr, "NETRootInfo::event: changeNumberOfDesktops(%ld)\n",
1879 event->xclient.data.l[0]);
1880#endif
1881
1882 changeNumberOfDesktops(event->xclient.data.l[0]);
1883 } else if (event->xclient.message_type == net_desktop_geometry) {
1884 dirty = DesktopGeometry;
1885
1886 NETSize sz;
1887 sz.width = event->xclient.data.l[0];
1888 sz.height = event->xclient.data.l[1];
1889
1890#ifdef NETWMDEBUG
1891 fprintf(stderr, "NETRootInfo::event: changeDesktopGeometry( -- , { %d, %d })\n",
1892 sz.width, sz.height);
1893#endif
1894
1895 changeDesktopGeometry(~0, sz);
1896 } else if (event->xclient.message_type == net_desktop_viewport) {
1897 dirty = DesktopViewport;
1898
1899 NETPoint pt;
1900 pt.x = event->xclient.data.l[0];
1901 pt.y = event->xclient.data.l[1];
1902
1903#ifdef NETWMDEBUG
1904 fprintf(stderr, "NETRootInfo::event: changeDesktopViewport(%d, { %d, %d })\n",
1905 p->current_desktop, pt.x, pt.y);
1906#endif
1907
1908 changeDesktopViewport(p->current_desktop, pt);
1909 } else if (event->xclient.message_type == net_current_desktop) {
1910 dirty = CurrentDesktop;
1911
1912#ifdef NETWMDEBUG
1913 fprintf(stderr, "NETRootInfo::event: changeCurrentDesktop(%ld)\n",
1914 event->xclient.data.l[0] + 1);
1915#endif
1916
1917 changeCurrentDesktop(event->xclient.data.l[0] + 1);
1918 } else if (event->xclient.message_type == net_active_window) {
1919 dirty = ActiveWindow;
1920
1921#ifdef NETWMDEBUG
1922 fprintf(stderr, "NETRootInfo::event: changeActiveWindow(0x%lx)\n",
1923 event->xclient.window);
1924#endif
1925
1926 RequestSource src = FromUnknown;
1927 Time timestamp = CurrentTime;
1928 Window active_window = None;
1929 // make sure there aren't unknown values
1930 if( event->xclient.data.l[0] >= FromUnknown
1931 && event->xclient.data.l[0] <= FromTool )
1932 {
1933 src = static_cast< RequestSource >( event->xclient.data.l[0] );
1934 timestamp = event->xclient.data.l[1];
1935 active_window = event->xclient.data.l[2];
1936 }
1937 changeActiveWindow( event->xclient.window, src, timestamp, active_window );
1938 } else if (event->xclient.message_type == net_wm_moveresize) {
1939
1940#ifdef NETWMDEBUG
1941 fprintf(stderr, "NETRootInfo::event: moveResize(%ld, %ld, %ld, %ld)\n",
1942 event->xclient.window,
1943 event->xclient.data.l[0],
1944 event->xclient.data.l[1],
1945 event->xclient.data.l[2]
1946 );
1947#endif
1948
1949 moveResize(event->xclient.window,
1950 event->xclient.data.l[0],
1951 event->xclient.data.l[1],
1952 event->xclient.data.l[2]);
1953 } else if (event->xclient.message_type == net_moveresize_window) {
1954
1955#ifdef NETWMDEBUG
1956 fprintf(stderr, "NETRootInfo::event: moveResizeWindow(%ld, %ld, %ld, %ld, %ld, %ld)\n",
1957 event->xclient.window,
1958 event->xclient.data.l[0],
1959 event->xclient.data.l[1],
1960 event->xclient.data.l[2],
1961 event->xclient.data.l[3],
1962 event->xclient.data.l[4]
1963 );
1964#endif
1965
1966 moveResizeWindow(event->xclient.window,
1967 event->xclient.data.l[0],
1968 event->xclient.data.l[1],
1969 event->xclient.data.l[2],
1970 event->xclient.data.l[3],
1971 event->xclient.data.l[4]);
1972 } else if (event->xclient.message_type == net_close_window) {
1973
1974#ifdef NETWMDEBUG
1975 fprintf(stderr, "NETRootInfo::event: closeWindow(0x%lx)\n",
1976 event->xclient.window);
1977#endif
1978
1979 closeWindow(event->xclient.window);
1980 } else if (event->xclient.message_type == net_restack_window) {
1981
1982#ifdef NETWMDEBUG
1983 fprintf(stderr, "NETRootInfo::event: restackWindow(0x%lx)\n",
1984 event->xclient.window);
1985#endif
1986
1987 RequestSource src = FromUnknown;
1988 Time timestamp = CurrentTime;
1989 // make sure there aren't unknown values
1990 if( event->xclient.data.l[0] >= FromUnknown
1991 && event->xclient.data.l[0] <= FromTool )
1992 {
1993 src = static_cast< RequestSource >( event->xclient.data.l[0] );
1994 timestamp = event->xclient.data.l[3];
1995 }
1996 restackWindow(event->xclient.window, src,
1997 event->xclient.data.l[1], event->xclient.data.l[2], timestamp);
1998 } else if (event->xclient.message_type == wm_protocols
1999 && (Atom)event->xclient.data.l[ 0 ] == net_wm_ping) {
2000 dirty = WMPing;
2001
2002#ifdef NETWMDEBUG
2003 fprintf(stderr, "NETRootInfo::event: gotPing(0x%lx,%lu)\n",
2004 event->xclient.window, event->xclient.data.l[1]);
2005#endif
2006 gotPing( event->xclient.data.l[2], event->xclient.data.l[1]);
2007 } else if (event->xclient.message_type == wm_protocols
2008 && (Atom)event->xclient.data.l[ 0 ] == net_wm_take_activity) {
2009 dirty2 = WM2TakeActivity;
2010
2011#ifdef NETWMDEBUG
2012 fprintf(stderr, "NETRootInfo::event: gotTakeActivity(0x%lx,%lu,0x%lx)\n",
2013 event->xclient.window, event->xclient.data.l[1], event->xclient.data.l[3]);
2014#endif
2015 gotTakeActivity( event->xclient.data.l[2], event->xclient.data.l[1],
2016 event->xclient.data.l[3]);
2017 } else if (event->xclient.message_type == net_showing_desktop) {
2018 dirty2 = WM2ShowingDesktop;
2019
2020#ifdef NETWMDEBUG
2021 fprintf(stderr, "NETRootInfo::event: changeShowingDesktop(%ld)\n",
2022 event->xclient.data.l[0]);
2023#endif
2024
2025 changeShowingDesktop(event->xclient.data.l[0]);
2026 }
2027 }
2028
2029 if (event->type == PropertyNotify) {
2030
2031#ifdef NETWMDEBUG
2032 fprintf(stderr, "NETRootInfo::event: handling PropertyNotify event\n");
2033#endif
2034
2035 XEvent pe = *event;
2036
2037 Bool done = False;
2038 Bool compaction = False;
2039 while (! done) {
2040
2041#ifdef NETWMDEBUG
2042 fprintf(stderr, "NETRootInfo::event: loop fire\n");
2043#endif
2044
2045 if (pe.xproperty.atom == net_client_list)
2046 dirty |= ClientList;
2047 else if (pe.xproperty.atom == net_client_list_stacking)
2048 dirty |= ClientListStacking;
2049 else if (pe.xproperty.atom == net_desktop_names)
2050 dirty |= DesktopNames;
2051 else if (pe.xproperty.atom == net_workarea)
2052 dirty |= WorkArea;
2053 else if (pe.xproperty.atom == net_number_of_desktops)
2054 dirty |= NumberOfDesktops;
2055 else if (pe.xproperty.atom == net_desktop_geometry)
2056 dirty |= DesktopGeometry;
2057 else if (pe.xproperty.atom == net_desktop_viewport)
2058 dirty |= DesktopViewport;
2059 else if (pe.xproperty.atom == net_current_desktop)
2060 dirty |= CurrentDesktop;
2061 else if (pe.xproperty.atom == net_active_window)
2062 dirty |= ActiveWindow;
2063 else if (pe.xproperty.atom == net_showing_desktop)
2064 dirty2 |= WM2ShowingDesktop;
2065 else if (pe.xproperty.atom == net_supported )
2066 dirty |= Supported; // update here?
2067 else if (pe.xproperty.atom == net_supporting_wm_check )
2068 dirty |= SupportingWMCheck;
2069 else if (pe.xproperty.atom == net_virtual_roots )
2070 dirty |= VirtualRoots;
2071 else if (pe.xproperty.atom == net_desktop_layout )
2072 dirty2 |= WM2DesktopLayout;
2073 else {
2074
2075#ifdef NETWMDEBUG
2076 fprintf(stderr, "NETRootInfo::event: putting back event and breaking\n");
2077#endif
2078
2079 if ( compaction )
2080 XPutBackEvent(p->display, &pe);
2081 break;
2082 }
2083
2084 // TODO: compaction is currently disabled, because it consumes the events, it should
2085 // however let also Qt process them - this caused a problem with KRunner when
2086 // doing Alt+F2, 'konsole' and Alt+F2 again didn't work - starting the Konsole
2087 // slowed things down a bit, this compaction got executed and consumed PropertyNotify
2088 // for WM_STATE
2089 if (false && XCheckTypedWindowEvent(p->display, p->root, PropertyNotify, &pe) )
2090 compaction = True;
2091 else
2092 break;
2093 }
2094
2095 do_update = true;
2096 }
2097
2098 if( do_update )
2099 update( props );
2100
2101#ifdef NETWMDEBUG
2102 fprintf(stderr, "NETRootInfo::event: handled events, returning dirty = 0x%lx, 0x%lx\n",
2103 dirty, dirty2);
2104#endif
2105
2106 if( properties_size > PROPERTIES_SIZE )
2107 properties_size = PROPERTIES_SIZE;
2108 for( int i = 0;
2109 i < properties_size;
2110 ++i )
2111 properties[ i ] = props[ i ];
2112}
2113
2114
2115// private functions to update the data we keep
2116
2117void NETRootInfo::update( const unsigned long dirty_props[] )
2118{
2119 Atom type_ret;
2120 int format_ret;
2121 unsigned char *data_ret;
2122 unsigned long nitems_ret, unused;
2123 unsigned long props[ PROPERTIES_SIZE ];
2124 for( int i = 0;
2125 i < PROPERTIES_SIZE;
2126 ++i )
2127 props[ i ] = dirty_props[ i ] & p->client_properties[ i ];
2128 const unsigned long& dirty = props[ PROTOCOLS ];
2129 const unsigned long& dirty2 = props[ PROTOCOLS2 ];
2130
2131 if (dirty & Supported ) {
2132 // only in Client mode
2133 for( int i = 0; i < PROPERTIES_SIZE; ++i )
2134 p->properties[ i ] = 0;
2135 if( XGetWindowProperty(p->display, p->root, net_supported,
2136 0l, MAX_PROP_SIZE, False, XA_ATOM, &type_ret,
2137 &format_ret, &nitems_ret, &unused, &data_ret)
2138 == Success ) {
2139 if( type_ret == XA_ATOM && format_ret == 32 ) {
2140 Atom* atoms = (Atom*) data_ret;
2141 for( unsigned int i = 0;
2142 i < nitems_ret;
2143 ++i )
2144 updateSupportedProperties( atoms[ i ] );
2145 }
2146 if ( data_ret )
2147 XFree(data_ret);
2148 }
2149 }
2150
2151 if (dirty & ClientList) {
2152 QList<Window> clientsToRemove;
2153 QList<Window> clientsToAdd;
2154
2155 bool read_ok = false;
2156 if (XGetWindowProperty(p->display, p->root, net_client_list,
2157 0l, MAX_PROP_SIZE, False, XA_WINDOW, &type_ret,
2158 &format_ret, &nitems_ret, &unused, &data_ret)
2159 == Success) {
2160 if (type_ret == XA_WINDOW && format_ret == 32) {
2161 Window *wins = (Window *) data_ret;
2162
2163 qsort(wins, nitems_ret, sizeof(Window), wcmp);
2164
2165 if (p->clients) {
2166 if (p->role == Client) {
2167 unsigned long new_index = 0, old_index = 0;
2168 unsigned long new_count = nitems_ret,
2169 old_count = p->clients_count;
2170
2171 while (old_index < old_count || new_index < new_count) {
2172 if (old_index == old_count) {
2173 clientsToAdd.append(wins[new_index++]);
2174 } else if (new_index == new_count) {
2175 clientsToRemove.append(p->clients[old_index++]);
2176 } else {
2177 if (p->clients[old_index] <
2178 wins[new_index]) {
2179 clientsToRemove.append(p->clients[old_index++]);
2180 } else if (wins[new_index] <
2181 p->clients[old_index]) {
2182 clientsToAdd.append(wins[new_index++]);
2183 } else {
2184 new_index++;
2185 old_index++;
2186 }
2187 }
2188 }
2189 }
2190
2191 delete [] p->clients;
2192 } else {
2193#ifdef NETWMDEBUG
2194 fprintf(stderr, "NETRootInfo::update: client list null, creating\n");
2195#endif
2196
2197 unsigned long n;
2198 for (n = 0; n < nitems_ret; n++) {
2199 clientsToAdd.append(wins[n]);
2200 }
2201 }
2202
2203 p->clients_count = nitems_ret;
2204 p->clients = nwindup(wins, p->clients_count);
2205 read_ok = true;
2206 }
2207
2208 if ( data_ret )
2209 XFree(data_ret);
2210 }
2211 if( !read_ok ) {
2212 for( unsigned int i = 0; i < p->clients_count; ++ i )
2213 clientsToRemove.append(p->clients[i]);
2214 p->clients_count = 0;
2215 delete[] p->clients;
2216 p->clients = NULL;
2217 }
2218
2219#ifdef NETWMDEBUG
2220 fprintf(stderr, "NETRootInfo::update: client list updated (%ld clients)\n",
2221 p->clients_count);
2222#endif
2223 for (int i = 0; i < clientsToRemove.size(); ++i) {
2224 removeClient(clientsToRemove.at(i));
2225 }
2226 for (int i = 0; i < clientsToAdd.size(); ++i) {
2227 addClient(clientsToAdd.at(i));
2228 }
2229 }
2230
2231 if (dirty & ClientListStacking) {
2232 p->stacking_count = 0;
2233 delete[] p->stacking;
2234 p->stacking = NULL;
2235 if (XGetWindowProperty(p->display, p->root, net_client_list_stacking,
2236 0, MAX_PROP_SIZE, False, XA_WINDOW, &type_ret,
2237 &format_ret, &nitems_ret, &unused, &data_ret)
2238 == Success) {
2239 if (type_ret == XA_WINDOW && format_ret == 32) {
2240 Window *wins = (Window *) data_ret;
2241
2242 p->stacking_count = nitems_ret;
2243 p->stacking = nwindup(wins, p->stacking_count);
2244 }
2245
2246#ifdef NETWMDEBUG
2247 fprintf(stderr,"NETRootInfo::update: client stacking updated (%ld clients)\n",
2248 p->stacking_count);
2249#endif
2250
2251 if ( data_ret )
2252 XFree(data_ret);
2253 }
2254 }
2255
2256 if (dirty & NumberOfDesktops) {
2257 p->number_of_desktops = 0;
2258
2259 if (XGetWindowProperty(p->display, p->root, net_number_of_desktops,
2260 0l, 1l, False, XA_CARDINAL, &type_ret, &format_ret,
2261 &nitems_ret, &unused, &data_ret)
2262 == Success) {
2263 if (type_ret == XA_CARDINAL && format_ret == 32 && nitems_ret == 1) {
2264 p->number_of_desktops = *((long *) data_ret);
2265 }
2266
2267#ifdef NETWMDEBUG
2268 fprintf(stderr, "NETRootInfo::update: number of desktops = %d\n",
2269 p->number_of_desktops);
2270#endif
2271 if ( data_ret )
2272 XFree(data_ret);
2273 }
2274 }
2275
2276 if (dirty & DesktopGeometry) {
2277 p->geometry = p->rootSize;
2278 if (XGetWindowProperty(p->display, p->root, net_desktop_geometry,
2279 0l, 2l, False, XA_CARDINAL, &type_ret, &format_ret,
2280 &nitems_ret, &unused, &data_ret)
2281 == Success) {
2282 if (type_ret == XA_CARDINAL && format_ret == 32 &&
2283 nitems_ret == 2) {
2284 long *data = (long *) data_ret;
2285
2286 p->geometry.width = data[0];
2287 p->geometry.height = data[1];
2288
2289#ifdef NETWMDEBUG
2290 fprintf(stderr, "NETRootInfo::update: desktop geometry updated\n");
2291#endif
2292 }
2293 if ( data_ret )
2294 XFree(data_ret);
2295 }
2296 }
2297
2298 if (dirty & DesktopViewport) {
2299 for (int i = 0; i < p->viewport.size(); i++)
2300 p->viewport[i].x = p->viewport[i].y = 0;
2301 if (XGetWindowProperty(p->display, p->root, net_desktop_viewport,
2302 0l, 2l, False, XA_CARDINAL, &type_ret, &format_ret,
2303 &nitems_ret, &unused, &data_ret)
2304 == Success) {
2305 if (type_ret == XA_CARDINAL && format_ret == 32 &&
2306 nitems_ret == 2) {
2307 long *data = (long *) data_ret;
2308
2309 int d, i, n;
2310 n = nitems_ret / 2;
2311 for (d = 0, i = 0; d < n; d++) {
2312 p->viewport[d].x = data[i++];
2313 p->viewport[d].y = data[i++];
2314 }
2315
2316#ifdef NETWMDEBUG
2317 fprintf(stderr,
2318 "NETRootInfo::update: desktop viewport array updated (%d entries)\n",
2319 p->viewport.size());
2320
2321 if (nitems_ret % 2 != 0) {
2322 fprintf(stderr,
2323 "NETRootInfo::update(): desktop viewport array "
2324 "size not a multiple of 2\n");
2325 }
2326#endif
2327 }
2328 if ( data_ret )
2329 XFree(data_ret);
2330 }
2331 }
2332
2333 if (dirty & CurrentDesktop) {
2334 p->current_desktop = 0;
2335 if (XGetWindowProperty(p->display, p->root, net_current_desktop,
2336 0l, 1l, False, XA_CARDINAL, &type_ret, &format_ret,
2337 &nitems_ret, &unused, &data_ret)
2338 == Success) {
2339 if (type_ret == XA_CARDINAL && format_ret == 32 && nitems_ret == 1) {
2340 p->current_desktop = *((long *) data_ret) + 1;
2341 }
2342
2343#ifdef NETWMDEBUG
2344 fprintf(stderr, "NETRootInfo::update: current desktop = %d\n",
2345 p->current_desktop);
2346#endif
2347 if ( data_ret )
2348 XFree(data_ret);
2349 }
2350 }
2351
2352 if (dirty & DesktopNames) {
2353 for( int i = 0; i < p->desktop_names.size(); ++i )
2354 delete[] p->desktop_names[ i ];
2355 p->desktop_names.reset();
2356 if (XGetWindowProperty(p->display, p->root, net_desktop_names,
2357 0l, MAX_PROP_SIZE, False, UTF8_STRING, &type_ret,
2358 &format_ret, &nitems_ret, &unused, &data_ret)
2359 == Success) {
2360 if (type_ret == UTF8_STRING && format_ret == 8) {
2361 const char *d = (const char *) data_ret;
2362 unsigned int s, n, index;
2363
2364 for (s = 0, n = 0, index = 0; n < nitems_ret; n++) {
2365 if (d[n] == '\0') {
2366 delete [] p->desktop_names[index];
2367 p->desktop_names[index++] = nstrndup((d + s), n - s + 1);
2368 s = n + 1;
2369 }
2370 }
2371 }
2372
2373#ifdef NETWMDEBUG
2374 fprintf(stderr, "NETRootInfo::update: desktop names array updated (%d entries)\n",
2375 p->desktop_names.size());
2376#endif
2377 if ( data_ret )
2378 XFree(data_ret);
2379 }
2380 }
2381
2382 if (dirty & ActiveWindow) {
2383 p->active = None;
2384 if (XGetWindowProperty(p->display, p->root, net_active_window, 0l, 1l,
2385 False, XA_WINDOW, &type_ret, &format_ret,
2386 &nitems_ret, &unused, &data_ret)
2387 == Success) {
2388 if (type_ret == XA_WINDOW && format_ret == 32 && nitems_ret == 1) {
2389 p->active = *((Window *) data_ret);
2390 }
2391
2392#ifdef NETWMDEBUG
2393 fprintf(stderr, "NETRootInfo::update: active window = 0x%lx\n",
2394 p->active);
2395#endif
2396 if ( data_ret )
2397 XFree(data_ret);
2398 }
2399 }
2400
2401 if (dirty & WorkArea) {
2402 p->workarea.reset();
2403 if (XGetWindowProperty(p->display, p->root, net_workarea, 0l,
2404 (p->number_of_desktops * 4), False, XA_CARDINAL,
2405 &type_ret, &format_ret, &nitems_ret, &unused,
2406 &data_ret)
2407 == Success) {
2408 if (type_ret == XA_CARDINAL && format_ret == 32 &&
2409 nitems_ret == (unsigned) (p->number_of_desktops * 4)) {
2410 long *d = (long *) data_ret;
2411 int i, j;
2412 for (i = 0, j = 0; i < p->number_of_desktops; i++) {
2413 p->workarea[i].pos.x = d[j++];
2414 p->workarea[i].pos.y = d[j++];
2415 p->workarea[i].size.width = d[j++];
2416 p->workarea[i].size.height = d[j++];
2417 }
2418 }
2419
2420#ifdef NETWMDEBUG
2421 fprintf(stderr, "NETRootInfo::update: work area array updated (%d entries)\n",
2422 p->workarea.size());
2423#endif
2424 if ( data_ret )
2425 XFree(data_ret);
2426 }
2427 }
2428
2429
2430 if (dirty & SupportingWMCheck) {
2431 p->supportwindow = None;
2432 delete[] p->name;
2433 p->name = NULL;
2434 if (XGetWindowProperty(p->display, p->root, net_supporting_wm_check,
2435 0l, 1l, False, XA_WINDOW, &type_ret, &format_ret,
2436 &nitems_ret, &unused, &data_ret)
2437 == Success) {
2438 if (type_ret == XA_WINDOW && format_ret == 32 && nitems_ret == 1) {
2439 p->supportwindow = *((Window *) data_ret);
2440
2441 unsigned char *name_ret;
2442 if (XGetWindowProperty(p->display, p->supportwindow,
2443 net_wm_name, 0l, MAX_PROP_SIZE, False,
2444 UTF8_STRING, &type_ret, &format_ret,
2445 &nitems_ret, &unused, &name_ret)
2446 == Success) {
2447 if (type_ret == UTF8_STRING && format_ret == 8)
2448 p->name = nstrndup((const char *) name_ret, nitems_ret);
2449
2450 if ( name_ret )
2451 XFree(name_ret);
2452 }
2453 }
2454
2455#ifdef NETWMDEBUG
2456 fprintf(stderr,
2457 "NETRootInfo::update: supporting window manager = '%s'\n",
2458 p->name);
2459#endif
2460 if ( data_ret )
2461 XFree(data_ret);
2462 }
2463 }
2464
2465 if (dirty & VirtualRoots) {
2466 p->virtual_roots_count = 0;
2467 delete[] p->virtual_roots;
2468 p->virtual_roots = NULL;
2469 if (XGetWindowProperty(p->display, p->root, net_virtual_roots,
2470 0, MAX_PROP_SIZE, False, XA_WINDOW, &type_ret,
2471 &format_ret, &nitems_ret, &unused, &data_ret)
2472 == Success) {
2473 if (type_ret == XA_WINDOW && format_ret == 32) {
2474 Window *wins = (Window *) data_ret;
2475
2476 p->virtual_roots_count = nitems_ret;
2477 p->virtual_roots = nwindup(wins, p->virtual_roots_count);
2478 }
2479
2480#ifdef NETWMDEBUG
2481 fprintf(stderr, "NETRootInfo::updated: virtual roots updated (%ld windows)\n",
2482 p->virtual_roots_count);
2483#endif
2484 if ( data_ret )
2485 XFree(data_ret);
2486 }
2487 }
2488
2489 if (dirty2 & WM2DesktopLayout) {
2490 p->desktop_layout_orientation = OrientationHorizontal;
2491 p->desktop_layout_corner = DesktopLayoutCornerTopLeft;
2492 p->desktop_layout_columns = p->desktop_layout_rows = 0;
2493 if (XGetWindowProperty(p->display, p->root, net_desktop_layout,
2494 0, MAX_PROP_SIZE, False, XA_CARDINAL, &type_ret,
2495 &format_ret, &nitems_ret, &unused, &data_ret)
2496 == Success) {
2497 if (type_ret == XA_CARDINAL && format_ret == 32) {
2498 long* data = (long*) data_ret;
2499 if( nitems_ret >= 4 && data[ 3 ] >= 0 && data[ 3 ] <= 3 )
2500 p->desktop_layout_corner = (NET::DesktopLayoutCorner)data[ 3 ];
2501 if( nitems_ret >= 3 ) {
2502 if( data[ 0 ] >= 0 && data[ 0 ] <= 1 )
2503 p->desktop_layout_orientation = (NET::Orientation)data[ 0 ];
2504 p->desktop_layout_columns = data[ 1 ];
2505 p->desktop_layout_rows = data[ 2 ];
2506 }
2507 }
2508
2509#ifdef NETWMDEBUG
2510 fprintf(stderr, "NETRootInfo::updated: desktop layout updated (%d %d %d %d)\n",
2511 p->desktop_layout_orientation, p->desktop_layout_columns,
2512 p->desktop_layout_rows, p->desktop_layout_corner );
2513#endif
2514 if ( data_ret )
2515 XFree(data_ret);
2516 }
2517 }
2518
2519 if (dirty2 & WM2ShowingDesktop) {
2520 p->showing_desktop = false;
2521 if (XGetWindowProperty(p->display, p->root, net_showing_desktop,
2522 0, MAX_PROP_SIZE, False, XA_CARDINAL, &type_ret,
2523 &format_ret, &nitems_ret, &unused, &data_ret)
2524 == Success) {
2525 if (type_ret == XA_CARDINAL && format_ret == 32 && nitems_ret == 1) {
2526 p->showing_desktop = *((long *) data_ret);
2527 }
2528
2529#ifdef NETWMDEBUG
2530 fprintf(stderr, "NETRootInfo::update: showing desktop = %d\n",
2531 p->showing_desktop);
2532#endif
2533 if ( data_ret )
2534 XFree(data_ret);
2535 }
2536 }
2537}
2538
2539
2540Display *NETRootInfo::x11Display() const {
2541 return p->display;
2542}
2543
2544
2545Window NETRootInfo::rootWindow() const {
2546 return p->root;
2547}
2548
2549
2550Window NETRootInfo::supportWindow() const {
2551 return p->supportwindow;
2552}
2553
2554
2555const char *NETRootInfo::wmName() const {
2556 return p->name; }
2557
2558
2559int NETRootInfo::screenNumber() const {
2560 return p->screen;
2561}
2562
2563
2564
2565const unsigned long* NETRootInfo::supportedProperties() const {
2566 return p->properties;
2567}
2568
2569const unsigned long* NETRootInfo::passedProperties() const {
2570 return p->role == WindowManager
2571 ? p->properties
2572 : p->client_properties;
2573}
2574
2575void NETRootInfo::setSupported( NET::Property property, bool on ) {
2576 if ( p->role != WindowManager )
2577 return;
2578
2579 if ( on && !isSupported( property ) ) {
2580 p->properties[ PROTOCOLS ] |= property;
2581 setSupported();
2582 } else if ( !on && isSupported( property ) ) {
2583 p->properties[ PROTOCOLS ] &= ~property;
2584 setSupported();
2585 }
2586}
2587
2588void NETRootInfo::setSupported( NET::Property2 property, bool on ) {
2589 if ( p->role != WindowManager )
2590 return;
2591
2592 if ( on && !isSupported( property ) ) {
2593 p->properties[ PROTOCOLS2 ] |= property;
2594 setSupported();
2595 } else if ( !on && isSupported( property ) ) {
2596 p->properties[ PROTOCOLS2 ] &= ~property;
2597 setSupported();
2598 }
2599}
2600
2601void NETRootInfo::setSupported( NET::WindowType property, bool on ) {
2602 if ( p->role != WindowManager )
2603 return;
2604
2605 if ( on && !isSupported( property ) ) {
2606 p->properties[ WINDOW_TYPES ] |= property;
2607 setSupported();
2608 } else if ( !on && isSupported( property ) ) {
2609 p->properties[ WINDOW_TYPES ] &= ~property;
2610 setSupported();
2611 }
2612}
2613
2614void NETRootInfo::setSupported( NET::State property, bool on ) {
2615 if ( p->role != WindowManager )
2616 return;
2617
2618 if ( on && !isSupported( property ) ) {
2619 p->properties[ STATES ] |= property;
2620 setSupported();
2621 } else if ( !on && isSupported( property ) ) {
2622 p->properties[ STATES ] &= ~property;
2623 setSupported();
2624 }
2625}
2626
2627void NETRootInfo::setSupported( NET::Action property, bool on ) {
2628 if ( p->role != WindowManager )
2629 return;
2630
2631 if ( on && !isSupported( property ) ) {
2632 p->properties[ ACTIONS ] |= property;
2633 setSupported();
2634 } else if ( !on && isSupported( property ) ) {
2635 p->properties[ ACTIONS ] &= ~property;
2636 setSupported();
2637 }
2638}
2639
2640bool NETRootInfo::isSupported( NET::Property property ) const {
2641 return p->properties[ PROTOCOLS ] & property;
2642}
2643
2644bool NETRootInfo::isSupported( NET::Property2 property ) const {
2645 return p->properties[ PROTOCOLS2 ] & property;
2646}
2647
2648bool NETRootInfo::isSupported( NET::WindowType type ) const {
2649 return p->properties[ WINDOW_TYPES ] & type;
2650}
2651
2652bool NETRootInfo::isSupported( NET::State state ) const {
2653 return p->properties[ STATES ] & state;
2654}
2655
2656bool NETRootInfo::isSupported( NET::Action action ) const {
2657 return p->properties[ ACTIONS ] & action;
2658}
2659
2660const Window *NETRootInfo::clientList() const {
2661 return p->clients;
2662}
2663
2664
2665int NETRootInfo::clientListCount() const {
2666 return p->clients_count;
2667}
2668
2669
2670const Window *NETRootInfo::clientListStacking() const {
2671 return p->stacking;
2672}
2673
2674
2675int NETRootInfo::clientListStackingCount() const {
2676 return p->stacking_count;
2677}
2678
2679
2680NETSize NETRootInfo::desktopGeometry(int) const {
2681 return p->geometry.width != 0 ? p->geometry : p->rootSize;
2682}
2683
2684
2685NETPoint NETRootInfo::desktopViewport(int desktop) const {
2686 if (desktop < 1) {
2687 NETPoint pt; // set to (0,0)
2688 return pt;
2689 }
2690
2691 return p->viewport[desktop - 1];
2692}
2693
2694
2695NETRect NETRootInfo::workArea(int desktop) const {
2696 if (desktop < 1) {
2697 NETRect rt;
2698 return rt;
2699 }
2700
2701 return p->workarea[desktop - 1];
2702}
2703
2704
2705const char *NETRootInfo::desktopName(int desktop) const {
2706 if (desktop < 1) {
2707 return 0;
2708 }
2709
2710 return p->desktop_names[desktop - 1];
2711}
2712
2713
2714const Window *NETRootInfo::virtualRoots( ) const {
2715 return p->virtual_roots;
2716}
2717
2718
2719int NETRootInfo::virtualRootsCount() const {
2720 return p->virtual_roots_count;
2721}
2722
2723
2724NET::Orientation NETRootInfo::desktopLayoutOrientation() const {
2725 return p->desktop_layout_orientation;
2726}
2727
2728
2729QSize NETRootInfo::desktopLayoutColumnsRows() const {
2730 return QSize( p->desktop_layout_columns, p->desktop_layout_rows );
2731}
2732
2733
2734NET::DesktopLayoutCorner NETRootInfo::desktopLayoutCorner() const {
2735 return p->desktop_layout_corner;
2736}
2737
2738
2739int NETRootInfo::numberOfDesktops( bool ignore_viewport ) const {
2740 if( !ignore_viewport && KWindowSystem::mapViewport())
2741 return KWindowSystem::numberOfDesktops();
2742 return p->number_of_desktops == 0 ? 1 : p->number_of_desktops;
2743}
2744
2745
2746int NETRootInfo::currentDesktop( bool ignore_viewport ) const {
2747 if( !ignore_viewport && KWindowSystem::mapViewport())
2748 return KWindowSystem::currentDesktop();
2749 return p->current_desktop == 0 ? 1 : p->current_desktop;
2750}
2751
2752
2753Window NETRootInfo::activeWindow() const {
2754 return p->active;
2755}
2756
2757
2758// NETWinInfo stuffs
2759
2760const int NETWinInfo::OnAllDesktops = NET::OnAllDesktops;
2761
2762NETWinInfo::NETWinInfo(Display *display, Window window, Window rootWindow,
2763 const unsigned long properties[], int properties_size,
2764 Role role)
2765{
2766
2767#ifdef NETWMDEBUG
2768 fprintf(stderr, "NETWinInfo::NETWinInfo: constructing object with role '%s'\n",
2769 (role == WindowManager) ? "WindowManager" : "Client");
2770#endif
2771
2772 p = new NETWinInfoPrivate;
2773 p->ref = 1;
2774
2775 p->display = display;
2776 p->window = window;
2777 p->root = rootWindow;
2778 p->mapping_state = Withdrawn;
2779 p->mapping_state_dirty = True;
2780 p->state = 0;
2781 p->types[ 0 ] = Unknown;
2782 p->name = (char *) 0;
2783 p->visible_name = (char *) 0;
2784 p->icon_name = (char *) 0;
2785 p->visible_icon_name = (char *) 0;
2786 p->desktop = p->pid = p->handled_icons = 0;
2787 p->user_time = -1U;
2788 p->startup_id = NULL;
2789 p->transient_for = None;
2790 p->opacity = 0xffffffffU;
2791 p->window_group = None;
2792 p->allowed_actions = 0;
2793 p->has_net_support = false;
2794 p->class_class = (char*) 0;
2795 p->class_name = (char*) 0;
2796 p->window_role = (char*) 0;
2797 p->client_machine = (char*) 0;
2798 p->icon_sizes = NULL;
2799 p->activities = (char *) 0;
2800 p->blockCompositing = false;
2801
2802 // p->strut.left = p->strut.right = p->strut.top = p->strut.bottom = 0;
2803 // p->frame_strut.left = p->frame_strut.right = p->frame_strut.top =
2804 // p->frame_strut.bottom = 0;
2805
2806 for( int i = 0;
2807 i < PROPERTIES_SIZE;
2808 ++i )
2809 p->properties[ i ] = 0;
2810 if( properties_size > PROPERTIES_SIZE )
2811 properties_size = PROPERTIES_SIZE;
2812 for( int i = 0;
2813 i < properties_size;
2814 ++i )
2815 p->properties[ i ] = properties[ i ];
2816
2817 p->icon_count = 0;
2818
2819 p->role = role;
2820
2821 if (! netwm_atoms_created) create_netwm_atoms(p->display);
2822
2823 update(p->properties);
2824}
2825
2826
2827NETWinInfo::NETWinInfo(Display *display, Window window, Window rootWindow,
2828 unsigned long properties, Role role)
2829{
2830
2831#ifdef NETWMDEBUG
2832 fprintf(stderr, "NETWinInfo::NETWinInfo: constructing object with role '%s'\n",
2833 (role == WindowManager) ? "WindowManager" : "Client");
2834#endif
2835
2836 p = new NETWinInfoPrivate;
2837 p->ref = 1;
2838
2839 p->display = display;
2840 p->window = window;
2841 p->root = rootWindow;
2842 p->mapping_state = Withdrawn;
2843 p->mapping_state_dirty = True;
2844 p->state = 0;
2845 p->types[ 0 ] = Unknown;
2846 p->name = (char *) 0;
2847 p->visible_name = (char *) 0;
2848 p->icon_name = (char *) 0;
2849 p->visible_icon_name = (char *) 0;
2850 p->desktop = p->pid = p->handled_icons = 0;
2851 p->user_time = -1U;
2852 p->startup_id = NULL;
2853 p->transient_for = None;
2854 p->opacity = 0xffffffffU;
2855 p->window_group = None;
2856 p->allowed_actions = 0;
2857 p->has_net_support = false;
2858 p->class_class = (char*) 0;
2859 p->class_name = (char*) 0;
2860 p->window_role = (char*) 0;
2861 p->client_machine = (char*) 0;
2862 p->icon_sizes = NULL;
2863 p->activities = (char *) 0;
2864 p->blockCompositing = false;
2865
2866 // p->strut.left = p->strut.right = p->strut.top = p->strut.bottom = 0;
2867 // p->frame_strut.left = p->frame_strut.right = p->frame_strut.top =
2868 // p->frame_strut.bottom = 0;
2869
2870 for( int i = 0;
2871 i < PROPERTIES_SIZE;
2872 ++i )
2873 p->properties[ i ] = 0;
2874 p->properties[ PROTOCOLS ] = properties;
2875
2876 p->icon_count = 0;
2877
2878 p->role = role;
2879
2880 if (! netwm_atoms_created) create_netwm_atoms(p->display);
2881
2882 update(p->properties);
2883}
2884
2885
2886NETWinInfo2::NETWinInfo2(Display *display, Window window, Window rootWindow,
2887 const unsigned long properties[], int properties_size, Role role)
2888 : NETWinInfo(display, window, rootWindow, properties, properties_size, role) {
2889}
2890
2891
2892NETWinInfo2::NETWinInfo2(Display *display, Window window, Window rootWindow,
2893 unsigned long properties, Role role)
2894 : NETWinInfo(display, window, rootWindow, properties, role) {
2895}
2896
2897
2898NETWinInfo::NETWinInfo(const NETWinInfo &wininfo) {
2899 p = wininfo.p;
2900 p->ref++;
2901}
2902
2903
2904NETWinInfo::~NETWinInfo() {
2905 refdec_nwi(p);
2906
2907 if (! p->ref) delete p;
2908}
2909
2910
2911// assignment operator
2912
2913const NETWinInfo &NETWinInfo::operator=(const NETWinInfo &wininfo) {
2914
2915#ifdef NETWMDEBUG
2916 fprintf(stderr, "NETWinInfo::operator=()\n");
2917#endif
2918
2919 if (p != wininfo.p) {
2920 refdec_nwi(p);
2921
2922 if (! p->ref) delete p;
2923 }
2924
2925 p = wininfo.p;
2926 p->ref++;
2927
2928 return *this;
2929}
2930
2931
2932void NETWinInfo::setIcon(NETIcon icon, Bool replace) {
2933 setIconInternal( p->icons, p->icon_count, net_wm_icon, icon, replace );
2934}
2935
2936void NETWinInfo::setIconInternal(NETRArray<NETIcon>& icons, int& icon_count, Atom property, NETIcon icon, Bool replace) {
2937 if (p->role != Client) return;
2938
2939 int proplen, i, sz, j;
2940
2941 if (replace) {
2942
2943 for (i = 0; i < icons.size(); i++) {
2944 delete [] icons[i].data;
2945 icons[i].data = 0;
2946 icons[i].size.width = 0;
2947 icons[i].size.height = 0;
2948 }
2949
2950 icon_count = 0;
2951 }
2952
2953 // assign icon
2954 icons[icon_count] = icon;
2955 icon_count++;
2956
2957 // do a deep copy, we want to own the data
2958 NETIcon &ni = icons[icon_count - 1];
2959 sz = ni.size.width * ni.size.height;
2960 CARD32 *d = new CARD32[sz];
2961 ni.data = (unsigned char *) d;
2962 memcpy(d, icon.data, sz * sizeof(CARD32));
2963
2964 // compute property length
2965 for (i = 0, proplen = 0; i < icon_count; i++) {
2966 proplen += 2 + (icons[i].size.width *
2967 icons[i].size.height);
2968 }
2969
2970 CARD32 *d32;
2971 long *prop = new long[proplen], *pprop = prop;
2972 for (i = 0; i < icon_count; i++) {
2973 // copy size into property
2974 *pprop++ = icons[i].size.width;
2975 *pprop++ = icons[i].size.height;
2976
2977 // copy data into property
2978 sz = (icons[i].size.width * icons[i].size.height);
2979 d32 = (CARD32 *) icons[i].data;
2980 for (j = 0; j < sz; j++) *pprop++ = *d32++;
2981 }
2982
2983 XChangeProperty(p->display, p->window, property, XA_CARDINAL, 32,
2984 PropModeReplace, (unsigned char *) prop, proplen);
2985
2986 delete [] prop;
2987 delete [] p->icon_sizes;
2988 p->icon_sizes = NULL;
2989}
2990
2991
2992void NETWinInfo::setIconGeometry(NETRect geometry) {
2993 if (p->role != Client) return;
2994
2995 p->icon_geom = geometry;
2996
2997 if( geometry.size.width == 0 ) // empty
2998 XDeleteProperty(p->display, p->window, net_wm_icon_geometry);
2999 else {
3000 long data[4];
3001 data[0] = geometry.pos.x;
3002 data[1] = geometry.pos.y;
3003 data[2] = geometry.size.width;
3004 data[3] = geometry.size.height;
3005
3006 XChangeProperty(p->display, p->window, net_wm_icon_geometry, XA_CARDINAL,
3007 32, PropModeReplace, (unsigned char *) data, 4);
3008 }
3009}
3010
3011
3012void NETWinInfo::setExtendedStrut(const NETExtendedStrut& extended_strut ) {
3013 if (p->role != Client) return;
3014
3015 p->extended_strut = extended_strut;
3016
3017 long data[12];
3018 data[0] = extended_strut.left_width;
3019 data[1] = extended_strut.right_width;
3020 data[2] = extended_strut.top_width;
3021 data[3] = extended_strut.bottom_width;
3022 data[4] = extended_strut.left_start;
3023 data[5] = extended_strut.left_end;
3024 data[6] = extended_strut.right_start;
3025 data[7] = extended_strut.right_end;
3026 data[8] = extended_strut.top_start;
3027 data[9] = extended_strut.top_end;
3028 data[10] = extended_strut.bottom_start;
3029 data[11] = extended_strut.bottom_end;
3030
3031 XChangeProperty(p->display, p->window, net_wm_extended_strut, XA_CARDINAL, 32,
3032 PropModeReplace, (unsigned char *) data, 12);
3033}
3034
3035
3036void NETWinInfo::setStrut(NETStrut strut) {
3037 if (p->role != Client) return;
3038
3039 p->strut = strut;
3040
3041 long data[4];
3042 data[0] = strut.left;
3043 data[1] = strut.right;
3044 data[2] = strut.top;
3045 data[3] = strut.bottom;
3046
3047 XChangeProperty(p->display, p->window, net_wm_strut, XA_CARDINAL, 32,
3048 PropModeReplace, (unsigned char *) data, 4);
3049}
3050
3051
3052void NETWinInfo2::setFullscreenMonitors(NETFullscreenMonitors topology) {
3053 if (p->role != Client) return;
3054
3055 p->fullscreen_monitors = topology;
3056
3057 long data[4];
3058 data[0] = topology.top;
3059 data[1] = topology.bottom;
3060 data[2] = topology.left;
3061 data[3] = topology.right;
3062
3063 XChangeProperty(p->display, p->window, net_wm_fullscreen_monitors, XA_CARDINAL, 32,
3064 PropModeReplace, (unsigned char *) data, 4);
3065}
3066
3067
3068void NETWinInfo::setState(unsigned long state, unsigned long mask) {
3069 if (p->mapping_state_dirty)
3070 updateWMState();
3071
3072 // setState() needs to know the current state, so read it even if not requested
3073 if( ( p->properties[ PROTOCOLS ] & WMState ) == 0 ) {
3074 p->properties[ PROTOCOLS ] |= WMState;
3075 unsigned long props[ PROPERTIES_SIZE ] = { WMState, 0 };
3076 assert( PROPERTIES_SIZE == 2 ); // add elements above
3077 update( props );
3078 p->properties[ PROTOCOLS ] &= ~WMState;
3079 }
3080
3081 if (p->role == Client && p->mapping_state != Withdrawn) {
3082
3083#ifdef NETWMDEBUG
3084 fprintf(stderr, "NETWinInfo::setState (0x%lx, 0x%lx) (Client)\n",
3085 state, mask);
3086#endif // NETWMDEBUG
3087
3088 XEvent e;
3089 e.xclient.type = ClientMessage;
3090 e.xclient.message_type = net_wm_state;
3091 e.xclient.display = p->display;
3092 e.xclient.window = p->window;
3093 e.xclient.format = 32;
3094 e.xclient.data.l[3] = 0l;
3095 e.xclient.data.l[4] = 0l;
3096
3097 if ((mask & Modal) && ((p->state & Modal) != (state & Modal))) {
3098 e.xclient.data.l[0] = (state & Modal) ? 1 : 0;
3099 e.xclient.data.l[1] = net_wm_state_modal;
3100 e.xclient.data.l[2] = 0l;
3101
3102 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3103 }
3104
3105 if ((mask & Sticky) && ((p->state & Sticky) != (state & Sticky))) {
3106 e.xclient.data.l[0] = (state & Sticky) ? 1 : 0;
3107 e.xclient.data.l[1] = net_wm_state_sticky;
3108 e.xclient.data.l[2] = 0l;
3109
3110 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3111 }
3112
3113 if ((mask & Max) && (( (p->state&mask) & Max) != (state & Max))) {
3114
3115 unsigned long wishstate = (p->state & ~mask) | (state & mask);
3116 if ( ( (wishstate & MaxHoriz) != (p->state & MaxHoriz) )
3117 && ( (wishstate & MaxVert) != (p->state & MaxVert) ) ) {
3118 if ( (wishstate & Max) == Max ) {
3119 e.xclient.data.l[0] = 1;
3120 e.xclient.data.l[1] = net_wm_state_max_horiz;
3121 e.xclient.data.l[2] = net_wm_state_max_vert;
3122 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3123 } else if ( (wishstate & Max) == 0 ) {
3124 e.xclient.data.l[0] = 0;
3125 e.xclient.data.l[1] = net_wm_state_max_horiz;
3126 e.xclient.data.l[2] = net_wm_state_max_vert;
3127 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3128 } else {
3129 e.xclient.data.l[0] = ( wishstate & MaxHoriz ) ? 1 : 0;
3130 e.xclient.data.l[1] = net_wm_state_max_horiz;
3131 e.xclient.data.l[2] = 0;
3132 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3133 e.xclient.data.l[0] = ( wishstate & MaxVert ) ? 1 : 0;
3134 e.xclient.data.l[1] = net_wm_state_max_vert;
3135 e.xclient.data.l[2] = 0;
3136 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3137 }
3138 } else if ( (wishstate & MaxVert) != (p->state & MaxVert) ) {
3139 e.xclient.data.l[0] = ( wishstate & MaxVert ) ? 1 : 0;
3140 e.xclient.data.l[1] = net_wm_state_max_vert;
3141 e.xclient.data.l[2] = 0;
3142 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3143 } else if ( (wishstate & MaxHoriz) != (p->state & MaxHoriz) ) {
3144 e.xclient.data.l[0] = ( wishstate & MaxHoriz ) ? 1 : 0;
3145 e.xclient.data.l[1] = net_wm_state_max_horiz;
3146 e.xclient.data.l[2] = 0;
3147 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3148 }
3149 }
3150
3151 if ((mask & Shaded) && ((p->state & Shaded) != (state & Shaded))) {
3152 e.xclient.data.l[0] = (state & Shaded) ? 1 : 0;
3153 e.xclient.data.l[1] = net_wm_state_shaded;
3154 e.xclient.data.l[2] = 0l;
3155
3156 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3157 }
3158
3159 if ((mask & SkipTaskbar) &&
3160 ((p->state & SkipTaskbar) != (state & SkipTaskbar))) {
3161 e.xclient.data.l[0] = (state & SkipTaskbar) ? 1 : 0;
3162 e.xclient.data.l[1] = net_wm_state_skip_taskbar;
3163 e.xclient.data.l[2] = 0l;
3164
3165 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3166 }
3167
3168 if ((mask & SkipPager) &&
3169 ((p->state & SkipPager) != (state & SkipPager))) {
3170 e.xclient.data.l[0] = (state & SkipPager) ? 1 : 0;
3171 e.xclient.data.l[1] = net_wm_state_skip_pager;
3172 e.xclient.data.l[2] = 0l;
3173
3174 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3175 }
3176
3177 if ((mask & Hidden) &&
3178 ((p->state & Hidden) != (state & Hidden))) {
3179 e.xclient.data.l[0] = (state & Hidden) ? 1 : 0;
3180 e.xclient.data.l[1] = net_wm_state_hidden;
3181 e.xclient.data.l[2] = 0l;
3182
3183 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3184 }
3185
3186 if ((mask & FullScreen) &&
3187 ((p->state & FullScreen) != (state & FullScreen))) {
3188 e.xclient.data.l[0] = (state & FullScreen) ? 1 : 0;
3189 e.xclient.data.l[1] = net_wm_state_fullscreen;
3190 e.xclient.data.l[2] = 0l;
3191
3192 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3193 }
3194
3195 if ((mask & KeepAbove) &&
3196 ((p->state & KeepAbove) != (state & KeepAbove))) {
3197 e.xclient.data.l[0] = (state & KeepAbove) ? 1 : 0;
3198 e.xclient.data.l[1] = net_wm_state_above;
3199 e.xclient.data.l[2] = 0l;
3200
3201 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3202 }
3203
3204 if ((mask & KeepBelow) &&
3205 ((p->state & KeepBelow) != (state & KeepBelow))) {
3206 e.xclient.data.l[0] = (state & KeepBelow) ? 1 : 0;
3207 e.xclient.data.l[1] = net_wm_state_below;
3208 e.xclient.data.l[2] = 0l;
3209
3210 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3211 }
3212
3213 if ((mask & StaysOnTop) && ((p->state & StaysOnTop) != (state & StaysOnTop))) {
3214 e.xclient.data.l[0] = (state & StaysOnTop) ? 1 : 0;
3215 e.xclient.data.l[1] = net_wm_state_stays_on_top;
3216 e.xclient.data.l[2] = 0l;
3217
3218 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3219 }
3220
3221 if ((mask & DemandsAttention) &&
3222 ((p->state & DemandsAttention) != (state & DemandsAttention))) {
3223 e.xclient.data.l[0] = (state & DemandsAttention) ? 1 : 0;
3224 e.xclient.data.l[1] = net_wm_state_demands_attention;
3225 e.xclient.data.l[2] = 0l;
3226
3227 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3228 }
3229
3230 } else {
3231 p->state &= ~mask;
3232 p->state |= state;
3233
3234 long data[50];
3235 int count = 0;
3236
3237 // hints
3238 if (p->state & Modal) data[count++] = net_wm_state_modal;
3239 if (p->state & MaxVert) data[count++] = net_wm_state_max_vert;
3240 if (p->state & MaxHoriz) data[count++] = net_wm_state_max_horiz;
3241 if (p->state & Shaded) data[count++] = net_wm_state_shaded;
3242 if (p->state & Hidden) data[count++] = net_wm_state_hidden;
3243 if (p->state & FullScreen) data[count++] = net_wm_state_fullscreen;
3244 if (p->state & DemandsAttention) data[count++] = net_wm_state_demands_attention;
3245
3246 // policy
3247 if (p->state & KeepAbove) data[count++] = net_wm_state_above;
3248 if (p->state & KeepBelow) data[count++] = net_wm_state_below;
3249 if (p->state & StaysOnTop) data[count++] = net_wm_state_stays_on_top;
3250 if (p->state & Sticky) data[count++] = net_wm_state_sticky;
3251 if (p->state & SkipTaskbar) data[count++] = net_wm_state_skip_taskbar;
3252 if (p->state & SkipPager) data[count++] = net_wm_state_skip_pager;
3253
3254#ifdef NETWMDEBUG
3255 fprintf(stderr, "NETWinInfo::setState: setting state property (%d)\n", count);
3256 for (int i = 0; i < count; i++) {
3257 char* data_ret = XGetAtomName(p->display, (Atom) data[i]);
3258 fprintf(stderr, "NETWinInfo::setState: state %ld '%s'\n",
3259 data[i], data_ret);
3260 if ( data_ret )
3261 XFree( data_ret );
3262 }
3263
3264#endif
3265
3266 XChangeProperty(p->display, p->window, net_wm_state, XA_ATOM, 32,
3267 PropModeReplace, (unsigned char *) data, count);
3268 }
3269}
3270
3271
3272void NETWinInfo::setWindowType(WindowType type) {
3273 if (p->role != Client) return;
3274
3275 int len;
3276 long data[2];
3277
3278 switch (type) {
3279 case Override:
3280 // spec extension: override window type. we must comply with the spec
3281 // and provide a fall back (normal seems best)
3282 data[0] = kde_net_wm_window_type_override;
3283 data[1] = net_wm_window_type_normal;
3284 len = 2;
3285 break;
3286
3287 case Dialog:
3288 data[0] = net_wm_window_type_dialog;
3289 data[1] = None;
3290 len = 1;
3291 break;
3292
3293 case Menu:
3294 data[0] = net_wm_window_type_menu;
3295 data[1] = None;
3296 len = 1;
3297 break;
3298
3299 case TopMenu:
3300 // spec extension: override window type. we must comply with the spec
3301 // and provide a fall back (dock seems best)
3302 data[0] = kde_net_wm_window_type_topmenu;
3303 data[1] = net_wm_window_type_dock;
3304 len = 2;
3305 break;
3306
3307 case Toolbar:
3308 data[0] = net_wm_window_type_toolbar;
3309 data[1] = None;
3310 len = 1;
3311 break;
3312
3313 case Dock:
3314 data[0] = net_wm_window_type_dock;
3315 data[1] = None;
3316 len = 1;
3317 break;
3318
3319 case Desktop:
3320 data[0] = net_wm_window_type_desktop;
3321 data[1] = None;
3322 len = 1;
3323 break;
3324
3325 case Utility:
3326 data[0] = net_wm_window_type_utility;
3327 data[1] = net_wm_window_type_dialog; // fallback for old netwm version
3328 len = 2;
3329 break;
3330
3331 case Splash:
3332 data[0] = net_wm_window_type_splash;
3333 data[1] = net_wm_window_type_dock; // fallback (dock seems best)
3334 len = 2;
3335 break;
3336
3337 case DropdownMenu:
3338 data[0] = net_wm_window_type_dropdown_menu;
3339 data[1] = net_wm_window_type_menu; // fallback (tearoff seems to be the best)
3340 len = 1;
3341 break;
3342
3343 case PopupMenu:
3344 data[0] = net_wm_window_type_popup_menu;
3345 data[1] = net_wm_window_type_menu; // fallback (tearoff seems to be the best)
3346 len = 1;
3347 break;
3348
3349 case Tooltip:
3350 data[0] = net_wm_window_type_tooltip;
3351 data[1] = None;
3352 len = 1;
3353 break;
3354
3355 case Notification:
3356 data[0] = net_wm_window_type_notification;
3357 data[1] = net_wm_window_type_utility; // fallback (utility seems to be the best)
3358 len = 1;
3359 break;
3360
3361 case ComboBox:
3362 data[0] = net_wm_window_type_combobox;
3363 data[1] = None;
3364 len = 1;
3365 break;
3366
3367 case DNDIcon:
3368 data[0] = net_wm_window_type_dnd;
3369 data[1] = None;
3370 len = 1;
3371 break;
3372
3373 default:
3374 case Normal:
3375 data[0] = net_wm_window_type_normal;
3376 data[1] = None;
3377 len = 1;
3378 break;
3379 }
3380
3381 XChangeProperty(p->display, p->window, net_wm_window_type, XA_ATOM, 32,
3382 PropModeReplace, (unsigned char *) &data, len);
3383}
3384
3385
3386void NETWinInfo::setName(const char *name) {
3387 if (p->role != Client) return;
3388
3389 delete [] p->name;
3390 p->name = nstrdup(name);
3391 if( p->name[ 0 ] != '\0' )
3392 XChangeProperty(p->display, p->window, net_wm_name, UTF8_STRING, 8,
3393 PropModeReplace, (unsigned char *) p->name,
3394 strlen(p->name));
3395 else
3396 XDeleteProperty(p->display, p->window, net_wm_name);
3397}
3398
3399
3400void NETWinInfo::setVisibleName(const char *visibleName) {
3401 if (p->role != WindowManager) return;
3402
3403 delete [] p->visible_name;
3404 p->visible_name = nstrdup(visibleName);
3405 if( p->visible_name[ 0 ] != '\0' )
3406 XChangeProperty(p->display, p->window, net_wm_visible_name, UTF8_STRING, 8,
3407 PropModeReplace, (unsigned char *) p->visible_name,
3408 strlen(p->visible_name));
3409 else
3410 XDeleteProperty(p->display, p->window, net_wm_visible_name);
3411}
3412
3413
3414void NETWinInfo::setIconName(const char *iconName) {
3415 if (p->role != Client) return;
3416
3417 delete [] p->icon_name;
3418 p->icon_name = nstrdup(iconName);
3419 if( p->icon_name[ 0 ] != '\0' )
3420 XChangeProperty(p->display, p->window, net_wm_icon_name, UTF8_STRING, 8,
3421 PropModeReplace, (unsigned char *) p->icon_name,
3422 strlen(p->icon_name));
3423 else
3424 XDeleteProperty(p->display, p->window, net_wm_icon_name);
3425}
3426
3427
3428void NETWinInfo::setVisibleIconName(const char *visibleIconName) {
3429 if (p->role != WindowManager) return;
3430
3431 delete [] p->visible_icon_name;
3432 p->visible_icon_name = nstrdup(visibleIconName);
3433 if( p->visible_icon_name[ 0 ] != '\0' )
3434 XChangeProperty(p->display, p->window, net_wm_visible_icon_name, UTF8_STRING, 8,
3435 PropModeReplace, (unsigned char *) p->visible_icon_name,
3436 strlen(p->visible_icon_name));
3437 else
3438 XDeleteProperty(p->display, p->window, net_wm_visible_icon_name);
3439}
3440
3441
3442void NETWinInfo::setDesktop(int desktop, bool ignore_viewport) {
3443 if (p->mapping_state_dirty)
3444 updateWMState();
3445
3446 if (p->role == Client && p->mapping_state != Withdrawn) {
3447 // we only send a ClientMessage if we are 1) a client and 2) managed
3448
3449 if ( desktop == 0 )
3450 return; // we can't do that while being managed
3451
3452 if( !ignore_viewport && KWindowSystem::mapViewport()) {
3453 KWindowSystem::setOnDesktop( p->window, desktop );
3454 return;
3455 }
3456
3457 XEvent e;
3458 e.xclient.type = ClientMessage;
3459 e.xclient.message_type = net_wm_desktop;
3460 e.xclient.display = p->display;
3461 e.xclient.window = p->window;
3462 e.xclient.format = 32;
3463 e.xclient.data.l[0] = desktop == OnAllDesktops ? OnAllDesktops : desktop - 1;
3464 e.xclient.data.l[1] = 0l;
3465 e.xclient.data.l[2] = 0l;
3466 e.xclient.data.l[3] = 0l;
3467 e.xclient.data.l[4] = 0l;
3468
3469 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3470 } else {
3471 // otherwise we just set or remove the property directly
3472 p->desktop = desktop;
3473 long d = desktop;
3474
3475 if ( d != OnAllDesktops ) {
3476 if ( d == 0 ) {
3477 XDeleteProperty( p->display, p->window, net_wm_desktop );
3478 return;
3479 }
3480
3481 d -= 1;
3482 }
3483
3484 XChangeProperty(p->display, p->window, net_wm_desktop, XA_CARDINAL, 32,
3485 PropModeReplace, (unsigned char *) &d, 1);
3486 }
3487}
3488
3489
3490void NETWinInfo::setPid(int pid) {
3491 if (p->role != Client) return;
3492
3493 p->pid = pid;
3494 long d = pid;
3495 XChangeProperty(p->display, p->window, net_wm_pid, XA_CARDINAL, 32,
3496 PropModeReplace, (unsigned char *) &d, 1);
3497}
3498
3499
3500void NETWinInfo::setHandledIcons(Bool handled) {
3501 if (p->role != Client) return;
3502
3503 p->handled_icons = handled;
3504 long d = handled;
3505 XChangeProperty(p->display, p->window, net_wm_handled_icons, XA_CARDINAL, 32,
3506 PropModeReplace, (unsigned char *) &d, 1);
3507}
3508
3509void NETWinInfo::setStartupId(const char* id) {
3510 if (p->role != Client) return;
3511
3512 delete[] p->startup_id;
3513 p->startup_id = nstrdup(id);
3514 XChangeProperty(p->display, p->window, net_startup_id, UTF8_STRING, 8,
3515 PropModeReplace, reinterpret_cast< unsigned char* >( p->startup_id ),
3516 strlen( p->startup_id ));
3517}
3518
3519void NETWinInfo::setOpacity(unsigned long opacity) {
3520// if (p->role != Client) return;
3521
3522 p->opacity = opacity;
3523 XChangeProperty(p->display, p->window, net_wm_window_opacity, XA_CARDINAL, 32,
3524 PropModeReplace, reinterpret_cast< unsigned char* >( &p->opacity ), 1);
3525}
3526
3527void NETWinInfo::setAllowedActions( unsigned long actions ) {
3528 if( p->role != WindowManager )
3529 return;
3530 long data[50];
3531 int count = 0;
3532
3533 p->allowed_actions = actions;
3534 if (p->allowed_actions & ActionMove) data[count++] = net_wm_action_move;
3535 if (p->allowed_actions & ActionResize) data[count++] = net_wm_action_resize;
3536 if (p->allowed_actions & ActionMinimize) data[count++] = net_wm_action_minimize;
3537 if (p->allowed_actions & ActionShade) data[count++] = net_wm_action_shade;
3538 if (p->allowed_actions & ActionStick) data[count++] = net_wm_action_stick;
3539 if (p->allowed_actions & ActionMaxVert) data[count++] = net_wm_action_max_vert;
3540 if (p->allowed_actions & ActionMaxHoriz) data[count++] = net_wm_action_max_horiz;
3541 if (p->allowed_actions & ActionFullScreen) data[count++] = net_wm_action_fullscreen;
3542 if (p->allowed_actions & ActionChangeDesktop) data[count++] = net_wm_action_change_desk;
3543 if (p->allowed_actions & ActionClose) data[count++] = net_wm_action_close;
3544
3545#ifdef NETWMDEBUG
3546 fprintf(stderr, "NETWinInfo::setAllowedActions: setting property (%d)\n", count);
3547 for (int i = 0; i < count; i++) {
3548 char* data_ret = XGetAtomName(p->display, (Atom) data[i]);
3549 fprintf(stderr, "NETWinInfo::setAllowedActions: action %ld '%s'\n",
3550 data[i], data_ret);
3551 if ( data_ret )
3552 XFree(data_ret);
3553 }
3554#endif
3555
3556 XChangeProperty(p->display, p->window, net_wm_allowed_actions, XA_ATOM, 32,
3557 PropModeReplace, (unsigned char *) data, count);
3558}
3559
3560void NETWinInfo::setFrameExtents(NETStrut strut) {
3561 if (p->role != WindowManager) return;
3562
3563 p->frame_strut = strut;
3564
3565 long d[4];
3566 d[0] = strut.left;
3567 d[1] = strut.right;
3568 d[2] = strut.top;
3569 d[3] = strut.bottom;
3570
3571 XChangeProperty(p->display, p->window, net_frame_extents, XA_CARDINAL, 32,
3572 PropModeReplace, (unsigned char *) d, 4);
3573 XChangeProperty(p->display, p->window, kde_net_wm_frame_strut, XA_CARDINAL, 32,
3574 PropModeReplace, (unsigned char *) d, 4);
3575}
3576
3577NETStrut NETWinInfo::frameExtents() const {
3578 return p->frame_strut;
3579}
3580
3581void NETWinInfo::setFrameOverlap(NETStrut strut) {
3582 if (strut.left != -1 || strut.top != -1 || strut.right != -1 || strut.bottom != -1) {
3583 strut.left = qMax(0, strut.left);
3584 strut.top = qMax(0, strut.top);
3585 strut.right = qMax(0, strut.right);
3586 strut.bottom = qMax(0, strut.bottom);
3587 }
3588
3589 p->frame_overlap = strut;
3590
3591 long d[4];
3592 d[0] = strut.left;
3593 d[1] = strut.right;
3594 d[2] = strut.top;
3595 d[3] = strut.bottom;
3596
3597 XChangeProperty(p->display, p->window, kde_net_wm_frame_overlap, XA_CARDINAL, 32,
3598 PropModeReplace, (unsigned char *) d, 4);
3599}
3600
3601NETStrut NETWinInfo::frameOverlap() const {
3602 return p->frame_overlap;
3603}
3604
3605void NETWinInfo::kdeGeometry(NETRect& frame, NETRect& window) {
3606 if (p->win_geom.size.width == 0 || p->win_geom.size.height == 0) {
3607 Window unused;
3608 int x, y;
3609 unsigned int w, h, junk;
3610 XGetGeometry(p->display, p->window, &unused, &x, &y, &w, &h, &junk, &junk);
3611 XTranslateCoordinates(p->display, p->window, p->root, 0, 0, &x, &y, &unused
3612 );
3613
3614 p->win_geom.pos.x = x;
3615 p->win_geom.pos.y = y;
3616
3617 p->win_geom.size.width = w;
3618 p->win_geom.size.height = h;
3619 }
3620// TODO try to work also without _NET_WM_FRAME_EXTENTS
3621 window = p->win_geom;
3622
3623 frame.pos.x = window.pos.x - p->frame_strut.left;
3624 frame.pos.y = window.pos.y - p->frame_strut.top;
3625 frame.size.width = window.size.width + p->frame_strut.left + p->frame_strut.right;
3626 frame.size.height = window.size.height + p->frame_strut.top + p->frame_strut.bottom;
3627}
3628
3629
3630NETIcon NETWinInfo::icon(int width, int height) const {
3631 return iconInternal( p->icons, p->icon_count, width, height );
3632}
3633
3634const int* NETWinInfo::iconSizes() const {
3635 if( p->icon_sizes == NULL ) {
3636 p->icon_sizes = new int[ p->icon_count * 2 + 2 ];
3637 for( int i = 0;
3638 i < p->icon_count;
3639 ++i ) {
3640 p->icon_sizes[ i * 2 ] = p->icons[ i ].size.width;
3641 p->icon_sizes[ i * 2 + 1 ] = p->icons[ i ].size.height;
3642 }
3643 p->icon_sizes[ p->icon_count * 2 ] = 0; // terminator
3644 p->icon_sizes[ p->icon_count * 2 + 1 ] = 0;
3645 }
3646 return p->icon_sizes;
3647}
3648
3649NETIcon NETWinInfo::iconInternal(NETRArray<NETIcon>& icons, int icon_count, int width, int height) const {
3650 NETIcon result;
3651
3652 if ( !icon_count ) {
3653 result.size.width = 0;
3654 result.size.height = 0;
3655 result.data = 0;
3656 return result;
3657 }
3658
3659 // find the largest icon
3660 result = icons[0];
3661 for (int i = 1; i < icons.size(); i++) {
3662 if( icons[i].size.width >= result.size.width &&
3663 icons[i].size.height >= result.size.height )
3664 result = icons[i];
3665 }
3666
3667 // return the largest icon if w and h are -1
3668 if (width == -1 && height == -1) return result;
3669
3670 // find the icon that's closest in size to w x h...
3671 for (int i = 0; i < icons.size(); i++) {
3672 if ((icons[i].size.width >= width &&
3673 icons[i].size.width < result.size.width) &&
3674 (icons[i].size.height >= height &&
3675 icons[i].size.height < result.size.height))
3676 result = icons[i];
3677 }
3678
3679 return result;
3680}
3681
3682void NETWinInfo::setUserTime( Time time ) {
3683 if (p->role != Client) return;
3684
3685 p->user_time = time;
3686 long d = time;
3687 XChangeProperty(p->display, p->window, net_wm_user_time, XA_CARDINAL, 32,
3688 PropModeReplace, (unsigned char *) &d, 1);
3689}
3690
3691
3692unsigned long NETWinInfo::event(XEvent *ev )
3693{
3694 unsigned long props[ 1 ];
3695 event( ev, props, 1 );
3696 return props[ 0 ];
3697}
3698
3699void NETWinInfo::event(XEvent *event, unsigned long* properties, int properties_size ) {
3700 unsigned long props[ PROPERTIES_SIZE ] = { 0, 0 };
3701 assert( PROPERTIES_SIZE == 2 ); // add elements above
3702 unsigned long& dirty = props[ PROTOCOLS ];
3703 unsigned long& dirty2 = props[ PROTOCOLS2 ];
3704 bool do_update = false;
3705
3706 if (p->role == WindowManager && event->type == ClientMessage &&
3707 event->xclient.format == 32) {
3708
3709#ifdef NETWMDEBUG
3710 fprintf(stderr, "NETWinInfo::event: handling ClientMessage event\n");
3711#endif // NETWMDEBUG
3712
3713 if (event->xclient.message_type == net_wm_state) {
3714 dirty = WMState;
3715
3716 // we need to generate a change mask
3717
3718#ifdef NETWMDEBUG
3719 fprintf(stderr,
3720 "NETWinInfo::event: state client message, getting new state/mask\n");
3721#endif
3722
3723 int i;
3724 long state = 0, mask = 0;
3725
3726 for (i = 1; i < 3; i++) {
3727#ifdef NETWMDEBUG
3728 char* debug_txt = XGetAtomName(p->display, (Atom) event->xclient.data.l[i]);
3729 fprintf(stderr, "NETWinInfo::event: message %ld '%s'\n",
3730 event->xclient.data.l[i], debug_txt );
3731 if ( debug_txt )
3732 XFree( debug_txt );
3733#endif
3734
3735 if ((Atom) event->xclient.data.l[i] == net_wm_state_modal)
3736 mask |= Modal;
3737 else if ((Atom) event->xclient.data.l[i] == net_wm_state_sticky)
3738 mask |= Sticky;
3739 else if ((Atom) event->xclient.data.l[i] == net_wm_state_max_vert)
3740 mask |= MaxVert;
3741 else if ((Atom) event->xclient.data.l[i] == net_wm_state_max_horiz)
3742 mask |= MaxHoriz;
3743 else if ((Atom) event->xclient.data.l[i] == net_wm_state_shaded)
3744 mask |= Shaded;
3745 else if ((Atom) event->xclient.data.l[i] == net_wm_state_skip_taskbar)
3746 mask |= SkipTaskbar;
3747 else if ((Atom) event->xclient.data.l[i] == net_wm_state_skip_pager)
3748 mask |= SkipPager;
3749 else if ((Atom) event->xclient.data.l[i] == net_wm_state_hidden)
3750 mask |= Hidden;
3751 else if ((Atom) event->xclient.data.l[i] == net_wm_state_fullscreen)
3752 mask |= FullScreen;
3753 else if ((Atom) event->xclient.data.l[i] == net_wm_state_above)
3754 mask |= KeepAbove;
3755 else if ((Atom) event->xclient.data.l[i] == net_wm_state_below)
3756 mask |= KeepBelow;
3757 else if ((Atom) event->xclient.data.l[i] == net_wm_state_demands_attention)
3758 mask |= DemandsAttention;
3759 else if ((Atom) event->xclient.data.l[i] == net_wm_state_stays_on_top)
3760 mask |= StaysOnTop;
3761 }
3762
3763 // when removing, we just leave newstate == 0
3764 switch (event->xclient.data.l[0]) {
3765 case 1: // set
3766 // to set... the change state should be the same as the mask
3767 state = mask;
3768 break;
3769
3770 case 2: // toggle
3771 // to toggle, we need to xor the current state with the new state
3772 state = (p->state & mask) ^ mask;
3773 break;
3774
3775 default:
3776 // to clear state, the new state should stay zero
3777 ;
3778 }
3779
3780#ifdef NETWMDEBUG
3781 fprintf(stderr, "NETWinInfo::event: calling changeState(%lx, %lx)\n",
3782 state, mask);
3783#endif
3784
3785 changeState(state, mask);
3786 } else if (event->xclient.message_type == net_wm_desktop) {
3787 dirty = WMDesktop;
3788
3789 if( event->xclient.data.l[0] == OnAllDesktops )
3790 changeDesktop( OnAllDesktops );
3791 else
3792 changeDesktop(event->xclient.data.l[0] + 1);
3793 } else if (event->xclient.message_type == net_wm_fullscreen_monitors) {
3794 dirty2 = WM2FullscreenMonitors;
3795
3796 NETFullscreenMonitors topology;
3797 topology.top = event->xclient.data.l[0];
3798 topology.bottom = event->xclient.data.l[1];
3799 topology.left = event->xclient.data.l[2];
3800 topology.right = event->xclient.data.l[3];
3801
3802#ifdef NETWMDEBUG
3803 fprintf(stderr, "NETWinInfo2::event: calling changeFullscreenMonitors"
3804 "(%ld, %ld, %ld, %ld, %ld)\n",
3805 event->xclient.window,
3806 event->xclient.data.l[0],
3807 event->xclient.data.l[1],
3808 event->xclient.data.l[2],
3809 event->xclient.data.l[3]
3810 );
3811#endif
3812 if (NETWinInfo2* this2 = dynamic_cast< NETWinInfo2* >( this ))
3813 this2->changeFullscreenMonitors(topology);
3814 }
3815 }
3816
3817 if (event->type == PropertyNotify) {
3818
3819#ifdef NETWMDEBUG
3820 fprintf(stderr, "NETWinInfo::event: handling PropertyNotify event\n");
3821#endif
3822
3823 XEvent pe = *event;
3824
3825 Bool done = False;
3826 Bool compaction = False;
3827 while (! done) {
3828
3829#ifdef NETWMDEBUG
3830 fprintf(stderr, "NETWinInfo::event: loop fire\n");
3831#endif
3832
3833 if (pe.xproperty.atom == net_wm_name)
3834 dirty |= WMName;
3835 else if (pe.xproperty.atom == net_wm_visible_name)
3836 dirty |= WMVisibleName;
3837 else if (pe.xproperty.atom == net_wm_desktop)
3838 dirty |= WMDesktop;
3839 else if (pe.xproperty.atom == net_wm_window_type)
3840 dirty |=WMWindowType;
3841 else if (pe.xproperty.atom == net_wm_state)
3842 dirty |= WMState;
3843 else if (pe.xproperty.atom == net_wm_strut)
3844 dirty |= WMStrut;
3845 else if (pe.xproperty.atom == net_wm_extended_strut)
3846 dirty2 |= WM2ExtendedStrut;
3847 else if (pe.xproperty.atom == net_wm_icon_geometry)
3848 dirty |= WMIconGeometry;
3849 else if (pe.xproperty.atom == net_wm_icon)
3850 dirty |= WMIcon;
3851 else if (pe.xproperty.atom == net_wm_pid)
3852 dirty |= WMPid;
3853 else if (pe.xproperty.atom == net_wm_handled_icons)
3854 dirty |= WMHandledIcons;
3855 else if (pe.xproperty.atom == net_startup_id)
3856 dirty2 |= WM2StartupId;
3857 else if (pe.xproperty.atom == net_wm_window_opacity)
3858 dirty2 |= WM2Opacity;
3859 else if (pe.xproperty.atom == net_wm_allowed_actions)
3860 dirty2 |= WM2AllowedActions;
3861 else if (pe.xproperty.atom == xa_wm_state)
3862 dirty |= XAWMState;
3863 else if (pe.xproperty.atom == net_frame_extents)
3864 dirty |= WMFrameExtents;
3865 else if (pe.xproperty.atom == kde_net_wm_frame_strut)
3866 dirty |= WMFrameExtents;
3867 else if (pe.xproperty.atom == kde_net_wm_frame_overlap)
3868 dirty2 |= WM2FrameOverlap;
3869 else if (pe.xproperty.atom == net_wm_icon_name)
3870 dirty |= WMIconName;
3871 else if (pe.xproperty.atom == net_wm_visible_icon_name)
3872 dirty |= WMVisibleIconName;
3873 else if (pe.xproperty.atom == net_wm_user_time)
3874 dirty2 |= WM2UserTime;
3875 else if (pe.xproperty.atom == XA_WM_HINTS)
3876 dirty2 |= WM2GroupLeader;
3877 else if (pe.xproperty.atom == XA_WM_TRANSIENT_FOR)
3878 dirty2 |= WM2TransientFor;
3879 else if (pe.xproperty.atom == XA_WM_CLASS)
3880 dirty2 |= WM2WindowClass;
3881 else if (pe.xproperty.atom == wm_window_role)
3882 dirty2 |= WM2WindowRole;
3883 else if (pe.xproperty.atom == XA_WM_CLIENT_MACHINE)
3884 dirty2 |= WM2ClientMachine;
3885 else if (pe.xproperty.atom == kde_net_wm_activities)
3886 dirty2 |= WM2Activities;
3887 else if (pe.xproperty.atom == kde_net_wm_block_compositing)
3888 dirty2 |= WM2BlockCompositing;
3889 else if (pe.xproperty.atom == kde_net_wm_shadow)
3890 dirty2 |= WM2KDEShadow;
3891 else {
3892
3893#ifdef NETWMDEBUG
3894 fprintf(stderr, "NETWinInfo::event: putting back event and breaking\n");
3895#endif
3896
3897 if ( compaction )
3898 XPutBackEvent(p->display, &pe);
3899 break;
3900 }
3901
3902 if (false && XCheckTypedWindowEvent(p->display, p->window, PropertyNotify, &pe) )
3903 compaction = True;
3904 else
3905 break;
3906 }
3907
3908 do_update = true;
3909 } else if (event->type == ConfigureNotify) {
3910
3911#ifdef NETWMDEBUG
3912 fprintf(stderr, "NETWinInfo::event: handling ConfigureNotify event\n");
3913#endif
3914
3915 dirty |= WMGeometry;
3916
3917 // update window geometry
3918 p->win_geom.pos.x = event->xconfigure.x;
3919 p->win_geom.pos.y = event->xconfigure.y;
3920 p->win_geom.size.width = event->xconfigure.width;
3921 p->win_geom.size.height = event->xconfigure.height;
3922 }
3923
3924 if( do_update )
3925 update( props );
3926
3927 if( properties_size > PROPERTIES_SIZE )
3928 properties_size = PROPERTIES_SIZE;
3929 for( int i = 0;
3930 i < properties_size;
3931 ++i )
3932 properties[ i ] = props[ i ];
3933}
3934
3935void NETWinInfo::updateWMState() {
3936 unsigned long props[ PROPERTIES_SIZE ] = { XAWMState, 0 };
3937 assert( PROPERTIES_SIZE == 2 ); // add elements above
3938 update( props );
3939}
3940
3941void NETWinInfo::update(const unsigned long dirty_props[]) {
3942 Atom type_ret;
3943 int format_ret;
3944 unsigned long nitems_ret, unused;
3945 unsigned char *data_ret;
3946 unsigned long props[ PROPERTIES_SIZE ];
3947 for( int i = 0;
3948 i < PROPERTIES_SIZE;
3949 ++i )
3950 props[ i ] = dirty_props[ i ] & p->properties[ i ];
3951 const unsigned long& dirty = props[ PROTOCOLS ];
3952 const unsigned long& dirty2 = props[ PROTOCOLS2 ];
3953
3954 // we *always* want to update WM_STATE if set in dirty_props
3955 if( dirty_props[ PROTOCOLS ] & XAWMState )
3956 props[ PROTOCOLS ] |= XAWMState;
3957
3958 if (dirty & XAWMState) {
3959 p->mapping_state = Withdrawn;
3960 if (XGetWindowProperty(p->display, p->window, xa_wm_state, 0l, 1l,
3961 False, xa_wm_state, &type_ret, &format_ret,
3962 &nitems_ret, &unused, &data_ret)
3963 == Success) {
3964 if (type_ret == xa_wm_state && format_ret == 32 &&
3965 nitems_ret == 1) {
3966 long *state = (long *) data_ret;
3967
3968 switch(*state) {
3969 case IconicState:
3970 p->mapping_state = Iconic;
3971 break;
3972 case NormalState:
3973 p->mapping_state = Visible;
3974 break;
3975 case WithdrawnState:
3976 default:
3977 p->mapping_state = Withdrawn;
3978 break;
3979 }
3980
3981 p->mapping_state_dirty = False;
3982 }
3983 if ( data_ret )
3984 XFree(data_ret);
3985 }
3986 }
3987
3988 if (dirty & WMState) {
3989 p->state = 0;
3990 if (XGetWindowProperty(p->display, p->window, net_wm_state, 0l, 2048l,
3991 False, XA_ATOM, &type_ret, &format_ret,
3992 &nitems_ret, &unused, &data_ret)
3993 == Success) {
3994 if (type_ret == XA_ATOM && format_ret == 32 && nitems_ret > 0) {
3995 // determine window state
3996#ifdef NETWMDEBUG
3997 fprintf(stderr, "NETWinInfo::update: updating window state (%ld)\n",
3998 nitems_ret);
3999#endif
4000
4001 long *states = (long *) data_ret;
4002 unsigned long count;
4003
4004 for (count = 0; count < nitems_ret; count++) {
4005#ifdef NETWMDEBUG
4006 char* data_ret = XGetAtomName(p->display, (Atom) states[count]);
4007 fprintf(stderr,
4008 "NETWinInfo::update: adding window state %ld '%s'\n",
4009 states[count], data_ret );
4010 if ( data_ret )
4011 XFree( data_ret );
4012#endif
4013
4014 if ((Atom) states[count] == net_wm_state_modal)
4015 p->state |= Modal;
4016 else if ((Atom) states[count] == net_wm_state_sticky)
4017 p->state |= Sticky;
4018 else if ((Atom) states[count] == net_wm_state_max_vert)
4019 p->state |= MaxVert;
4020 else if ((Atom) states[count] == net_wm_state_max_horiz)
4021 p->state |= MaxHoriz;
4022 else if ((Atom) states[count] == net_wm_state_shaded)
4023 p->state |= Shaded;
4024 else if ((Atom) states[count] == net_wm_state_skip_taskbar)
4025 p->state |= SkipTaskbar;
4026 else if ((Atom) states[count] == net_wm_state_skip_pager)
4027 p->state |= SkipPager;
4028 else if ((Atom) states[count] == net_wm_state_hidden)
4029 p->state |= Hidden;
4030 else if ((Atom) states[count] == net_wm_state_fullscreen)
4031 p->state |= FullScreen;
4032 else if ((Atom) states[count] == net_wm_state_above)
4033 p->state |= KeepAbove;
4034 else if ((Atom) states[count] == net_wm_state_below)
4035 p->state |= KeepBelow;
4036 else if ((Atom) states[count] == net_wm_state_demands_attention)
4037 p->state |= DemandsAttention;
4038 else if ((Atom) states[count] == net_wm_state_stays_on_top)
4039 p->state |= StaysOnTop;
4040 }
4041 }
4042 if ( data_ret )
4043 XFree(data_ret);
4044 }
4045 }
4046
4047 if (dirty & WMDesktop) {
4048 p->desktop = 0;
4049 if (XGetWindowProperty(p->display, p->window, net_wm_desktop, 0l, 1l,
4050 False, XA_CARDINAL, &type_ret,
4051 &format_ret, &nitems_ret,
4052 &unused, &data_ret)
4053 == Success) {
4054 if (type_ret == XA_CARDINAL && format_ret == 32 &&
4055 nitems_ret == 1) {
4056 p->desktop = *((long *) data_ret);
4057 if ((signed) p->desktop != OnAllDesktops)
4058 p->desktop++;
4059
4060 if ( p->desktop == 0 )
4061 p->desktop = OnAllDesktops;
4062 }
4063 if ( data_ret )
4064 XFree(data_ret);
4065 }
4066 }
4067
4068 if (dirty & WMName) {
4069 delete[] p->name;
4070 p->name = NULL;
4071 if (XGetWindowProperty(p->display, p->window, net_wm_name, 0l,
4072 MAX_PROP_SIZE, False, UTF8_STRING, &type_ret,
4073 &format_ret, &nitems_ret, &unused, &data_ret)
4074 == Success) {
4075 if (type_ret == UTF8_STRING && format_ret == 8 && nitems_ret > 0) {
4076 p->name = nstrndup((const char *) data_ret, nitems_ret);
4077 }
4078
4079 if( data_ret )
4080 XFree(data_ret);
4081 }
4082 }
4083
4084 if (dirty & WMVisibleName) {
4085 delete[] p->visible_name;
4086 p->visible_name = NULL;
4087 if (XGetWindowProperty(p->display, p->window, net_wm_visible_name, 0l,
4088 MAX_PROP_SIZE, False, UTF8_STRING, &type_ret,
4089 &format_ret, &nitems_ret, &unused, &data_ret)
4090 == Success) {
4091 if (type_ret == UTF8_STRING && format_ret == 8 && nitems_ret > 0) {
4092 p->visible_name = nstrndup((const char *) data_ret, nitems_ret);
4093 }
4094
4095 if( data_ret )
4096 XFree(data_ret);
4097 }
4098 }
4099
4100 if (dirty & WMIconName) {
4101 delete[] p->icon_name;
4102 p->icon_name = NULL;
4103 if (XGetWindowProperty(p->display, p->window, net_wm_icon_name, 0l,
4104 MAX_PROP_SIZE, False, UTF8_STRING, &type_ret,
4105 &format_ret, &nitems_ret, &unused, &data_ret)
4106 == Success) {
4107 if (type_ret == UTF8_STRING && format_ret == 8 && nitems_ret > 0) {
4108 p->icon_name = nstrndup((const char *) data_ret, nitems_ret);
4109 }
4110
4111 if( data_ret )
4112 XFree(data_ret);
4113 }
4114 }
4115
4116 if (dirty & WMVisibleIconName)
4117 {
4118 delete[] p->visible_icon_name;
4119 p->visible_icon_name = NULL;
4120 if (XGetWindowProperty(p->display, p->window, net_wm_visible_icon_name, 0l,
4121 MAX_PROP_SIZE, False, UTF8_STRING, &type_ret,
4122 &format_ret, &nitems_ret, &unused, &data_ret)
4123 == Success) {
4124 if (type_ret == UTF8_STRING && format_ret == 8 && nitems_ret > 0) {
4125 p->visible_icon_name = nstrndup((const char *) data_ret, nitems_ret);
4126 }
4127
4128 if( data_ret )
4129 XFree(data_ret);
4130 }
4131 }
4132
4133 if (dirty & WMWindowType) {
4134 p->types.reset();
4135 p->types[ 0 ] = Unknown;
4136 p->has_net_support = false;
4137 if (XGetWindowProperty(p->display, p->window, net_wm_window_type, 0l, 2048l,
4138 False, XA_ATOM, &type_ret, &format_ret,
4139 &nitems_ret, &unused, &data_ret)
4140 == Success) {
4141 if (type_ret == XA_ATOM && format_ret == 32 && nitems_ret > 0) {
4142 // determine the window type
4143#ifdef NETWMDEBUG
4144 fprintf(stderr, "NETWinInfo::update: getting window type (%ld)\n",
4145 nitems_ret);
4146#endif
4147
4148 p->has_net_support = true;
4149
4150 unsigned long count = 0;
4151 long *types = (long *) data_ret;
4152 int pos = 0;
4153
4154 while (count < nitems_ret) {
4155 // remember all window types we know
4156#ifdef NETWMDEBUG
4157 char* debug_type = XGetAtomName(p->display, (Atom) types[count]);
4158 fprintf(stderr,
4159 "NETWinInfo::update: examining window type %ld %s\n",
4160 types[count], debug_type );
4161 if ( debug_type )
4162 XFree( debug_type );
4163#endif
4164
4165 if ((Atom) types[count] == net_wm_window_type_normal)
4166 p->types[ pos++ ] = Normal;
4167 else if ((Atom) types[count] == net_wm_window_type_desktop)
4168 p->types[ pos++ ] = Desktop;
4169 else if ((Atom) types[count] == net_wm_window_type_dock)
4170 p->types[ pos++ ] = Dock;
4171 else if ((Atom) types[count] == net_wm_window_type_toolbar)
4172 p->types[ pos++ ] = Toolbar;
4173 else if ((Atom) types[count] == net_wm_window_type_menu)
4174 p->types[ pos++ ] = Menu;
4175 else if ((Atom) types[count] == net_wm_window_type_dialog)
4176 p->types[ pos++ ] = Dialog;
4177 else if ((Atom) types[count] == net_wm_window_type_utility)
4178 p->types[ pos++ ] = Utility;
4179 else if ((Atom) types[count] == net_wm_window_type_splash)
4180 p->types[ pos++ ] = Splash;
4181 else if ((Atom) types[count] == net_wm_window_type_dropdown_menu)
4182 p->types[ pos++ ] = DropdownMenu;
4183 else if ((Atom) types[count] == net_wm_window_type_popup_menu)
4184 p->types[ pos++ ] = PopupMenu;
4185 else if ((Atom) types[count] == net_wm_window_type_tooltip)
4186 p->types[ pos++ ] = Tooltip;
4187 else if ((Atom) types[count] == net_wm_window_type_notification)
4188 p->types[ pos++ ] = Notification;
4189 else if ((Atom) types[count] == net_wm_window_type_combobox)
4190 p->types[ pos++ ] = ComboBox;
4191 else if ((Atom) types[count] == net_wm_window_type_dnd)
4192 p->types[ pos++ ] = DNDIcon;
4193 else if ((Atom) types[count] == kde_net_wm_window_type_override)
4194 p->types[ pos++ ] = Override;
4195 else if ((Atom) types[count] == kde_net_wm_window_type_topmenu)
4196 p->types[ pos++ ] = TopMenu;
4197
4198 count++;
4199 }
4200 }
4201
4202 if ( data_ret )
4203 XFree(data_ret);
4204 }
4205 }
4206
4207 if (dirty & WMStrut) {
4208 p->strut = NETStrut();
4209 if (XGetWindowProperty(p->display, p->window, net_wm_strut, 0l, 4l,
4210 False, XA_CARDINAL, &type_ret, &format_ret,
4211 &nitems_ret, &unused, &data_ret)
4212 == Success) {
4213 if (type_ret == XA_CARDINAL && format_ret == 32 &&
4214 nitems_ret == 4) {
4215 long *d = (long *) data_ret;
4216 p->strut.left = d[0];
4217 p->strut.right = d[1];
4218 p->strut.top = d[2];
4219 p->strut.bottom = d[3];
4220 }
4221 if ( data_ret )
4222 XFree(data_ret);
4223 }
4224 }
4225
4226 if (dirty2 & WM2ExtendedStrut) {
4227 p->extended_strut = NETExtendedStrut();
4228 if (XGetWindowProperty(p->display, p->window, net_wm_extended_strut, 0l, 12l,
4229 False, XA_CARDINAL, &type_ret, &format_ret,
4230 &nitems_ret, &unused, &data_ret)
4231 == Success) {
4232 if (type_ret == XA_CARDINAL && format_ret == 32 &&
4233 nitems_ret == 12) {
4234 long *d = (long *) data_ret;
4235 p->extended_strut.left_width = d[0];
4236 p->extended_strut.right_width = d[1];
4237 p->extended_strut.top_width = d[2];
4238 p->extended_strut.bottom_width = d[3];
4239 p->extended_strut.left_start = d[4];
4240 p->extended_strut.left_end = d[5];
4241 p->extended_strut.right_start = d[6];
4242 p->extended_strut.right_end = d[7];
4243 p->extended_strut.top_start = d[8];
4244 p->extended_strut.top_end = d[9];
4245 p->extended_strut.bottom_start = d[10];
4246 p->extended_strut.bottom_end = d[11];
4247 }
4248 if ( data_ret )
4249 XFree(data_ret);
4250 }
4251 }
4252
4253 if (dirty2 & WM2FullscreenMonitors) {
4254 p->fullscreen_monitors = NETFullscreenMonitors();
4255 if (XGetWindowProperty(p->display, p->window, net_wm_fullscreen_monitors, 0l, 4l,
4256 False, XA_CARDINAL, &type_ret, &format_ret,
4257 &nitems_ret, &unused, &data_ret)
4258 == Success) {
4259 if (type_ret == XA_CARDINAL && format_ret == 32 &&
4260 nitems_ret == 4) {
4261 long *d = (long *) data_ret;
4262 p->fullscreen_monitors.top = d[0];
4263 p->fullscreen_monitors.bottom = d[1];
4264 p->fullscreen_monitors.left = d[2];
4265 p->fullscreen_monitors.right = d[3];
4266 }
4267 if ( data_ret )
4268 XFree(data_ret);
4269 }
4270 }
4271
4272 if (dirty & WMIconGeometry) {
4273 p->icon_geom = NETRect();
4274 if (XGetWindowProperty(p->display, p->window, net_wm_icon_geometry, 0l, 4l,
4275 False, XA_CARDINAL, &type_ret, &format_ret,
4276 &nitems_ret, &unused, &data_ret)
4277 == Success) {
4278 if (type_ret == XA_CARDINAL && format_ret == 32 &&
4279 nitems_ret == 4) {
4280 long *d = (long *) data_ret;
4281 p->icon_geom.pos.x = d[0];
4282 p->icon_geom.pos.y = d[1];
4283 p->icon_geom.size.width = d[2];
4284 p->icon_geom.size.height = d[3];
4285 }
4286 if ( data_ret )
4287 XFree(data_ret);
4288 }
4289 }
4290
4291 if (dirty & WMIcon) {
4292 readIcon(p->display,p->window,net_wm_icon,p->icons,p->icon_count);
4293 delete[] p->icon_sizes;
4294 p->icon_sizes = NULL;
4295 }
4296
4297 if (dirty & WMFrameExtents) {
4298 p->frame_strut = NETStrut();
4299 bool ok = false;
4300 if (XGetWindowProperty(p->display, p->window, net_frame_extents,
4301 0l, 4l, False, XA_CARDINAL, &type_ret, &format_ret,
4302 &nitems_ret, &unused, &data_ret) == Success) {
4303 if (type_ret == XA_CARDINAL && format_ret == 32 && nitems_ret == 4) {
4304 ok = true;
4305 long *d = (long *) data_ret;
4306
4307 p->frame_strut.left = d[0];
4308 p->frame_strut.right = d[1];
4309 p->frame_strut.top = d[2];
4310 p->frame_strut.bottom = d[3];
4311 }
4312 if ( data_ret )
4313 XFree(data_ret);
4314 }
4315 if (!ok && XGetWindowProperty(p->display, p->window, kde_net_wm_frame_strut,
4316 0l, 4l, False, XA_CARDINAL, &type_ret, &format_ret,
4317 &nitems_ret, &unused, &data_ret) == Success) {
4318 if (type_ret == XA_CARDINAL && format_ret == 32 && nitems_ret == 4) {
4319 ok = true;
4320 long *d = (long *) data_ret;
4321
4322 p->frame_strut.left = d[0];
4323 p->frame_strut.right = d[1];
4324 p->frame_strut.top = d[2];
4325 p->frame_strut.bottom = d[3];
4326 }
4327 if ( data_ret )
4328 XFree(data_ret);
4329 }
4330 }
4331
4332 if (dirty2 & WM2FrameOverlap) {
4333 p->frame_overlap = NETStrut();
4334 if (XGetWindowProperty(p->display, p->window, kde_net_wm_frame_overlap,
4335 0l, 4l, False, XA_CARDINAL, &type_ret, &format_ret,
4336 &nitems_ret, &unused, &data_ret) == Success) {
4337 if (type_ret == XA_CARDINAL && format_ret == 32 && nitems_ret == 4) {
4338 long *d = (long *) data_ret;
4339
4340 p->frame_overlap.left = d[0];
4341 p->frame_overlap.right = d[1];
4342 p->frame_overlap.top = d[2];
4343 p->frame_overlap.bottom = d[3];
4344 }
4345 if ( data_ret )
4346 XFree(data_ret);
4347 }
4348 }
4349
4350 if (dirty2 & WM2Activities) {
4351 delete[] p->activities;
4352 p->activities = NULL;
4353 if (XGetWindowProperty(p->display, p->window, kde_net_wm_activities, 0l,
4354 MAX_PROP_SIZE, False, XA_STRING, &type_ret,
4355 &format_ret, &nitems_ret, &unused, &data_ret)
4356 == Success) {
4357 if (type_ret == XA_STRING && format_ret == 8 && nitems_ret > 0) {
4358 p->activities = nstrndup((const char *) data_ret, nitems_ret);
4359 }
4360
4361 if( data_ret )
4362 XFree(data_ret);
4363 }
4364 }
4365
4366 if (dirty2 & WM2BlockCompositing) {
4367 p->blockCompositing = false;
4368 if (XGetWindowProperty(p->display, p->window, kde_net_wm_block_compositing, 0l,
4369 1, False, XA_STRING, &type_ret,
4370 &format_ret, &nitems_ret, &unused, &data_ret) == Success) {
4371 p->blockCompositing = (data_ret != NULL);
4372 if (data_ret) // stupid question to everyone - since the result is "Success", is this check required?
4373 XFree(data_ret);
4374 }
4375 }
4376
4377 if (dirty & WMPid) {
4378 p->pid = 0;
4379 if (XGetWindowProperty(p->display, p->window, net_wm_pid, 0l, 1l,
4380 False, XA_CARDINAL, &type_ret, &format_ret,
4381 &nitems_ret, &unused, &data_ret) == Success) {
4382 if (type_ret == XA_CARDINAL && format_ret == 32 && nitems_ret == 1) {
4383 p->pid = *((long *) data_ret);
4384 }
4385 if ( data_ret )
4386 XFree(data_ret);
4387 }
4388 }
4389
4390 if (dirty2 & WM2StartupId)
4391 {
4392 delete[] p->startup_id;
4393 p->startup_id = NULL;
4394 if (XGetWindowProperty(p->display, p->window, net_startup_id, 0l,
4395 MAX_PROP_SIZE, False, UTF8_STRING, &type_ret,
4396 &format_ret, &nitems_ret, &unused, &data_ret)
4397 == Success) {
4398 if (type_ret == UTF8_STRING && format_ret == 8 && nitems_ret > 0) {
4399 p->startup_id = nstrndup((const char *) data_ret, nitems_ret);
4400 }
4401
4402 if( data_ret )
4403 XFree(data_ret);
4404 }
4405 }
4406
4407 if (dirty2 & WM2Opacity)
4408 {
4409 p->opacity = 0xffffffffU;
4410 if (XGetWindowProperty(p->display, p->window, net_wm_window_opacity, 0l,
4411 MAX_PROP_SIZE, False, XA_CARDINAL, &type_ret,
4412 &format_ret, &nitems_ret, &unused, &data_ret)
4413 == Success) {
4414 if (type_ret == XA_CARDINAL && format_ret == 32 && nitems_ret == 1) {
4415 // 32bit values are passed as long, so on 64bit systems when reading
4416 // 0xffffffff is apparently considered to be -1 and sign-extended to 64bits.
4417 // Therefore convert it back to 32bits to fit the stupid _NET_WM_WINDOW_OPACITY format.
4418 p->opacity = *((unsigned long*)data_ret) & 0xffffffffU;
4419 }
4420
4421 if( data_ret )
4422 XFree(data_ret);
4423 }
4424 }
4425
4426 if( dirty2 & WM2AllowedActions ) {
4427 p->allowed_actions = 0;
4428 if (XGetWindowProperty(p->display, p->window, net_wm_allowed_actions, 0l, 2048l,
4429 False, XA_ATOM, &type_ret, &format_ret,
4430 &nitems_ret, &unused, &data_ret)
4431 == Success) {
4432 if (type_ret == XA_ATOM && format_ret == 32 && nitems_ret > 0) {
4433 // determine actions
4434#ifdef NETWMDEBUG
4435 fprintf(stderr, "NETWinInfo::update: updating allowed actions (%ld)\n",
4436 nitems_ret);
4437#endif
4438
4439 long *actions = (long *) data_ret;
4440 unsigned long count;
4441
4442 for (count = 0; count < nitems_ret; count++) {
4443#ifdef NETWMDEBUG
4444 fprintf(stderr,
4445 "NETWinInfo::update: adding allowed action %ld '%s'\n",
4446 actions[count],
4447 XGetAtomName(p->display, (Atom) actions[count]));
4448#endif
4449
4450 if ((Atom) actions[count] == net_wm_action_move)
4451 p->allowed_actions |= ActionMove;
4452 if ((Atom) actions[count] == net_wm_action_resize)
4453 p->allowed_actions |= ActionResize;
4454 if ((Atom) actions[count] == net_wm_action_minimize)
4455 p->allowed_actions |= ActionMinimize;
4456 if ((Atom) actions[count] == net_wm_action_shade)
4457 p->allowed_actions |= ActionShade;
4458 if ((Atom) actions[count] == net_wm_action_stick)
4459 p->allowed_actions |= ActionStick;
4460 if ((Atom) actions[count] == net_wm_action_max_vert)
4461 p->allowed_actions |= ActionMaxVert;
4462 if ((Atom) actions[count] == net_wm_action_max_horiz)
4463 p->allowed_actions |= ActionMaxHoriz;
4464 if ((Atom) actions[count] == net_wm_action_fullscreen)
4465 p->allowed_actions |= ActionFullScreen;
4466 if ((Atom) actions[count] == net_wm_action_change_desk)
4467 p->allowed_actions |= ActionChangeDesktop;
4468 if ((Atom) actions[count] == net_wm_action_close)
4469 p->allowed_actions |= ActionClose;
4470 }
4471 }
4472 if ( data_ret )
4473 XFree(data_ret);
4474 }
4475 }
4476
4477 if (dirty2 & WM2UserTime) {
4478 p->user_time = -1U;
4479 if (XGetWindowProperty(p->display, p->window, net_wm_user_time, 0l, 1l,
4480 False, XA_CARDINAL, &type_ret, &format_ret,
4481 &nitems_ret, &unused, &data_ret) == Success) {
4482 // don't do nitems_ret check - Qt does PropModeAppend to avoid API call for it
4483 if (type_ret == XA_CARDINAL && format_ret == 32 /*&& nitems_ret == 1*/) {
4484 p->user_time = *((long *) data_ret);
4485 }
4486 if ( data_ret )
4487 XFree(data_ret);
4488 }
4489 }
4490
4491 if (dirty2 & WM2TransientFor) {
4492 p->transient_for = None;
4493 XGetTransientForHint(p->display, p->window, &p->transient_for);
4494 }
4495
4496 if (dirty2 & WM2GroupLeader) {
4497 XWMHints *hints = XGetWMHints(p->display, p->window);
4498 p->window_group = None;
4499 if ( hints )
4500 {
4501 if( hints->flags & WindowGroupHint )
4502 p->window_group = hints->window_group;
4503 XFree( reinterpret_cast< char* >( hints ));
4504 }
4505 }
4506
4507 if( dirty2 & WM2WindowClass ) {
4508 delete[] p->class_class;
4509 delete[] p->class_name;
4510 p->class_class = NULL;
4511 p->class_name = NULL;
4512 XClassHint hint;
4513 if( XGetClassHint( p->display, p->window, &hint )) {
4514 p->class_class = nstrdup( hint.res_class );
4515 p->class_name = nstrdup( hint.res_name );
4516 XFree( hint.res_class );
4517 XFree( hint.res_name );
4518 }
4519 }
4520
4521 if( dirty2 & WM2WindowRole ) {
4522 delete[] p->window_role;
4523 p->window_role = NULL;
4524 if (XGetWindowProperty(p->display, p->window, wm_window_role, 0l,
4525 MAX_PROP_SIZE, False, XA_STRING, &type_ret,
4526 &format_ret, &nitems_ret, &unused, &data_ret)
4527 == Success) {
4528 if (type_ret == XA_STRING && format_ret == 8 && nitems_ret > 0) {
4529 p->window_role = nstrndup((const char *) data_ret, nitems_ret);
4530 }
4531 if( data_ret )
4532 XFree(data_ret);
4533 }
4534 }
4535
4536 if( dirty2 & WM2ClientMachine ) {
4537 delete[] p->client_machine;
4538 p->client_machine = NULL;
4539 if (XGetWindowProperty(p->display, p->window, XA_WM_CLIENT_MACHINE, 0l,
4540 MAX_PROP_SIZE, False, XA_STRING, &type_ret,
4541 &format_ret, &nitems_ret, &unused, &data_ret)
4542 == Success) {
4543 if (type_ret == XA_STRING && format_ret == 8 && nitems_ret > 0) {
4544 p->client_machine = nstrndup((const char *) data_ret, nitems_ret);
4545 }
4546 if( data_ret )
4547 XFree(data_ret);
4548 }
4549 }
4550}
4551
4552
4553NETRect NETWinInfo::iconGeometry() const {
4554 return p->icon_geom;
4555}
4556
4557
4558unsigned long NETWinInfo::state() const {
4559 return p->state;
4560}
4561
4562
4563NETStrut NETWinInfo::strut() const {
4564 return p->strut;
4565}
4566
4567NETExtendedStrut NETWinInfo::extendedStrut() const {
4568 return p->extended_strut;
4569}
4570
4571NETFullscreenMonitors NETWinInfo2::fullscreenMonitors() const {
4572 return p->fullscreen_monitors;
4573}
4574
4575bool NET::typeMatchesMask( WindowType type, unsigned long mask ) {
4576 switch( type ) {
4577#define CHECK_TYPE_MASK( type ) \
4578 case type: \
4579 if( mask & type##Mask ) \
4580 return true; \
4581 break;
4582 CHECK_TYPE_MASK( Normal )
4583 CHECK_TYPE_MASK( Desktop )
4584 CHECK_TYPE_MASK( Dock )
4585 CHECK_TYPE_MASK( Toolbar )
4586 CHECK_TYPE_MASK( Menu )
4587 CHECK_TYPE_MASK( Dialog )
4588 CHECK_TYPE_MASK( Override )
4589 CHECK_TYPE_MASK( TopMenu )
4590 CHECK_TYPE_MASK( Utility )
4591 CHECK_TYPE_MASK( Splash )
4592 CHECK_TYPE_MASK( DropdownMenu )
4593 CHECK_TYPE_MASK( PopupMenu )
4594 CHECK_TYPE_MASK( Tooltip )
4595 CHECK_TYPE_MASK( Notification )
4596 CHECK_TYPE_MASK( ComboBox )
4597 CHECK_TYPE_MASK( DNDIcon )
4598#undef CHECK_TYPE_MASK
4599 default:
4600 break;
4601 }
4602 return false;
4603}
4604
4605NET::WindowType NETWinInfo::windowType( unsigned long supported_types ) const {
4606 for( int i = 0;
4607 i < p->types.size();
4608 ++i ) {
4609 // return the type only if the application supports it
4610 if( typeMatchesMask( p->types[ i ], supported_types ))
4611 return p->types[ i ];
4612 }
4613 return Unknown;
4614}
4615
4616bool NETWinInfo::hasWindowType() const {
4617 return p->types.size() > 0;
4618}
4619
4620const char *NETWinInfo::name() const {
4621 return p->name;
4622}
4623
4624
4625const char *NETWinInfo::visibleName() const {
4626 return p->visible_name;
4627}
4628
4629
4630const char *NETWinInfo::iconName() const {
4631 return p->icon_name;
4632}
4633
4634
4635const char *NETWinInfo::visibleIconName() const {
4636 return p->visible_icon_name;
4637}
4638
4639
4640int NETWinInfo::desktop( bool ignore_viewport ) const {
4641 if( !ignore_viewport && KWindowSystem::mapViewport())
4642 return KWindowSystem::windowInfo( p->window, NET::Desktop ).desktop();
4643 return p->desktop;
4644}
4645
4646int NETWinInfo::pid() const {
4647 return p->pid;
4648}
4649
4650Time NETWinInfo::userTime() const {
4651 return p->user_time;
4652}
4653
4654const char* NETWinInfo::startupId() const {
4655 return p->startup_id;
4656}
4657
4658unsigned long NETWinInfo::opacity() const {
4659 return p->opacity;
4660}
4661
4662unsigned long NETWinInfo::allowedActions() const {
4663 return p->allowed_actions;
4664}
4665
4666bool NETWinInfo::hasNETSupport() const {
4667 return p->has_net_support;
4668}
4669
4670Window NETWinInfo::transientFor() const {
4671 return p->transient_for;
4672}
4673
4674Window NETWinInfo::groupLeader() const {
4675 return p->window_group;
4676}
4677
4678const char* NETWinInfo::windowClassClass() const {
4679 return p->class_class;
4680}
4681
4682const char* NETWinInfo::windowClassName() const {
4683 return p->class_name;
4684}
4685
4686const char* NETWinInfo::windowRole() const {
4687 return p->window_role;
4688}
4689
4690const char* NETWinInfo::clientMachine() const {
4691 return p->client_machine;
4692}
4693
4694const char* NETWinInfo::activities() const {
4695 return p->activities;
4696}
4697
4698void NETWinInfo::setBlockingCompositing(bool active) {
4699 if (p->role != Client) return;
4700
4701 p->blockCompositing = active;
4702 if (active) {
4703 long d = 1;
4704 XChangeProperty(p->display, p->window, kde_net_wm_block_compositing, XA_CARDINAL, 32,
4705 PropModeReplace, (unsigned char *) &d, 1);
4706 }
4707 else
4708 XDeleteProperty(p->display, p->window, kde_net_wm_block_compositing);
4709}
4710
4711bool NETWinInfo::isBlockingCompositing() const {
4712 return p->blockCompositing;
4713}
4714
4715Bool NETWinInfo::handledIcons() const {
4716 return p->handled_icons;
4717}
4718
4719
4720const unsigned long* NETWinInfo::passedProperties() const {
4721 return p->properties;
4722}
4723
4724
4725NET::MappingState NETWinInfo::mappingState() const {
4726 return p->mapping_state;
4727}
4728
4729void NETRootInfo::virtual_hook( int, void* )
4730{ /*BASE::virtual_hook( id, data );*/ }
4731
4732void NETWinInfo::virtual_hook( int, void* )
4733{ /*BASE::virtual_hook( id, data );*/ }
4734
4735int NET::timestampCompare( unsigned long time1, unsigned long time2 )
4736 {
4737 return KXUtils::timestampCompare( time1, time2 );
4738 }
4739
4740int NET::timestampDiff( unsigned long time1, unsigned long time2 )
4741 {
4742 return KXUtils::timestampDiff( time1, time2 );
4743 }
4744
4745#endif
KWindowInfo::desktop
int desktop() const
Returns the virtual desktop this window is on (NET::OnAllDesktops if the window is on all desktops).
Definition: kwindowinfo_mac.cpp:273
KWindowSystem::setOnDesktop
static void setOnDesktop(WId win, int desktop)
Moves window win to desktop desktop.
Definition: kwindowsystem_mac.cpp:406
KWindowSystem::mapViewport
static bool mapViewport()
Definition: kwindowsystem_x11.cpp:1042
KWindowSystem::currentDesktop
static int currentDesktop()
Returns the current virtual desktop.
Definition: kwindowsystem_mac.cpp:384
KWindowSystem::windowInfo
static KWindowInfo windowInfo(WId win, unsigned long properties, unsigned long properties2=0)
Returns information about window win.
Definition: kwindowsystem_mac.cpp:330
KWindowSystem::setCurrentDesktop
static void setCurrentDesktop(int desktop)
Convenience function to set the current desktop to desktop.
Definition: kwindowsystem_mac.cpp:394
KWindowSystem::numberOfDesktops
static int numberOfDesktops()
Returns the number of virtual desktops.
Definition: kwindowsystem_mac.cpp:389
NETRArray
Definition: netwm.h:43
NETRootInfo
Common API for root window properties/protocols.
Definition: netwm.h:58
NETRootInfo::changeDesktopViewport
virtual void changeDesktopViewport(int desktop, const NETPoint &viewport)
A Window Manager should subclass NETRootInfo and reimplement this function when it wants to know when...
Definition: netwm.h:701
NETRootInfo::clientListCount
int clientListCount() const
Returns the number of managed windows in clientList array.
Definition: netwm.cpp:2665
NETRootInfo::moveResizeWindow
virtual void moveResizeWindow(Window window, int flags, int x, int y, int width, int height)
A Window Manager should subclass NETRootInfo and reimplement this function when it wants to know when...
Definition: netwm.h:768
NETRootInfo::setDesktopLayout
void setDesktopLayout(NET::Orientation orientation, int columns, int rows, NET::DesktopLayoutCorner corner)
Sets the desktop layout.
Definition: netwm.cpp:1634
NETRootInfo::x11Display
Display * x11Display() const
Returns the X11 Display struct used.
Definition: netwm.cpp:2540
NETRootInfo::desktopLayoutOrientation
NET::Orientation desktopLayoutOrientation() const
Returns the desktop layout orientation.
Definition: netwm.cpp:2724
NETRootInfo::virtualRootsCount
int virtualRootsCount() const
Returns the number of window in the virtualRoots array.
Definition: netwm.cpp:2719
NETRootInfo::supportWindow
Window supportWindow() const
Returns the Window id of the supportWindow.
Definition: netwm.cpp:2550
NETRootInfo::virtualRoots
const Window * virtualRoots() const
Returns an array of Window id's, which contain the virtual root windows.
Definition: netwm.cpp:2714
NETRootInfo::restackRequest
void restackRequest(Window window, RequestSource source, Window above, int detail, Time timestamp)
Sends the _NET_RESTACK_WINDOW request.
Definition: netwm.cpp:1761
NETRootInfo::ACTIONS
@ ACTIONS
Definition: netwm.h:64
NETRootInfo::PROTOCOLS
@ PROTOCOLS
Definition: netwm.h:64
NETRootInfo::STATES
@ STATES
Definition: netwm.h:64
NETRootInfo::PROTOCOLS2
@ PROTOCOLS2
Definition: netwm.h:64
NETRootInfo::WINDOW_TYPES
@ WINDOW_TYPES
Definition: netwm.h:64
NETRootInfo::PROPERTIES_SIZE
@ PROPERTIES_SIZE
Definition: netwm.h:65
NETRootInfo::setDesktopViewport
void setDesktopViewport(int desktop, const NETPoint &viewport)
Sets the viewport for the current desktop to the specified point.
Definition: netwm.cpp:1026
NETRootInfo::currentDesktop
int currentDesktop(bool ignore_viewport=false) const
Returns the current desktop.
Definition: netwm.cpp:2746
NETRootInfo::event
void event(XEvent *event, unsigned long *properties, int properties_size)
This function takes the passed XEvent and returns an OR'ed list of NETRootInfo properties that have c...
Definition: netwm.cpp:1858
NETRootInfo::addClient
virtual void addClient(Window window)
A Client should subclass NETRootInfo and reimplement this function when it wants to know when a windo...
Definition: netwm.h:662
NETRootInfo::setVirtualRoots
void setVirtualRoots(const Window *windows, unsigned int count)
Sets the list of virtual root windows on the root window.
Definition: netwm.cpp:1616
NETRootInfo::moveResize
virtual void moveResize(Window window, int x_root, int y_root, unsigned long direction)
A Window Manager should subclass NETRootInfo and reimplement this function when it wants to know when...
Definition: netwm.h:733
NETRootInfo::removeClient
virtual void removeClient(Window window)
A Client should subclass NETRootInfo and reimplement this function when it wants to know when a windo...
Definition: netwm.h:670
NETRootInfo::gotTakeActivity
virtual void gotTakeActivity(Window window, Time timestamp, long flags)
A Window Manager should subclass NETRootInfo and reimplement this function when it wants to receive r...
Definition: netwm.h:790
NETRootInfo::setDesktopName
void setDesktopName(int desktop, const char *desktopName)
Sets the name of the specified desktop.
Definition: netwm.cpp:955
NETRootInfo::NETRootInfo
NETRootInfo(Display *display, Window supportWindow, const char *wmName, const unsigned long properties[], int properties_size, int screen=-1, bool doActivate=true)
Window Managers should use this constructor to create a NETRootInfo object, which will be used to set...
Definition: netwm.cpp:630
NETRootInfo::activate
void activate()
Window Managers must call this after creating the NETRootInfo object, and before using any other meth...
Definition: netwm.cpp:827
NETRootInfo::clientListStackingCount
int clientListStackingCount() const
Returns the number of managed windows in the clientListStacking array.
Definition: netwm.cpp:2675
NETRootInfo::setActiveWindow
void setActiveWindow(Window window, NET::RequestSource src, Time timestamp, Window active_window)
Requests that the specified window becomes the active (focused) one.
Definition: netwm.cpp:1556
NETRootInfo::desktopViewport
NETPoint desktopViewport(int desktop) const
Returns the viewport of the specified desktop.
Definition: netwm.cpp:2685
NETRootInfo::setClientList
void setClientList(const Window *windows, unsigned int count)
Sets the list of managed windows on the Root/Desktop window.
Definition: netwm.cpp:848
NETRootInfo::sendPing
void sendPing(Window window, Time timestamp)
Sends a ping with the given timestamp to the window, using the _NET_WM_PING protocol.
Definition: netwm.cpp:1785
NETRootInfo::gotPing
virtual void gotPing(Window window, Time timestamp)
A Window Manager should subclass NETRootInfo and reimplement this function when it wants to receive r...
Definition: netwm.h:742
NETRootInfo::setWorkArea
void setWorkArea(int desktop, const NETRect &workArea)
Sets the workarea for the specified desktop.
Definition: netwm.cpp:1587
NETRootInfo::rootWindow
Window rootWindow() const
Returns the Window id of the rootWindow.
Definition: netwm.cpp:2545
NETRootInfo::closeWindow
virtual void closeWindow(Window window)
A Window Manager should subclass NETRootInfo and reimplement this function when it wants to know when...
Definition: netwm.h:718
NETRootInfo::~NETRootInfo
virtual ~NETRootInfo()
Destroys the NETRootInfo object.
Definition: netwm.cpp:804
NETRootInfo::restackWindow
virtual void restackWindow(Window window, RequestSource source, Window above, int detail, Time timestamp)
A Window Manager should subclass NETRootInfo and reimplement this function when it wants to know when...
Definition: netwm.h:781
NETRootInfo::setSupported
void setSupported(NET::Property property, bool on=true)
Sets the given property if on is true, and clears the property otherwise.
Definition: netwm.cpp:2575
NETRootInfo::virtual_hook
virtual void virtual_hook(int id, void *data)
Virtual hook, used to add new "virtual" functions while maintaining binary compatibility.
Definition: netwm.cpp:4729
NETRootInfo::changeDesktopGeometry
virtual void changeDesktopGeometry(int desktop, const NETSize &geom)
A Window Manager should subclass NETRootInfo and reimplement this function when it wants to know when...
Definition: netwm.h:690
NETRootInfo::takeActivity
void takeActivity(Window window, Time timestamp, long flags)
Sends a take activity message with the given timestamp to the window, using the _NET_WM_TAKE_ACTIVITY...
Definition: netwm.cpp:1807
NETRootInfo::desktopLayoutCorner
NET::DesktopLayoutCorner desktopLayoutCorner() const
Returns the desktop layout starting corner.
Definition: netwm.cpp:2734
NETRootInfo::desktopName
const char * desktopName(int desktop) const
Returns the name for the specified desktop.
Definition: netwm.cpp:2705
NETRootInfo::moveResizeWindowRequest
void moveResizeWindowRequest(Window window, int flags, int x, int y, int width, int height)
Clients (such as pagers/taskbars) that wish to move/resize a window using WM2MoveResizeWindow (_NET_M...
Definition: netwm.cpp:1736
NETRootInfo::setShowingDesktop
void setShowingDesktop(bool showing)
Sets the _NET_SHOWING_DESKTOP status (whether desktop is being shown).
Definition: netwm.cpp:1657
NETRootInfo::changeNumberOfDesktops
virtual void changeNumberOfDesktops(int numberOfDesktops)
A Window Manager should subclass NETRootInfo and reimplement this function when it wants to know when...
Definition: netwm.h:679
NETRootInfo::passedProperties
const unsigned long * passedProperties() const
Returns the properties argument passed to the constructor.
Definition: netwm.cpp:2569
NETRootInfo::setCurrentDesktop
void setCurrentDesktop(int desktop, bool ignore_viewport=false)
Sets the current desktop to the specified desktop.
Definition: netwm.cpp:918
NETRootInfo::desktopLayoutColumnsRows
QSize desktopLayoutColumnsRows() const
Returns the desktop layout number of columns and rows.
Definition: netwm.cpp:2729
NETRootInfo::activeWindow
Window activeWindow() const
Returns the active (focused) window.
Definition: netwm.cpp:2753
NETRootInfo::setClientListStacking
void setClientListStacking(const Window *windows, unsigned int count)
Sets the list of managed windows in stacking order on the Root/Desktop window.
Definition: netwm.cpp:867
NETRootInfo::changeActiveWindow
virtual void changeActiveWindow(Window window, NET::RequestSource src, Time timestamp, Window active_window)
A Window Manager should subclass NETRootInfo and reimplement this function when it wants to know when...
Definition: netwm.h:753
NETRootInfo::setNumberOfDesktops
void setNumberOfDesktops(int numberOfDesktops)
Sets the number of desktops to the specified number.
Definition: netwm.cpp:886
NETRootInfo::workArea
NETRect workArea(int desktop) const
Returns the workArea for the specified desktop.
Definition: netwm.cpp:2695
NETRootInfo::moveResizeRequest
void moveResizeRequest(Window window, int x_root, int y_root, Direction direction)
Clients (such as pagers/taskbars) that wish to start a WMMoveResize (where the window manager control...
Definition: netwm.cpp:1710
NETRootInfo::screenNumber
int screenNumber() const
Returns the screenNumber.
Definition: netwm.cpp:2559
NETRootInfo::supportedProperties
const unsigned long * supportedProperties() const
In the Window Manager mode, this is equivalent to the properties argument passed to the constructor.
Definition: netwm.cpp:2565
NETRootInfo::changeCurrentDesktop
virtual void changeCurrentDesktop(int desktop)
A Window Manager should subclass NETRootInfo and reimplement this function when it wants to know when...
Definition: netwm.h:710
NETRootInfo::isSupported
bool isSupported(NET::Property property) const
Returns true if the given property is supported by the window manager.
Definition: netwm.cpp:2640
NETRootInfo::closeWindowRequest
void closeWindowRequest(Window window)
Clients (such as pagers/taskbars) that wish to close a window should call this function.
Definition: netwm.cpp:1686
NETRootInfo::operator=
const NETRootInfo & operator=(const NETRootInfo &rootinfo)
Assignment operator.
Definition: netwm.cpp:1833
NETRootInfo::wmName
const char * wmName() const
Returns the name of the Window Manager.
Definition: netwm.cpp:2555
NETRootInfo::clientList
const Window * clientList() const
Returns an array of Window id's, which contain all managed windows.
Definition: netwm.cpp:2660
NETRootInfo::changeShowingDesktop
virtual void changeShowingDesktop(bool showing)
A Window Manager should subclass NETRootInfo and reimplement this function when it wants to know when...
Definition: netwm.h:799
NETRootInfo::setDesktopGeometry
void setDesktopGeometry(int desktop, const NETSize &geometry)
Sets the desktop geometry to the specified geometry.
Definition: netwm.cpp:991
NETRootInfo::numberOfDesktops
int numberOfDesktops(bool ignore_viewport=false) const
Returns the number of desktops.
Definition: netwm.cpp:2739
NETRootInfo::showingDesktop
bool showingDesktop() const
Returns the status of _NET_SHOWING_DESKTOP.
Definition: netwm.cpp:1681
NETRootInfo::desktopGeometry
NETSize desktopGeometry(int desktop) const
Returns the desktop geometry size.
Definition: netwm.cpp:2680
NETRootInfo::clientListStacking
const Window * clientListStacking() const
Returns an array of Window id's, which contain all managed windows in stacking order.
Definition: netwm.cpp:2670
NETWinInfo2
This class is an extension of the NETWinInfo class, and exists solely for binary compatibility reason...
Definition: netwm.h:1381
NETWinInfo2::fullscreenMonitors
NETFullscreenMonitors fullscreenMonitors() const
Returns the desired fullscreen monitor topology for this client, should it be in fullscreen state.
Definition: netwm.cpp:4571
NETWinInfo2::setFullscreenMonitors
void setFullscreenMonitors(NETFullscreenMonitors topology)
Sets the desired multiple-monitor topology (4 monitor indices indicating the top, bottom,...
Definition: netwm.cpp:3052
NETWinInfo
Common API for application window properties/protocols.
Definition: netwm.h:829
NETWinInfo::setPid
void setPid(int pid)
Set the application window's process id.
Definition: netwm.cpp:3490
NETWinInfo::setFrameOverlap
void setFrameOverlap(NETStrut strut)
Sets the window frame overlap strut, i.e.
Definition: netwm.cpp:3581
NETWinInfo::hasWindowType
bool hasWindowType() const
This function returns false if the window has not window type specified at all.
Definition: netwm.cpp:4616
NETWinInfo::transientFor
Window transientFor() const
Returns the WM_TRANSIENT_FOR property for the window, i.e.
Definition: netwm.cpp:4670
NETWinInfo::handledIcons
Bool handledIcons() const
Returns whether or not this client handles icons.
Definition: netwm.cpp:4715
NETWinInfo::setOpacity
void setOpacity(unsigned long opacity)
Sets opacity (0 = transparent, 0xffffffff = opaque ) on the window.
Definition: netwm.cpp:3519
NETWinInfo::kdeGeometry
void kdeGeometry(NETRect &frame, NETRect &window)
Places the window frame geometry in frame, and the application window geometry in window.
Definition: netwm.cpp:3605
NETWinInfo::changeDesktop
virtual void changeDesktop(int desktop)
A Window Manager should subclass NETWinInfo and reimplement this function when it wants to know when ...
Definition: netwm.h:1345
NETWinInfo::activities
const char * activities() const
returns a comma-separated list of the activities the window is associated with.
Definition: netwm.cpp:4694
NETWinInfo::isBlockingCompositing
bool isBlockingCompositing() const
Returns whether the client wishes to block compositing (for better performance)
Definition: netwm.cpp:4711
NETWinInfo::desktop
int desktop(bool ignore_viewport=false) const
Returns the desktop where the window is residing.
Definition: netwm.cpp:4640
NETWinInfo::name
const char * name() const
Returns the name of the window in UTF-8 format.
Definition: netwm.cpp:4620
NETWinInfo::opacity
unsigned long opacity() const
Returns the opacity of the window.
Definition: netwm.cpp:4658
NETWinInfo::mappingState
MappingState mappingState() const
Returns the mapping state for the window (see the NET base class documentation for a description of m...
Definition: netwm.cpp:4725
NETWinInfo::setStrut
void setStrut(NETStrut strut)
Definition: netwm.cpp:3036
NETWinInfo::windowType
WindowType windowType(unsigned long supported_types) const
Returns the window type for this client (see the NET base class documentation for a description of th...
Definition: netwm.cpp:4605
NETWinInfo::windowRole
const char * windowRole() const
Returns the window role for the window (i.e.
Definition: netwm.cpp:4686
NETWinInfo::frameExtents
NETStrut frameExtents() const
Returns the frame decoration strut, i.e.
Definition: netwm.cpp:3577
NETWinInfo::PROTOCOLS2
@ PROTOCOLS2
Definition: netwm.h:835
NETWinInfo::PROTOCOLS
@ PROTOCOLS
Definition: netwm.h:835
NETWinInfo::changeState
virtual void changeState(unsigned long state, unsigned long mask)
A Window Manager should subclass NETWinInfo and reimplement this function when it wants to know when ...
Definition: netwm.h:1356
NETWinInfo::setIconName
void setIconName(const char *name)
Sets the iconic name for the application window.
Definition: netwm.cpp:3414
NETWinInfo::groupLeader
Window groupLeader() const
Returns the leader window for the group the window is in, if any.
Definition: netwm.cpp:4674
NETWinInfo::icon
NETIcon icon(int width=-1, int height=-1) const
Returns an icon.
Definition: netwm.cpp:3630
NETWinInfo::NETWinInfo2
friend class NETWinInfo2
Definition: netwm.h:1371
NETWinInfo::setExtendedStrut
void setExtendedStrut(const NETExtendedStrut &extended_strut)
Set the extended (partial) strut for the application window.
Definition: netwm.cpp:3012
NETWinInfo::strut
NETStrut strut() const
Definition: netwm.cpp:4563
NETWinInfo::allowedActions
unsigned long allowedActions() const
Returns actions that the window manager allows for the window.
Definition: netwm.cpp:4662
NETWinInfo::setUserTime
void setUserTime(Time time)
Sets user timestamp time on the window (property _NET_WM_USER_TIME).
Definition: netwm.cpp:3682
NETWinInfo::event
void event(XEvent *event, unsigned long *properties, int properties_size)
This function takes the passed XEvent and returns an OR'ed list of NETWinInfo properties that have ch...
Definition: netwm.cpp:3699
NETWinInfo::extendedStrut
NETExtendedStrut extendedStrut() const
Returns the extended (partial) strut specified by this client.
Definition: netwm.cpp:4567
NETWinInfo::operator=
const NETWinInfo & operator=(const NETWinInfo &wintinfo)
Assignment operator.
Definition: netwm.cpp:2913
NETWinInfo::setHandledIcons
void setHandledIcons(Bool handled)
Set whether this application window handles icons.
Definition: netwm.cpp:3500
NETWinInfo::state
unsigned long state() const
Returns the state of the window (see the NET base class documentation for a description of the variou...
Definition: netwm.cpp:4558
NETWinInfo::visibleIconName
const char * visibleIconName() const
Returns the visible iconic name as set by the window manager in UTF-8 format.
Definition: netwm.cpp:4635
NETWinInfo::iconName
const char * iconName() const
Returns the iconic name of the window in UTF-8 format.
Definition: netwm.cpp:4630
NETWinInfo::iconSizes
const int * iconSizes() const
Returns a list of provided icon sizes.
Definition: netwm.cpp:3634
NETWinInfo::passedProperties
const unsigned long * passedProperties() const
Returns the properties argument passed to the constructor.
Definition: netwm.cpp:4720
NETWinInfo::startupId
const char * startupId() const
Returns the startup notification id of the window.
Definition: netwm.cpp:4654
NETWinInfo::setFrameExtents
void setFrameExtents(NETStrut strut)
Set the frame decoration strut, i.e.
Definition: netwm.cpp:3560
NETWinInfo::userTime
Time userTime() const
Returns the time of last user action on the window, or -1 if not set.
Definition: netwm.cpp:4650
NETWinInfo::setWindowType
void setWindowType(WindowType type)
Sets the window type for this client (see the NET base class documentation for a description of the v...
Definition: netwm.cpp:3272
NETWinInfo::virtual_hook
virtual void virtual_hook(int id, void *data)
Virtual hook, used to add new "virtual" functions while maintaining binary compatibility.
Definition: netwm.cpp:4732
NETWinInfo::frameOverlap
NETStrut frameOverlap() const
Returns the frame overlap strut, i.e.
Definition: netwm.cpp:3601
NETWinInfo::clientMachine
const char * clientMachine() const
Returns the client machine for the window (i.e.
Definition: netwm.cpp:4690
NETWinInfo::setVisibleName
void setVisibleName(const char *visibleName)
For Window Managers only: set the visible name ( i.e.
Definition: netwm.cpp:3400
NETWinInfo::setBlockingCompositing
void setBlockingCompositing(bool active)
Sets whether the client wishes to block compositing (for better performance)
Definition: netwm.cpp:4698
NETWinInfo::setVisibleIconName
void setVisibleIconName(const char *name)
For Window Managers only: set the visible iconic name ( i.e.
Definition: netwm.cpp:3428
NETWinInfo::setDesktop
void setDesktop(int desktop, bool ignore_viewport=false)
Set which window the desktop is (should be) on.
Definition: netwm.cpp:3442
NETWinInfo::OnAllDesktops
static const int OnAllDesktops
Sentinel value to indicate that the client wishes to be visible on all desktops.
Definition: netwm.h:1335
NETWinInfo::visibleName
const char * visibleName() const
Returns the visible name as set by the window manager in UTF-8 format.
Definition: netwm.cpp:4625
NETWinInfo::setIcon
void setIcon(NETIcon icon, Bool replace=True)
Set icons for the application window.
Definition: netwm.cpp:2932
NETWinInfo::setStartupId
void setStartupId(const char *startup_id)
Sets the startup notification id id on the window.
Definition: netwm.cpp:3509
NETWinInfo::hasNETSupport
bool hasNETSupport() const
Returns true if the window has any window type set, even if the type itself is not known to this impl...
Definition: netwm.cpp:4666
NETWinInfo::pid
int pid() const
Returns the process id for the client window.
Definition: netwm.cpp:4646
NETWinInfo::NETWinInfo
NETWinInfo(Display *display, Window window, Window rootWindow, const unsigned long properties[], int properties_size, Role role=Client)
Create a NETWinInfo object, which will be used to set/read/change information stored on an applicatio...
Definition: netwm.cpp:2762
NETWinInfo::setState
void setState(unsigned long state, unsigned long mask)
Set the state for the application window (see the NET base class documentation for a description of w...
Definition: netwm.cpp:3068
NETWinInfo::~NETWinInfo
virtual ~NETWinInfo()
Destroys the NETWinInfo object.
Definition: netwm.cpp:2904
NETWinInfo::setAllowedActions
void setAllowedActions(unsigned long actions)
Sets actions that the window manager allows for the window.
Definition: netwm.cpp:3527
NETWinInfo::windowClassName
const char * windowClassName() const
Returns the name component of the window class for the window (i.e.
Definition: netwm.cpp:4682
NETWinInfo::windowClassClass
const char * windowClassClass() const
Returns the class component of the window class for the window (i.e.
Definition: netwm.cpp:4678
NETWinInfo::iconGeometry
NETRect iconGeometry() const
Returns the icon geometry.
Definition: netwm.cpp:4553
NETWinInfo::setIconGeometry
void setIconGeometry(NETRect geometry)
Set the icon geometry for the application window.
Definition: netwm.cpp:2992
NETWinInfo::setName
void setName(const char *name)
Sets the name for the application window.
Definition: netwm.cpp:3386
NET::State
State
Window state.
Definition: netwm_def.h:425
NET::Max
@ Max
convenience value.
Definition: netwm_def.h:449
NET::StaysOnTop
@ StaysOnTop
Definition: netwm_def.h:466
NET::TopMenuMask
@ TopMenuMask
Definition: netwm_def.h:392
NET::DesktopLayoutCorner
DesktopLayoutCorner
Starting corner for desktop layout.
Definition: netwm_def.h:736
NET::DesktopLayoutCornerTopLeft
@ DesktopLayoutCornerTopLeft
Definition: netwm_def.h:737
NET::WindowType
WindowType
Window type.
Definition: netwm_def.h:305
NET::Splash
@ Splash
indicates that this window is a splash screen window.
Definition: netwm_def.h:353
NET::Notification
@ Notification
indicates a notification window
Definition: netwm_def.h:369
NET::Override
@ Override
Definition: netwm_def.h:340
NET::Desktop
@ Desktop
indicates a desktop feature.
Definition: netwm_def.h:320
NET::DNDIcon
@ DNDIcon
indicates a window that represents the dragged object during DND operation
Definition: netwm_def.h:377
NET::Normal
@ Normal
indicates that this is a normal, top-level window
Definition: netwm_def.h:313
NET::Unknown
@ Unknown
indicates that the window did not define a window type.
Definition: netwm_def.h:309
NET::TopMenu
@ TopMenu
indicates a toplevel menu (AKA macmenu).
Definition: netwm_def.h:345
NET::Tooltip
@ Tooltip
indicates a tooltip window
Definition: netwm_def.h:365
NET::Dialog
@ Dialog
indicates that this is a dialog window
Definition: netwm_def.h:336
NET::Toolbar
@ Toolbar
indicates a toolbar window
Definition: netwm_def.h:328
NET::Menu
@ Menu
indicates a pinnable (torn-off) menu window
Definition: netwm_def.h:332
NET::DropdownMenu
@ DropdownMenu
indicates a dropdown menu (from a menubar typically)
Definition: netwm_def.h:357
NET::PopupMenu
@ PopupMenu
indicates a popup menu (a context menu typically)
Definition: netwm_def.h:361
NET::ComboBox
@ ComboBox
indicates that the window is a list for a combobox
Definition: netwm_def.h:373
NET::Dock
@ Dock
indicates a dock or panel feature
Definition: netwm_def.h:324
NET::Utility
@ Utility
indicates a utility window
Definition: netwm_def.h:349
NET::Role
Role
Application role.
Definition: netwm_def.h:290
NET::Client
@ Client
indicates that the application is a client application.
Definition: netwm_def.h:294
NET::WindowManager
@ WindowManager
indicates that the application is a window manager application.
Definition: netwm_def.h:298
NET::typeMatchesMask
static bool typeMatchesMask(WindowType type, unsigned long mask)
Returns true if the given window type matches the mask given using WindowTypeMask flags.
Definition: netwm.cpp:4575
NET::OnAllDesktops
@ OnAllDesktops
Definition: netwm_def.h:704
NET::Property2
Property2
Supported properties.
Definition: netwm_def.h:675
NET::WM2DesktopLayout
@ WM2DesktopLayout
Definition: netwm_def.h:691
NET::WM2WindowClass
@ WM2WindowClass
Definition: netwm_def.h:686
NET::WM2TakeActivity
@ WM2TakeActivity
Definition: netwm_def.h:684
NET::WM2WindowRole
@ WM2WindowRole
Definition: netwm_def.h:687
NET::WM2TransientFor
@ WM2TransientFor
Definition: netwm_def.h:678
NET::WM2GroupLeader
@ WM2GroupLeader
Definition: netwm_def.h:679
NET::WM2ClientMachine
@ WM2ClientMachine
Definition: netwm_def.h:688
NET::timestampCompare
static int timestampCompare(unsigned long time1, unsigned long time2)
Compares two X timestamps, taking into account wrapping and 64bit architectures.
Definition: netwm.cpp:4735
NET::Property
Property
Supported properties.
Definition: netwm_def.h:612
NET::SupportingWMCheck
@ SupportingWMCheck
Definition: netwm_def.h:624
NET::WMPing
@ WMPing
Definition: netwm_def.h:641
NET::DesktopNames
@ DesktopNames
Definition: netwm_def.h:621
NET::Supported
@ Supported
Definition: netwm_def.h:614
NET::XAWMState
@ XAWMState
Definition: netwm_def.h:642
NET::WMGeometry
@ WMGeometry
Definition: netwm_def.h:648
NET::RequestSource
RequestSource
Source of the request.
Definition: netwm_def.h:710
NET::FromTool
@ FromTool
indicated that the request comes from pager or similar tool
Definition: netwm_def.h:722
NET::FromUnknown
@ FromUnknown
Definition: netwm_def.h:714
NET::Direction
Direction
Direction for WMMoveResize.
Definition: netwm_def.h:512
NET::timestampDiff
static int timestampDiff(unsigned long time1, unsigned long time2)
Returns a difference of two X timestamps, time2 - time1, where time2 must be later than time1,...
Definition: netwm.cpp:4740
NET::Action
Action
Actions that can be done with a window (_NET_WM_ALLOWED_ACTIONS).
Definition: netwm_def.h:553
NET::ActionClose
@ ActionClose
Definition: netwm_def.h:564
NET::Orientation
Orientation
Orientation.
Definition: netwm_def.h:728
NET::OrientationHorizontal
@ OrientationHorizontal
Definition: netwm_def.h:729
NET::MappingState
MappingState
Client window mapping state.
Definition: netwm_def.h:533
NET::Iconic
@ Iconic
indicates that the client window is not visible, but its icon is.
Definition: netwm_def.h:547
NET::Withdrawn
@ Withdrawn
indicates that neither the client window nor its icon is visible.
Definition: netwm_def.h:541
NET::Visible
@ Visible
indicates the client window is visible to the user.
Definition: netwm_def.h:537
QList
mask
#define mask
Atom
unsigned long Atom
Definition: kapplication.h:40
kwindowsystem.h
kxutils.h
KStandardAction::FullScreen
@ FullScreen
Definition: kstandardaction.h:161
KStandardGuiItem::ok
KGuiItem ok()
Returns the 'Ok' gui item.
Definition: kstandardguiitem.cpp:107
KStandardGuiItem::CloseWindow
@ CloseWindow
Definition: kstandardguiitem.h:53
KXUtils::timestampDiff
int timestampDiff(unsigned long time1_, unsigned long time2_)
Returns a difference of two X timestamps, time2 - time1, where time2 must be later than time1,...
Definition: kxutils.cpp:120
KXUtils::timestampCompare
int timestampCompare(unsigned long time1_, unsigned long time2_)
Compares two X timestamps, taking into account wrapping and 64bit architectures.
Definition: kxutils.cpp:111
Window
Window
None
None
net_wm_state_hidden
static Atom net_wm_state_hidden
Definition: netwm.cpp:132
net_wm_window_type_splash
static Atom net_wm_window_type_splash
Definition: netwm.cpp:116
net_wm_allowed_actions
static Atom net_wm_allowed_actions
Definition: netwm.cpp:87
net_wm_window_type
static Atom net_wm_window_type
Definition: netwm.cpp:77
net_wm_state
static Atom net_wm_state
Definition: netwm.cpp:78
net_wm_window_opacity
static Atom net_wm_window_opacity
Definition: netwm.cpp:90
net_wm_window_type_dialog
static Atom net_wm_window_type_dialog
Definition: netwm.cpp:114
nwindup
static Window * nwindup(const Window *w1, int n)
Definition: netwm.cpp:186
net_supporting_wm_check
static Atom net_supporting_wm_check
Definition: netwm.cpp:60
net_wm_window_type_toolbar
static Atom net_wm_window_type_toolbar
Definition: netwm.cpp:112
net_wm_strut
static Atom net_wm_strut
Definition: netwm.cpp:79
net_supported
static Atom net_supported
Definition: netwm.cpp:50
net_wm_action_max_horiz
static Atom net_wm_action_max_horiz
Definition: netwm.cpp:145
netwm_atoms_created
static Bool netwm_atoms_created
Definition: netwm.cpp:159
MAX_PROP_SIZE
const long MAX_PROP_SIZE
Definition: netwm.cpp:164
net_close_window
static Atom net_close_window
Definition: netwm.cpp:66
net_wm_state_stays_on_top
static Atom net_wm_state_stays_on_top
Definition: netwm.cpp:151
net_wm_desktop
static Atom net_wm_desktop
Definition: netwm.cpp:76
net_wm_icon_name
static Atom net_wm_icon_name
Definition: netwm.cpp:74
net_wm_icon_geometry
static Atom net_wm_icon_geometry
Definition: netwm.cpp:81
net_current_desktop
static Atom net_current_desktop
Definition: netwm.cpp:55
net_wm_state_shaded
static Atom net_wm_state_shaded
Definition: netwm.cpp:129
net_wm_state_skip_pager
static Atom net_wm_state_skip_pager
Definition: netwm.cpp:131
net_wm_action_max_vert
static Atom net_wm_action_max_vert
Definition: netwm.cpp:144
net_wm_pid
static Atom net_wm_pid
Definition: netwm.cpp:83
net_desktop_viewport
static Atom net_desktop_viewport
Definition: netwm.cpp:54
net_wm_window_type_notification
static Atom net_wm_window_type_notification
Definition: netwm.cpp:120
net_wm_name
static Atom net_wm_name
Definition: netwm.cpp:72
net_wm_action_close
static Atom net_wm_action_close
Definition: netwm.cpp:148
wcmp
static int wcmp(const void *a, const void *b)
Definition: netwm.cpp:249
kde_net_wm_window_type_topmenu
static Atom kde_net_wm_window_type_topmenu
Definition: netwm.cpp:96
kde_net_wm_shadow
static Atom kde_net_wm_shadow
Definition: netwm.cpp:101
net_wm_full_placement
static Atom net_wm_full_placement
Definition: netwm.cpp:157
net_wm_state_max_horiz
static Atom net_wm_state_max_horiz
Definition: netwm.cpp:128
net_wm_state_skip_taskbar
static Atom net_wm_state_skip_taskbar
Definition: netwm.cpp:130
net_wm_window_type_popup_menu
static Atom net_wm_window_type_popup_menu
Definition: netwm.cpp:118
nstrndup
static char * nstrndup(const char *s1, int l)
Definition: netwm.cpp:176
net_wm_action_minimize
static Atom net_wm_action_minimize
Definition: netwm.cpp:141
net_wm_window_type_tooltip
static Atom net_wm_window_type_tooltip
Definition: netwm.cpp:119
kde_net_wm_frame_overlap
static Atom kde_net_wm_frame_overlap
Definition: netwm.cpp:98
net_wm_state_demands_attention
static Atom net_wm_state_demands_attention
Definition: netwm.cpp:136
net_wm_action_stick
static Atom net_wm_action_stick
Definition: netwm.cpp:143
net_wm_ping
static Atom net_wm_ping
Definition: netwm.cpp:105
net_wm_state_fullscreen
static Atom net_wm_state_fullscreen
Definition: netwm.cpp:133
wm_protocols
static Atom wm_protocols
Definition: netwm.cpp:104
kde_net_wm_block_compositing
static Atom kde_net_wm_block_compositing
Definition: netwm.cpp:100
refdec_nri
static void refdec_nri(NETRootInfoPrivate *p)
Definition: netwm.cpp:195
net_wm_extended_strut
static Atom net_wm_extended_strut
Definition: netwm.cpp:80
UTF8_STRING
static Atom UTF8_STRING
Definition: netwm.cpp:47
net_wm_action_fullscreen
static Atom net_wm_action_fullscreen
Definition: netwm.cpp:146
kde_net_wm_window_type_override
static Atom kde_net_wm_window_type_override
Definition: netwm.cpp:95
net_wm_state_above
static Atom net_wm_state_above
Definition: netwm.cpp:134
net_wm_window_type_combobox
static Atom net_wm_window_type_combobox
Definition: netwm.cpp:121
nstrdup
static char * nstrdup(const char *s1)
Definition: netwm.cpp:166
net_workarea
static Atom net_workarea
Definition: netwm.cpp:59
net_wm_fullscreen_monitors
static Atom net_wm_fullscreen_monitors
Definition: netwm.cpp:92
kde_net_wm_activities
static Atom kde_net_wm_activities
Definition: netwm.cpp:99
net_desktop_geometry
static Atom net_desktop_geometry
Definition: netwm.cpp:53
kde_net_wm_temporary_rules
static Atom kde_net_wm_temporary_rules
Definition: netwm.cpp:97
net_wm_window_type_desktop
static Atom net_wm_window_type_desktop
Definition: netwm.cpp:110
net_wm_handled_icons
static Atom net_wm_handled_icons
Definition: netwm.cpp:85
net_wm_action_resize
static Atom net_wm_action_resize
Definition: netwm.cpp:140
net_client_list
static Atom net_client_list
Definition: netwm.cpp:51
net_restack_window
static Atom net_restack_window
Definition: netwm.cpp:67
xa_wm_state
static Atom xa_wm_state
Definition: netwm.cpp:154
net_startup_id
static Atom net_startup_id
Definition: netwm.cpp:86
net_virtual_roots
static Atom net_virtual_roots
Definition: netwm.cpp:61
kde_net_wm_frame_strut
static Atom kde_net_wm_frame_strut
Definition: netwm.cpp:91
readIcon
static void readIcon(Display *display, Window window, Atom property, NETRArray< NETIcon > &icons, int &icon_count)
Definition: netwm.cpp:479
wm_window_role
static Atom wm_window_role
Definition: netwm.cpp:88
net_wm_window_type_dropdown_menu
static Atom net_wm_window_type_dropdown_menu
Definition: netwm.cpp:117
net_active_window
static Atom net_active_window
Definition: netwm.cpp:58
net_desktop_layout
static Atom net_desktop_layout
Definition: netwm.cpp:63
net_wm_action_shade
static Atom net_wm_action_shade
Definition: netwm.cpp:142
net_number_of_desktops
static Atom net_number_of_desktops
Definition: netwm.cpp:57
create_netwm_atoms
static void create_netwm_atoms(Display *d)
Definition: netwm.cpp:260
netAtomCount
static const int netAtomCount
Definition: netwm.cpp:259
net_wm_window_type_normal
static Atom net_wm_window_type_normal
Definition: netwm.cpp:109
net_wm_user_time
static Atom net_wm_user_time
Definition: netwm.cpp:84
net_wm_visible_name
static Atom net_wm_visible_name
Definition: netwm.cpp:73
net_wm_action_change_desk
static Atom net_wm_action_change_desk
Definition: netwm.cpp:147
net_desktop_names
static Atom net_desktop_names
Definition: netwm.cpp:56
net_wm_window_type_menu
static Atom net_wm_window_type_menu
Definition: netwm.cpp:113
net_moveresize_window
static Atom net_moveresize_window
Definition: netwm.cpp:69
net_wm_state_sticky
static Atom net_wm_state_sticky
Definition: netwm.cpp:126
net_wm_state_below
static Atom net_wm_state_below
Definition: netwm.cpp:135
net_client_list_stacking
static Atom net_client_list_stacking
Definition: netwm.cpp:52
net_wm_visible_icon_name
static Atom net_wm_visible_icon_name
Definition: netwm.cpp:75
net_wm_window_type_dnd
static Atom net_wm_window_type_dnd
Definition: netwm.cpp:122
net_wm_take_activity
static Atom net_wm_take_activity
Definition: netwm.cpp:106
netwm_sendevent_mask
const unsigned long netwm_sendevent_mask
Definition: netwm.cpp:160
net_showing_desktop
static Atom net_showing_desktop
Definition: netwm.cpp:62
net_wm_icon
static Atom net_wm_icon
Definition: netwm.cpp:82
CHECK_TYPE_MASK
#define CHECK_TYPE_MASK(type)
net_frame_extents
static Atom net_frame_extents
Definition: netwm.cpp:89
net_wm_window_type_utility
static Atom net_wm_window_type_utility
Definition: netwm.cpp:115
refdec_nwi
static void refdec_nwi(NETWinInfoPrivate *p)
Definition: netwm.cpp:219
net_wm_state_modal
static Atom net_wm_state_modal
Definition: netwm.cpp:125
net_wm_state_max_vert
static Atom net_wm_state_max_vert
Definition: netwm.cpp:127
net_wm_window_type_dock
static Atom net_wm_window_type_dock
Definition: netwm.cpp:111
net_wm_action_move
static Atom net_wm_action_move
Definition: netwm.cpp:139
net_wm_moveresize
static Atom net_wm_moveresize
Definition: netwm.cpp:68
netwm.h
NETExtendedStrut
Partial strut class for NET classes.
Definition: netwm_def.h:152
NETExtendedStrut::bottom_width
int bottom_width
Bottom border of the strut, width and range.
Definition: netwm_def.h:178
NETExtendedStrut::left_end
int left_end
Definition: netwm_def.h:163
NETExtendedStrut::top_start
int top_start
Definition: netwm_def.h:173
NETExtendedStrut::bottom_start
int bottom_start
Definition: netwm_def.h:178
NETExtendedStrut::left_width
int left_width
Left border of the strut, width and range.
Definition: netwm_def.h:163
NETExtendedStrut::right_width
int right_width
Right border of the strut, width and range.
Definition: netwm_def.h:168
NETExtendedStrut::left_start
int left_start
Definition: netwm_def.h:163
NETExtendedStrut::bottom_end
int bottom_end
Definition: netwm_def.h:178
NETExtendedStrut::top_end
int top_end
Definition: netwm_def.h:173
NETExtendedStrut::top_width
int top_width
Top border of the strut, width and range.
Definition: netwm_def.h:173
NETExtendedStrut::right_start
int right_start
Definition: netwm_def.h:168
NETExtendedStrut::right_end
int right_end
Definition: netwm_def.h:168
NETFullscreenMonitors
Simple multiple monitor topology class for NET classes.
Definition: netwm_def.h:234
NETFullscreenMonitors::right
int right
Monitor index whose right border defines the right edge of the topology.
Definition: netwm_def.h:259
NETFullscreenMonitors::top
int top
Monitor index whose top border defines the top edge of the topology.
Definition: netwm_def.h:244
NETFullscreenMonitors::left
int left
Monitor index whose left border defines the left edge of the topology.
Definition: netwm_def.h:254
NETFullscreenMonitors::bottom
int bottom
Monitor index whose bottom border defines the bottom edge of the topology.
Definition: netwm_def.h:249
NETIcon
Simple icon class for NET classes.
Definition: netwm_def.h:121
NETIcon::size
NETSize size
Size of the icon.
Definition: netwm_def.h:132
NETIcon::data
unsigned char * data
Image data for the icon.
Definition: netwm_def.h:139
NETPoint
Simple point class for NET classes.
Definition: netwm_def.h:43
NETPoint::x
int x
x coordinate.
Definition: netwm_def.h:52
NETPoint::y
int y
y coordinate
Definition: netwm_def.h:53
NETRect
Simple rectangle class for NET classes.
Definition: netwm_def.h:93
NETRect::pos
NETPoint pos
Position of the rectangle.
Definition: netwm_def.h:99
NETRect::size
NETSize size
Size of the rectangle.
Definition: netwm_def.h:106
NETSize
Simple size class for NET classes.
Definition: netwm_def.h:70
NETSize::height
int height
Height.
Definition: netwm_def.h:80
NETSize::width
int width
Width.
Definition: netwm_def.h:79
NETStrut
Definition: netwm_def.h:194
NETStrut::bottom
int bottom
Bottom border of the strut.
Definition: netwm_def.h:218
NETStrut::left
int left
Left border of the strut.
Definition: netwm_def.h:203
NETStrut::right
int right
Right border of the strut.
Definition: netwm_def.h:208
NETStrut::top
int top
Top border of the strut.
Definition: netwm_def.h:213
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal