Browse Source

Set WM_CLASS and WM_NAME on all our windows (#551)

The only exception is the window for _NET_SUPPORTING_WM_CHECK. That window
already had a _NET_WM_NAME property before and doesn't get a WM_NAME property in
this commit. I just decided for myself that it doesn't need one. :-)

Right after startup with the default config we now have the following situation:

$ xwininfo -root -tree

xwininfo: Window id: 0x2d7 (the root window) (has no name)

  Root window id: 0x2d7 (the root window) (has no name)
  Parent window id: 0x0 (none)
     7 children:
     0x200011 "Awesome drawin": ("awesome" "awesome")  1500x20+0+0  +0+0
     0x200010 "Awesome drawin": ("awesome" "awesome")  1x1+0+0  +0+0
     0x20000d "Awesome drawin": ("awesome" "awesome")  100x30+0+0  +0+0
     0x20000a "Awesome no input window": ("awesome" "awesome")  1x1+-1+-1  +-1+-1
     0x200009 "Awesome systray window": ("awesome" "awesome")  1x1+-1+-1  +-1+-1
     0x200008 "awesome": ("awesome" "awesome")  1x1+-1+-1  +-1+-1
     0x200007 "Awesome WM_Sn selection owner window": ("awesome" "awesome")  1x1+-1+-1  +-1+-1

One of those drawin is the awful.wibox. Another drawin is created by awful.menu.
I guess that the third one is created by awful.tooltip, but I'm not sure. Wow,
so many windows...

Closes https://github.com/awesomeWM/awesome/pull/556.

Signed-off-by: Uli Schlachter <psychon@znc.in>
Uli Schlachter 3 years ago
parent
commit
6ca85af53b
6 changed files with 25 additions and 0 deletions
  1. 5
    0
      awesome.c
  2. 4
    0
      ewmh.c
  3. 2
    0
      objects/drawin.c
  4. 3
    0
      selection.c
  5. 2
    0
      systray.c
  6. 9
    0
      xwindow.h

+ 5
- 0
awesome.c View File

@@ -238,6 +238,9 @@ acquire_WM_Sn(bool replace)
238 238
                       -1, -1, 1, 1, 0,
239 239
                       XCB_COPY_FROM_PARENT, globalconf.screen->root_visual,
240 240
                       0, NULL);
241
+    xwindow_set_class_instance(globalconf.selection_owner_window);
242
+    xwindow_set_name_static(globalconf.selection_owner_window,
243
+            "Awesome WM_Sn selection owner window");
241 244
 
242 245
     atom_name = xcb_atom_name_by_screen("WM_S", globalconf.default_screen);
243 246
     if(!atom_name)
@@ -666,6 +669,8 @@ main(int argc, char **argv)
666 669
                           1,
667 670
                           globalconf.default_cmap
668 671
                       });
672
+    xwindow_set_class_instance(globalconf.focus.window_no_focus);
673
+    xwindow_set_name_static(globalconf.focus.window_no_focus, "Awesome no input window");
669 674
     xcb_map_window(globalconf.connection, globalconf.focus.window_no_focus);
670 675
     xcb_create_gc(globalconf.connection, globalconf.gc, globalconf.focus.window_no_focus,
671 676
                   XCB_GC_FOREGROUND | XCB_GC_BACKGROUND,

+ 4
- 0
ewmh.c View File

@@ -23,6 +23,7 @@
23 23
 #include "objects/client.h"
24 24
 #include "objects/tag.h"
25 25
 #include "common/atoms.h"
26
+#include "xwindow.h"
26 27
 
27 28
 #include <sys/types.h>
28 29
 #include <unistd.h>
@@ -198,6 +199,9 @@ ewmh_init(void)
198 199
     xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
199 200
                         father, _NET_WM_NAME, UTF8_STRING, 8, 7, "awesome");
200 201
 
202
+    /* Set an instance, just because we can */
203
+    xwindow_set_class_instance(father);
204
+
201 205
     /* set the window manager PID */
202 206
     i = getpid();
203 207
     xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,

+ 2
- 0
objects/drawin.c View File

@@ -353,6 +353,8 @@ drawin_allocator(lua_State *L)
353 353
                           globalconf.default_cmap,
354 354
                           xcursor_new(globalconf.cursor_ctx, xcursor_font_fromstr(w->cursor))
355 355
                       });
356
+    xwindow_set_class_instance(w->window);
357
+    xwindow_set_name_static(w->window, "Awesome drawin");
356 358
 
357 359
     /* Set the right properties */
358 360
     ewmh_update_window_type(w->window, window_translate_type(w->type));

+ 3
- 0
selection.c View File

@@ -31,6 +31,7 @@
31 31
 #include "globalconf.h"
32 32
 #include "common/atoms.h"
33 33
 #include "event.h"
34
+#include "xwindow.h"
34 35
 
35 36
 #include <xcb/xcb_atom.h>
36 37
 #include <xcb/xcb_event.h>
@@ -63,6 +64,8 @@ luaA_selection_get(lua_State *L)
63 64
         xcb_create_window(globalconf.connection, screen->root_depth, selection_window, screen->root,
64 65
                           0, 0, 1, 1, 0, XCB_COPY_FROM_PARENT, screen->root_visual,
65 66
                           mask, values);
67
+        xwindow_set_class_instance(selection_window);
68
+        xwindow_set_name_static(selection_window, "Awesome selection window");
66 69
     }
67 70
 
68 71
     xcb_convert_selection(globalconf.connection, selection_window,

+ 2
- 0
systray.c View File

@@ -50,6 +50,8 @@ systray_init(void)
50 50
                       XCB_COPY_FROM_PARENT, xscreen->root_visual,
51 51
                       XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK, (const uint32_t [])
52 52
                       { xscreen->black_pixel, XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT });
53
+    xwindow_set_class_instance(globalconf.systray.window);
54
+    xwindow_set_name_static(globalconf.systray.window, "Awesome systray window");
53 55
 
54 56
     atom_name = xcb_atom_name_by_screen("_NET_SYSTEM_TRAY", globalconf.default_screen);
55 57
     if(!atom_name)

+ 9
- 0
xwindow.h View File

@@ -44,5 +44,14 @@ cairo_surface_t *xwindow_get_shape(xcb_window_t, enum xcb_shape_sk_t);
44 44
 void xwindow_set_shape(xcb_window_t, int, int, enum xcb_shape_sk_t, cairo_surface_t *, int);
45 45
 void xwindow_translate_for_gravity(xcb_gravity_t, int16_t, int16_t, int16_t, int16_t, int16_t *, int16_t *);
46 46
 
47
+#define xwindow_set_name_static(win, name) \
48
+    xcb_icccm_set_wm_name(globalconf.connection, win, XCB_ATOM_STRING, 8, sizeof(name) - 1, name)
49
+#define xwindow_set_class_instance(win) \
50
+    xwindow_set_class_instance_static(win, "awesome", "awesome")
51
+#define xwindow_set_class_instance_static(win, instance, class) \
52
+    _xwindow_set_class_instance_static(win, instance "\0" class)
53
+#define _xwindow_set_class_instance_static(win, instance_class) \
54
+    xcb_icccm_set_wm_class(globalconf.connection, win, sizeof(instance_class), instance_class)
55
+
47 56
 #endif
48 57
 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

Loading…
Cancel
Save