Add some missing Window getters

Implemented properly when it was easy for me, but a lot of places are
stubbed out for now.
This commit is contained in:
Mads Marquart
2025-09-05 18:47:51 +02:00
parent e99d59feaf
commit b23e38efcb
12 changed files with 562 additions and 16 deletions

View File

@@ -115,10 +115,18 @@ impl CoreWindow for Window {
self.0.safe_area()
}
fn min_surface_size(&self) -> Option<PhysicalSize<u32>> {
self.0.min_surface_size()
}
fn set_min_surface_size(&self, min_size: Option<Size>) {
self.0.set_min_surface_size(min_size)
}
fn max_surface_size(&self) -> Option<PhysicalSize<u32>> {
self.0.max_surface_size()
}
fn set_max_surface_size(&self, max_size: Option<Size>) {
self.0.set_max_surface_size(max_size)
}
@@ -135,10 +143,18 @@ impl CoreWindow for Window {
self.0.set_title(title);
}
fn is_transparent(&self) -> bool {
self.0.is_transparent()
}
fn set_transparent(&self, transparent: bool) {
self.0.set_transparent(transparent);
}
fn is_blurred(&self) -> bool {
self.0.is_blurred()
}
fn set_blur(&self, blur: bool) {
self.0.set_blur(blur);
}
@@ -199,10 +215,19 @@ impl CoreWindow for Window {
self.0.is_decorated()
}
fn window_level(&self) -> WindowLevel {
self.0.window_level()
}
fn set_window_level(&self, level: WindowLevel) {
self.0.set_window_level(level);
}
fn window_icon(&self) -> Option<winit_core::icon::Icon> {
warn!("getting the window icon is unimplemented on X11");
None
}
fn set_window_icon(&self, window_icon: Option<winit_core::icon::Icon>) {
let icon = match window_icon.as_ref() {
Some(icon) => icon.cast_ref::<RgbaIcon>(),
@@ -239,6 +264,10 @@ impl CoreWindow for Window {
self.0.theme()
}
fn content_protected(&self) -> bool {
self.0.content_protected()
}
fn set_content_protected(&self, protected: bool) {
self.0.set_content_protected(protected);
}
@@ -247,6 +276,10 @@ impl CoreWindow for Window {
self.0.title()
}
fn cursor(&self) -> Cursor {
self.0.cursor()
}
fn set_cursor(&self, cursor: Cursor) {
self.0.set_cursor(cursor);
}
@@ -1357,9 +1390,18 @@ impl UnownedWindow {
self.xconn.flush_requests().expect("Failed to set window title");
}
fn is_transparent(&self) -> bool {
warn!("getting transparency state is unimplemented on X11");
false
}
#[inline]
pub fn set_transparent(&self, _transparent: bool) {}
fn is_blurred(&self) -> bool {
false
}
#[inline]
pub fn set_blur(&self, _blur: bool) {}
@@ -1404,6 +1446,11 @@ impl UnownedWindow {
self.toggle_atom(_NET_WM_STATE_BELOW, level == WindowLevel::AlwaysOnBottom)
}
fn window_level(&self) -> WindowLevel {
warn!("getting the window level is unimplemented on X11");
WindowLevel::default()
}
#[inline]
pub fn set_window_level(&self, level: WindowLevel) {
self.set_window_level_inner(level)
@@ -1665,6 +1712,11 @@ impl UnownedWindow {
.expect("Failed to call `XSetWMNormalHints`");
}
fn min_surface_size(&self) -> Option<PhysicalSize<u32>> {
let size = self.shared_state_lock().min_surface_size;
size.map(|size| size.to_physical(self.scale_factor()))
}
#[inline]
pub fn set_min_surface_size(&self, dimensions: Option<Size>) {
self.shared_state_lock().min_surface_size = dimensions;
@@ -1681,6 +1733,11 @@ impl UnownedWindow {
.expect("Failed to call `XSetWMNormalHints`");
}
fn max_surface_size(&self) -> Option<PhysicalSize<u32>> {
let size = self.shared_state_lock().max_surface_size;
size.map(|size| size.to_physical(self.scale_factor()))
}
#[inline]
pub fn set_max_surface_size(&self, dimensions: Option<Size>) {
self.shared_state_lock().max_surface_size = dimensions;
@@ -1799,6 +1856,12 @@ impl UnownedWindow {
self.xwindow as ffi::Window
}
#[inline]
pub fn cursor(&self) -> Cursor {
warn!("getting the cursor is unimplemented on X11");
Cursor::default()
}
#[inline]
pub fn set_cursor(&self, cursor: Cursor) {
match cursor {
@@ -2255,6 +2318,10 @@ impl UnownedWindow {
None
}
pub fn content_protected(&self) -> bool {
false
}
pub fn set_content_protected(&self, _protected: bool) {}
#[inline]