Skip to content

Commit

Permalink
qubes-guid: add window_background_color setting
Browse files Browse the repository at this point in the history
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 <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
  • Loading branch information
Euwiiwueir committed Jun 22, 2024
1 parent 7e85df2 commit 51399c3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
7 changes: 7 additions & 0 deletions gui-daemon/guid.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 11 additions & 2 deletions gui-daemon/xside.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions gui-daemon/xside.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) */
Expand Down

0 comments on commit 51399c3

Please sign in to comment.