-
-
Notifications
You must be signed in to change notification settings - Fork 182
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
fix(window): improve wayland-display #979
base: dev
Are you sure you want to change the base?
Conversation
The changes add a custom header bar with window control buttons (close, maximize/restore, minimize) to the Linux Wayland platform implementation. This provides a consistent user experience for window management across platforms. The header bar is implemented using GTK widgets and is added to the top of the application window. The drag area of the header bar is also used to enable window moving and resizing functionality.
## Explanation The changes made in this commit ensure that the window is only maximized if it is also resizable. This is to prevent issues where a non-resizable window is maximized, which could lead to unexpected behavior. The main changes are: 1. In the `set_maximized` function, the code checks if the window is resizable before maximizing it. If it's not resizable, the window is not maximized. 2. In the `is_maximizable` function, the code checks if the window is resizable and if the maximized state is true before returning `true`. These changes improve the overall behavior and consistency of the window maximization functionality.
Package Changes Through 342b42dNo changes. Add a change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Zamoca42 thank you, this looks awesome, left a few comments
@@ -421,6 +422,33 @@ impl<T: 'static> EventLoop<T> { | |||
| EventMask::SCROLL_MASK, | |||
); | |||
|
|||
const TITLEBAR_HEIGHT: f64 = 30.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this feels like a magic number, shouldn't we query and check the actual height of the header bar?
if !window.is_decorated() | ||
&& window.is_resizable() | ||
&& !window.is_maximized() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why was these checks removed?
@@ -87,6 +89,10 @@ impl Window { | |||
|
|||
let window = window_builder.build(); | |||
|
|||
if is_wayland { | |||
WlHeader::setup(&window); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how does this look like on Desktop environments that has server side decorations. I think KDE has server side decorations.
@@ -569,9 +575,12 @@ impl Window { | |||
} | |||
|
|||
pub fn set_maximized(&self, maximized: bool) { | |||
let resizable = self.is_resizable(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of just ignoring the maximized request, should we instead make the window resizable, maximize it, then make it non-resizable again?
@@ -594,7 +603,7 @@ impl Window { | |||
} | |||
|
|||
pub fn is_maximizable(&self) -> bool { | |||
true | |||
self.window.is_resizable() && self.maximized.load(Ordering::Acquire) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is_maximizable
is not the same as is_maximized
Fixes #977
Reproduce Errror Protocol 71
In the resizable example, when
resizable
is set tofalse
andwith_maximized(true)
is used, it works fine on macOS, but an “Error Protocol 71” occurs on Linux using Wayland.This behavior seems a bit unusual.
MacOS
Wayland on Linux
Changes
1. Added conditions for maximizing in the Linux environment.
To prevent “Error Protocol 71,” I added a condition to check the resizable state when maximizing in the Linux environment.
2. Wayland Header
While X11 has built-in headers for maximize and minimize buttons, Wayland does not have these buttons by default. Therefore, I added headers specifically for Wayland.
before
after
3. resizing in Wayland
Unlike X11, in Wayland, even when the
resizable
condition is set to true, resizing was not possible, and moving the window was also not allowed. However, by modifying the conditions in the event loop, window movement is now enabled.before
after
Issues still not resolved
In Linux, when creating a window, it should maximize on the screen with
with_maximized(true)
, just like on macOS, even ifresizable
is set tofalse
.