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

@@ -351,6 +351,11 @@ impl CoreWindow for Window {
PhysicalInsets::new(0, 0, 0, 0)
}
fn min_surface_size(&self) -> Option<PhysicalSize<u32>> {
let size = self.window_state.lock().unwrap().min_surface_size();
size.map(|size| size.to_physical(self.scale_factor()))
}
fn set_min_surface_size(&self, min_size: Option<Size>) {
let scale_factor = self.scale_factor();
let min_size = min_size.map(|size| size.to_logical(scale_factor));
@@ -359,6 +364,11 @@ impl CoreWindow for Window {
self.request_redraw();
}
fn max_surface_size(&self) -> Option<PhysicalSize<u32>> {
let size = self.window_state.lock().unwrap().max_surface_size();
size.map(|size| size.to_physical(self.scale_factor()))
}
/// Set the maximum surface size for the window.
#[inline]
fn set_max_surface_size(&self, max_size: Option<Size>) {
@@ -382,6 +392,10 @@ impl CoreWindow for Window {
self.window_state.lock().unwrap().set_title(new_title);
}
fn is_transparent(&self) -> bool {
self.window_state.lock().unwrap().is_transparent()
}
#[inline]
fn set_transparent(&self, transparent: bool) {
self.window_state.lock().unwrap().set_transparent(transparent);
@@ -487,6 +501,10 @@ impl CoreWindow for Window {
self.window_state.lock().unwrap().scale_factor()
}
fn is_blurred(&self) -> bool {
self.window_state.lock().unwrap().is_blurred()
}
#[inline]
fn set_blur(&self, blur: bool) {
self.window_state.lock().unwrap().set_blur(blur);
@@ -502,8 +520,16 @@ impl CoreWindow for Window {
self.window_state.lock().unwrap().is_decorated()
}
fn window_level(&self) -> WindowLevel {
WindowLevel::default()
}
fn set_window_level(&self, _level: WindowLevel) {}
fn window_icon(&self) -> Option<winit_core::icon::Icon> {
self.window_state.lock().unwrap().window_icon()
}
fn set_window_icon(&self, window_icon: Option<winit_core::icon::Icon>) {
self.window_state.lock().unwrap().set_window_icon(window_icon)
}
@@ -566,8 +592,17 @@ impl CoreWindow for Window {
self.window_state.lock().unwrap().theme()
}
fn content_protected(&self) -> bool {
false
}
fn set_content_protected(&self, _protected: bool) {}
fn cursor(&self) -> Cursor {
warn!("getting the cursor is unimplemented on Wayland");
Cursor::default()
}
fn set_cursor(&self, cursor: Cursor) {
let window_state = &mut self.window_state.lock().unwrap();

View File

@@ -780,6 +780,10 @@ impl WindowState {
});
}
pub fn min_surface_size(&self) -> Option<LogicalSize<u32>> {
self.min_surface_size
}
/// Set maximum inner window size.
pub fn set_min_surface_size(&mut self, size: Option<LogicalSize<u32>>) {
// Ensure that the window has the right minimum size.
@@ -798,6 +802,10 @@ impl WindowState {
self.window.set_min_size(Some(size.into()));
}
pub fn max_surface_size(&self) -> Option<LogicalSize<u32>> {
self.max_surface_size
}
/// Set maximum inner window size.
pub fn set_max_surface_size(&mut self, size: Option<LogicalSize<u32>>) {
let size = size.map(|size| {
@@ -1059,6 +1067,10 @@ impl WindowState {
}
}
pub fn is_blurred(&self) -> bool {
self.blur.is_some()
}
/// Make window background blurred
#[inline]
pub fn set_blur(&mut self, blurred: bool) {
@@ -1099,6 +1111,11 @@ impl WindowState {
self.title = title;
}
pub fn window_icon(&self) -> Option<winit_core::icon::Icon> {
warn!("getting the window icon is unimplemented on Wayland");
None
}
/// Set the window's icon
pub fn set_window_icon(&mut self, window_icon: Option<winit_core::icon::Icon>) {
let xdg_toplevel_icon_manager = match self.xdg_toplevel_icon_manager.as_ref() {
@@ -1138,6 +1155,10 @@ impl WindowState {
}
}
pub fn is_transparent(&self) -> bool {
self.transparent
}
/// Mark the window as transparent.
#[inline]
pub fn set_transparent(&mut self, transparent: bool) {