Skip to content

Commit 6ca85af

Browse files
psychonblueyed
authored andcommitted
Set WM_CLASS and WM_NAME on all our windows (awesomeWM#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 awesomeWM#556. Signed-off-by: Uli Schlachter <[email protected]>
1 parent c9c6081 commit 6ca85af

File tree

6 files changed

+25
-0
lines changed

6 files changed

+25
-0
lines changed

awesome.c

+5
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ acquire_WM_Sn(bool replace)
238238
-1, -1, 1, 1, 0,
239239
XCB_COPY_FROM_PARENT, globalconf.screen->root_visual,
240240
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");
241244

242245
atom_name = xcb_atom_name_by_screen("WM_S", globalconf.default_screen);
243246
if(!atom_name)
@@ -666,6 +669,8 @@ main(int argc, char **argv)
666669
1,
667670
globalconf.default_cmap
668671
});
672+
xwindow_set_class_instance(globalconf.focus.window_no_focus);
673+
xwindow_set_name_static(globalconf.focus.window_no_focus, "Awesome no input window");
669674
xcb_map_window(globalconf.connection, globalconf.focus.window_no_focus);
670675
xcb_create_gc(globalconf.connection, globalconf.gc, globalconf.focus.window_no_focus,
671676
XCB_GC_FOREGROUND | XCB_GC_BACKGROUND,

ewmh.c

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "objects/client.h"
2424
#include "objects/tag.h"
2525
#include "common/atoms.h"
26+
#include "xwindow.h"
2627

2728
#include <sys/types.h>
2829
#include <unistd.h>
@@ -198,6 +199,9 @@ ewmh_init(void)
198199
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
199200
father, _NET_WM_NAME, UTF8_STRING, 8, 7, "awesome");
200201

202+
/* Set an instance, just because we can */
203+
xwindow_set_class_instance(father);
204+
201205
/* set the window manager PID */
202206
i = getpid();
203207
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,

objects/drawin.c

+2
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ drawin_allocator(lua_State *L)
353353
globalconf.default_cmap,
354354
xcursor_new(globalconf.cursor_ctx, xcursor_font_fromstr(w->cursor))
355355
});
356+
xwindow_set_class_instance(w->window);
357+
xwindow_set_name_static(w->window, "Awesome drawin");
356358

357359
/* Set the right properties */
358360
ewmh_update_window_type(w->window, window_translate_type(w->type));

selection.c

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "globalconf.h"
3232
#include "common/atoms.h"
3333
#include "event.h"
34+
#include "xwindow.h"
3435

3536
#include <xcb/xcb_atom.h>
3637
#include <xcb/xcb_event.h>
@@ -63,6 +64,8 @@ luaA_selection_get(lua_State *L)
6364
xcb_create_window(globalconf.connection, screen->root_depth, selection_window, screen->root,
6465
0, 0, 1, 1, 0, XCB_COPY_FROM_PARENT, screen->root_visual,
6566
mask, values);
67+
xwindow_set_class_instance(selection_window);
68+
xwindow_set_name_static(selection_window, "Awesome selection window");
6669
}
6770

6871
xcb_convert_selection(globalconf.connection, selection_window,

systray.c

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ systray_init(void)
5050
XCB_COPY_FROM_PARENT, xscreen->root_visual,
5151
XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK, (const uint32_t [])
5252
{ 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");
5355

5456
atom_name = xcb_atom_name_by_screen("_NET_SYSTEM_TRAY", globalconf.default_screen);
5557
if(!atom_name)

xwindow.h

+9
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,14 @@ cairo_surface_t *xwindow_get_shape(xcb_window_t, enum xcb_shape_sk_t);
4444
void xwindow_set_shape(xcb_window_t, int, int, enum xcb_shape_sk_t, cairo_surface_t *, int);
4545
void xwindow_translate_for_gravity(xcb_gravity_t, int16_t, int16_t, int16_t, int16_t, int16_t *, int16_t *);
4646

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+
4756
#endif
4857
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

0 commit comments

Comments
 (0)