Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows briefly appear before size/position rules (e.g., ResizeTo, SnapToEdge) take effect #1718

Open
bdantas opened this issue Apr 16, 2024 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed later Not priority at the moment

Comments

@bdantas
Copy link
Contributor

bdantas commented Apr 16, 2024

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.

@Consolatis Consolatis added enhancement New feature or request help wanted Extra attention is needed later Not priority at the moment labels Apr 16, 2024
@tokyo4j
Copy link
Contributor

tokyo4j commented Apr 19, 2024

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.

@Consolatis
Copy link
Member

Consolatis commented Apr 19, 2024

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed later Not priority at the moment
Projects
None yet
Development

No branches or pull requests

3 participants