fix: window state events
This commit is contained in:
parent
43f4760b0e
commit
ec30b8004f
5 changed files with 28 additions and 1 deletions
|
|
@ -375,6 +375,11 @@ pub enum WindowEvent {
|
||||||
/// - **iOS / Android / Web / Orbital / Windows:** Unsupported.
|
/// - **iOS / Android / Web / Orbital / Windows:** Unsupported.
|
||||||
SuggestedBounds(Option<PhysicalSize<u32>>),
|
SuggestedBounds(Option<PhysicalSize<u32>>),
|
||||||
|
|
||||||
|
/// The window state has changed.
|
||||||
|
///
|
||||||
|
/// - **iOS / Android / Web / Orbital / Windows:** Unsupported.
|
||||||
|
WindowStateChanged,
|
||||||
|
|
||||||
/// The system window theme has changed.
|
/// The system window theme has changed.
|
||||||
///
|
///
|
||||||
/// Applications might wish to react to this to change the theme of the content of the window
|
/// Applications might wish to react to this to change the theme of the content of the window
|
||||||
|
|
|
||||||
|
|
@ -395,6 +395,11 @@ impl EventLoop {
|
||||||
app.window_event(&self.active_event_loop, window_id, event);
|
app.window_event(&self.active_event_loop, window_id, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if compositor_update.xdg_window_state.is_some() {
|
||||||
|
let event = WindowEvent::WindowStateChanged;
|
||||||
|
app.window_event(&self.active_event_loop, window_id, event);
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE: Rescale changed the physical size which winit operates in, thus we should
|
// NOTE: Rescale changed the physical size which winit operates in, thus we should
|
||||||
// resize.
|
// resize.
|
||||||
if compositor_update.resized || compositor_update.scale_changed {
|
if compositor_update.resized || compositor_update.scale_changed {
|
||||||
|
|
|
||||||
|
|
@ -313,6 +313,12 @@ impl WindowHandler for WinitState {
|
||||||
self.window_compositor_updates[pos].suggested_bounds |= configure.suggested_bounds
|
self.window_compositor_updates[pos].suggested_bounds |= configure.suggested_bounds
|
||||||
!= winit_window.last_configure.as_ref().and_then(|last| last.suggested_bounds);
|
!= winit_window.last_configure.as_ref().and_then(|last| last.suggested_bounds);
|
||||||
|
|
||||||
|
self.window_compositor_updates[pos].xdg_window_state = winit_window
|
||||||
|
.last_configure
|
||||||
|
.as_ref()
|
||||||
|
.is_none_or(|last| last.state != configure.state)
|
||||||
|
.then_some(configure.state);
|
||||||
|
|
||||||
self.window_compositor_updates[pos].resized |=
|
self.window_compositor_updates[pos].resized |=
|
||||||
winit_window.configure(configure, &self.shm, &self.subcompositor_state);
|
winit_window.configure(configure, &self.shm, &self.subcompositor_state);
|
||||||
|
|
||||||
|
|
@ -445,6 +451,9 @@ pub struct WindowCompositorUpdate {
|
||||||
|
|
||||||
/// New suggested bounds.
|
/// New suggested bounds.
|
||||||
pub suggested_bounds: bool,
|
pub suggested_bounds: bool,
|
||||||
|
|
||||||
|
/// New xdg window state.
|
||||||
|
pub xdg_window_state: Option<sctk::reexports::csd_frame::WindowState>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowCompositorUpdate {
|
impl WindowCompositorUpdate {
|
||||||
|
|
@ -455,6 +464,7 @@ impl WindowCompositorUpdate {
|
||||||
scale_changed: false,
|
scale_changed: false,
|
||||||
close_window: false,
|
close_window: false,
|
||||||
suggested_bounds: false,
|
suggested_bounds: false,
|
||||||
|
xdg_window_state: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -252,6 +252,11 @@ impl Window {
|
||||||
pub fn surface(&self) -> &WlSurface {
|
pub fn surface(&self) -> &WlSurface {
|
||||||
self.window.wl_surface()
|
self.window.wl_surface()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn xdg_window_state(&self) -> Option<sctk::reexports::csd_frame::WindowState> {
|
||||||
|
self.window_state.lock().unwrap().last_configure.as_ref().map(|c| c.state)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for Window {
|
impl Drop for Window {
|
||||||
|
|
|
||||||
|
|
@ -557,7 +557,9 @@ impl ApplicationHandler for Application {
|
||||||
| WindowEvent::DragDropped { .. }
|
| WindowEvent::DragDropped { .. }
|
||||||
| WindowEvent::Destroyed
|
| WindowEvent::Destroyed
|
||||||
| WindowEvent::Ime(_)
|
| WindowEvent::Ime(_)
|
||||||
| WindowEvent::Moved(_) => (),
|
| WindowEvent::Moved(_)
|
||||||
|
| WindowEvent::SuggestedBounds(_)
|
||||||
|
| WindowEvent::WindowStateChanged => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue