mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-24 06:11:30 +11:00
Implement set_maximized, set_fullscreen and set_decorations for wayland (#383)
* wayland: implement Window::set_decorations() * wayland: implement Window::set_maximized() * wayland: implement Window::set_fullscreen() * Update changelog.
This commit is contained in:
parent
dddd9de151
commit
0ea4f93f05
|
@ -1,5 +1,7 @@
|
|||
# Unreleased
|
||||
|
||||
- Implement `Window::set_fullscreen`, `Window::set_maximized` and `Window::set_decorations` for Wayland.
|
||||
|
||||
# Version 0.10.0 (2017-12-27)
|
||||
|
||||
- Add support for `Touch` for emscripten backend.
|
||||
|
|
|
@ -248,9 +248,7 @@ impl Window {
|
|||
pub fn set_maximized(&self, maximized: bool) {
|
||||
match self {
|
||||
&Window::X(ref w) => w.set_maximized(maximized),
|
||||
&Window::Wayland(ref _w) => {
|
||||
unimplemented!();
|
||||
}
|
||||
&Window::Wayland(ref w) => w.set_maximized(maximized),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -258,9 +256,7 @@ impl Window {
|
|||
pub fn set_fullscreen(&self, monitor: Option<RootMonitorId>) {
|
||||
match self {
|
||||
&Window::X(ref w) => w.set_fullscreen(monitor),
|
||||
&Window::Wayland(ref _w) => {
|
||||
unimplemented!();
|
||||
}
|
||||
&Window::Wayland(ref w) => w.set_fullscreen(monitor)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -268,9 +264,7 @@ impl Window {
|
|||
pub fn set_decorations(&self, decorations: bool) {
|
||||
match self {
|
||||
&Window::X(ref w) => w.set_decorations(decorations),
|
||||
&Window::Wayland(ref _w) => {
|
||||
unimplemented!();
|
||||
}
|
||||
&Window::Wayland(ref w) => w.set_decorations(decorations)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ pub struct Window {
|
|||
size: Arc<Mutex<(u32, u32)>>,
|
||||
kill_switch: (Arc<Mutex<bool>>, Arc<Mutex<bool>>),
|
||||
display: Arc<wl_display::WlDisplay>,
|
||||
need_frame_refresh: Arc<Mutex<bool>>
|
||||
}
|
||||
|
||||
impl Window {
|
||||
|
@ -59,6 +60,7 @@ impl Window {
|
|||
}
|
||||
|
||||
let kill_switch = Arc::new(Mutex::new(false));
|
||||
let need_frame_refresh = Arc::new(Mutex::new(true));
|
||||
let frame = Arc::new(Mutex::new(frame));
|
||||
|
||||
{
|
||||
|
@ -67,7 +69,7 @@ impl Window {
|
|||
closed: false,
|
||||
newsize: None,
|
||||
need_refresh: false,
|
||||
need_frame_refresh: true,
|
||||
need_frame_refresh: need_frame_refresh.clone(),
|
||||
surface: surface.clone().unwrap(),
|
||||
kill_switch: kill_switch.clone(),
|
||||
frame: Arc::downgrade(&frame)
|
||||
|
@ -81,7 +83,8 @@ impl Window {
|
|||
frame: frame,
|
||||
monitors: monitor_list,
|
||||
size: size,
|
||||
kill_switch: (kill_switch, evlp.cleanup_needed.clone())
|
||||
kill_switch: (kill_switch, evlp.cleanup_needed.clone()),
|
||||
need_frame_refresh: need_frame_refresh
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -160,6 +163,28 @@ impl Window {
|
|||
factor
|
||||
}
|
||||
|
||||
pub fn set_decorations(&self, decorate: bool) {
|
||||
self.frame.lock().unwrap().set_decorate(decorate);
|
||||
*(self.need_frame_refresh.lock().unwrap()) = true;
|
||||
}
|
||||
|
||||
pub fn set_maximized(&self, maximized: bool) {
|
||||
if maximized {
|
||||
self.frame.lock().unwrap().set_state(FrameState::Maximized);
|
||||
} else {
|
||||
self.frame.lock().unwrap().set_state(FrameState::Regular);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_fullscreen(&self, monitor: Option<RootMonitorId>) {
|
||||
if let Some(RootMonitorId { inner: PlatformMonitorId::Wayland(ref monitor_id) }) = monitor {
|
||||
let info = monitor_id.info.lock().unwrap();
|
||||
self.frame.lock().unwrap().set_state(FrameState::Fullscreen(Some(&info.output)));
|
||||
} else {
|
||||
self.frame.lock().unwrap().set_state(FrameState::Regular);
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_cursor_position(&self, _x: i32, _y: i32) -> Result<(), ()> {
|
||||
// TODO: not yet possible on wayland
|
||||
|
@ -197,7 +222,7 @@ struct InternalWindow {
|
|||
surface: wl_surface::WlSurface,
|
||||
newsize: Option<(i32, i32)>,
|
||||
need_refresh: bool,
|
||||
need_frame_refresh: bool,
|
||||
need_frame_refresh: Arc<Mutex<bool>>,
|
||||
closed: bool,
|
||||
kill_switch: Arc<Mutex<bool>>,
|
||||
frame: Weak<Mutex<Frame>>
|
||||
|
@ -242,7 +267,7 @@ impl WindowStore {
|
|||
f(
|
||||
window.newsize.take(),
|
||||
window.need_refresh,
|
||||
window.need_frame_refresh,
|
||||
::std::mem::replace(&mut *window.need_frame_refresh.lock().unwrap(), false),
|
||||
window.closed,
|
||||
make_wid(&window.surface),
|
||||
opt_mutex_lock.as_mut().map(|m| &mut **m)
|
||||
|
@ -271,7 +296,7 @@ fn decorated_impl() -> FrameImplementation<FrameIData> {
|
|||
if window.surface.equals(&idata.surface) {
|
||||
window.newsize = newsize;
|
||||
window.need_refresh = true;
|
||||
window.need_frame_refresh = true;
|
||||
*(window.need_frame_refresh.lock().unwrap()) = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -289,7 +314,7 @@ fn decorated_impl() -> FrameImplementation<FrameIData> {
|
|||
let store = evqh.state().get_mut(&idata.store_token);
|
||||
for window in &mut store.windows {
|
||||
if window.surface.equals(&idata.surface) {
|
||||
window.need_frame_refresh = true;
|
||||
*(window.need_frame_refresh.lock().unwrap()) = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue