windows briefly appear before size/position rules (e.g., ResizeTo, SnapToEdge) take effect
bdantas opened this issue · comments
Windows appear for a split second in their default size/position before ResizeTo
or SnapToEdge
rule is applied. It would be preferable for window to be drawn with the matching rules already applied than to draw the window first and then apply the rules.
I'm a dummy when it comes to windowing. If what I'm requesting is impossible or more trouble than it's worth, please feel free to close this issue.
This can be solved by applying window rules before the client maps a surface. I confirmed the following patch solves the flickering issue for xdg-shell clients, but I'm not sure if it's okay to apply normal actions against views that have not been mapped.
diff --git a/src/xdg.c b/src/xdg.c
index 4e6d6dad..ce06259a 100644
--- a/src/xdg.c
+++ b/src/xdg.c
@@ -795,6 +795,8 @@ xdg_surface_new(struct wl_listener *listener, void *data)
CONNECT_SIGNAL(xdg_surface, xdg_toplevel_view, new_popup);
wl_list_insert(&server->views, &view->link);
+
+ window_rules_apply(view, LAB_WINDOW_RULE_EVENT_ON_FIRST_MAP);
}
void
Another approach would be disabling the view node until the client applies the geometry requested by window rules, but the problem is wlroots automatically sends wl_surface.leave
and doesn't return frame callback if the node is disabled, thus the configure event timeouts.
The window rules are set up to have different events even though only ON_FIRST_MAP
is implemented so far (and is the default if the event
argument is missing from the window rule). I guess we could just add another event like ON_CREATE
or something like that. However, I am also not sure about the implications of having the event run before map.
E.g. something like this:
<windowRule identifier="foot" event="onCreate">
<action name="SnapToEdge" direction="up" />
</windowRule>