[gtk: 1/2] x11: ensure WM class is not null even if display is initialized early
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk: 1/2] x11: ensure WM class is not null even if display is initialized early
- Date: Wed, 18 Aug 2021 18:24:38 +0000 (UTC)
commit 2ebde276d1ce27876a788e28d7445417681e22fe
Author: Vincent Bernat <vincent bernat ch>
Date: Sat Jul 31 12:29:47 2021 +0200
x11: ensure WM class is not null even if display is initialized early
With gtkmm, when using `Application()`, the display is initialized
before we know the application name and therefore, the program class
associated to the display is NULL.
Instead of providing a default value, we set it equal to program name
when NULL. Moreover, we give up on capitalizing the class name to keep
the code super simple. Also, not using a capitalized name is
consistent with `gdk_x11_display_open()`. If someone has a good reason
to use a capitalized name, here is how to do it.
```c
class_hint = XAllocClassHint ();
class_hint->res_name = (char *) g_get_prgname ();
if (display_x11->program_class)
{
class_hint->res_class = (char *) g_strdup (display_x11->program_class);
}
else if (class_hint->res_name && class_hint->res_name[0])
{
class_hint->res_class = (char *) g_strdup (class_hint->res_name);
class_hint->res_class[0] = g_ascii_toupper (class_hint->res_class[0]);
}
XSetClassHint (xdisplay, impl->xid, class_hint);
g_free (class_hint->res_class);
XFree (class_hint);
```
Fix eff53c023a26 ("x11: set a default value for program_class")
gdk/x11/gdkdisplay-x11.c | 3 ---
gdk/x11/gdksurface-x11.c | 5 ++++-
2 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index 30d040a132..33a3648f4e 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -204,9 +204,6 @@ static void
gdk_x11_display_init (GdkX11Display *self)
{
self->monitors = g_list_store_new (GDK_TYPE_MONITOR);
- self->program_class = g_strdup (g_get_prgname ());
- if (self->program_class && self->program_class[0])
- self->program_class[0] = g_ascii_toupper (self->program_class[0]);
}
static void
diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c
index 505fbd2b9a..dd1d0d3bd2 100644
--- a/gdk/x11/gdksurface-x11.c
+++ b/gdk/x11/gdksurface-x11.c
@@ -1282,7 +1282,10 @@ _gdk_x11_display_create_surface (GdkDisplay *display,
class_hint = XAllocClassHint ();
class_hint->res_name = (char *) g_get_prgname ();
- class_hint->res_class = (char *) display_x11->program_class;
+ if (display_x11->program_class)
+ class_hint->res_class = (char *) display_x11->program_class;
+ else
+ class_hint->res_class = class_hint->res_name;
XSetClassHint (xdisplay, impl->xid, class_hint);
XFree (class_hint);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]