On X11 and Wayland, add is_maximized support
Fixes #1845. Co-authored-by: Kirill Chibisov <contact@kchibisov.com>
This commit is contained in:
parent
67cca71524
commit
c916eb6137
4 changed files with 39 additions and 2 deletions
|
|
@ -54,6 +54,9 @@ pub struct Window {
|
|||
/// Fullscreen state.
|
||||
fullscreen: Arc<AtomicBool>,
|
||||
|
||||
/// Maximized state.
|
||||
maximized: Arc<AtomicBool>,
|
||||
|
||||
/// Available windowing features.
|
||||
windowing_features: WindowingFeatures,
|
||||
|
||||
|
|
@ -87,6 +90,8 @@ impl Window {
|
|||
let scale_factor = sctk::get_surface_scale_factor(&surface);
|
||||
|
||||
let window_id = super::make_wid(&surface);
|
||||
let maximized = Arc::new(AtomicBool::new(false));
|
||||
let maximzied_clone = maximized.clone();
|
||||
let fullscreen = Arc::new(AtomicBool::new(false));
|
||||
let fullscreen_clone = fullscreen.clone();
|
||||
|
||||
|
|
@ -113,6 +118,8 @@ impl Window {
|
|||
window_update.refresh_frame = true;
|
||||
}
|
||||
Event::Configure { new_size, states } => {
|
||||
let is_maximized = states.contains(&State::Maximized);
|
||||
maximzied_clone.store(is_maximized, Ordering::Relaxed);
|
||||
let is_fullscreen = states.contains(&State::Fullscreen);
|
||||
fullscreen_clone.store(is_fullscreen, Ordering::Relaxed);
|
||||
|
||||
|
|
@ -235,6 +242,7 @@ impl Window {
|
|||
window_requests,
|
||||
event_loop_awakener: event_loop_window_target.event_loop_awakener.clone(),
|
||||
fullscreen,
|
||||
maximized,
|
||||
windowing_features,
|
||||
};
|
||||
|
||||
|
|
@ -368,6 +376,11 @@ impl Window {
|
|||
self.event_loop_awakener.ping();
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_maximized(&self) -> bool {
|
||||
self.maximized.load(Ordering::Relaxed)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_maximized(&self, maximized: bool) {
|
||||
let maximize_request = WindowRequest::Maximize(maximized);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue