Skip to content

fix: maximization on X11 #2824

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

Closed
wants to merge 1 commit into from
Closed

fix: maximization on X11 #2824

wants to merge 1 commit into from

Conversation

murar8
Copy link

@murar8 murar8 commented Oct 4, 2024

Took a stab at a fix for #2657

What kind of change does this PR introduce?

  • Fix

Did this PR introduce a breaking change?

  • No

@fredizzimo
Copy link
Member

Is it not enough to call window.set_maximized(true) here after showing the window?

skia_renderer.window().set_visible(true);

According to this, it should work rust-windowing/winit#2360 (comment)

We also have to be careful to not cause any artifacts which #2562 tries to fix. See the discussion there. Although it might be impossible in the case of maximization.

@murar8
Copy link
Author

murar8 commented Oct 8, 2024

Is it not enough to call window.set_maximized(true) here after showing the window?

I'm not very knowledgeable about X11 internals, but that was my first attempt and it doesn't seem to work, looks like it needs a rendering cycle with the window visible first. Please check out the updated code.

We also have to be careful to not cause any artifacts which #2562 tries to fix. See the discussion there. Although it might be impossible in the case of maximization.

Thanks, I checked out your code and I agree with you, it looks like showing the window already maximized would not be feasible. There will be an artifact in the sense that the window will be maximized after it is made visible. Attaching an example below.
Grabación de pantalla desde 2024-10-08 11-15-12.webm

Alacritty seems to do it without glitches and they do as you suggest
https://github.com/alacritty/alacritty/blob/a1ed79bd2c014be49a85e2100ce374b86c8839e8/alacritty/src/display/mod.rs#L489

@murar8
Copy link
Author

murar8 commented Oct 8, 2024

Interestingly, when testing out this code:

diff --git a/src/window/window_wrapper.rs b/src/window/window_wrapper.rs
index 39b57a0..0e821dd 100644
--- a/src/window/window_wrapper.rs
+++ b/src/window/window_wrapper.rs
@@ -410,8 +410,16 @@ impl WinitWindowWrapper {
         }
         skia_renderer.swap_buffers();
         if self.ui_state == UIState::FirstFrame {
-            skia_renderer.window().set_visible(true);
+            let window = skia_renderer.window();
+            window.set_visible(true);
             self.ui_state = UIState::Showing;
+            let is_x11 = {
+                let handle = window.window_handle().unwrap().as_raw();
+                matches!(handle, RawWindowHandle::Xlib(_) | RawWindowHandle::Xcb(_))
+            };
+            if is_x11 {
+                window.set_maximized(true);
+            }
         }
         tracy_frame();
         tracy_gpu_collect();

Works only when --frame=none

@fredizzimo
Copy link
Member

Does the latest version work without glitches? In that case I think it's good enough.

Copy link

Test Results

  6 files  ±0    6 suites  ±0   15s ⏱️ -1s
112 tests ±0  112 ✅ ±0  0 💤 ±0  0 ❌ ±0 
656 runs  ±0  656 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 41bd30c. ± Comparison against base commit 6d0aa1a.

@murar8
Copy link
Author

murar8 commented Oct 24, 2024

@fredizzimo It is usable but still a bit glitchy, if you would like a temporary workaround it will work, otherwise feel free to close for now, when I have some free time I will hack on it some more.

@fredizzimo
Copy link
Member

I'm putting this into draft status for now. I have to test it myself, and I also don't think I saw any problems on X11 on KDE Plasma before, so the original problem might be limited to some desktops/window managers only.

@fredizzimo fredizzimo marked this pull request as draft October 30, 2024 20:46
@murar8 murar8 closed this by deleting the head repository Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants