From 396b13f5a83bfc4c54a8fccdcf3fb4ab4e2cfd0c Mon Sep 17 00:00:00 2001 From: lbonn Date: Sat, 5 Feb 2022 13:13:17 +0100 Subject: [PATCH] wayland: quick fix for changing height We use the surface size of a fullscreen layer to calculate screen size. But when height is recomputed and given as a percentage, this definition becomes self-referencing. Do a quick fix by caching the monitor resolution. --- source/wayland/view.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/source/wayland/view.c b/source/wayland/view.c index 69c2b3ed..f0054e21 100644 --- a/source/wayland/view.c +++ b/source/wayland/view.c @@ -80,16 +80,31 @@ static struct { guint repaint_source; /** Window fullscreen */ gboolean fullscreen; + + int monitor_width; + int monitor_height; } WlState = { .flags = MENU_NORMAL, .idle_timeout = 0, .count = 0L, .repaint_source = 0, .fullscreen = FALSE, + .monitor_width = 0, + .monitor_height = 0, }; static void wayland_rofi_view_get_current_monitor(int *width, int *height) { - display_get_surface_dimensions(width, height); + // TODO: handle changing monitor resolution + if (WlState.monitor_width == 0 && WlState.monitor_height == 0) { + display_get_surface_dimensions(&WlState.monitor_width, &WlState.monitor_height); + } + + if (width) { + *width = WlState.monitor_width; + } + if (height) { + *height = WlState.monitor_height; + } } /**