From 51399c372c40d2b00052871105197be64e7c01d7 Mon Sep 17 00:00:00 2001 From: Euwiiwueir Date: Sat, 22 Jun 2024 19:24:04 -0400 Subject: [PATCH] qubes-guid: add window_background_color setting This configuration setting allows changing the background pixel for local windows that display content of VM windows. Generally the color is only visible rarely and briefly. Previous to this commit the color was hardcoded to white which is suboptimal for users running dark desktop styling. This is the downstream translation of these VM features: - gui-window-background-color - gui-default-window-background-color Testing process: [user@dom0 ~]$ qvm-features dom0 gui-default-window-background-color [user@dom0 ~]$ qvm-run --dispvm=default-dvm --service qubes.StartApp+debian-xterm # (Then play with the terminal's window to expose the color) Related to: QubesOS/qubes-issues#9304 --- gui-daemon/guid.conf | 7 +++++++ gui-daemon/xside.c | 13 +++++++++++-- gui-daemon/xside.h | 2 ++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/gui-daemon/guid.conf b/gui-daemon/guid.conf index 7f2dff08..3f1530a9 100644 --- a/gui-daemon/guid.conf +++ b/gui-daemon/guid.conf @@ -70,6 +70,13 @@ global: { # # trayicon_mode = "border1"; + # Set the fill color to be shown in a window when content is pending or + # unavailable. This is rarely visible except very briefly. Possible values are + # a color name (see: /etc/X11/rgb.txt) or a specification in format 0xRRGGBB. + # When running a dark-styled desktop theme, "black" is recommended. + # + # window_background_color = "white"; + # Timeout when waiting for qubes-gui-agent # # startup_timeout = 45; diff --git a/gui-daemon/xside.c b/gui-daemon/xside.c index 0a4d8bb9..947596c8 100644 --- a/gui-daemon/xside.c +++ b/gui-daemon/xside.c @@ -361,7 +361,7 @@ static Window mkwindow(Ghandles * g, struct windowdata *vm_window) my_size_hints.height = vm_window->height; attr.override_redirect = vm_window->override_redirect; - attr.background_pixel = WhitePixel(g->display, DefaultScreen(g->display)); + attr.background_pixel = g->window_background_pixel; child_win = XCreateWindow(g->display, g->root_win, vm_window->x, vm_window->y, vm_window->width, @@ -690,6 +690,9 @@ static void mkghandles(Ghandles * g) else if (g->trayicon_mode == TRAY_TINT) init_tray_tint(g); /* nothing extra needed for TRAY_BORDER */ + /* parse window background color */ + g->window_background_pixel = parse_color(g->window_background_color_pre_parse, + g->display, g->screen).pixel; /* parse -p arguments now, as we have X server connection */ parse_cmdline_prop(g); /* init window lists */ @@ -3791,7 +3794,7 @@ static void usage(FILE *stream) fprintf(stream, " --domid=ID, -d ID\tdomain ID running GUI agent\n"); fprintf(stream, " --target-domid=ID, -t ID\tdomain ID of actual VM (may be different from --domid in case of stubdomain)\n"); fprintf(stream, " --name=NAME, -N NAME\tVM name\n"); - fprintf(stream, " --color=COLOR, -c COLOR\tVM color (in format 0xRRGGBB)\n"); + fprintf(stream, " --color=COLOR, -c COLOR\tVM color (format 0xRRGGBB or color name)\n"); fprintf(stream, " --label=LABEL_INDEX, -l LABEL_INDEX\tVM label index\n"); fprintf(stream, " --icon=ICON, -i ICON\tIcon name (without suffix), or full icon path\n"); fprintf(stream, " --qrexec-for-clipboard, -Q\tforce usage of Qrexec for clipboard operations\n"); @@ -4123,6 +4126,7 @@ static void load_default_config_values(Ghandles * g) g->trayicon_border = 0; g->trayicon_tint_reduce_saturation = 0; g->trayicon_tint_whitehack = 0; + g->window_background_color_pre_parse = "white"; } // parse string describing key sequence like Ctrl-Alt-c @@ -4211,6 +4215,11 @@ static void parse_vm_config(Ghandles * g, config_setting_t * group) parse_trayicon_mode(g, config_setting_get_string(setting)); } + if ((setting = + config_setting_get_member(group, "window_background_color"))) { + g->window_background_color_pre_parse = config_setting_get_string(setting); + } + if ((setting = config_setting_get_member(group, "startup_timeout"))) { g->startup_timeout = config_setting_get_int(setting); diff --git a/gui-daemon/xside.h b/gui-daemon/xside.h index 8ca478e9..f799c86e 100644 --- a/gui-daemon/xside.h +++ b/gui-daemon/xside.h @@ -225,6 +225,8 @@ struct _global_handles { int trayicon_border; /* position of trayicon border - 0 - no border, 1 - at the edges, 2 - 1px from the edges */ bool trayicon_tint_reduce_saturation; /* reduce trayicon saturation by 50% (available only for "tint" mode) */ bool trayicon_tint_whitehack; /* replace white pixels with almost-white 0xfefefe (available only for "tint" mode) */ + const char *window_background_color_pre_parse; /* user-provided description of window background pixel */ + unsigned long window_background_pixel; /* parsed version of the above */ bool disable_override_redirect; /* Disable “override redirect” windows */ char *screensaver_names[MAX_SCREENSAVER_NAMES]; /* WM_CLASS names for windows detected as screensavers */ Cursor *cursors; /* preloaded cursors (using XCreateFontCursor) */