29 #include <tqapplication.h>
30 #ifdef Q_WS_X11 //FIXME
44 static Atom UTF8_STRING = 0;
47 static Atom net_supported = 0;
48 static Atom net_client_list = 0;
49 static Atom net_client_list_stacking = 0;
50 static Atom net_desktop_geometry = 0;
51 static Atom net_desktop_viewport = 0;
52 static Atom net_current_desktop = 0;
53 static Atom net_desktop_names = 0;
54 static Atom net_number_of_desktops = 0;
55 static Atom net_active_window = 0;
56 static Atom net_workarea = 0;
57 static Atom net_supporting_wm_check = 0;
58 static Atom net_virtual_roots = 0;
59 static Atom net_showing_desktop = 0;
60 static Atom net_desktop_layout = 0;
63 static Atom net_close_window = 0;
64 static Atom net_restack_window = 0;
65 static Atom net_wm_moveresize = 0;
66 static Atom net_moveresize_window = 0;
69 static Atom net_wm_name = 0;
70 static Atom net_wm_visible_name = 0;
71 static Atom net_wm_icon_name = 0;
72 static Atom net_wm_visible_icon_name = 0;
73 static Atom net_wm_desktop = 0;
74 static Atom net_wm_window_type = 0;
75 static Atom net_wm_state = 0;
76 static Atom net_wm_strut = 0;
77 static Atom net_wm_extended_strut = 0;
78 static Atom net_wm_icon_geometry = 0;
79 static Atom net_wm_icon = 0;
80 static Atom net_wm_pid = 0;
81 static Atom net_wm_user_time = 0;
82 static Atom net_wm_handled_icons = 0;
83 static Atom net_startup_id = 0;
84 static Atom net_wm_allowed_actions = 0;
85 static Atom wm_window_role = 0;
86 static Atom net_frame_extents = 0;
89 static Atom kde_net_system_tray_windows = 0;
90 static Atom kde_net_wm_system_tray_window_for = 0;
91 static Atom kde_net_wm_frame_strut = 0;
92 static Atom kde_net_wm_window_type_override = 0;
93 static Atom kde_net_wm_window_type_topmenu = 0;
94 static Atom kde_net_wm_temporary_rules = 0;
97 static Atom wm_protocols = 0;
98 static Atom net_wm_ping = 0;
99 static Atom net_wm_take_activity = 0;
102 static Atom net_wm_window_type_normal = 0;
103 static Atom net_wm_window_type_desktop = 0;
104 static Atom net_wm_window_type_dock = 0;
105 static Atom net_wm_window_type_toolbar = 0;
106 static Atom net_wm_window_type_menu = 0;
107 static Atom net_wm_window_type_dialog = 0;
108 static Atom net_wm_window_type_utility = 0;
109 static Atom net_wm_window_type_splash = 0;
110 static Atom net_wm_window_type_dropdown_menu = 0;
111 static Atom net_wm_window_type_popup_menu = 0;
112 static Atom net_wm_window_type_tooltip = 0;
113 static Atom net_wm_window_type_notification = 0;
114 static Atom net_wm_window_type_combobox = 0;
115 static Atom net_wm_window_type_dnd = 0;
118 static Atom net_wm_state_modal = 0;
119 static Atom net_wm_state_sticky = 0;
120 static Atom net_wm_state_max_vert = 0;
121 static Atom net_wm_state_max_horiz = 0;
122 static Atom net_wm_state_shaded = 0;
123 static Atom net_wm_state_skip_taskbar = 0;
124 static Atom net_wm_state_skip_pager = 0;
125 static Atom net_wm_state_hidden = 0;
126 static Atom net_wm_state_fullscreen = 0;
127 static Atom net_wm_state_above = 0;
128 static Atom net_wm_state_below = 0;
129 static Atom net_wm_state_demands_attention = 0;
132 static Atom net_wm_action_move = 0;
133 static Atom net_wm_action_resize = 0;
134 static Atom net_wm_action_minimize = 0;
135 static Atom net_wm_action_shade = 0;
136 static Atom net_wm_action_stick = 0;
137 static Atom net_wm_action_max_vert = 0;
138 static Atom net_wm_action_max_horiz = 0;
139 static Atom net_wm_action_fullscreen = 0;
140 static Atom net_wm_action_change_desk = 0;
141 static Atom net_wm_action_close = 0;
144 static Atom net_wm_state_stays_on_top = 0;
147 static Atom xa_wm_state = 0;
150 static Atom net_wm_full_placement = 0;
152 static Bool netwm_atoms_created = False;
153 const unsigned long netwm_sendevent_mask = (SubstructureRedirectMask|
154 SubstructureNotifyMask);
157 const long MAX_PROP_SIZE = 100000;
159 static char *nstrdup(
const char *s1) {
160 if (! s1)
return (
char *) 0;
162 int l = strlen(s1) + 1;
163 char *s2 =
new char[l];
169 static char *nstrndup(
const char *s1,
int l) {
170 if (! s1 || l == 0)
return (
char *) 0;
172 char *s2 =
new char[l+1];
179 static Window *nwindup(Window *w1,
int n) {
180 if (! w1 || n == 0)
return (Window *) 0;
182 Window *w2 =
new Window[n];
183 while (n--) w2[n] = w1[n];
188 static void refdec_nri(NETRootInfoPrivate *p) {
191 fprintf(stderr,
"NET: decrementing NETRootInfoPrivate::ref (%d)\n", p->ref - 1);
197 fprintf(stderr,
"NET: \tno more references, deleting\n");
201 delete [] p->stacking;
202 delete [] p->clients;
203 delete [] p->virtual_roots;
204 delete [] p->kde_system_tray_windows;
207 for (i = 0; i < p->desktop_names.size(); i++)
208 delete [] p->desktop_names[i];
213 static void refdec_nwi(NETWinInfoPrivate *p) {
216 fprintf(stderr,
"NET: decrementing NETWinInfoPrivate::ref (%d)\n", p->ref - 1);
222 fprintf(stderr,
"NET: \tno more references, deleting\n");
226 delete [] p->visible_name;
227 delete [] p->icon_name;
228 delete [] p->visible_icon_name;
229 delete [] p->startup_id;
232 for (i = 0; i < p->icons.size(); i++)
233 delete [] p->icons[i].data;
238 static int wcmp(
const void *a,
const void *b) {
239 return *((Window *) a) - *((Window *) b);
243 static const int netAtomCount = 85;
244 static void create_atoms(Display *d) {
245 static const char *
const names[netAtomCount] =
249 "_NET_SUPPORTING_WM_CHECK",
251 "_NET_CLIENT_LIST_STACKING",
252 "_NET_NUMBER_OF_DESKTOPS",
253 "_NET_DESKTOP_GEOMETRY",
254 "_NET_DESKTOP_VIEWPORT",
255 "_NET_CURRENT_DESKTOP",
256 "_NET_DESKTOP_NAMES",
257 "_NET_ACTIVE_WINDOW",
259 "_NET_VIRTUAL_ROOTS",
260 "_NET_DESKTOP_LAYOUT",
261 "_NET_SHOWING_DESKTOP",
263 "_NET_RESTACK_WINDOW",
265 "_NET_WM_MOVERESIZE",
266 "_NET_MOVERESIZE_WINDOW",
268 "_NET_WM_VISIBLE_NAME",
270 "_NET_WM_VISIBLE_ICON_NAME",
272 "_NET_WM_WINDOW_TYPE",
275 "_NET_WM_STRUT_PARTIAL",
276 "_NET_WM_ICON_GEOMETRY",
280 "_NET_WM_HANDLED_ICONS",
282 "_NET_WM_ALLOWED_ACTIONS",
284 "_NET_WM_TAKE_ACTIVITY",
286 "_NET_FRAME_EXTENTS",
288 "_NET_WM_WINDOW_TYPE_NORMAL",
289 "_NET_WM_WINDOW_TYPE_DESKTOP",
290 "_NET_WM_WINDOW_TYPE_DOCK",
291 "_NET_WM_WINDOW_TYPE_TOOLBAR",
292 "_NET_WM_WINDOW_TYPE_MENU",
293 "_NET_WM_WINDOW_TYPE_DIALOG",
294 "_NET_WM_WINDOW_TYPE_UTILITY",
295 "_NET_WM_WINDOW_TYPE_SPLASH",
296 "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU",
297 "_NET_WM_WINDOW_TYPE_POPUP_MENU",
298 "_NET_WM_WINDOW_TYPE_TOOLTIP",
299 "_NET_WM_WINDOW_TYPE_NOTIFICATION",
300 "_NET_WM_WINDOW_TYPE_COMBOBOX",
301 "_NET_WM_WINDOW_TYPE_DND",
303 "_NET_WM_STATE_MODAL",
304 "_NET_WM_STATE_STICKY",
305 "_NET_WM_STATE_MAXIMIZED_VERT",
306 "_NET_WM_STATE_MAXIMIZED_HORZ",
307 "_NET_WM_STATE_SHADED",
308 "_NET_WM_STATE_SKIP_TASKBAR",
309 "_NET_WM_STATE_SKIP_PAGER",
310 "_NET_WM_STATE_HIDDEN",
311 "_NET_WM_STATE_FULLSCREEN",
312 "_NET_WM_STATE_ABOVE",
313 "_NET_WM_STATE_BELOW",
314 "_NET_WM_STATE_DEMANDS_ATTENTION",
316 "_NET_WM_ACTION_MOVE",
317 "_NET_WM_ACTION_RESIZE",
318 "_NET_WM_ACTION_MINIMIZE",
319 "_NET_WM_ACTION_SHADE",
320 "_NET_WM_ACTION_STICK",
321 "_NET_WM_ACTION_MAXIMIZE_VERT",
322 "_NET_WM_ACTION_MAXIMIZE_HORZ",
323 "_NET_WM_ACTION_FULLSCREEN",
324 "_NET_WM_ACTION_CHANGE_DESKTOP",
325 "_NET_WM_ACTION_CLOSE",
327 "_NET_WM_STATE_STAYS_ON_TOP",
329 "_KDE_NET_SYSTEM_TRAY_WINDOWS",
330 "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR",
331 "_KDE_NET_WM_FRAME_STRUT",
332 "_KDE_NET_WM_WINDOW_TYPE_OVERRIDE",
333 "_KDE_NET_WM_WINDOW_TYPE_TOPMENU",
334 "_KDE_NET_WM_TEMPORARY_RULES",
339 "_NET_WM_FULL_PLACEMENT"
342 Atom atoms[netAtomCount], *atomsp[netAtomCount] =
346 &net_supporting_wm_check,
348 &net_client_list_stacking,
349 &net_number_of_desktops,
350 &net_desktop_geometry,
351 &net_desktop_viewport,
352 &net_current_desktop,
358 &net_showing_desktop,
363 &net_moveresize_window,
365 &net_wm_visible_name,
367 &net_wm_visible_icon_name,
372 &net_wm_extended_strut,
373 &net_wm_icon_geometry,
377 &net_wm_handled_icons,
379 &net_wm_allowed_actions,
381 &net_wm_take_activity,
385 &net_wm_window_type_normal,
386 &net_wm_window_type_desktop,
387 &net_wm_window_type_dock,
388 &net_wm_window_type_toolbar,
389 &net_wm_window_type_menu,
390 &net_wm_window_type_dialog,
391 &net_wm_window_type_utility,
392 &net_wm_window_type_splash,
393 &net_wm_window_type_dropdown_menu,
394 &net_wm_window_type_popup_menu,
395 &net_wm_window_type_tooltip,
396 &net_wm_window_type_notification,
397 &net_wm_window_type_combobox,
398 &net_wm_window_type_dnd,
401 &net_wm_state_sticky,
402 &net_wm_state_max_vert,
403 &net_wm_state_max_horiz,
404 &net_wm_state_shaded,
405 &net_wm_state_skip_taskbar,
406 &net_wm_state_skip_pager,
407 &net_wm_state_hidden,
408 &net_wm_state_fullscreen,
411 &net_wm_state_demands_attention,
414 &net_wm_action_resize,
415 &net_wm_action_minimize,
416 &net_wm_action_shade,
417 &net_wm_action_stick,
418 &net_wm_action_max_vert,
419 &net_wm_action_max_horiz,
420 &net_wm_action_fullscreen,
421 &net_wm_action_change_desk,
422 &net_wm_action_close,
424 &net_wm_state_stays_on_top,
426 &kde_net_system_tray_windows,
427 &kde_net_wm_system_tray_window_for,
428 &kde_net_wm_frame_strut,
429 &kde_net_wm_window_type_override,
430 &kde_net_wm_window_type_topmenu,
431 &kde_net_wm_temporary_rules,
436 &net_wm_full_placement
439 assert( !netwm_atoms_created );
441 int i = netAtomCount;
445 XInternAtoms(d, (
char **) names, netAtomCount, False, atoms);
449 *atomsp[i] = atoms[i];
451 netwm_atoms_created = True;
455 static void readIcon(Display* display, Window window, Atom property, NETRArray<NETIcon>& icons,
int& icon_count) {
458 fprintf(stderr,
"NET: readIcon\n");
463 unsigned long nitems_ret = 0, after_ret = 0;
464 unsigned char *data_ret = 0;
467 for (
int i = 0; i < icons.size(); i++)
468 delete [] icons[i].data;
473 unsigned char *buffer = 0;
474 unsigned long offset = 0;
475 unsigned long buffer_offset = 0;
476 unsigned long bufsize = 0;
480 if (XGetWindowProperty(display, window, property, offset,
481 MAX_PROP_SIZE, False, XA_CARDINAL, &type_ret,
482 &format_ret, &nitems_ret, &after_ret, &data_ret)
486 if (nitems_ret < 3 || type_ret != XA_CARDINAL ||
497 bufsize = nitems_ret *
sizeof(long) + after_ret;
498 buffer = (
unsigned char *) malloc(bufsize);
500 else if (buffer_offset + nitems_ret*
sizeof(
long) > bufsize)
502 fprintf(stderr,
"NETWM: Warning readIcon() needs buffer adjustment!\n");
503 bufsize = buffer_offset + nitems_ret *
sizeof(long) + after_ret;
504 buffer = (
unsigned char *) realloc(buffer, bufsize);
506 memcpy((buffer + buffer_offset), data_ret, nitems_ret *
sizeof(
long));
507 buffer_offset += nitems_ret *
sizeof(long);
508 offset += nitems_ret;
518 while (after_ret > 0);
521 unsigned long i, j, k, sz, s;
522 unsigned long *d = (
unsigned long *) buffer;
523 for (i = 0, j = 0; i < bufsize;) {
524 icons[j].size.width = *d++;
526 icons[j].size.height = *d++;
529 sz = icons[j].size.width * icons[j].size.height;
530 s = sz *
sizeof(long);
532 if ( i + s - 1 > bufsize || sz == 0 || sz > 1024 * 1024 ) {
536 delete [] icons[j].data;
537 data32 =
new CARD32[sz];
538 icons[j].data = (
unsigned char *) data32;
539 for (k = 0; k < sz; k++, i +=
sizeof(long)) {
540 *data32++ = (CARD32) *d++;
547 fprintf(stderr,
"NET: readIcon got %d icons\n", icon_count);
555 NETRArray<Z>::NETRArray()
558 d = (Z*) calloc(capacity,
sizeof(Z));
563 NETRArray<Z>::~NETRArray() {
569 void NETRArray<Z>::reset() {
572 d = (Z*) realloc(d,
sizeof(Z)*capacity);
573 memset( (
void*) d, 0,
sizeof(Z)*capacity );
577 Z &NETRArray<Z>::operator[](
int index) {
578 if (index >= capacity) {
582 int newcapacity = 2*capacity > index+1 ? 2*capacity : index+1;
584 d = (Z*) realloc(d,
sizeof(Z)*newcapacity);
585 memset( (
void*) &d[capacity], 0,
sizeof(Z)*(newcapacity-capacity) );
586 capacity = newcapacity;
597 NETRootInfo::NETRootInfo(Display *display, Window supportWindow,
const char *wmName,
598 const unsigned long properties[],
int properties_size,
599 int screen,
bool doActivate)
603 fprintf(stderr,
"NETRootInfo::NETRootInfo: using window manager constructor\n");
606 p =
new NETRootInfoPrivate;
609 p->display = display;
610 p->name = nstrdup(wmName);
615 p->screen = DefaultScreen(p->display);
618 p->root = RootWindow(p->display, p->screen);
619 p->supportwindow = supportWindow;
620 p->number_of_desktops = p->current_desktop = 0;
622 p->clients = p->stacking = p->virtual_roots = (Window *) 0;
623 p->clients_count = p->stacking_count = p->virtual_roots_count = 0;
624 p->kde_system_tray_windows = 0;
625 p->kde_system_tray_windows_count = 0;
626 p->showing_desktop =
false;
627 p->desktop_layout_orientation = OrientationHorizontal;
628 p->desktop_layout_corner = DesktopLayoutCornerTopLeft;
629 p->desktop_layout_columns = p->desktop_layout_rows = 0;
630 setDefaultProperties();
631 if( properties_size > PROPERTIES_SIZE ) {
632 fprintf( stderr,
"[netwm] NETRootInfo::NETRootInfo(): properties array too large\n");
633 properties_size = PROPERTIES_SIZE;
635 for(
int i = 0; i < properties_size; ++i )
636 p->properties[ i ] = properties[ i ];
638 p->properties[ PROTOCOLS ] |= ( Supported | SupportingWMCheck );
639 p->client_properties[ PROTOCOLS ] = DesktopNames
641 p->client_properties[ PROTOCOLS2 ] = WM2TakeActivity | WM2DesktopLayout;
643 role = WindowManager;
645 if (! netwm_atoms_created) create_atoms(p->display);
647 if (doActivate) activate();
650 NETRootInfo::NETRootInfo(Display *display, Window supportWindow,
const char *wmName,
651 unsigned long properties,
int screen,
bool doActivate)
655 fprintf(stderr,
"NETRootInfo::NETRootInfo: using window manager constructor\n");
658 p =
new NETRootInfoPrivate;
661 p->display = display;
662 p->name = nstrdup(wmName);
667 p->screen = DefaultScreen(p->display);
670 p->root = RootWindow(p->display, p->screen);
671 p->supportwindow = supportWindow;
672 p->number_of_desktops = p->current_desktop = 0;
674 p->clients = p->stacking = p->virtual_roots = (Window *) 0;
675 p->clients_count = p->stacking_count = p->virtual_roots_count = 0;
676 p->kde_system_tray_windows = 0;
677 p->kde_system_tray_windows_count = 0;
678 p->showing_desktop =
false;
679 setDefaultProperties();
680 p->properties[ PROTOCOLS ] = properties;
682 p->properties[ PROTOCOLS ] |= ( Supported | SupportingWMCheck );
683 p->client_properties[ PROTOCOLS ] = DesktopNames
685 p->client_properties[ PROTOCOLS2 ] = WM2TakeActivity;
687 role = WindowManager;
689 if (! netwm_atoms_created) create_atoms(p->display);
691 if (doActivate) activate();
695 NETRootInfo::NETRootInfo(Display *display,
const unsigned long properties[],
int properties_size,
696 int screen,
bool doActivate)
700 fprintf(stderr,
"NETRootInfo::NETRootInfo: using Client constructor\n");
703 p =
new NETRootInfoPrivate;
708 p->display = display;
713 p->screen = DefaultScreen(p->display);
716 p->root = RootWindow(p->display, p->screen);
717 p->rootSize.width = WidthOfScreen(ScreenOfDisplay(p->display, p->screen));
718 p->rootSize.height = HeightOfScreen(ScreenOfDisplay(p->display, p->screen));
720 p->supportwindow = None;
721 p->number_of_desktops = p->current_desktop = 0;
723 p->clients = p->stacking = p->virtual_roots = (Window *) 0;
724 p->clients_count = p->stacking_count = p->virtual_roots_count = 0;
725 p->kde_system_tray_windows = 0;
726 p->kde_system_tray_windows_count = 0;
727 p->showing_desktop =
false;
728 p->desktop_layout_orientation = OrientationHorizontal;
729 p->desktop_layout_corner = DesktopLayoutCornerTopLeft;
730 p->desktop_layout_columns = p->desktop_layout_rows = 0;
731 setDefaultProperties();
732 if( properties_size > 2 ) {
733 fprintf( stderr,
"[netwm] NETWinInfo::NETWinInfo(): properties array too large\n");
736 for(
int i = 0; i < properties_size; ++i )
740 p->client_properties[ PROTOCOLS ] = properties[ i ];
743 p->client_properties[ PROTOCOLS2 ] = properties[ i ];
746 for(
int i = 0; i < PROPERTIES_SIZE; ++i )
747 p->properties[ i ] = 0;
751 if (! netwm_atoms_created) create_atoms(p->display);
753 if (doActivate) activate();
756 NETRootInfo::NETRootInfo(Display *display,
unsigned long properties,
int screen,
761 fprintf(stderr,
"NETRootInfo::NETRootInfo: using Client constructor\n");
764 p =
new NETRootInfoPrivate;
769 p->display = display;
774 p->screen = DefaultScreen(p->display);
777 p->root = RootWindow(p->display, p->screen);
778 p->rootSize.width = WidthOfScreen(ScreenOfDisplay(p->display, p->screen));
779 p->rootSize.height = HeightOfScreen(ScreenOfDisplay(p->display, p->screen));
781 p->supportwindow = None;
782 p->number_of_desktops = p->current_desktop = 0;
784 p->clients = p->stacking = p->virtual_roots = (Window *) 0;
785 p->clients_count = p->stacking_count = p->virtual_roots_count = 0;
786 p->kde_system_tray_windows = 0;
787 p->kde_system_tray_windows_count = 0;
788 p->showing_desktop =
false;
789 p->desktop_layout_orientation = OrientationHorizontal;
790 p->desktop_layout_corner = DesktopLayoutCornerTopLeft;
791 p->desktop_layout_columns = p->desktop_layout_rows = 0;
792 setDefaultProperties();
793 p->client_properties[ PROTOCOLS ] = properties;
794 for(
int i = 0; i < PROPERTIES_SIZE; ++i )
795 p->properties[ i ] = 0;
799 if (! netwm_atoms_created) create_atoms(p->display);
801 if (doActivate) activate();
805 NETRootInfo2::NETRootInfo2(Display *display, Window supportWindow,
const char *wmName,
806 unsigned long properties[],
int properties_size,
807 int screen,
bool doActivate)
808 : NETRootInfo( display, supportWindow, wmName, properties, properties_size,
813 NETRootInfo2::NETRootInfo2(Display *display,
const unsigned long properties[],
int properties_size,
814 int screen,
bool doActivate)
815 : NETRootInfo( display, properties, properties_size, screen, doActivate )
819 NETRootInfo3::NETRootInfo3(Display *display, Window supportWindow,
const char *wmName,
820 unsigned long properties[],
int properties_size,
821 int screen,
bool doActivate)
822 : NETRootInfo2( display, supportWindow, wmName, properties, properties_size,
827 NETRootInfo3::NETRootInfo3(Display *display,
const unsigned long properties[],
int properties_size,
828 int screen,
bool doActivate)
829 : NETRootInfo2( display, properties, properties_size, screen, doActivate )
833 NETRootInfo4::NETRootInfo4(Display *display, Window supportWindow,
const char *wmName,
834 unsigned long properties[],
int properties_size,
835 int screen,
bool doActivate)
836 : NETRootInfo3( display, supportWindow, wmName, properties, properties_size,
841 NETRootInfo4::NETRootInfo4(Display *display,
const unsigned long properties[],
int properties_size,
842 int screen,
bool doActivate)
843 : NETRootInfo3( display, properties, properties_size, screen, doActivate )
849 NETRootInfo::NETRootInfo(
const NETRootInfo &rootinfo) {
852 fprintf(stderr,
"NETRootInfo::NETRootInfo: using copy constructor\n");
856 role = rootinfo.role;
864 NETRootInfo::~NETRootInfo() {
867 if (! p->ref)
delete p;
871 void NETRootInfo::setDefaultProperties()
873 p->properties[ PROTOCOLS ] = Supported | SupportingWMCheck;
874 p->properties[ WINDOW_TYPES ] = NormalMask | DesktopMask | DockMask
875 | ToolbarMask | MenuMask | DialogMask;
876 p->properties[ STATES ] = Modal | Sticky | MaxVert | MaxHoriz | Shaded
877 | SkipTaskbar | StaysOnTop;
878 p->properties[ PROTOCOLS2 ] = 0;
879 p->properties[ ACTIONS ] = 0;
880 p->client_properties[ PROTOCOLS ] = 0;
881 p->client_properties[ WINDOW_TYPES ] = 0;
882 p->client_properties[ STATES ] = 0;
883 p->client_properties[ PROTOCOLS2 ] = 0;
884 p->client_properties[ ACTIONS ] = 0;
887 void NETRootInfo::activate() {
888 if (role == WindowManager) {
892 "NETRootInfo::activate: setting supported properties on root\n");
896 update(p->client_properties);
900 fprintf(stderr,
"NETRootInfo::activate: updating client information\n");
903 update(p->client_properties);
908 void NETRootInfo::setClientList(Window *windows,
unsigned int count) {
909 if (role != WindowManager)
return;
911 p->clients_count = count;
913 delete [] p->clients;
914 p->clients = nwindup(windows, count);
917 fprintf(stderr,
"NETRootInfo::setClientList: setting list with %ld windows\n",
921 XChangeProperty(p->display, p->root, net_client_list, XA_WINDOW, 32,
922 PropModeReplace, (
unsigned char *)p->clients,
927 void NETRootInfo::setClientListStacking(Window *windows,
unsigned int count) {
928 if (role != WindowManager)
return;
930 p->stacking_count = count;
931 delete [] p->stacking;
932 p->stacking = nwindup(windows, count);
936 "NETRootInfo::setClientListStacking: setting list with %ld windows\n",
940 XChangeProperty(p->display, p->root, net_client_list_stacking, XA_WINDOW, 32,
941 PropModeReplace, (
unsigned char *) p->stacking,
946 void NETRootInfo::setKDESystemTrayWindows(Window *windows,
unsigned int count) {
947 if (role != WindowManager)
return;
949 p->kde_system_tray_windows_count = count;
950 delete [] p->kde_system_tray_windows;
951 p->kde_system_tray_windows = nwindup(windows, count);
955 "NETRootInfo::setKDESystemTrayWindows: setting list with %ld windows\n",
956 p->kde_system_tray_windows_count);
959 XChangeProperty(p->display, p->root, kde_net_system_tray_windows, XA_WINDOW, 32,
961 (
unsigned char *) p->kde_system_tray_windows,
962 p->kde_system_tray_windows_count);
966 void NETRootInfo::setNumberOfDesktops(
int numberOfDesktops) {
970 "NETRootInfo::setNumberOfDesktops: setting desktop count to %d (%s)\n",
971 numberOfDesktops, (role == WindowManager) ?
"WM" :
"Client");
974 if (role == WindowManager) {
975 p->number_of_desktops = numberOfDesktops;
976 long d = numberOfDesktops;
977 XChangeProperty(p->display, p->root, net_number_of_desktops, XA_CARDINAL, 32,
978 PropModeReplace, (
unsigned char *) &d, 1);
982 e.xclient.type = ClientMessage;
983 e.xclient.message_type = net_number_of_desktops;
984 e.xclient.display = p->display;
985 e.xclient.window = p->root;
986 e.xclient.format = 32;
987 e.xclient.data.l[0] = numberOfDesktops;
988 e.xclient.data.l[1] = 0l;
989 e.xclient.data.l[2] = 0l;
990 e.xclient.data.l[3] = 0l;
991 e.xclient.data.l[4] = 0l;
993 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
998 void NETRootInfo::setCurrentDesktop(
int desktop) {
1002 "NETRootInfo::setCurrentDesktop: setting current desktop = %d (%s)\n",
1003 desktop, (role == WindowManager) ?
"WM" :
"Client");
1006 if (role == WindowManager) {
1007 p->current_desktop = desktop;
1008 long d = p->current_desktop - 1;
1009 XChangeProperty(p->display, p->root, net_current_desktop, XA_CARDINAL, 32,
1010 PropModeReplace, (
unsigned char *) &d, 1);
1014 e.xclient.type = ClientMessage;
1015 e.xclient.message_type = net_current_desktop;
1016 e.xclient.display = p->display;
1017 e.xclient.window = p->root;
1018 e.xclient.format = 32;
1019 e.xclient.data.l[0] = desktop - 1;
1020 e.xclient.data.l[1] = 0l;
1021 e.xclient.data.l[2] = 0l;
1022 e.xclient.data.l[3] = 0l;
1023 e.xclient.data.l[4] = 0l;
1025 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
1030 void NETRootInfo::setDesktopName(
int desktop,
const char *desktopName) {
1032 if (desktop < 1)
return;
1034 delete [] p->desktop_names[desktop - 1];
1035 p->desktop_names[desktop - 1] = nstrdup(desktopName);
1037 unsigned int i, proplen,
1038 num = ((p->number_of_desktops > p->desktop_names.size()) ?
1039 p->number_of_desktops : p->desktop_names.size());
1040 for (i = 0, proplen = 0; i < num; i++)
1041 proplen += (p->desktop_names[i] != 0 ? strlen(p->desktop_names[i])+1 : 1 );
1043 char *prop =
new char[proplen], *propp = prop;
1045 for (i = 0; i < num; i++)
1046 if (p->desktop_names[i]) {
1047 strcpy(propp, p->desktop_names[i]);
1048 propp += strlen(p->desktop_names[i]) + 1;
1054 "NETRootInfo::setDesktopName(%d, '%s')\n"
1055 "NETRootInfo::setDesktopName: total property length = %d",
1056 desktop, desktopName, proplen);
1059 XChangeProperty(p->display, p->root, net_desktop_names, UTF8_STRING, 8,
1060 PropModeReplace, (
unsigned char *) prop, proplen);
1066 void NETRootInfo::setDesktopGeometry(
int ,
const NETSize &geometry) {
1069 fprintf(stderr,
"NETRootInfo::setDesktopGeometry( -- , { %d, %d }) (%s)\n",
1070 geometry.
width, geometry.
height, (role == WindowManager) ?
"WM" :
"Client");
1073 if (role == WindowManager) {
1074 p->geometry = geometry;
1077 data[0] = p->geometry.
width;
1078 data[1] = p->geometry.height;
1080 XChangeProperty(p->display, p->root, net_desktop_geometry, XA_CARDINAL, 32,
1081 PropModeReplace, (
unsigned char *) data, 2);
1085 e.xclient.type = ClientMessage;
1086 e.xclient.message_type = net_desktop_geometry;
1087 e.xclient.display = p->display;
1088 e.xclient.window = p->root;
1089 e.xclient.format = 32;
1090 e.xclient.data.l[0] = geometry.
width;
1091 e.xclient.data.l[1] = geometry.
height;
1092 e.xclient.data.l[2] = 0l;
1093 e.xclient.data.l[3] = 0l;
1094 e.xclient.data.l[4] = 0l;
1096 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
1101 void NETRootInfo::setDesktopViewport(
int desktop,
const NETPoint &viewport) {
1104 fprintf(stderr,
"NETRootInfo::setDesktopViewport(%d, { %d, %d }) (%s)\n",
1105 desktop, viewport.
x, viewport.
y, (role == WindowManager) ?
"WM" :
"Client");
1108 if (desktop < 1)
return;
1110 if (role == WindowManager) {
1111 p->viewport[desktop - 1] = viewport;
1114 l = p->number_of_desktops * 2;
1115 long *data =
new long[l];
1116 for (d = 0, i = 0; d < p->number_of_desktops; d++) {
1117 data[i++] = p->viewport[d].
x;
1118 data[i++] = p->viewport[d].y;
1121 XChangeProperty(p->display, p->root, net_desktop_viewport, XA_CARDINAL, 32,
1122 PropModeReplace, (
unsigned char *) data, l);
1128 e.xclient.type = ClientMessage;
1129 e.xclient.message_type = net_desktop_viewport;
1130 e.xclient.display = p->display;
1131 e.xclient.window = p->root;
1132 e.xclient.format = 32;
1133 e.xclient.data.l[0] = viewport.
x;
1134 e.xclient.data.l[1] = viewport.
y;
1135 e.xclient.data.l[2] = 0l;
1136 e.xclient.data.l[3] = 0l;
1137 e.xclient.data.l[4] = 0l;
1139 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
1144 void NETRootInfo::setSupported() {
1145 if (role != WindowManager) {
1147 fprintf(stderr,
"NETRootInfo::setSupported - role != WindowManager\n");
1153 Atom atoms[netAtomCount];
1157 atoms[0] = net_supported;
1158 atoms[1] = net_supporting_wm_check;
1160 if (p->properties[ PROTOCOLS ] & ClientList)
1161 atoms[pnum++] = net_client_list;
1163 if (p->properties[ PROTOCOLS ] & ClientListStacking)
1164 atoms[pnum++] = net_client_list_stacking;
1166 if (p->properties[ PROTOCOLS ] & NumberOfDesktops)
1167 atoms[pnum++] = net_number_of_desktops;
1169 if (p->properties[ PROTOCOLS ] & DesktopGeometry)
1170 atoms[pnum++] = net_desktop_geometry;
1172 if (p->properties[ PROTOCOLS ] & DesktopViewport)
1173 atoms[pnum++] = net_desktop_viewport;
1175 if (p->properties[ PROTOCOLS ] & CurrentDesktop)
1176 atoms[pnum++] = net_current_desktop;
1178 if (p->properties[ PROTOCOLS ] & DesktopNames)
1179 atoms[pnum++] = net_desktop_names;
1181 if (p->properties[ PROTOCOLS ] & ActiveWindow)
1182 atoms[pnum++] = net_active_window;
1184 if (p->properties[ PROTOCOLS ] & WorkArea)
1185 atoms[pnum++] = net_workarea;
1187 if (p->properties[ PROTOCOLS ] & VirtualRoots)
1188 atoms[pnum++] = net_virtual_roots;
1190 if (p->properties[ PROTOCOLS2 ] & WM2DesktopLayout)
1191 atoms[pnum++] = net_desktop_layout;
1193 if (p->properties[ PROTOCOLS ] & CloseWindow)
1194 atoms[pnum++] = net_close_window;
1196 if (p->properties[ PROTOCOLS2 ] & WM2RestackWindow)
1197 atoms[pnum++] = net_restack_window;
1199 if (p->properties[ PROTOCOLS2 ] & WM2ShowingDesktop)
1200 atoms[pnum++] = net_showing_desktop;
1203 if (p->properties[ PROTOCOLS ] & WMMoveResize)
1204 atoms[pnum++] = net_wm_moveresize;
1206 if (p->properties[ PROTOCOLS2 ] & WM2MoveResizeWindow)
1207 atoms[pnum++] = net_moveresize_window;
1209 if (p->properties[ PROTOCOLS ] & WMName)
1210 atoms[pnum++] = net_wm_name;
1212 if (p->properties[ PROTOCOLS ] & WMVisibleName)
1213 atoms[pnum++] = net_wm_visible_name;
1215 if (p->properties[ PROTOCOLS ] & WMIconName)
1216 atoms[pnum++] = net_wm_icon_name;
1218 if (p->properties[ PROTOCOLS ] & WMVisibleIconName)
1219 atoms[pnum++] = net_wm_visible_icon_name;
1221 if (p->properties[ PROTOCOLS ] & WMDesktop)
1222 atoms[pnum++] = net_wm_desktop;
1224 if (p->properties[ PROTOCOLS ] & WMWindowType) {
1225 atoms[pnum++] = net_wm_window_type;
1228 if (p->properties[ WINDOW_TYPES ] & NormalMask)
1229 atoms[pnum++] = net_wm_window_type_normal;
1230 if (p->properties[ WINDOW_TYPES ] & DesktopMask)
1231 atoms[pnum++] = net_wm_window_type_desktop;
1232 if (p->properties[ WINDOW_TYPES ] & DockMask)
1233 atoms[pnum++] = net_wm_window_type_dock;
1234 if (p->properties[ WINDOW_TYPES ] & ToolbarMask)
1235 atoms[pnum++] = net_wm_window_type_toolbar;
1236 if (p->properties[ WINDOW_TYPES ] & MenuMask)
1237 atoms[pnum++] = net_wm_window_type_menu;
1238 if (p->properties[ WINDOW_TYPES ] & DialogMask)
1239 atoms[pnum++] = net_wm_window_type_dialog;
1240 if (p->properties[ WINDOW_TYPES ] & UtilityMask)
1241 atoms[pnum++] = net_wm_window_type_utility;
1242 if (p->properties[ WINDOW_TYPES ] & SplashMask)
1243 atoms[pnum++] = net_wm_window_type_splash;
1244 if (p->properties[ WINDOW_TYPES ] & DropdownMenuMask)
1245 atoms[pnum++] = net_wm_window_type_dropdown_menu;
1246 if (p->properties[ WINDOW_TYPES ] & PopupMenuMask)
1247 atoms[pnum++] = net_wm_window_type_popup_menu;
1248 if (p->properties[ WINDOW_TYPES ] & TooltipMask)
1249 atoms[pnum++] = net_wm_window_type_tooltip;
1250 if (p->properties[ WINDOW_TYPES ] & NotificationMask)
1251 atoms[pnum++] = net_wm_window_type_notification;
1252 if (p->properties[ WINDOW_TYPES ] & ComboBoxMask)
1253 atoms[pnum++] = net_wm_window_type_combobox;
1254 if (p->properties[ WINDOW_TYPES ] & DNDIconMask)
1255 atoms[pnum++] = net_wm_window_type_dnd;
1257 if (p->properties[ WINDOW_TYPES ] & OverrideMask)
1258 atoms[pnum++] = kde_net_wm_window_type_override;
1259 if (p->properties[ WINDOW_TYPES ] & TopMenuMask)
1260 atoms[pnum++] = kde_net_wm_window_type_topmenu;
1263 if (p->properties[ PROTOCOLS ] & WMState) {
1264 atoms[pnum++] = net_wm_state;
1267 if (p->properties[ STATES ] & Modal)
1268 atoms[pnum++] = net_wm_state_modal;
1269 if (p->properties[ STATES ] & Sticky)
1270 atoms[pnum++] = net_wm_state_sticky;
1271 if (p->properties[ STATES ] & MaxVert)
1272 atoms[pnum++] = net_wm_state_max_vert;
1273 if (p->properties[ STATES ] & MaxHoriz)
1274 atoms[pnum++] = net_wm_state_max_horiz;
1275 if (p->properties[ STATES ] & Shaded)
1276 atoms[pnum++] = net_wm_state_shaded;
1277 if (p->properties[ STATES ] & SkipTaskbar)
1278 atoms[pnum++] = net_wm_state_skip_taskbar;
1279 if (p->properties[ STATES ] & SkipPager)
1280 atoms[pnum++] = net_wm_state_skip_pager;
1281 if (p->properties[ STATES ] & Hidden)
1282 atoms[pnum++] = net_wm_state_hidden;
1283 if (p->properties[ STATES ] & FullScreen)
1284 atoms[pnum++] = net_wm_state_fullscreen;
1285 if (p->properties[ STATES ] & KeepAbove)
1286 atoms[pnum++] = net_wm_state_above;
1287 if (p->properties[ STATES ] & KeepBelow)
1288 atoms[pnum++] = net_wm_state_below;
1289 if (p->properties[ STATES ] & DemandsAttention)
1290 atoms[pnum++] = net_wm_state_demands_attention;
1292 if (p->properties[ STATES ] & StaysOnTop)
1293 atoms[pnum++] = net_wm_state_stays_on_top;
1296 if (p->properties[ PROTOCOLS ] & WMStrut)
1297 atoms[pnum++] = net_wm_strut;
1299 if (p->properties[ PROTOCOLS2 ] & WM2ExtendedStrut)
1300 atoms[pnum++] = net_wm_extended_strut;
1302 if (p->properties[ PROTOCOLS ] & WMIconGeometry)
1303 atoms[pnum++] = net_wm_icon_geometry;
1305 if (p->properties[ PROTOCOLS ] & WMIcon)
1306 atoms[pnum++] = net_wm_icon;
1308 if (p->properties[ PROTOCOLS ] & WMPid)
1309 atoms[pnum++] = net_wm_pid;
1311 if (p->properties[ PROTOCOLS ] & WMHandledIcons)
1312 atoms[pnum++] = net_wm_handled_icons;
1314 if (p->properties[ PROTOCOLS ] & WMPing)
1315 atoms[pnum++] = net_wm_ping;
1317 if (p->properties[ PROTOCOLS2 ] & WM2TakeActivity)
1318 atoms[pnum++] = net_wm_take_activity;
1320 if (p->properties[ PROTOCOLS2 ] & WM2UserTime)
1321 atoms[pnum++] = net_wm_user_time;
1323 if (p->properties[ PROTOCOLS2 ] & WM2StartupId)
1324 atoms[pnum++] = net_startup_id;
1326 if (p->properties[ PROTOCOLS2 ] & WM2AllowedActions) {
1327 atoms[pnum++] = net_wm_allowed_actions;
1330 if (p->properties[ ACTIONS ] & ActionMove)
1331 atoms[pnum++] = net_wm_action_move;
1332 if (p->properties[ ACTIONS ] & ActionResize)
1333 atoms[pnum++] = net_wm_action_resize;
1334 if (p->properties[ ACTIONS ] & ActionMinimize)
1335 atoms[pnum++] = net_wm_action_minimize;
1336 if (p->properties[ ACTIONS ] & ActionShade)
1337 atoms[pnum++] = net_wm_action_shade;
1338 if (p->properties[ ACTIONS ] & ActionStick)
1339 atoms[pnum++] = net_wm_action_stick;
1340 if (p->properties[ ACTIONS ] & ActionMaxVert)
1341 atoms[pnum++] = net_wm_action_max_vert;
1342 if (p->properties[ ACTIONS ] & ActionMaxHoriz)
1343 atoms[pnum++] = net_wm_action_max_horiz;
1344 if (p->properties[ ACTIONS ] & ActionFullScreen)
1345 atoms[pnum++] = net_wm_action_fullscreen;
1346 if (p->properties[ ACTIONS ] & ActionChangeDesktop)
1347 atoms[pnum++] = net_wm_action_change_desk;
1348 if (p->properties[ ACTIONS ] & ActionClose)
1349 atoms[pnum++] = net_wm_action_close;
1353 if (p->properties[ PROTOCOLS ] & KDESystemTrayWindows)
1354 atoms[pnum++] = kde_net_system_tray_windows;
1356 if (p->properties[ PROTOCOLS ] & WMKDESystemTrayWinFor)
1357 atoms[pnum++] = kde_net_wm_system_tray_window_for;
1359 if (p->properties[ PROTOCOLS ] & WMFrameExtents) {
1360 atoms[pnum++] = net_frame_extents;
1361 atoms[pnum++] = kde_net_wm_frame_strut;
1364 if (p->properties[ PROTOCOLS2 ] & WM2KDETemporaryRules)
1365 atoms[pnum++] = kde_net_wm_temporary_rules;
1366 if (p->properties[ PROTOCOLS2 ] & WM2FullPlacement)
1367 atoms[pnum++] = net_wm_full_placement;
1369 XChangeProperty(p->display, p->root, net_supported, XA_ATOM, 32,
1370 PropModeReplace, (
unsigned char *) atoms, pnum);
1371 XChangeProperty(p->display, p->root, net_supporting_wm_check, XA_WINDOW, 32,
1372 PropModeReplace, (
unsigned char *) &(p->supportwindow), 1);
1376 "NETRootInfo::setSupported: _NET_SUPPORTING_WM_CHECK = 0x%lx on 0x%lx\n"
1377 " : _NET_WM_NAME = '%s' on 0x%lx\n",
1378 p->supportwindow, p->supportwindow, p->name, p->supportwindow);
1381 XChangeProperty(p->display, p->supportwindow, net_supporting_wm_check,
1382 XA_WINDOW, 32, PropModeReplace,
1383 (
unsigned char *) &(p->supportwindow), 1);
1384 XChangeProperty(p->display, p->supportwindow, net_wm_name, UTF8_STRING, 8,
1385 PropModeReplace, (
unsigned char *) p->name,
1389 void NETRootInfo::updateSupportedProperties( Atom atom )
1391 if( atom == net_supported )
1392 p->properties[ PROTOCOLS ] |= Supported;
1394 else if( atom == net_supporting_wm_check )
1395 p->properties[ PROTOCOLS ] |= SupportingWMCheck;
1397 else if( atom == net_client_list )
1398 p->properties[ PROTOCOLS ] |= ClientList;
1400 else if( atom == net_client_list_stacking )
1401 p->properties[ PROTOCOLS ] |= ClientListStacking;
1403 else if( atom == net_number_of_desktops )
1404 p->properties[ PROTOCOLS ] |= NumberOfDesktops;
1406 else if( atom == net_desktop_geometry )
1407 p->properties[ PROTOCOLS ] |= DesktopGeometry;
1409 else if( atom == net_desktop_viewport )
1410 p->properties[ PROTOCOLS ] |= DesktopViewport;
1412 else if( atom == net_current_desktop )
1413 p->properties[ PROTOCOLS ] |= CurrentDesktop;
1415 else if( atom == net_desktop_names )
1416 p->properties[ PROTOCOLS ] |= DesktopNames;
1418 else if( atom == net_active_window )
1419 p->properties[ PROTOCOLS ] |= ActiveWindow;
1421 else if( atom == net_workarea )
1422 p->properties[ PROTOCOLS ] |= WorkArea;
1424 else if( atom == net_virtual_roots )
1425 p->properties[ PROTOCOLS ] |= VirtualRoots;
1427 else if( atom == net_desktop_layout )
1428 p->properties[ PROTOCOLS2 ] |= WM2DesktopLayout;
1430 else if( atom == net_close_window )
1431 p->properties[ PROTOCOLS ] |= CloseWindow;
1433 else if( atom == net_restack_window )
1434 p->properties[ PROTOCOLS2 ] |= WM2RestackWindow;
1436 else if( atom == net_showing_desktop )
1437 p->properties[ PROTOCOLS2 ] |= WM2ShowingDesktop;
1440 else if( atom == net_wm_moveresize )
1441 p->properties[ PROTOCOLS ] |= WMMoveResize;
1443 else if( atom == net_moveresize_window )
1444 p->properties[ PROTOCOLS2 ] |= WM2MoveResizeWindow;
1446 else if( atom == net_wm_name )
1447 p->properties[ PROTOCOLS ] |= WMName;
1449 else if( atom == net_wm_visible_name )
1450 p->properties[ PROTOCOLS ] |= WMVisibleName;
1452 else if( atom == net_wm_icon_name )
1453 p->properties[ PROTOCOLS ] |= WMIconName;
1455 else if( atom == net_wm_visible_icon_name )
1456 p->properties[ PROTOCOLS ] |= WMVisibleIconName;
1458 else if( atom == net_wm_desktop )
1459 p->properties[ PROTOCOLS ] |= WMDesktop;
1461 else if( atom == net_wm_window_type )
1462 p->properties[ PROTOCOLS ] |= WMWindowType;
1465 else if( atom == net_wm_window_type_normal )
1466 p->properties[ WINDOW_TYPES ] |= NormalMask;
1467 else if( atom == net_wm_window_type_desktop )
1468 p->properties[ WINDOW_TYPES ] |= DesktopMask;
1469 else if( atom == net_wm_window_type_dock )
1470 p->properties[ WINDOW_TYPES ] |= DockMask;
1471 else if( atom == net_wm_window_type_toolbar )
1472 p->properties[ WINDOW_TYPES ] |= ToolbarMask;
1473 else if( atom == net_wm_window_type_menu )
1474 p->properties[ WINDOW_TYPES ] |= MenuMask;
1475 else if( atom == net_wm_window_type_dialog )
1476 p->properties[ WINDOW_TYPES ] |= DialogMask;
1477 else if( atom == net_wm_window_type_utility )
1478 p->properties[ WINDOW_TYPES ] |= UtilityMask;
1479 else if( atom == net_wm_window_type_splash )
1480 p->properties[ WINDOW_TYPES ] |= SplashMask;
1481 else if( atom == net_wm_window_type_dropdown_menu )
1482 p->properties[ WINDOW_TYPES ] |= DropdownMenuMask;
1483 else if( atom == net_wm_window_type_popup_menu )
1484 p->properties[ WINDOW_TYPES ] |= PopupMenuMask;
1485 else if( atom == net_wm_window_type_tooltip )
1486 p->properties[ WINDOW_TYPES ] |= TooltipMask;
1487 else if( atom == net_wm_window_type_notification )
1488 p->properties[ WINDOW_TYPES ] |= NotificationMask;
1489 else if( atom == net_wm_window_type_combobox )
1490 p->properties[ WINDOW_TYPES ] |= ComboBoxMask;
1491 else if( atom == net_wm_window_type_dnd )
1492 p->properties[ WINDOW_TYPES ] |= DNDIconMask;
1494 else if( atom == kde_net_wm_window_type_override )
1495 p->properties[ WINDOW_TYPES ] |= OverrideMask;
1496 else if( atom == kde_net_wm_window_type_topmenu )
1497 p->properties[ WINDOW_TYPES ] |= TopMenuMask;
1499 else if( atom == net_wm_state )
1500 p->properties[ PROTOCOLS ] |= WMState;
1503 else if( atom == net_wm_state_modal )
1504 p->properties[ STATES ] |= Modal;
1505 else if( atom == net_wm_state_sticky )
1506 p->properties[ STATES ] |= Sticky;
1507 else if( atom == net_wm_state_max_vert )
1508 p->properties[ STATES ] |= MaxVert;
1509 else if( atom == net_wm_state_max_horiz )
1510 p->properties[ STATES ] |= MaxHoriz;
1511 else if( atom == net_wm_state_shaded )
1512 p->properties[ STATES ] |= Shaded;
1513 else if( atom == net_wm_state_skip_taskbar )
1514 p->properties[ STATES ] |= SkipTaskbar;
1515 else if( atom == net_wm_state_skip_pager )
1516 p->properties[ STATES ] |= SkipPager;
1517 else if( atom == net_wm_state_hidden )
1518 p->properties[ STATES ] |= Hidden;
1519 else if( atom == net_wm_state_fullscreen )
1520 p->properties[ STATES ] |= FullScreen;
1521 else if( atom == net_wm_state_above )
1522 p->properties[ STATES ] |= KeepAbove;
1523 else if( atom == net_wm_state_below )
1524 p->properties[ STATES ] |= KeepBelow;
1525 else if( atom == net_wm_state_demands_attention )
1526 p->properties[ STATES ] |= DemandsAttention;
1528 else if( atom == net_wm_state_stays_on_top )
1529 p->properties[ STATES ] |= StaysOnTop;
1531 else if( atom == net_wm_strut )
1532 p->properties[ PROTOCOLS ] |= WMStrut;
1534 else if( atom == net_wm_extended_strut )
1535 p->properties[ PROTOCOLS2 ] |= WM2ExtendedStrut;
1537 else if( atom == net_wm_icon_geometry )
1538 p->properties[ PROTOCOLS ] |= WMIconGeometry;
1540 else if( atom == net_wm_icon )
1541 p->properties[ PROTOCOLS ] |= WMIcon;
1543 else if( atom == net_wm_pid )
1544 p->properties[ PROTOCOLS ] |= WMPid;
1546 else if( atom == net_wm_handled_icons )
1547 p->properties[ PROTOCOLS ] |= WMHandledIcons;
1549 else if( atom == net_wm_ping )
1550 p->properties[ PROTOCOLS ] |= WMPing;
1552 else if( atom == net_wm_take_activity )
1553 p->properties[ PROTOCOLS2 ] |= WM2TakeActivity;
1555 else if( atom == net_wm_user_time )
1556 p->properties[ PROTOCOLS2 ] |= WM2UserTime;
1558 else if( atom == net_startup_id )
1559 p->properties[ PROTOCOLS2 ] |= WM2StartupId;
1561 else if( atom == net_wm_allowed_actions )
1562 p->properties[ PROTOCOLS2 ] |= WM2AllowedActions;
1565 else if( atom == net_wm_action_move )
1566 p->properties[ ACTIONS ] |= ActionMove;
1567 else if( atom == net_wm_action_resize )
1568 p->properties[ ACTIONS ] |= ActionResize;
1569 else if( atom == net_wm_action_minimize )
1570 p->properties[ ACTIONS ] |= ActionMinimize;
1571 else if( atom == net_wm_action_shade )
1572 p->properties[ ACTIONS ] |= ActionShade;
1573 else if( atom == net_wm_action_stick )
1574 p->properties[ ACTIONS ] |= ActionStick;
1575 else if( atom == net_wm_action_max_vert )
1576 p->properties[ ACTIONS ] |= ActionMaxVert;
1577 else if( atom == net_wm_action_max_horiz )
1578 p->properties[ ACTIONS ] |= ActionMaxHoriz;
1579 else if( atom == net_wm_action_fullscreen )
1580 p->properties[ ACTIONS ] |= ActionFullScreen;
1581 else if( atom == net_wm_action_change_desk )
1582 p->properties[ ACTIONS ] |= ActionChangeDesktop;
1583 else if( atom == net_wm_action_close )
1584 p->properties[ ACTIONS ] |= ActionClose;
1587 else if( atom == kde_net_system_tray_windows )
1588 p->properties[ PROTOCOLS ] |= KDESystemTrayWindows;
1590 else if( atom == kde_net_wm_system_tray_window_for )
1591 p->properties[ PROTOCOLS ] |= WMKDESystemTrayWinFor;
1593 else if( atom == net_frame_extents )
1594 p->properties[ PROTOCOLS ] |= WMFrameExtents;
1595 else if( atom == kde_net_wm_frame_strut )
1596 p->properties[ PROTOCOLS ] |= WMKDEFrameStrut;
1598 else if( atom == kde_net_wm_temporary_rules )
1599 p->properties[ PROTOCOLS2 ] |= WM2KDETemporaryRules;
1600 else if( atom == net_wm_full_placement )
1601 p->properties[ PROTOCOLS2 ] |= WM2FullPlacement;
1604 void NETRootInfo::setActiveWindow(Window window) {
1605 setActiveWindow( window, FromUnknown, GET_QT_X_USER_TIME(), None );
1609 Time timestamp, Window active_window ) {
1612 fprintf(stderr,
"NETRootInfo::setActiveWindow(0x%lx) (%s)\n",
1613 window, (role == WindowManager) ?
"WM" :
"Client");
1616 if (role == WindowManager) {
1618 XChangeProperty(p->display, p->root, net_active_window, XA_WINDOW, 32,
1619 PropModeReplace, (
unsigned char *) &(p->active), 1);
1623 e.xclient.type = ClientMessage;
1624 e.xclient.message_type = net_active_window;
1625 e.xclient.display = p->display;
1626 e.xclient.window = window;
1627 e.xclient.format = 32;
1628 e.xclient.data.l[0] = src;
1629 e.xclient.data.l[1] = timestamp;
1630 e.xclient.data.l[2] = active_window;
1631 e.xclient.data.l[3] = 0l;
1632 e.xclient.data.l[4] = 0l;
1634 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
1639 void NETRootInfo::setWorkArea(
int desktop,
const NETRect &workarea) {
1642 fprintf(stderr,
"NETRootInfo::setWorkArea(%d, { %d, %d, %d, %d }) (%s)\n",
1644 (role == WindowManager) ?
"WM" :
"Client");
1647 if (role != WindowManager || desktop < 1)
return;
1649 p->workarea[desktop - 1] = workarea;
1651 long *wa =
new long[p->number_of_desktops * 4];
1653 for (i = 0, o = 0; i < p->number_of_desktops; i++) {
1654 wa[o++] = p->workarea[i].
pos.
x;
1655 wa[o++] = p->workarea[i].pos.y;
1656 wa[o++] = p->workarea[i].size.width;
1657 wa[o++] = p->workarea[i].size.height;
1660 XChangeProperty(p->display, p->root, net_workarea, XA_CARDINAL, 32,
1661 PropModeReplace, (
unsigned char *) wa,
1662 p->number_of_desktops * 4);
1668 void NETRootInfo::setVirtualRoots(Window *windows,
unsigned int count) {
1669 if (role != WindowManager)
return;
1671 p->virtual_roots_count = count;
1672 p->virtual_roots = windows;
1675 fprintf(stderr,
"NETRootInfo::setVirtualRoots: setting list with %ld windows\n",
1676 p->virtual_roots_count);
1679 XChangeProperty(p->display, p->root, net_virtual_roots, XA_WINDOW, 32,
1680 PropModeReplace, (
unsigned char *) p->virtual_roots,
1681 p->virtual_roots_count);
1685 void NETRootInfo::setDesktopLayout(
NET::Orientation orientation,
int columns,
int rows,
1688 p->desktop_layout_orientation = orientation;
1689 p->desktop_layout_columns = columns;
1690 p->desktop_layout_rows = rows;
1691 p->desktop_layout_corner = corner;
1694 fprintf(stderr,
"NETRootInfo::setDesktopLayout: %d %d %d %d\n",
1695 orientation, columns, rows, corner);
1699 data[ 0 ] = orientation;
1700 data[ 1 ] = columns;
1703 XChangeProperty(p->display, p->root, net_desktop_layout, XA_CARDINAL, 32,
1704 PropModeReplace, (
unsigned char *) &data, 4);
1708 void NETRootInfo::setShowingDesktop(
bool showing ) {
1709 if (role == WindowManager) {
1710 long d = p->showing_desktop = showing;
1711 XChangeProperty(p->display, p->root, net_showing_desktop, XA_CARDINAL, 32,
1712 PropModeReplace, (
unsigned char *) &d, 1);
1716 e.xclient.type = ClientMessage;
1717 e.xclient.message_type = net_showing_desktop;
1718 e.xclient.display = p->display;
1719 e.xclient.window = 0;
1720 e.xclient.format = 32;
1721 e.xclient.data.l[0] = showing ? 1 : 0;
1722 e.xclient.data.l[1] = 0;
1723 e.xclient.data.l[2] = 0;
1724 e.xclient.data.l[3] = 0;
1725 e.xclient.data.l[4] = 0;
1727 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
1732 bool NETRootInfo::showingDesktop()
const {
1733 return p->showing_desktop;
1737 void NETRootInfo::closeWindowRequest(Window window) {
1740 fprintf(stderr,
"NETRootInfo::closeWindowRequest: requesting close for 0x%lx\n",
1746 e.xclient.type = ClientMessage;
1747 e.xclient.message_type = net_close_window;
1748 e.xclient.display = p->display;
1749 e.xclient.window = window;
1750 e.xclient.format = 32;
1751 e.xclient.data.l[0] = 0l;
1752 e.xclient.data.l[1] = 0l;
1753 e.xclient.data.l[2] = 0l;
1754 e.xclient.data.l[3] = 0l;
1755 e.xclient.data.l[4] = 0l;
1757 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
1761 void NETRootInfo::moveResizeRequest(Window window,
int x_root,
int y_root,
1762 Direction direction)
1767 "NETRootInfo::moveResizeRequest: requesting resize/move for 0x%lx (%d, %d, %d)\n",
1768 window, x_root, y_root, direction);
1773 e.xclient.type = ClientMessage;
1774 e.xclient.message_type = net_wm_moveresize;
1775 e.xclient.display = p->display;
1776 e.xclient.window = window,
1777 e.xclient.format = 32;
1778 e.xclient.data.l[0] = x_root;
1779 e.xclient.data.l[1] = y_root;
1780 e.xclient.data.l[2] = direction;
1781 e.xclient.data.l[3] = 0l;
1782 e.xclient.data.l[4] = 0l;
1784 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
1787 void NETRootInfo::moveResizeWindowRequest(Window window,
int flags,
int x,
int y,
int width,
int height )
1792 "NETRootInfo::moveResizeWindowRequest: resizing/moving 0x%lx (%d, %d, %d, %d, %d)\n",
1793 window, flags, x, y, width, height);
1798 e.xclient.type = ClientMessage;
1799 e.xclient.message_type = net_moveresize_window;
1800 e.xclient.display = p->display;
1801 e.xclient.window = window,
1802 e.xclient.format = 32;
1803 e.xclient.data.l[0] = flags;
1804 e.xclient.data.l[1] = x;
1805 e.xclient.data.l[2] = y;
1806 e.xclient.data.l[3] = width;
1807 e.xclient.data.l[4] = height;
1809 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
1812 void NETRootInfo::restackRequest(Window window, Window above,
int detail)
1814 restackRequest( window, FromTool, above, detail, GET_QT_X_USER_TIME() );
1817 void NETRootInfo::restackRequest(Window window, RequestSource src, Window above,
int detail, Time timestamp )
1821 "NETRootInfo::restackRequest: requesting restack for 0x%lx (%lx, %d)\n",
1822 window, above, detail);
1827 e.xclient.type = ClientMessage;
1828 e.xclient.message_type = net_restack_window;
1829 e.xclient.display = p->display;
1830 e.xclient.window = window,
1831 e.xclient.format = 32;
1832 e.xclient.data.l[0] = src;
1833 e.xclient.data.l[1] = above;
1834 e.xclient.data.l[2] = detail;
1835 e.xclient.data.l[3] = timestamp;
1836 e.xclient.data.l[4] = 0l;
1838 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
1841 void NETRootInfo2::sendPing( Window window, Time timestamp )
1843 if (role != WindowManager)
return;
1845 fprintf(stderr,
"NETRootInfo2::setPing: window 0x%lx, timestamp %lu\n",
1846 window, timestamp );
1849 e.xclient.type = ClientMessage;
1850 e.xclient.message_type = wm_protocols;
1851 e.xclient.display = p->display;
1852 e.xclient.window = window,
1853 e.xclient.format = 32;
1854 e.xclient.data.l[0] = net_wm_ping;
1855 e.xclient.data.l[1] = timestamp;
1856 e.xclient.data.l[2] = window;
1857 e.xclient.data.l[3] = 0;
1858 e.xclient.data.l[4] = 0;
1860 XSendEvent(p->display, window, False, 0, &e);
1863 void NETRootInfo3::takeActivity( Window window, Time timestamp,
long flags )
1865 if (role != WindowManager)
return;
1867 fprintf(stderr,
"NETRootInfo2::takeActivity: window 0x%lx, timestamp %lu, flags 0x%lx\n",
1868 window, timestamp, flags );
1871 e.xclient.type = ClientMessage;
1872 e.xclient.message_type = wm_protocols;
1873 e.xclient.display = p->display;
1874 e.xclient.window = window,
1875 e.xclient.format = 32;
1876 e.xclient.data.l[0] = net_wm_take_activity;
1877 e.xclient.data.l[1] = timestamp;
1878 e.xclient.data.l[2] = window;
1879 e.xclient.data.l[3] = flags;
1880 e.xclient.data.l[4] = 0;
1882 XSendEvent(p->display, window, False, 0, &e);
1889 const NETRootInfo &NETRootInfo::operator=(
const NETRootInfo &rootinfo) {
1892 fprintf(stderr,
"NETRootInfo::operator=()\n");
1895 if (p != rootinfo.p) {
1898 if (! p->ref)
delete p;
1902 role = rootinfo.role;
1908 unsigned long NETRootInfo::event(XEvent *ev )
1910 unsigned long props[ 1 ];
1911 event( ev, props, 1 );
1915 void NETRootInfo::event(XEvent *event,
unsigned long* properties,
int properties_size )
1917 unsigned long props[ PROPERTIES_SIZE ] = { 0, 0, 0, 0, 0 };
1918 assert( PROPERTIES_SIZE == 5 );
1919 unsigned long& dirty = props[ PROTOCOLS ];
1920 unsigned long& dirty2 = props[ PROTOCOLS2 ];
1921 bool do_update =
false;
1925 if (role == WindowManager && event->type == ClientMessage &&
1926 event->xclient.format == 32) {
1928 fprintf(stderr,
"NETRootInfo::event: handling ClientMessage event\n");
1931 if (event->xclient.message_type == net_number_of_desktops) {
1932 dirty = NumberOfDesktops;
1935 fprintf(stderr,
"NETRootInfo::event: changeNumberOfDesktops(%ld)\n",
1936 event->xclient.data.l[0]);
1939 changeNumberOfDesktops(event->xclient.data.l[0]);
1940 }
else if (event->xclient.message_type == net_desktop_geometry) {
1941 dirty = DesktopGeometry;
1944 sz.
width =
event->xclient.data.l[0];
1945 sz.
height =
event->xclient.data.l[1];
1948 fprintf(stderr,
"NETRootInfo::event: changeDesktopGeometry( -- , { %d, %d })\n",
1952 changeDesktopGeometry(~0, sz);
1953 }
else if (event->xclient.message_type == net_desktop_viewport) {
1954 dirty = DesktopViewport;
1957 pt.
x =
event->xclient.data.l[0];
1958 pt.
y =
event->xclient.data.l[1];
1961 fprintf(stderr,
"NETRootInfo::event: changeDesktopViewport(%d, { %d, %d })\n",
1962 p->current_desktop, pt.
x, pt.
y);
1965 changeDesktopViewport(p->current_desktop, pt);
1966 }
else if (event->xclient.message_type == net_current_desktop) {
1967 dirty = CurrentDesktop;
1970 fprintf(stderr,
"NETRootInfo::event: changeCurrentDesktop(%ld)\n",
1971 event->xclient.data.l[0] + 1);
1974 changeCurrentDesktop(event->xclient.data.l[0] + 1);
1975 }
else if (event->xclient.message_type == net_active_window) {
1976 dirty = ActiveWindow;
1979 fprintf(stderr,
"NETRootInfo::event: changeActiveWindow(0x%lx)\n",
1980 event->xclient.window);
1983 changeActiveWindow(event->xclient.window);
1984 if( NETRootInfo2* this2 = dynamic_cast< NETRootInfo2* >(
this ))
1986 RequestSource src = FromUnknown;
1987 Time timestamp = CurrentTime;
1988 Window active_window = None;
1990 if( event->xclient.data.l[0] >= FromUnknown
1991 && event->xclient.data.l[0] <= FromTool )
1993 src =
static_cast< RequestSource
>(
event->xclient.data.l[0] );
1994 timestamp =
event->xclient.data.l[1];
1995 active_window =
event->xclient.data.l[2];
1997 this2->changeActiveWindow( event->xclient.window, src, timestamp, active_window );
1999 }
else if (event->xclient.message_type == net_wm_moveresize) {
2002 fprintf(stderr,
"NETRootInfo::event: moveResize(%ld, %ld, %ld, %ld)\n",
2003 event->xclient.window,
2004 event->xclient.data.l[0],
2005 event->xclient.data.l[1],
2006 event->xclient.data.l[2]
2010 moveResize(event->xclient.window,
2011 event->xclient.data.l[0],
2012 event->xclient.data.l[1],
2013 event->xclient.data.l[2]);
2014 }
else if (event->xclient.message_type == net_moveresize_window) {
2017 fprintf(stderr,
"NETRootInfo::event: moveResizeWindow(%ld, %ld, %ld, %ld, %ld, %ld)\n",
2018 event->xclient.window,
2019 event->xclient.data.l[0],
2020 event->xclient.data.l[1],
2021 event->xclient.data.l[2],
2022 event->xclient.data.l[3],
2023 event->xclient.data.l[4]
2027 if( NETRootInfo2* this2 = dynamic_cast< NETRootInfo2* >(
this ))
2028 this2->moveResizeWindow(event->xclient.window,
2029 event->xclient.data.l[0],
2030 event->xclient.data.l[1],
2031 event->xclient.data.l[2],
2032 event->xclient.data.l[3],
2033 event->xclient.data.l[4]);
2034 }
else if (event->xclient.message_type == net_close_window) {
2037 fprintf(stderr,
"NETRootInfo::event: closeWindow(0x%lx)\n",
2038 event->xclient.window);
2041 closeWindow(event->xclient.window);
2042 }
else if (event->xclient.message_type == net_restack_window) {
2045 fprintf(stderr,
"NETRootInfo::event: restackWindow(0x%lx)\n",
2046 event->xclient.window);
2049 if( NETRootInfo3* this3 = dynamic_cast< NETRootInfo3* >(
this ))
2051 RequestSource src = FromUnknown;
2052 Time timestamp = CurrentTime;
2054 if( event->xclient.data.l[0] >= FromUnknown
2055 && event->xclient.data.l[0] <= FromTool )
2057 src =
static_cast< RequestSource
>(
event->xclient.data.l[0] );
2058 timestamp =
event->xclient.data.l[3];
2060 this3->restackWindow(event->xclient.window, src,
2061 event->xclient.data.l[1], event->xclient.data.l[2], timestamp);
2063 else if( NETRootInfo2* this2 = dynamic_cast< NETRootInfo2* >(
this ))
2064 this2->restackWindow(event->xclient.window,
2065 event->xclient.data.l[1], event->xclient.data.l[2]);
2066 }
else if (event->xclient.message_type == wm_protocols
2067 && (Atom)event->xclient.data.l[ 0 ] == net_wm_ping) {
2071 fprintf(stderr,
"NETRootInfo2::event: gotPing(0x%lx,%lu)\n",
2072 event->xclient.window, event->xclient.data.l[1]);
2074 if( NETRootInfo2* this2 = dynamic_cast< NETRootInfo2* >(
this ))
2075 this2->gotPing( event->xclient.data.l[2], event->xclient.data.l[1]);
2076 }
else if (event->xclient.message_type == wm_protocols
2077 && (Atom)event->xclient.data.l[ 0 ] == net_wm_take_activity) {
2078 dirty2 = WM2TakeActivity;
2081 fprintf(stderr,
"NETRootInfo2::event: gotTakeActivity(0x%lx,%lu,0x%lx)\n",
2082 event->xclient.window, event->xclient.data.l[1], event->xclient.data.l[3]);
2084 if( NETRootInfo3* this3 = dynamic_cast< NETRootInfo3* >(
this ))
2085 this3->gotTakeActivity( event->xclient.data.l[2], event->xclient.data.l[1],
2086 event->xclient.data.l[3]);
2087 }
else if (event->xclient.message_type == net_showing_desktop) {
2088 dirty2 = WM2ShowingDesktop;
2091 fprintf(stderr,
"NETRootInfo::event: changeShowingDesktop(%ld)\n",
2092 event->xclient.data.l[0]);
2095 if( NETRootInfo4* this4 = dynamic_cast< NETRootInfo4* >(
this ))
2096 this4->changeShowingDesktop(event->xclient.data.l[0]);
2100 if (event->type == PropertyNotify) {
2103 fprintf(stderr,
"NETRootInfo::event: handling PropertyNotify event\n");
2109 Bool compaction = False;
2113 fprintf(stderr,
"NETRootInfo::event: loop fire\n");
2116 if (pe.xproperty.atom == net_client_list)
2117 dirty |= ClientList;
2118 else if (pe.xproperty.atom == net_client_list_stacking)
2119 dirty |= ClientListStacking;
2120 else if (pe.xproperty.atom == kde_net_system_tray_windows)
2121 dirty |= KDESystemTrayWindows;
2122 else if (pe.xproperty.atom == net_desktop_names)
2123 dirty |= DesktopNames;
2124 else if (pe.xproperty.atom == net_workarea)
2126 else if (pe.xproperty.atom == net_number_of_desktops)
2127 dirty |= NumberOfDesktops;
2128 else if (pe.xproperty.atom == net_desktop_geometry)
2129 dirty |= DesktopGeometry;
2130 else if (pe.xproperty.atom == net_desktop_viewport)
2131 dirty |= DesktopViewport;
2132 else if (pe.xproperty.atom == net_current_desktop)
2133 dirty |= CurrentDesktop;
2134 else if (pe.xproperty.atom == net_active_window)
2135 dirty |= ActiveWindow;
2136 else if (pe.xproperty.atom == net_showing_desktop)
2137 dirty2 |= WM2ShowingDesktop;
2140 else if (pe.xproperty.atom == net_supporting_wm_check )
2141 dirty |= SupportingWMCheck;
2142 else if (pe.xproperty.atom == net_virtual_roots )
2143 dirty |= VirtualRoots;
2144 else if (pe.xproperty.atom == net_desktop_layout )
2145 dirty2 |= WM2DesktopLayout;
2149 fprintf(stderr,
"NETRootInfo::event: putting back event and breaking\n");
2153 XPutBackEvent(p->display, &pe);
2157 if (XCheckTypedWindowEvent(p->display, p->root, PropertyNotify, &pe) )
2170 fprintf(stderr,
"NETRootInfo::event: handled events, returning dirty = 0x%lx, 0x%lx\n",
2174 if( properties_size > PROPERTIES_SIZE )
2175 properties_size = PROPERTIES_SIZE;
2177 i < properties_size;
2179 properties[ i ] = props[ i ];
2185 void NETRootInfo::update(
const unsigned long dirty_props[] )
2189 unsigned char *data_ret;
2190 unsigned long nitems_ret, unused;
2191 unsigned long props[ PROPERTIES_SIZE ];
2193 i < PROPERTIES_SIZE;
2195 props[ i ] = dirty_props[ i ] & p->client_properties[ i ];
2196 const unsigned long& dirty = props[ PROTOCOLS ];
2197 const unsigned long& dirty2 = props[ PROTOCOLS2 ];
2199 if (dirty & Supported ) {
2201 for(
int i = 0; i < PROPERTIES_SIZE; ++i )
2202 p->properties[ i ] = 0;
2203 if( XGetWindowProperty(p->display, p->root, net_supported,
2204 0l, MAX_PROP_SIZE, False, XA_ATOM, &type_ret,
2205 &format_ret, &nitems_ret, &unused, &data_ret)
2207 if( type_ret == XA_ATOM && format_ret == 32 ) {
2208 Atom* atoms = (Atom*) data_ret;
2209 for(
unsigned int i = 0;
2212 updateSupportedProperties( atoms[ i ] );
2219 if (dirty & ClientList) {
2220 bool read_ok =
false;
2221 if (XGetWindowProperty(p->display, p->root, net_client_list,
2222 0l, MAX_PROP_SIZE, False, XA_WINDOW, &type_ret,
2223 &format_ret, &nitems_ret, &unused, &data_ret)
2225 if (type_ret == XA_WINDOW && format_ret == 32) {
2226 Window *wins = (Window *) data_ret;
2228 qsort(wins, nitems_ret,
sizeof(Window), wcmp);
2231 if (role == Client) {
2232 unsigned long new_index = 0, old_index = 0;
2233 unsigned long new_count = nitems_ret,
2234 old_count = p->clients_count;
2236 while (old_index < old_count || new_index < new_count) {
2237 if (old_index == old_count) {
2238 addClient(wins[new_index++]);
2239 }
else if (new_index == new_count) {
2240 removeClient(p->clients[old_index++]);
2242 if (p->clients[old_index] <
2244 removeClient(p->clients[old_index++]);
2245 }
else if (wins[new_index] <
2246 p->clients[old_index]) {
2247 addClient(wins[new_index++]);
2256 delete [] p->clients;
2259 fprintf(stderr,
"NETRootInfo::update: client list null, creating\n");
2263 for (n = 0; n < nitems_ret; n++) {
2268 p->clients_count = nitems_ret;
2269 p->clients = nwindup(wins, p->clients_count);
2277 for(
unsigned int i = 0; i < p->clients_count; ++ i )
2278 removeClient(p->clients[i]);
2279 p->clients_count = 0;
2280 delete[] p->clients;
2285 fprintf(stderr,
"NETRootInfo::update: client list updated (%ld clients)\n",
2290 if (dirty & KDESystemTrayWindows) {
2291 bool read_ok =
false;
2292 if (XGetWindowProperty(p->display, p->root, kde_net_system_tray_windows,
2293 0l, MAX_PROP_SIZE, False, XA_WINDOW, &type_ret,
2294 &format_ret, &nitems_ret, &unused, &data_ret)
2296 if (type_ret == XA_WINDOW && format_ret == 32) {
2297 Window *wins = (Window *) data_ret;
2299 qsort(wins, nitems_ret,
sizeof(Window), wcmp);
2301 if (p->kde_system_tray_windows) {
2302 if (role == Client) {
2303 unsigned long new_index = 0, new_count = nitems_ret;
2304 unsigned long old_index = 0,
2305 old_count = p->kde_system_tray_windows_count;
2307 while(old_index < old_count || new_index < new_count) {
2308 if (old_index == old_count) {
2309 addSystemTrayWin(wins[new_index++]);
2310 }
else if (new_index == new_count) {
2311 removeSystemTrayWin(p->kde_system_tray_windows[old_index++]);
2313 if (p->kde_system_tray_windows[old_index] <
2315 removeSystemTrayWin(p->kde_system_tray_windows[old_index++]);
2316 }
else if (wins[new_index] <
2317 p->kde_system_tray_windows[old_index]) {
2318 addSystemTrayWin(wins[new_index++]);
2329 for (n = 0; n < nitems_ret; n++) {
2330 addSystemTrayWin(wins[n]);
2334 p->kde_system_tray_windows_count = nitems_ret;
2335 delete [] p->kde_system_tray_windows;
2336 p->kde_system_tray_windows =
2337 nwindup(wins, p->kde_system_tray_windows_count);
2345 for(
unsigned int i = 0; i < p->kde_system_tray_windows_count; ++i )
2346 removeSystemTrayWin(p->kde_system_tray_windows[i]);
2347 p->kde_system_tray_windows_count = 0;
2348 delete [] p->kde_system_tray_windows;
2349 p->kde_system_tray_windows = NULL;
2353 if (dirty & ClientListStacking) {
2354 p->stacking_count = 0;
2355 delete[] p->stacking;
2357 if (XGetWindowProperty(p->display, p->root, net_client_list_stacking,
2358 0, MAX_PROP_SIZE, False, XA_WINDOW, &type_ret,
2359 &format_ret, &nitems_ret, &unused, &data_ret)
2361 if (type_ret == XA_WINDOW && format_ret == 32) {
2362 Window *wins = (Window *) data_ret;
2364 p->stacking_count = nitems_ret;
2365 p->stacking = nwindup(wins, p->stacking_count);
2369 fprintf(stderr,
"NETRootInfo::update: client stacking updated (%ld clients)\n",
2378 if (dirty & NumberOfDesktops) {
2379 p->number_of_desktops = 0;
2381 if (XGetWindowProperty(p->display, p->root, net_number_of_desktops,
2382 0l, 1l, False, XA_CARDINAL, &type_ret, &format_ret,
2383 &nitems_ret, &unused, &data_ret)
2385 if (type_ret == XA_CARDINAL && format_ret == 32 && nitems_ret == 1) {
2386 p->number_of_desktops = *((
long *) data_ret);
2390 fprintf(stderr,
"NETRootInfo::update: number of desktops = %d\n",
2391 p->number_of_desktops);
2398 if (dirty & DesktopGeometry) {
2399 p->geometry = p->rootSize;
2400 if (XGetWindowProperty(p->display, p->root, net_desktop_geometry,
2401 0l, 2l, False, XA_CARDINAL, &type_ret, &format_ret,
2402 &nitems_ret, &unused, &data_ret)
2404 if (type_ret == XA_CARDINAL && format_ret == 32 &&
2406 long *data = (
long *) data_ret;
2408 p->geometry.width = data[0];
2409 p->geometry.height = data[1];
2412 fprintf(stderr,
"NETRootInfo::update: desktop geometry updated\n");
2420 if (dirty & DesktopViewport) {
2421 for (
int i = 0; i < p->viewport.size(); i++)
2422 p->viewport[i].x = p->viewport[i].y = 0;
2423 if (XGetWindowProperty(p->display, p->root, net_desktop_viewport,
2424 0l, 2l, False, XA_CARDINAL, &type_ret, &format_ret,
2425 &nitems_ret, &unused, &data_ret)
2427 if (type_ret == XA_CARDINAL && format_ret == 32 &&
2429 long *data = (
long *) data_ret;
2433 for (d = 0, i = 0; d < n; d++) {
2434 p->viewport[d].x = data[i++];
2435 p->viewport[d].y = data[i++];
2440 "NETRootInfo::update: desktop viewport array updated (%d entries)\n",
2441 p->viewport.size());
2443 if (nitems_ret % 2 != 0) {
2445 "NETRootInfo::update(): desktop viewport array "
2446 "size not a multiple of 2\n");
2455 if (dirty & CurrentDesktop) {
2456 p->current_desktop = 0;
2457 if (XGetWindowProperty(p->display, p->root, net_current_desktop,
2458 0l, 1l, False, XA_CARDINAL, &type_ret, &format_ret,
2459 &nitems_ret, &unused, &data_ret)
2461 if (type_ret == XA_CARDINAL && format_ret == 32 && nitems_ret == 1) {
2462 p->current_desktop = *((
long *) data_ret) + 1;
2466 fprintf(stderr,
"NETRootInfo::update: current desktop = %d\n",
2467 p->current_desktop);
2474 if (dirty & DesktopNames) {
2475 for(
int i = 0; i < p->desktop_names.size(); ++i )
2476 delete[] p->desktop_names[ i ];
2477 p->desktop_names.reset();
2478 if (XGetWindowProperty(p->display, p->root, net_desktop_names,
2479 0l, MAX_PROP_SIZE, False, UTF8_STRING, &type_ret,
2480 &format_ret, &nitems_ret, &unused, &data_ret)
2482 if (type_ret == UTF8_STRING && format_ret == 8) {
2483 const char *d = (
const char *) data_ret;
2484 unsigned int s, n, index;
2486 for (s = 0, n = 0, index = 0; n < nitems_ret; n++) {
2488 delete [] p->desktop_names[index];
2489 p->desktop_names[index++] = nstrndup((d + s), n - s + 1);
2496 fprintf(stderr,
"NETRootInfo::update: desktop names array updated (%d entries)\n",
2497 p->desktop_names.size());
2504 if (dirty & ActiveWindow) {
2506 if (XGetWindowProperty(p->display, p->root, net_active_window, 0l, 1l,
2507 False, XA_WINDOW, &type_ret, &format_ret,
2508 &nitems_ret, &unused, &data_ret)
2510 if (type_ret == XA_WINDOW && format_ret == 32 && nitems_ret == 1) {
2511 p->active = *((Window *) data_ret);
2515 fprintf(stderr,
"NETRootInfo::update: active window = 0x%lx\n",
2523 if (dirty & WorkArea) {
2524 p->workarea.reset();
2525 if (XGetWindowProperty(p->display, p->root, net_workarea, 0l,
2526 (p->number_of_desktops * 4), False, XA_CARDINAL,
2527 &type_ret, &format_ret, &nitems_ret, &unused,
2530 if (type_ret == XA_CARDINAL && format_ret == 32 &&
2531 nitems_ret == (
unsigned) (p->number_of_desktops * 4)) {
2532 long *d = (
long *) data_ret;
2534 for (i = 0, j = 0; i < p->number_of_desktops; i++) {
2535 p->workarea[i].pos.x = d[j++];
2536 p->workarea[i].pos.y = d[j++];
2537 p->workarea[i].size.width = d[j++];
2538 p->workarea[i].size.height = d[j++];
2543 fprintf(stderr,
"NETRootInfo::update: work area array updated (%d entries)\n",
2544 p->workarea.size());
2552 if (dirty & SupportingWMCheck) {
2553 p->supportwindow = None;
2556 if (XGetWindowProperty(p->display, p->root, net_supporting_wm_check,
2557 0l, 1l, False, XA_WINDOW, &type_ret, &format_ret,
2558 &nitems_ret, &unused, &data_ret)
2560 if (type_ret == XA_WINDOW && format_ret == 32 && nitems_ret == 1) {
2561 p->supportwindow = *((Window *) data_ret);
2563 unsigned char *name_ret;
2564 if (XGetWindowProperty(p->display, p->supportwindow,
2565 net_wm_name, 0l, MAX_PROP_SIZE, False,
2566 UTF8_STRING, &type_ret, &format_ret,
2567 &nitems_ret, &unused, &name_ret)
2569 if (type_ret == UTF8_STRING && format_ret == 8)
2570 p->name = nstrndup((
const char *) name_ret, nitems_ret);
2579 "NETRootInfo::update: supporting window manager = '%s'\n",
2587 if (dirty & VirtualRoots) {
2588 p->virtual_roots_count = 0;
2589 delete[] p->virtual_roots;
2590 p->virtual_roots = NULL;
2591 if (XGetWindowProperty(p->display, p->root, net_virtual_roots,
2592 0, MAX_PROP_SIZE, False, XA_WINDOW, &type_ret,
2593 &format_ret, &nitems_ret, &unused, &data_ret)
2595 if (type_ret == XA_WINDOW && format_ret == 32) {
2596 Window *wins = (Window *) data_ret;
2598 p->virtual_roots_count = nitems_ret;
2599 p->virtual_roots = nwindup(wins, p->virtual_roots_count);
2603 fprintf(stderr,
"NETRootInfo::updated: virtual roots updated (%ld windows)\n",
2604 p->virtual_roots_count);
2611 if (dirty2 & WM2DesktopLayout) {
2612 p->desktop_layout_orientation = OrientationHorizontal;
2613 p->desktop_layout_corner = DesktopLayoutCornerTopLeft;
2614 p->desktop_layout_columns = p->desktop_layout_rows = 0;
2615 if (XGetWindowProperty(p->display, p->root, net_desktop_layout,
2616 0, MAX_PROP_SIZE, False, XA_CARDINAL, &type_ret,
2617 &format_ret, &nitems_ret, &unused, &data_ret)
2619 if (type_ret == XA_CARDINAL && format_ret == 32) {
2620 long* data = (
long*) data_ret;
2621 if( nitems_ret >= 4 && data[ 3 ] >= 0 && data[ 3 ] <= 3 )
2623 if( nitems_ret >= 3 ) {
2624 if( data[ 0 ] >= 0 && data[ 0 ] <= 1 )
2626 p->desktop_layout_columns = data[ 1 ];
2627 p->desktop_layout_rows = data[ 2 ];
2632 fprintf(stderr,
"NETRootInfo::updated: desktop layout updated (%d %d %d %d)\n",
2633 p->desktop_layout_orientation, p->desktop_layout_columns,
2634 p->desktop_layout_rows, p->desktop_layout_corner );
2641 if (dirty2 & WM2ShowingDesktop) {
2642 p->showing_desktop =
false;
2643 if (XGetWindowProperty(p->display, p->root, net_showing_desktop,
2644 0, MAX_PROP_SIZE, False, XA_CARDINAL, &type_ret,
2645 &format_ret, &nitems_ret, &unused, &data_ret)
2647 if (type_ret == XA_CARDINAL && format_ret == 32 && nitems_ret == 1) {
2648 p->showing_desktop = *((
long *) data_ret);
2652 fprintf(stderr,
"NETRootInfo::update: showing desktop = %d\n",
2653 p->showing_desktop);
2662 Display *NETRootInfo::x11Display()
const {
2667 Window NETRootInfo::rootWindow()
const {
2672 Window NETRootInfo::supportWindow()
const {
2673 return p->supportwindow;
2677 const char *NETRootInfo::wmName()
const {
2681 int NETRootInfo::screenNumber()
const {
2686 unsigned long NETRootInfo::supported()
const {
2687 return role == WindowManager
2688 ? p->properties[ PROTOCOLS ]
2689 : p->client_properties[ PROTOCOLS ];
2692 const unsigned long* NETRootInfo::supportedProperties()
const {
2693 return p->properties;
2696 const unsigned long* NETRootInfo::passedProperties()
const {
2697 return role == WindowManager
2699 : p->client_properties;
2702 bool NETRootInfo::isSupported(
NET::Property property )
const {
2703 return p->properties[ PROTOCOLS ] & property;
2707 return p->properties[ PROTOCOLS2 ] & property;
2711 return p->properties[ WINDOW_TYPES ] & type;
2714 bool NETRootInfo::isSupported(
NET::State state )
const {
2715 return p->properties[ STATES ] & state;
2718 bool NETRootInfo::isSupported(
NET::Action action )
const {
2719 return p->properties[ ACTIONS ] & action;
2722 const Window *NETRootInfo::clientList()
const {
2727 int NETRootInfo::clientListCount()
const {
2728 return p->clients_count;
2732 const Window *NETRootInfo::clientListStacking()
const {
2737 int NETRootInfo::clientListStackingCount()
const {
2738 return p->stacking_count;
2742 const Window *NETRootInfo::kdeSystemTrayWindows()
const {
2743 return p->kde_system_tray_windows;
2747 int NETRootInfo::kdeSystemTrayWindowsCount()
const {
2748 return p->kde_system_tray_windows_count;
2752 NETSize NETRootInfo::desktopGeometry(
int)
const {
2753 return p->geometry.
width != 0 ? p->geometry : p->rootSize;
2757 NETPoint NETRootInfo::desktopViewport(
int desktop)
const {
2763 return p->viewport[desktop - 1];
2767 NETRect NETRootInfo::workArea(
int desktop)
const {
2773 return p->workarea[desktop - 1];
2777 const char *NETRootInfo::desktopName(
int desktop)
const {
2782 return p->desktop_names[desktop - 1];
2786 const Window *NETRootInfo::virtualRoots( )
const {
2787 return p->virtual_roots;
2791 int NETRootInfo::virtualRootsCount()
const {
2792 return p->virtual_roots_count;
2797 return p->desktop_layout_orientation;
2801 TQSize NETRootInfo::desktopLayoutColumnsRows()
const {
2802 return TQSize( p->desktop_layout_columns, p->desktop_layout_rows );
2807 return p->desktop_layout_corner;
2811 int NETRootInfo::numberOfDesktops()
const {
2812 return p->number_of_desktops == 0 ? 1 : p->number_of_desktops;
2816 int NETRootInfo::currentDesktop()
const {
2817 return p->current_desktop == 0 ? 1 : p->current_desktop;
2821 Window NETRootInfo::activeWindow()
const {
2828 const int NETWinInfo::OnAllDesktops = NET::OnAllDesktops;
2830 NETWinInfo::NETWinInfo(Display *display, Window window, Window rootWindow,
2831 const unsigned long properties[],
int properties_size,
2836 fprintf(stderr,
"NETWinInfo::NETWinInfo: constructing object with role '%s'\n",
2837 (role == WindowManager) ?
"WindowManager" :
"Client");
2840 p =
new NETWinInfoPrivate;
2843 p->display = display;
2845 p->root = rootWindow;
2846 p->mapping_state = Withdrawn;
2847 p->mapping_state_dirty = True;
2849 p->types[ 0 ] = Unknown;
2850 p->name = (
char *) 0;
2851 p->visible_name = (
char *) 0;
2852 p->icon_name = (
char *) 0;
2853 p->visible_icon_name = (
char *) 0;
2854 p->desktop = p->pid = p->handled_icons = 0;
2856 p->startup_id = NULL;
2857 p->transient_for = None;
2858 p->window_group = None;
2859 p->allowed_actions = 0;
2860 p->has_net_support =
false;
2861 p->class_class = (
char*) 0;
2862 p->class_name = (
char*) 0;
2863 p->role = (
char*) 0;
2864 p->client_machine = (
char*) 0;
2870 p->kde_system_tray_win_for = 0;
2873 i < PROPERTIES_SIZE;
2875 p->properties[ i ] = 0;
2876 if( properties_size > PROPERTIES_SIZE )
2877 properties_size = PROPERTIES_SIZE;
2879 i < properties_size;
2881 p->properties[ i ] = properties[ i ];
2887 if (! netwm_atoms_created) create_atoms(p->display);
2889 update(p->properties);
2893 NETWinInfo::NETWinInfo(Display *display, Window window, Window rootWindow,
2894 unsigned long properties, Role role)
2898 fprintf(stderr,
"NETWinInfo::NETWinInfo: constructing object with role '%s'\n",
2899 (role == WindowManager) ?
"WindowManager" :
"Client");
2902 p =
new NETWinInfoPrivate;
2905 p->display = display;
2907 p->root = rootWindow;
2908 p->mapping_state = Withdrawn;
2909 p->mapping_state_dirty = True;
2911 p->types[ 0 ] = Unknown;
2912 p->name = (
char *) 0;
2913 p->visible_name = (
char *) 0;
2914 p->icon_name = (
char *) 0;
2915 p->visible_icon_name = (
char *) 0;
2916 p->desktop = p->pid = p->handled_icons = 0;
2918 p->startup_id = NULL;
2919 p->transient_for = None;
2920 p->window_group = None;
2921 p->allowed_actions = 0;
2922 p->has_net_support =
false;
2923 p->class_class = (
char*) 0;
2924 p->class_name = (
char*) 0;
2925 p->role = (
char*) 0;
2926 p->client_machine = (
char*) 0;
2932 p->kde_system_tray_win_for = 0;
2935 i < PROPERTIES_SIZE;
2937 p->properties[ i ] = 0;
2938 p->properties[ PROTOCOLS ] = properties;
2944 if (! netwm_atoms_created) create_atoms(p->display);
2946 update(p->properties);
2950 NETWinInfo::NETWinInfo(
const NETWinInfo &wininfo) {
2956 NETWinInfo::~NETWinInfo() {
2959 if (! p->ref)
delete p;
2965 const NETWinInfo &NETWinInfo::operator=(
const NETWinInfo &wininfo) {
2968 fprintf(stderr,
"NETWinInfo::operator=()\n");
2971 if (p != wininfo.p) {
2974 if (! p->ref)
delete p;
2978 role = wininfo.role;
2985 void NETWinInfo::setIcon(
NETIcon icon, Bool replace) {
2986 setIconInternal( p->icons, p->icon_count, net_wm_icon, icon, replace );
2989 void NETWinInfo::setIconInternal(NETRArray<NETIcon>& icons,
int& icon_count, Atom property,
NETIcon icon, Bool replace) {
2990 if (role != Client)
return;
2992 int proplen, i, sz, j;
2996 for (i = 0; i < icons.size(); i++) {
2997 delete [] icons[i].data;
2999 icons[i].size.width = 0;
3000 icons[i].size.height = 0;
3007 icons[icon_count] = icon;
3011 NETIcon &ni = icons[icon_count - 1];
3013 CARD32 *d =
new CARD32[sz];
3014 ni.
data = (
unsigned char *) d;
3015 memcpy(d, icon.
data, sz *
sizeof(CARD32));
3018 for (i = 0, proplen = 0; i < icon_count; i++) {
3019 proplen += 2 + (icons[i].size.width *
3020 icons[i].size.height);
3024 long *prop =
new long[proplen], *pprop = prop;
3025 for (i = 0; i < icon_count; i++) {
3027 *pprop++ = icons[i].size.width;
3028 *pprop++ = icons[i].size.height;
3031 sz = (icons[i].size.width * icons[i].size.height);
3032 d32 = (CARD32 *) icons[i].data;
3033 for (j = 0; j < sz; j++) *pprop++ = *d32++;
3036 XChangeProperty(p->display, p->window, property, XA_CARDINAL, 32,
3037 PropModeReplace, (
unsigned char *) prop, proplen);
3043 void NETWinInfo::setIconGeometry(
NETRect geometry) {
3044 if (role != Client)
return;
3046 p->icon_geom = geometry;
3049 XDeleteProperty(p->display, p->window, net_wm_icon_geometry);
3052 data[0] = geometry.
pos.
x;
3053 data[1] = geometry.
pos.
y;
3057 XChangeProperty(p->display, p->window, net_wm_icon_geometry, XA_CARDINAL,
3058 32, PropModeReplace, (
unsigned char *) data, 4);
3063 void NETWinInfo::setExtendedStrut(
const NETExtendedStrut& extended_strut ) {
3064 if (role != Client)
return;
3066 p->extended_strut = extended_strut;
3073 data[4] = extended_strut.left_start;
3074 data[5] = extended_strut.left_end;
3075 data[6] = extended_strut.right_start;
3076 data[7] = extended_strut.right_end;
3077 data[8] = extended_strut.top_start;
3078 data[9] = extended_strut.top_end;
3079 data[10] = extended_strut.bottom_start;
3080 data[11] = extended_strut.bottom_end;
3082 XChangeProperty(p->display, p->window, net_wm_extended_strut, XA_CARDINAL, 32,
3083 PropModeReplace, (
unsigned char *) data, 12);
3087 void NETWinInfo::setStrut(
NETStrut strut) {
3088 if (role != Client)
return;
3093 data[0] = strut.
left;
3094 data[1] = strut.
right;
3095 data[2] = strut.
top;
3098 XChangeProperty(p->display, p->window, net_wm_strut, XA_CARDINAL, 32,
3099 PropModeReplace, (
unsigned char *) data, 4);
3103 void NETWinInfo::setState(
unsigned long state,
unsigned long mask) {
3104 if (p->mapping_state_dirty)
3108 if( ( p->properties[ PROTOCOLS ] & WMState ) == 0 ) {
3109 p->properties[ PROTOCOLS ] |= WMState;
3110 unsigned long props[ PROPERTIES_SIZE ] = { WMState, 0 };
3111 assert( PROPERTIES_SIZE == 2 );
3113 p->properties[ PROTOCOLS ] &= ~WMState;
3116 if (role == Client && p->mapping_state != Withdrawn) {
3119 fprintf(stderr,
"NETWinInfo::setState (0x%lx, 0x%lx) (Client)\n",
3121 #endif // NETWMDEBUG
3124 e.xclient.type = ClientMessage;
3125 e.xclient.message_type = net_wm_state;
3126 e.xclient.display = p->display;
3127 e.xclient.window = p->window;
3128 e.xclient.format = 32;
3129 e.xclient.data.l[3] = 0l;
3130 e.xclient.data.l[4] = 0l;
3132 if ((mask & Modal) && ((p->state & Modal) != (state & Modal))) {
3133 e.xclient.data.l[0] = (state & Modal) ? 1 : 0;
3134 e.xclient.data.l[1] = net_wm_state_modal;
3135 e.xclient.data.l[2] = 0l;
3137 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3140 if ((mask & Sticky) && ((p->state & Sticky) != (state & Sticky))) {
3141 e.xclient.data.l[0] = (state & Sticky) ? 1 : 0;
3142 e.xclient.data.l[1] = net_wm_state_sticky;
3143 e.xclient.data.l[2] = 0l;
3145 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3148 if ((mask & Max) && (( (p->state&mask) & Max) != (state & Max))) {
3150 unsigned long wishstate = (p->state & ~mask) | (state & mask);
3151 if ( ( (wishstate & MaxHoriz) != (p->state & MaxHoriz) )
3152 && ( (wishstate & MaxVert) != (p->state & MaxVert) ) ) {
3153 if ( (wishstate & Max) == Max ) {
3154 e.xclient.data.l[0] = 1;
3155 e.xclient.data.l[1] = net_wm_state_max_horiz;
3156 e.xclient.data.l[2] = net_wm_state_max_vert;
3157 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3158 }
else if ( (wishstate & Max) == 0 ) {
3159 e.xclient.data.l[0] = 0;
3160 e.xclient.data.l[1] = net_wm_state_max_horiz;
3161 e.xclient.data.l[2] = net_wm_state_max_vert;
3162 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3164 e.xclient.data.l[0] = ( wishstate & MaxHoriz ) ? 1 : 0;
3165 e.xclient.data.l[1] = net_wm_state_max_horiz;
3166 e.xclient.data.l[2] = 0;
3167 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3168 e.xclient.data.l[0] = ( wishstate & MaxVert ) ? 1 : 0;
3169 e.xclient.data.l[1] = net_wm_state_max_vert;
3170 e.xclient.data.l[2] = 0;
3171 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3173 }
else if ( (wishstate & MaxVert) != (p->state & MaxVert) ) {
3174 e.xclient.data.l[0] = ( wishstate & MaxVert ) ? 1 : 0;
3175 e.xclient.data.l[1] = net_wm_state_max_vert;
3176 e.xclient.data.l[2] = 0;
3177 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3178 }
else if ( (wishstate & MaxHoriz) != (p->state & MaxHoriz) ) {
3179 e.xclient.data.l[0] = ( wishstate & MaxHoriz ) ? 1 : 0;
3180 e.xclient.data.l[1] = net_wm_state_max_horiz;
3181 e.xclient.data.l[2] = 0;
3182 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3186 if ((mask & Shaded) && ((p->state & Shaded) != (state & Shaded))) {
3187 e.xclient.data.l[0] = (state & Shaded) ? 1 : 0;
3188 e.xclient.data.l[1] = net_wm_state_shaded;
3189 e.xclient.data.l[2] = 0l;
3191 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3194 if ((mask & SkipTaskbar) &&
3195 ((p->state & SkipTaskbar) != (state & SkipTaskbar))) {
3196 e.xclient.data.l[0] = (state & SkipTaskbar) ? 1 : 0;
3197 e.xclient.data.l[1] = net_wm_state_skip_taskbar;
3198 e.xclient.data.l[2] = 0l;
3200 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3203 if ((mask & SkipPager) &&
3204 ((p->state & SkipPager) != (state & SkipPager))) {
3205 e.xclient.data.l[0] = (state & SkipPager) ? 1 : 0;
3206 e.xclient.data.l[1] = net_wm_state_skip_pager;
3207 e.xclient.data.l[2] = 0l;
3209 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3212 if ((mask & Hidden) &&
3213 ((p->state & Hidden) != (state & Hidden))) {
3214 e.xclient.data.l[0] = (state & Hidden) ? 1 : 0;
3215 e.xclient.data.l[1] = net_wm_state_hidden;
3216 e.xclient.data.l[2] = 0l;
3218 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3221 if ((mask & FullScreen) &&
3222 ((p->state & FullScreen) != (state & FullScreen))) {
3223 e.xclient.data.l[0] = (state & FullScreen) ? 1 : 0;
3224 e.xclient.data.l[1] = net_wm_state_fullscreen;
3225 e.xclient.data.l[2] = 0l;
3227 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3230 if ((mask & KeepAbove) &&
3231 ((p->state & KeepAbove) != (state & KeepAbove))) {
3232 e.xclient.data.l[0] = (state & KeepAbove) ? 1 : 0;
3233 e.xclient.data.l[1] = net_wm_state_above;
3234 e.xclient.data.l[2] = 0l;
3236 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3239 if ((mask & KeepBelow) &&
3240 ((p->state & KeepBelow) != (state & KeepBelow))) {
3241 e.xclient.data.l[0] = (state & KeepBelow) ? 1 : 0;
3242 e.xclient.data.l[1] = net_wm_state_below;
3243 e.xclient.data.l[2] = 0l;
3245 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3248 if ((mask & StaysOnTop) && ((p->state & StaysOnTop) != (state & StaysOnTop))) {
3249 e.xclient.data.l[0] = (state & StaysOnTop) ? 1 : 0;
3250 e.xclient.data.l[1] = net_wm_state_stays_on_top;
3251 e.xclient.data.l[2] = 0l;
3253 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3256 if ((mask & DemandsAttention) &&
3257 ((p->state & DemandsAttention) != (state & DemandsAttention))) {
3258 e.xclient.data.l[0] = (state & DemandsAttention) ? 1 : 0;
3259 e.xclient.data.l[1] = net_wm_state_demands_attention;
3260 e.xclient.data.l[2] = 0l;
3262 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3273 if (p->state & Modal) data[count++] = net_wm_state_modal;
3274 if (p->state & MaxVert) data[count++] = net_wm_state_max_vert;
3275 if (p->state & MaxHoriz) data[count++] = net_wm_state_max_horiz;
3276 if (p->state & Shaded) data[count++] = net_wm_state_shaded;
3277 if (p->state & Hidden) data[count++] = net_wm_state_hidden;
3278 if (p->state & FullScreen) data[count++] = net_wm_state_fullscreen;
3279 if (p->state & DemandsAttention) data[count++] = net_wm_state_demands_attention;
3282 if (p->state & KeepAbove) data[count++] = net_wm_state_above;
3283 if (p->state & KeepBelow) data[count++] = net_wm_state_below;
3284 if (p->state & StaysOnTop) data[count++] = net_wm_state_stays_on_top;
3285 if (p->state & Sticky) data[count++] = net_wm_state_sticky;
3286 if (p->state & SkipTaskbar) data[count++] = net_wm_state_skip_taskbar;
3287 if (p->state & SkipPager) data[count++] = net_wm_state_skip_pager;
3290 fprintf(stderr,
"NETWinInfo::setState: setting state property (%d)\n", count);
3291 for (
int i = 0; i < count; i++) {
3292 char* data_ret = XGetAtomName(p->display, (Atom) data[i]);
3293 fprintf(stderr,
"NETWinInfo::setState: state %ld '%s'\n",
3301 XChangeProperty(p->display, p->window, net_wm_state, XA_ATOM, 32,
3302 PropModeReplace, (
unsigned char *) data, count);
3307 void NETWinInfo::setWindowType(WindowType type) {
3308 if (role != Client)
return;
3317 data[0] = kde_net_wm_window_type_override;
3318 data[1] = net_wm_window_type_normal;
3323 data[0] = net_wm_window_type_dialog;
3329 data[0] = net_wm_window_type_menu;
3337 data[0] = kde_net_wm_window_type_topmenu;
3338 data[1] = net_wm_window_type_dock;
3343 data[0] = net_wm_window_type_toolbar;
3349 data[0] = net_wm_window_type_dock;
3355 data[0] = net_wm_window_type_desktop;
3361 data[0] = net_wm_window_type_utility;
3362 data[1] = net_wm_window_type_dialog;
3367 data[0] = net_wm_window_type_splash;
3368 data[1] = net_wm_window_type_dock;
3373 data[0] = net_wm_window_type_dropdown_menu;
3379 data[0] = net_wm_window_type_popup_menu;
3385 data[0] = net_wm_window_type_tooltip;
3391 data[0] = net_wm_window_type_notification;
3397 data[0] = net_wm_window_type_combobox;
3403 data[0] = net_wm_window_type_dnd;
3410 data[0] = net_wm_window_type_normal;
3416 XChangeProperty(p->display, p->window, net_wm_window_type, XA_ATOM, 32,
3417 PropModeReplace, (
unsigned char *) &data, len);
3421 void NETWinInfo::setName(
const char *name) {
3422 if (role != Client)
return;
3425 p->name = nstrdup(name);
3426 if( p->name[ 0 ] !=
'\0' )
3427 XChangeProperty(p->display, p->window, net_wm_name, UTF8_STRING, 8,
3428 PropModeReplace, (
unsigned char *) p->name,
3431 XDeleteProperty(p->display, p->window, net_wm_name);
3435 void NETWinInfo::setVisibleName(
const char *visibleName) {
3436 if (role != WindowManager)
return;
3438 delete [] p->visible_name;
3439 p->visible_name = nstrdup(visibleName);
3440 if( p->visible_name[ 0 ] !=
'\0' )
3441 XChangeProperty(p->display, p->window, net_wm_visible_name, UTF8_STRING, 8,
3442 PropModeReplace, (
unsigned char *) p->visible_name,
3443 strlen(p->visible_name));
3445 XDeleteProperty(p->display, p->window, net_wm_visible_name);
3449 void NETWinInfo::setIconName(
const char *iconName) {
3450 if (role != Client)
return;
3452 delete [] p->icon_name;
3453 p->icon_name = nstrdup(iconName);
3454 if( p->icon_name[ 0 ] !=
'\0' )
3455 XChangeProperty(p->display, p->window, net_wm_icon_name, UTF8_STRING, 8,
3456 PropModeReplace, (
unsigned char *) p->icon_name,
3457 strlen(p->icon_name));
3459 XDeleteProperty(p->display, p->window, net_wm_icon_name);
3463 void NETWinInfo::setVisibleIconName(
const char *visibleIconName) {
3464 if (role != WindowManager)
return;
3466 delete [] p->visible_icon_name;
3467 p->visible_icon_name = nstrdup(visibleIconName);
3468 if( p->visible_icon_name[ 0 ] !=
'\0' )
3469 XChangeProperty(p->display, p->window, net_wm_visible_icon_name, UTF8_STRING, 8,
3470 PropModeReplace, (
unsigned char *) p->visible_icon_name,
3471 strlen(p->visible_icon_name));
3473 XDeleteProperty(p->display, p->window, net_wm_visible_icon_name);
3477 void NETWinInfo::setDesktop(
int desktop) {
3478 if (p->mapping_state_dirty)
3481 if (role == Client && p->mapping_state != Withdrawn) {
3489 e.xclient.type = ClientMessage;
3490 e.xclient.message_type = net_wm_desktop;
3491 e.xclient.display = p->display;
3492 e.xclient.window = p->window;
3493 e.xclient.format = 32;
3494 e.xclient.data.l[0] = desktop == OnAllDesktops ? OnAllDesktops : desktop - 1;
3495 e.xclient.data.l[1] = 0l;
3496 e.xclient.data.l[2] = 0l;
3497 e.xclient.data.l[3] = 0l;
3498 e.xclient.data.l[4] = 0l;
3500 XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e);
3503 p->desktop = desktop;
3506 if ( d != OnAllDesktops ) {
3508 XDeleteProperty( p->display, p->window, net_wm_desktop );
3515 XChangeProperty(p->display, p->window, net_wm_desktop, XA_CARDINAL, 32,
3516 PropModeReplace, (
unsigned char *) &d, 1);
3521 void NETWinInfo::setPid(
int pid) {
3522 if (role != Client)
return;
3526 XChangeProperty(p->display, p->window, net_wm_pid, XA_CARDINAL, 32,
3527 PropModeReplace, (
unsigned char *) &d, 1);
3531 void NETWinInfo::setHandledIcons(Bool handled) {
3532 if (role != Client)
return;
3534 p->handled_icons = handled;
3536 XChangeProperty(p->display, p->window, net_wm_handled_icons, XA_CARDINAL, 32,
3537 PropModeReplace, (
unsigned char *) &d, 1);
3540 void NETWinInfo::setStartupId(
const char*
id) {
3541 if (role != Client)
return;
3543 delete[] p->startup_id;
3544 p->startup_id = nstrdup(
id);
3545 XChangeProperty(p->display, p->window, net_startup_id, UTF8_STRING, 8,
3546 PropModeReplace, reinterpret_cast< unsigned char* >( p->startup_id ),
3547 strlen( p->startup_id ));
3550 void NETWinInfo::setAllowedActions(
unsigned long actions ) {
3551 if( role != WindowManager )
3556 p->allowed_actions = actions;
3557 if (p->allowed_actions & ActionMove) data[count++] = net_wm_action_move;
3558 if (p->allowed_actions & ActionResize) data[count++] = net_wm_action_resize;
3559 if (p->allowed_actions & ActionMinimize) data[count++] = net_wm_action_minimize;
3560 if (p->allowed_actions & ActionShade) data[count++] = net_wm_action_shade;
3561 if (p->allowed_actions & ActionStick) data[count++] = net_wm_action_stick;
3562 if (p->allowed_actions & ActionMaxVert) data[count++] = net_wm_action_max_vert;
3563 if (p->allowed_actions & ActionMaxHoriz) data[count++] = net_wm_action_max_horiz;
3564 if (p->allowed_actions & ActionFullScreen) data[count++] = net_wm_action_fullscreen;
3565 if (p->allowed_actions & ActionChangeDesktop) data[count++] = net_wm_action_change_desk;
3566 if (p->allowed_actions & ActionClose) data[count++] = net_wm_action_close;
3569 fprintf(stderr,
"NETWinInfo::setAllowedActions: setting property (%d)\n", count);
3570 for (
int i = 0; i < count; i++) {
3571 char* data_ret = XGetAtomName(p->display, (Atom) data[i]);
3572 fprintf(stderr,
"NETWinInfo::setAllowedActions: action %ld '%s'\n",
3579 XChangeProperty(p->display, p->window, net_wm_allowed_actions, XA_ATOM, 32,
3580 PropModeReplace, (
unsigned char *) data, count);
3583 void NETWinInfo::setKDESystemTrayWinFor(Window window) {
3584 if (role != Client)
return;
3586 p->kde_system_tray_win_for = window;
3587 XChangeProperty(p->display, p->window, kde_net_wm_system_tray_window_for,
3588 XA_WINDOW, 32, PropModeReplace,
3589 (
unsigned char *) &(p->kde_system_tray_win_for), 1);
3593 void NETWinInfo::setKDEFrameStrut(
NETStrut strut) {
3594 setFrameExtents( strut );
3597 void NETWinInfo::setFrameExtents(
NETStrut strut) {
3598 if (role != WindowManager)
return;
3600 p->frame_strut = strut;
3608 XChangeProperty(p->display, p->window, net_frame_extents, XA_CARDINAL, 32,
3609 PropModeReplace, (
unsigned char *) d, 4);
3610 XChangeProperty(p->display, p->window, kde_net_wm_frame_strut, XA_CARDINAL, 32,
3611 PropModeReplace, (
unsigned char *) d, 4);
3616 if (p->win_geom.size.width == 0 || p->win_geom.size.height == 0) {
3619 unsigned int w, h, junk;
3620 XGetGeometry(p->display, p->window, &unused, &x, &y, &w, &h, &junk, &junk);
3621 XTranslateCoordinates(p->display, p->window, p->root, 0, 0, &x, &y, &unused
3624 p->win_geom.pos.x = x;
3625 p->win_geom.pos.y = y;
3627 p->win_geom.size.width = w;
3628 p->win_geom.size.height = h;
3631 window = p->win_geom;
3633 frame.
pos.
x = window.
pos.
x - p->frame_strut.left;
3634 frame.
pos.
y = window.
pos.
y - p->frame_strut.top;
3640 NETIcon NETWinInfo::icon(
int width,
int height)
const {
3641 return iconInternal( p->icons, p->icon_count, width, height );
3644 NETIcon NETWinInfo::iconInternal(NETRArray<NETIcon>& icons,
int icon_count,
int width,
int height)
const {
3647 if ( !icon_count ) {
3656 for (
int i = 1; i < icons.size(); i++) {
3657 if( icons[i].size.width >= result.
size.
width &&
3663 if (width == -1 && height == -1)
return result;
3666 for (
int i = 0; i < icons.size(); i++) {
3667 if ((icons[i].size.width >= width &&
3668 icons[i].size.width < result.
size.
width) &&
3669 (icons[i].size.height >= height &&
3677 void NETWinInfo::setUserTime( Time time ) {
3678 if (role != Client)
return;
3680 p->user_time = time;
3682 XChangeProperty(p->display, p->window, net_wm_user_time, XA_CARDINAL, 32,
3683 PropModeReplace, (
unsigned char *) &d, 1);
3687 unsigned long NETWinInfo::event(XEvent *ev )
3689 unsigned long props[ 1 ];
3690 event( ev, props, 1 );
3694 void NETWinInfo::event(XEvent *event,
unsigned long* properties,
int properties_size ) {
3695 unsigned long props[ PROPERTIES_SIZE ] = { 0, 0 };
3696 assert( PROPERTIES_SIZE == 2 );
3697 unsigned long& dirty = props[ PROTOCOLS ];
3698 unsigned long& dirty2 = props[ PROTOCOLS2 ];
3699 bool do_update =
false;
3701 if (role == WindowManager && event->type == ClientMessage &&
3702 event->xclient.format == 32) {
3705 fprintf(stderr,
"NETWinInfo::event: handling ClientMessage event\n");
3706 #endif // NETWMDEBUG
3708 if (event->xclient.message_type == net_wm_state) {
3715 "NETWinInfo::event: state client message, getting new state/mask\n");
3719 long state = 0, mask = 0;
3721 for (i = 1; i < 3; i++) {
3723 char* debug_txt = XGetAtomName(p->display, (Atom) event->xclient.data.l[i]);
3724 fprintf(stderr,
"NETWinInfo::event: message %ld '%s'\n",
3725 event->xclient.data.l[i], debug_txt );
3730 if ((Atom) event->xclient.data.l[i] == net_wm_state_modal)
3732 else if ((Atom) event->xclient.data.l[i] == net_wm_state_sticky)
3734 else if ((Atom) event->xclient.data.l[i] == net_wm_state_max_vert)
3736 else if ((Atom) event->xclient.data.l[i] == net_wm_state_max_horiz)
3738 else if ((Atom) event->xclient.data.l[i] == net_wm_state_shaded)
3740 else if ((Atom) event->xclient.data.l[i] == net_wm_state_skip_taskbar)
3741 mask |= SkipTaskbar;
3742 else if ((Atom) event->xclient.data.l[i] == net_wm_state_skip_pager)
3744 else if ((Atom) event->xclient.data.l[i] == net_wm_state_hidden)
3746 else if ((Atom) event->xclient.data.l[i] == net_wm_state_fullscreen)
3748 else if ((Atom) event->xclient.data.l[i] == net_wm_state_above)
3750 else if ((Atom) event->xclient.data.l[i] == net_wm_state_below)
3752 else if ((Atom) event->xclient.data.l[i] == net_wm_state_demands_attention)
3753 mask |= DemandsAttention;
3754 else if ((Atom) event->xclient.data.l[i] == net_wm_state_stays_on_top)
3759 switch (event->xclient.data.l[0]) {
3767 state = (p->state & mask) ^ mask;
3776 fprintf(stderr,
"NETWinInfo::event: calling changeState(%lx, %lx)\n",
3780 changeState(state, mask);
3781 }
else if (event->xclient.message_type == net_wm_desktop) {
3784 if( event->xclient.data.l[0] == OnAllDesktops )
3785 changeDesktop( OnAllDesktops );
3787 changeDesktop(event->xclient.data.l[0] + 1);
3791 if (event->type == PropertyNotify) {
3794 fprintf(stderr,
"NETWinInfo::event: handling PropertyNotify event\n");
3800 Bool compaction = False;
3804 fprintf(stderr,
"NETWinInfo::event: loop fire\n");
3807 if (pe.xproperty.atom == net_wm_name)
3809 else if (pe.xproperty.atom == net_wm_visible_name)
3810 dirty |= WMVisibleName;
3811 else if (pe.xproperty.atom == net_wm_desktop)
3813 else if (pe.xproperty.atom == net_wm_window_type)
3814 dirty |=WMWindowType;
3815 else if (pe.xproperty.atom == net_wm_state)
3817 else if (pe.xproperty.atom == net_wm_strut)
3819 else if (pe.xproperty.atom == net_wm_extended_strut)
3820 dirty2 |= WM2ExtendedStrut;
3821 else if (pe.xproperty.atom == net_wm_icon_geometry)
3822 dirty |= WMIconGeometry;
3823 else if (pe.xproperty.atom == net_wm_icon)
3825 else if (pe.xproperty.atom == net_wm_pid)
3827 else if (pe.xproperty.atom == net_wm_handled_icons)
3828 dirty |= WMHandledIcons;
3829 else if (pe.xproperty.atom == net_startup_id)
3830 dirty2 |= WM2StartupId;
3831 else if (pe.xproperty.atom == net_wm_allowed_actions)
3832 dirty2 |= WM2AllowedActions;
3833 else if (pe.xproperty.atom == kde_net_wm_system_tray_window_for)
3834 dirty |= WMKDESystemTrayWinFor;
3835 else if (pe.xproperty.atom == xa_wm_state)
3837 else if (pe.xproperty.atom == net_frame_extents)
3838 dirty |= WMFrameExtents;
3839 else if (pe.xproperty.atom == kde_net_wm_frame_strut)
3840 dirty |= WMKDEFrameStrut;
3841 else if (pe.xproperty.atom == net_wm_icon_name)
3842 dirty |= WMIconName;
3843 else if (pe.xproperty.atom == net_wm_visible_icon_name)
3844 dirty |= WMVisibleIconName;
3845 else if (pe.xproperty.atom == net_wm_user_time)
3846 dirty2 |= WM2UserTime;
3847 else if (pe.xproperty.atom == XA_WM_HINTS)
3848 dirty2 |= WM2GroupLeader;
3849 else if (pe.xproperty.atom == XA_WM_TRANSIENT_FOR)
3850 dirty2 |= WM2TransientFor;
3851 else if (pe.xproperty.atom == XA_WM_CLASS)
3852 dirty2 |= WM2WindowClass;
3853 else if (pe.xproperty.atom == wm_window_role)
3854 dirty2 |= WM2WindowRole;
3855 else if (pe.xproperty.atom == XA_WM_CLIENT_MACHINE)
3856 dirty2 |= WM2ClientMachine;
3860 fprintf(stderr,
"NETWinInfo::event: putting back event and breaking\n");
3864 XPutBackEvent(p->display, &pe);
3868 if (XCheckTypedWindowEvent(p->display, p->window, PropertyNotify, &pe) )
3875 }
else if (event->type == ConfigureNotify) {
3878 fprintf(stderr,
"NETWinInfo::event: handling ConfigureNotify event\n");
3881 dirty |= WMGeometry;
3884 p->win_geom.pos.x =
event->xconfigure.x;
3885 p->win_geom.pos.y =
event->xconfigure.y;
3886 p->win_geom.size.width =
event->xconfigure.width;
3887 p->win_geom.size.height =
event->xconfigure.height;
3893 if( properties_size > PROPERTIES_SIZE )
3894 properties_size = PROPERTIES_SIZE;
3896 i < properties_size;
3898 properties[ i ] = props[ i ];
3901 void NETWinInfo::updateWMState() {
3902 unsigned long props[ PROPERTIES_SIZE ] = { XAWMState, 0 };
3903 assert( PROPERTIES_SIZE == 2 );
3907 void NETWinInfo::update(
const unsigned long dirty_props[]) {
3910 unsigned long nitems_ret, unused;
3911 unsigned char *data_ret;
3912 unsigned long props[ PROPERTIES_SIZE ];
3914 i < PROPERTIES_SIZE;
3916 props[ i ] = dirty_props[ i ] & p->properties[ i ];
3917 const unsigned long& dirty = props[ PROTOCOLS ];
3918 const unsigned long& dirty2 = props[ PROTOCOLS2 ];
3921 if( dirty_props[ PROTOCOLS ] & XAWMState )
3922 props[ PROTOCOLS ] |= XAWMState;
3924 if (dirty & XAWMState) {
3925 p->mapping_state = Withdrawn;
3926 if (XGetWindowProperty(p->display, p->window, xa_wm_state, 0l, 1l,
3927 False, xa_wm_state, &type_ret, &format_ret,
3928 &nitems_ret, &unused, &data_ret)
3930 if (type_ret == xa_wm_state && format_ret == 32 &&
3932 long *state = (
long *) data_ret;
3936 p->mapping_state = Iconic;
3939 p->mapping_state = Visible;
3941 case WithdrawnState:
3943 p->mapping_state = Withdrawn;
3947 p->mapping_state_dirty = False;
3954 if (dirty & WMState) {
3956 if (XGetWindowProperty(p->display, p->window, net_wm_state, 0l, 2048l,
3957 False, XA_ATOM, &type_ret, &format_ret,
3958 &nitems_ret, &unused, &data_ret)
3960 if (type_ret == XA_ATOM && format_ret == 32 && nitems_ret > 0) {
3963 fprintf(stderr,
"NETWinInfo::update: updating window state (%ld)\n",
3967 long *states = (
long *) data_ret;
3968 unsigned long count;
3970 for (count = 0; count < nitems_ret; count++) {
3972 char* data_ret = XGetAtomName(p->display, (Atom) states[count]);
3974 "NETWinInfo::update: adding window state %ld '%s'\n",
3975 states[count], data_ret );
3980 if ((Atom) states[count] == net_wm_state_modal)
3982 else if ((Atom) states[count] == net_wm_state_sticky)
3984 else if ((Atom) states[count] == net_wm_state_max_vert)
3985 p->state |= MaxVert;
3986 else if ((Atom) states[count] == net_wm_state_max_horiz)
3987 p->state |= MaxHoriz;
3988 else if ((Atom) states[count] == net_wm_state_shaded)
3990 else if ((Atom) states[count] == net_wm_state_skip_taskbar)
3991 p->state |= SkipTaskbar;
3992 else if ((Atom) states[count] == net_wm_state_skip_pager)
3993 p->state |= SkipPager;
3994 else if ((Atom) states[count] == net_wm_state_hidden)
3996 else if ((Atom) states[count] == net_wm_state_fullscreen)
3997 p->state |= FullScreen;
3998 else if ((Atom) states[count] == net_wm_state_above)
3999 p->state |= KeepAbove;
4000 else if ((Atom) states[count] == net_wm_state_below)
4001 p->state |= KeepBelow;
4002 else if ((Atom) states[count] == net_wm_state_demands_attention)
4003 p->state |= DemandsAttention;
4004 else if ((Atom) states[count] == net_wm_state_stays_on_top)
4005 p->state |= StaysOnTop;
4013 if (dirty & WMDesktop) {
4015 if (XGetWindowProperty(p->display, p->window, net_wm_desktop, 0l, 1l,
4016 False, XA_CARDINAL, &type_ret,
4017 &format_ret, &nitems_ret,
4020 if (type_ret == XA_CARDINAL && format_ret == 32 &&
4022 p->desktop = *((
long *) data_ret);
4023 if ((
signed) p->desktop != OnAllDesktops)
4026 if ( p->desktop == 0 )
4027 p->desktop = OnAllDesktops;
4034 if (dirty & WMName) {
4037 if (XGetWindowProperty(p->display, p->window, net_wm_name, 0l,
4038 MAX_PROP_SIZE, False, UTF8_STRING, &type_ret,
4039 &format_ret, &nitems_ret, &unused, &data_ret)
4041 if (type_ret == UTF8_STRING && format_ret == 8 && nitems_ret > 0) {
4042 p->name = nstrndup((
const char *) data_ret, nitems_ret);
4050 if (dirty & WMVisibleName) {
4051 delete[] p->visible_name;
4052 p->visible_name = NULL;
4053 if (XGetWindowProperty(p->display, p->window, net_wm_visible_name, 0l,
4054 MAX_PROP_SIZE, False, UTF8_STRING, &type_ret,
4055 &format_ret, &nitems_ret, &unused, &data_ret)
4057 if (type_ret == UTF8_STRING && format_ret == 8 && nitems_ret > 0) {
4058 p->visible_name = nstrndup((
const char *) data_ret, nitems_ret);
4066 if (dirty & WMIconName) {
4067 delete[] p->icon_name;
4068 p->icon_name = NULL;
4069 if (XGetWindowProperty(p->display, p->window, net_wm_icon_name, 0l,
4070 MAX_PROP_SIZE, False, UTF8_STRING, &type_ret,
4071 &format_ret, &nitems_ret, &unused, &data_ret)
4073 if (type_ret == UTF8_STRING && format_ret == 8 && nitems_ret > 0) {
4074 p->icon_name = nstrndup((
const char *) data_ret, nitems_ret);
4082 if (dirty & WMVisibleIconName)
4084 delete[] p->visible_icon_name;
4085 p->visible_icon_name = NULL;
4086 if (XGetWindowProperty(p->display, p->window, net_wm_visible_icon_name, 0l,
4087 MAX_PROP_SIZE, False, UTF8_STRING, &type_ret,
4088 &format_ret, &nitems_ret, &unused, &data_ret)
4090 if (type_ret == UTF8_STRING && format_ret == 8 && nitems_ret > 0) {
4091 p->visible_icon_name = nstrndup((
const char *) data_ret, nitems_ret);
4099 if (dirty & WMWindowType) {
4101 p->types[ 0 ] = Unknown;
4102 p->has_net_support =
false;
4103 if (XGetWindowProperty(p->display, p->window, net_wm_window_type, 0l, 2048l,
4104 False, XA_ATOM, &type_ret, &format_ret,
4105 &nitems_ret, &unused, &data_ret)
4107 if (type_ret == XA_ATOM && format_ret == 32 && nitems_ret > 0) {
4110 fprintf(stderr,
"NETWinInfo::update: getting window type (%ld)\n",
4114 p->has_net_support =
true;
4116 unsigned long count = 0;
4117 long *types = (
long *) data_ret;
4120 while (count < nitems_ret) {
4123 char* debug_type = XGetAtomName(p->display, (Atom) types[count]);
4125 "NETWinInfo::update: examining window type %ld %s\n",
4126 types[count], debug_type );
4128 XFree( debug_type );
4131 if ((Atom) types[count] == net_wm_window_type_normal)
4132 p->types[ pos++ ] = Normal;
4133 else if ((Atom) types[count] == net_wm_window_type_desktop)
4134 p->types[ pos++ ] = Desktop;
4135 else if ((Atom) types[count] == net_wm_window_type_dock)
4136 p->types[ pos++ ] = Dock;
4137 else if ((Atom) types[count] == net_wm_window_type_toolbar)
4138 p->types[ pos++ ] = Tool;
4139 else if ((Atom) types[count] == net_wm_window_type_menu)
4140 p->types[ pos++ ] = Menu;
4141 else if ((Atom) types[count] == net_wm_window_type_dialog)
4142 p->types[ pos++ ] = Dialog;
4143 else if ((Atom) types[count] == net_wm_window_type_utility)
4144 p->types[ pos++ ] = Utility;
4145 else if ((Atom) types[count] == net_wm_window_type_splash)
4146 p->types[ pos++ ] = Splash;
4147 else if ((Atom) types[count] == net_wm_window_type_dropdown_menu)
4148 p->types[ pos++ ] = DropdownMenu;
4149 else if ((Atom) types[count] == net_wm_window_type_popup_menu)
4150 p->types[ pos++ ] = PopupMenu;
4151 else if ((Atom) types[count] == net_wm_window_type_tooltip)
4152 p->types[ pos++ ] = Tooltip;
4153 else if ((Atom) types[count] == net_wm_window_type_notification)
4154 p->types[ pos++ ] = Notification;
4155 else if ((Atom) types[count] == net_wm_window_type_combobox)
4156 p->types[ pos++ ] = ComboBox;
4157 else if ((Atom) types[count] == net_wm_window_type_dnd)
4158 p->types[ pos++ ] = DNDIcon;
4159 else if ((Atom) types[count] == kde_net_wm_window_type_override)
4160 p->types[ pos++ ] = Override;
4161 else if ((Atom) types[count] == kde_net_wm_window_type_topmenu)
4162 p->types[ pos++ ] = TopMenu;
4173 if (dirty & WMStrut) {
4175 if (XGetWindowProperty(p->display, p->window, net_wm_strut, 0l, 4l,
4176 False, XA_CARDINAL, &type_ret, &format_ret,
4177 &nitems_ret, &unused, &data_ret)
4179 if (type_ret == XA_CARDINAL && format_ret == 32 &&
4181 long *d = (
long *) data_ret;
4182 p->strut.left = d[0];
4183 p->strut.right = d[1];
4184 p->strut.top = d[2];
4185 p->strut.bottom = d[3];
4192 if (dirty2 & WM2ExtendedStrut) {
4194 if (XGetWindowProperty(p->display, p->window, net_wm_extended_strut, 0l, 12l,
4195 False, XA_CARDINAL, &type_ret, &format_ret,
4196 &nitems_ret, &unused, &data_ret)
4198 if (type_ret == XA_CARDINAL && format_ret == 32 &&
4200 long *d = (
long *) data_ret;
4201 p->extended_strut.left_width = d[0];
4202 p->extended_strut.right_width = d[1];
4203 p->extended_strut.top_width = d[2];
4204 p->extended_strut.bottom_width = d[3];
4205 p->extended_strut.left_start = d[4];
4206 p->extended_strut.left_end = d[5];
4207 p->extended_strut.right_start = d[6];
4208 p->extended_strut.right_end = d[7];
4209 p->extended_strut.top_start = d[8];
4210 p->extended_strut.top_end = d[9];
4211 p->extended_strut.bottom_start = d[10];
4212 p->extended_strut.bottom_end = d[11];
4219 if (dirty & WMIconGeometry) {
4221 if (XGetWindowProperty(p->display, p->window, net_wm_icon_geometry, 0l, 4l,
4222 False, XA_CARDINAL, &type_ret, &format_ret,
4223 &nitems_ret, &unused, &data_ret)
4225 if (type_ret == XA_CARDINAL && format_ret == 32 &&
4227 long *d = (
long *) data_ret;
4228 p->icon_geom.pos.x = d[0];
4229 p->icon_geom.pos.y = d[1];
4230 p->icon_geom.size.width = d[2];
4231 p->icon_geom.size.height = d[3];
4238 if (dirty & WMIcon) {
4239 readIcon(p->display,p->window,net_wm_icon,p->icons,p->icon_count);
4242 if (dirty & WMKDESystemTrayWinFor) {
4243 p->kde_system_tray_win_for = 0;
4244 if (XGetWindowProperty(p->display, p->window, kde_net_wm_system_tray_window_for,
4245 0l, 1l, False, XA_WINDOW, &type_ret, &format_ret,
4246 &nitems_ret, &unused, &data_ret)
4248 if (type_ret == XA_WINDOW && format_ret == 32 &&
4250 p->kde_system_tray_win_for = *((Window *) data_ret);
4251 if ( p->kde_system_tray_win_for == 0 )
4252 p->kde_system_tray_win_for = p->root;
4259 if (dirty & WMFrameExtents) {
4262 if (XGetWindowProperty(p->display, p->window, net_frame_extents,
4263 0l, 4l, False, XA_CARDINAL, &type_ret, &format_ret,
4264 &nitems_ret, &unused, &data_ret) == Success) {
4265 if (type_ret == XA_CARDINAL && format_ret == 32 && nitems_ret == 4) {
4267 long *d = (
long *) data_ret;
4269 p->frame_strut.left = d[0];
4270 p->frame_strut.right = d[1];
4271 p->frame_strut.top = d[2];
4272 p->frame_strut.bottom = d[3];
4277 if (!ok && XGetWindowProperty(p->display, p->window, kde_net_wm_frame_strut,
4278 0l, 4l, False, XA_CARDINAL, &type_ret, &format_ret,
4279 &nitems_ret, &unused, &data_ret) == Success) {
4280 if (type_ret == XA_CARDINAL && format_ret == 32 && nitems_ret == 4) {
4282 long *d = (
long *) data_ret;
4284 p->frame_strut.left = d[0];
4285 p->frame_strut.right = d[1];
4286 p->frame_strut.top = d[2];
4287 p->frame_strut.bottom = d[3];
4294 if (dirty & WMPid) {
4296 if (XGetWindowProperty(p->display, p->window, net_wm_pid, 0l, 1l,
4297 False, XA_CARDINAL, &type_ret, &format_ret,
4298 &nitems_ret, &unused, &data_ret) == Success) {
4299 if (type_ret == XA_CARDINAL && format_ret == 32 && nitems_ret == 1) {
4300 p->pid = *((
long *) data_ret);
4307 if (dirty2 & WM2StartupId)
4309 delete[] p->startup_id;
4310 p->startup_id = NULL;
4311 if (XGetWindowProperty(p->display, p->window, net_startup_id, 0l,
4312 MAX_PROP_SIZE, False, UTF8_STRING, &type_ret,
4313 &format_ret, &nitems_ret, &unused, &data_ret)
4315 if (type_ret == UTF8_STRING && format_ret == 8 && nitems_ret > 0) {
4316 p->startup_id = nstrndup((
const char *) data_ret, nitems_ret);
4324 if( dirty2 & WM2AllowedActions ) {
4325 p->allowed_actions = 0;
4326 if (XGetWindowProperty(p->display, p->window, net_wm_allowed_actions, 0l, 2048l,
4327 False, XA_ATOM, &type_ret, &format_ret,
4328 &nitems_ret, &unused, &data_ret)
4330 if (type_ret == XA_ATOM && format_ret == 32 && nitems_ret > 0) {
4333 fprintf(stderr,
"NETWinInfo::update: updating allowed actions (%ld)\n",
4337 long *actions = (
long *) data_ret;
4338 unsigned long count;
4340 for (count = 0; count < nitems_ret; count++) {
4342 char* debug_action = XGetAtomName(p->display, (Atom) actions[count]);
4344 "NETWinInfo::update: adding allowed action %ld '%s'\n",
4345 actions[count], debug_action);
4346 if( debug_action ) {
4347 XFree( debug_action );
4351 if ((Atom) actions[count] == net_wm_action_move)
4352 p->allowed_actions |= ActionMove;
4353 if ((Atom) actions[count] == net_wm_action_resize)
4354 p->allowed_actions |= ActionResize;
4355 if ((Atom) actions[count] == net_wm_action_minimize)
4356 p->allowed_actions |= ActionMinimize;
4357 if ((Atom) actions[count] == net_wm_action_shade)
4358 p->allowed_actions |= ActionShade;
4359 if ((Atom) actions[count] == net_wm_action_stick)
4360 p->allowed_actions |= ActionStick;
4361 if ((Atom) actions[count] == net_wm_action_max_vert)
4362 p->allowed_actions |= ActionMaxVert;
4363 if ((Atom) actions[count] == net_wm_action_max_horiz)
4364 p->allowed_actions |= ActionMaxHoriz;
4365 if ((Atom) actions[count] == net_wm_action_fullscreen)
4366 p->allowed_actions |= ActionFullScreen;
4367 if ((Atom) actions[count] == net_wm_action_change_desk)
4368 p->allowed_actions |= ActionChangeDesktop;
4369 if ((Atom) actions[count] == net_wm_action_close)
4370 p->allowed_actions |= ActionClose;
4378 if (dirty2 & WM2UserTime) {
4380 if (XGetWindowProperty(p->display, p->window, net_wm_user_time, 0l, 1l,
4381 False, XA_CARDINAL, &type_ret, &format_ret,
4382 &nitems_ret, &unused, &data_ret) == Success) {
4384 if (type_ret == XA_CARDINAL && format_ret == 32 ) {
4385 p->user_time = *((
long *) data_ret);
4392 if (dirty2 & WM2TransientFor) {
4393 p->transient_for = None;
4394 XGetTransientForHint(p->display, p->window, &p->transient_for);
4397 if (dirty2 & WM2GroupLeader) {
4398 XWMHints *hints = XGetWMHints(p->display, p->window);
4399 p->window_group = None;
4402 if( hints->flags & WindowGroupHint )
4403 p->window_group = hints->window_group;
4404 XFree( reinterpret_cast< char* >( hints ));
4408 if( dirty2 & WM2WindowClass ) {
4409 delete[] p->class_class;
4410 delete[] p->class_name;
4411 p->class_class = NULL;
4412 p->class_name = NULL;
4414 if( XGetClassHint( p->display, p->window, &hint )) {
4415 p->class_class = strdup( hint.res_class );
4416 p->class_name = strdup( hint.res_name );
4417 XFree( hint.res_class );
4418 XFree( hint.res_name );
4422 if( dirty2 & WM2WindowRole ) {
4425 if (XGetWindowProperty(p->display, p->window, wm_window_role, 0l,
4426 MAX_PROP_SIZE, False, XA_STRING, &type_ret,
4427 &format_ret, &nitems_ret, &unused, &data_ret)
4429 if (type_ret == XA_STRING && format_ret == 8 && nitems_ret > 0) {
4430 p->role = nstrndup((
const char *) data_ret, nitems_ret);
4437 if( dirty2 & WM2ClientMachine ) {
4438 delete[] p->client_machine;
4439 p->client_machine = NULL;
4440 if (XGetWindowProperty(p->display, p->window, XA_WM_CLIENT_MACHINE, 0l,
4441 MAX_PROP_SIZE, False, XA_STRING, &type_ret,
4442 &format_ret, &nitems_ret, &unused, &data_ret)
4444 if (type_ret == XA_STRING && format_ret == 8 && nitems_ret > 0) {
4445 p->client_machine = nstrndup((
const char *) data_ret, nitems_ret);
4454 NETRect NETWinInfo::iconGeometry()
const {
4455 return p->icon_geom;
4459 unsigned long NETWinInfo::state()
const {
4464 NETStrut NETWinInfo::strut()
const {
4469 return p->extended_strut;
4474 #define CHECK_TYPE_MASK( type ) \
4476 if( mask & type##Mask ) \
4479 CHECK_TYPE_MASK( Normal )
4480 CHECK_TYPE_MASK( Desktop )
4481 CHECK_TYPE_MASK( Dock )
4482 CHECK_TYPE_MASK( Toolbar )
4483 CHECK_TYPE_MASK( Menu )
4484 CHECK_TYPE_MASK( Dialog )
4486 CHECK_TYPE_MASK( TopMenu )
4488 CHECK_TYPE_MASK(
Splash )
4495 #undef CHECK_TYPE_MASK
4502 NET::WindowType NETWinInfo::windowType(
unsigned long supported_types )
const {
4504 i < p->types.size();
4507 if( typeMatchesMask( p->types[ i ], supported_types ))
4508 return p->types[ i ];
4514 return p->types[ 0 ];
4518 const char *NETWinInfo::name()
const {
4523 const char *NETWinInfo::visibleName()
const {
4524 return p->visible_name;
4528 const char *NETWinInfo::iconName()
const {
4529 return p->icon_name;
4533 const char *NETWinInfo::visibleIconName()
const {
4534 return p->visible_icon_name;
4538 int NETWinInfo::desktop()
const {
4542 int NETWinInfo::pid()
const {
4546 Time NETWinInfo::userTime()
const {
4547 return p->user_time;
4550 const char* NETWinInfo::startupId()
const {
4551 return p->startup_id;
4554 unsigned long NETWinInfo::allowedActions()
const {
4555 return p->allowed_actions;
4558 bool NETWinInfo::hasNETSupport()
const {
4559 return p->has_net_support;
4562 Window NETWinInfo::transientFor()
const {
4563 return p->transient_for;
4566 Window NETWinInfo::groupLeader()
const {
4567 return p->window_group;
4570 const char* NETWinInfo::windowClassClass()
const {
4571 return p->class_class;
4574 const char* NETWinInfo::windowClassName()
const {
4575 return p->class_name;
4578 const char* NETWinInfo::windowRole()
const {
4582 const char* NETWinInfo::clientMachine()
const {
4583 return p->client_machine;
4586 Bool NETWinInfo::handledIcons()
const {
4587 return p->handled_icons;
4591 Window NETWinInfo::kdeSystemTrayWinFor()
const {
4592 return p->kde_system_tray_win_for;
4595 const unsigned long* NETWinInfo::passedProperties()
const {
4596 return p->properties;
4599 unsigned long NETWinInfo::properties()
const {
4600 return p->properties[ PROTOCOLS ];
4605 return p->mapping_state;
4608 void NETRootInfo::virtual_hook(
int,
void* )
4611 void NETWinInfo::virtual_hook(
int,
void* )
4620 if( time1 == time2 )
4622 return ( time1 - time2 ) < 0x7fffffffU ? 1 : -1;
4627 return time2 - time1;
4632 TQ_UINT32 time1 = time1_;
4633 TQ_UINT32 time2 = time2_;
4634 if( time1 == time2 )
4636 return TQ_UINT32( time1 - time2 ) < 0x7fffffffU ? 1 : -1;
4641 TQ_UINT32 time1 = time1_;
4642 TQ_UINT32 time2 = time2_;
4643 return TQ_UINT32( time2 - time1 );