On Wayland, provide option for better CSD
While most compositors provide server side decorations, the GNOME does not, and won't provide them. Also Wayland clients must render client side decorations. Winit was already drawing some decorations, however they were bad looking and provided no text rendering, so the title was missing. However this commit makes use of the SCTK external frame similar to GTK's Adwaita theme supporting text rendering and looking similar to other GTK applications. Fixes #1967.
This commit is contained in:
parent
f04fa5d54f
commit
829a140d9b
9 changed files with 118 additions and 14 deletions
|
|
@ -32,6 +32,9 @@ pub use crate::platform_impl::x11;
|
|||
#[cfg(feature = "x11")]
|
||||
pub use crate::platform_impl::{x11::util::WindowType as XWindowType, XNotSupported};
|
||||
|
||||
#[cfg(feature = "wayland")]
|
||||
pub use crate::window::Theme;
|
||||
|
||||
/// Additional methods on `EventLoopWindowTarget` that are specific to Unix.
|
||||
pub trait EventLoopWindowTargetExtUnix {
|
||||
/// True if the `EventLoopWindowTarget` uses Wayland.
|
||||
|
|
@ -70,7 +73,6 @@ impl<T> EventLoopWindowTargetExtUnix for EventLoopWindowTarget<T> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
#[doc(hidden)]
|
||||
#[cfg(feature = "x11")]
|
||||
fn xlib_xconnection(&self) -> Option<Arc<XConnection>> {
|
||||
match self.p {
|
||||
|
|
@ -179,6 +181,13 @@ pub trait WindowExtUnix {
|
|||
#[cfg(feature = "wayland")]
|
||||
fn wayland_display(&self) -> Option<*mut raw::c_void>;
|
||||
|
||||
/// Updates [`Theme`] of window decorations.
|
||||
///
|
||||
/// You can also use `WINIT_WAYLAND_CSD_THEME` env variable to set the theme.
|
||||
/// Possible values for env variable are: "dark" and light"
|
||||
#[cfg(feature = "wayland")]
|
||||
fn wayland_set_csd_theme(&self, config: Theme);
|
||||
|
||||
/// Check if the window is ready for drawing
|
||||
///
|
||||
/// It is a remnant of a previous implementation detail for the
|
||||
|
|
@ -221,7 +230,6 @@ impl WindowExtUnix for Window {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
#[doc(hidden)]
|
||||
#[cfg(feature = "x11")]
|
||||
fn xlib_xconnection(&self) -> Option<Arc<XConnection>> {
|
||||
match self.window {
|
||||
|
|
@ -261,6 +269,16 @@ impl WindowExtUnix for Window {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[cfg(feature = "wayland")]
|
||||
fn wayland_set_csd_theme(&self, theme: Theme) {
|
||||
match self.window {
|
||||
LinuxWindow::Wayland(ref w) => w.set_csd_theme(theme),
|
||||
#[cfg(feature = "x11")]
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_ready(&self) -> bool {
|
||||
true
|
||||
|
|
@ -299,6 +317,13 @@ pub trait WindowBuilderExtUnix {
|
|||
#[cfg(feature = "x11")]
|
||||
fn with_gtk_theme_variant(self, variant: String) -> Self;
|
||||
|
||||
/// Build window with certain decoration [`Theme`]
|
||||
///
|
||||
/// You can also use `WINIT_WAYLAND_CSD_THEME` env variable to set the theme.
|
||||
/// Possible values for env variable are: "dark" and light"
|
||||
#[cfg(feature = "wayland")]
|
||||
fn with_wayland_csd_theme(self, theme: Theme) -> Self;
|
||||
|
||||
/// Build window with resize increment hint. Only implemented on X11.
|
||||
///
|
||||
/// ```
|
||||
|
|
@ -375,6 +400,13 @@ impl WindowBuilderExtUnix for WindowBuilder {
|
|||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[cfg(feature = "wayland")]
|
||||
fn with_wayland_csd_theme(mut self, theme: Theme) -> Self {
|
||||
self.platform_specific.csd_theme = Some(theme);
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[cfg(feature = "x11")]
|
||||
fn with_resize_increments<S: Into<Size>>(mut self, increments: S) -> Self {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue