mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-24 22:31:30 +11:00
Get rid of FullScreenState::get_monitor()
This commit is contained in:
parent
b3ef9c8b22
commit
60b575a7c1
10
src/lib.rs
10
src/lib.rs
|
@ -364,16 +364,6 @@ pub enum FullScreenState {
|
||||||
Exclusive(MonitorId),
|
Exclusive(MonitorId),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FullScreenState {
|
|
||||||
pub fn get_monitor(&self) -> Option<platform::MonitorId> {
|
|
||||||
if let FullScreenState::Exclusive(ref monitor) = *self {
|
|
||||||
Some(monitor.0.clone())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Describes how winit handles the cursor.
|
/// Describes how winit handles the cursor.
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
pub enum CursorState {
|
pub enum CursorState {
|
||||||
|
|
|
@ -4,8 +4,10 @@ use std::sync::atomic::AtomicBool;
|
||||||
use wayland_client::{EventQueue, EventQueueHandle, Proxy};
|
use wayland_client::{EventQueue, EventQueueHandle, Proxy};
|
||||||
use wayland_client::protocol::{wl_display,wl_surface};
|
use wayland_client::protocol::{wl_display,wl_surface};
|
||||||
|
|
||||||
use {CreationError, MouseCursor, CursorState, WindowAttributes};
|
use {CreationError, MouseCursor, CursorState, WindowAttributes, FullScreenState};
|
||||||
use platform::MonitorId as PlatformMonitorId;
|
use platform::MonitorId as PlatformMonitorId;
|
||||||
|
use window::MonitorId as RootMonitorId;
|
||||||
|
use super::context::MonitorId as WaylandMonitorId;
|
||||||
|
|
||||||
use super::{WaylandContext, EventsLoop};
|
use super::{WaylandContext, EventsLoop};
|
||||||
use super::wayland_window;
|
use super::wayland_window;
|
||||||
|
@ -54,7 +56,7 @@ impl Window {
|
||||||
*(decorated.handler()) = Some(DecoratedHandler::new());
|
*(decorated.handler()) = Some(DecoratedHandler::new());
|
||||||
|
|
||||||
// set fullscreen if necessary
|
// set fullscreen if necessary
|
||||||
if let Some(PlatformMonitorId::Wayland(ref monitor_id)) = attributes.fullscreen.get_monitor() {
|
if let FullScreenState::Exclusive(RootMonitorId(PlatformMonitorId::Wayland(ref monitor_id))) = attributes.fullscreen {
|
||||||
ctxt.with_output(monitor_id.clone(), |output| {
|
ctxt.with_output(monitor_id.clone(), |output| {
|
||||||
decorated.set_fullscreen(Some(output))
|
decorated.set_fullscreen(Some(output))
|
||||||
});
|
});
|
||||||
|
|
|
@ -384,8 +384,8 @@ impl Window {
|
||||||
|
|
||||||
fn create_window(attrs: &WindowAttributes) -> Option<IdRef> {
|
fn create_window(attrs: &WindowAttributes) -> Option<IdRef> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let screen = match attrs.fullscreen.get_monitor() {
|
let screen = match attrs.fullscreen {
|
||||||
Some(ref monitor_id) => {
|
FullScreenState::Exclusive(ref monitor_id) => {
|
||||||
let native_id = match monitor_id.get_native_identifier() {
|
let native_id = match monitor_id.get_native_identifier() {
|
||||||
NativeMonitorId::Numeric(num) => num,
|
NativeMonitorId::Numeric(num) => num,
|
||||||
_ => panic!("OS X monitors should always have a numeric native ID")
|
_ => panic!("OS X monitors should always have a numeric native ID")
|
||||||
|
@ -411,7 +411,7 @@ impl Window {
|
||||||
};
|
};
|
||||||
Some(matching_screen.unwrap_or(appkit::NSScreen::mainScreen(nil)))
|
Some(matching_screen.unwrap_or(appkit::NSScreen::mainScreen(nil)))
|
||||||
},
|
},
|
||||||
None => None
|
_ => None,
|
||||||
};
|
};
|
||||||
let frame = match screen {
|
let frame = match screen {
|
||||||
Some(screen) => appkit::NSScreen::frame(screen),
|
Some(screen) => appkit::NSScreen::frame(screen),
|
||||||
|
|
|
@ -21,6 +21,7 @@ use CursorState;
|
||||||
use MouseCursor;
|
use MouseCursor;
|
||||||
use WindowAttributes;
|
use WindowAttributes;
|
||||||
use FullScreenState;
|
use FullScreenState;
|
||||||
|
use MonitorId as RootMonitorId;
|
||||||
|
|
||||||
use dwmapi;
|
use dwmapi;
|
||||||
use kernel32;
|
use kernel32;
|
||||||
|
@ -328,12 +329,13 @@ unsafe fn init(window: WindowAttributes, pl_attribs: PlatformSpecificWindowBuild
|
||||||
// switching to fullscreen if necessary
|
// switching to fullscreen if necessary
|
||||||
// this means adjusting the window's position so that it overlaps the right monitor,
|
// this means adjusting the window's position so that it overlaps the right monitor,
|
||||||
// and change the monitor's resolution if necessary
|
// and change the monitor's resolution if necessary
|
||||||
if let Some(ref monitor) = window.fullscreen.get_monitor() {
|
let fullscreen = if let FullScreenState::Exclusive(RootMonitorId(ref monitor)) = window.fullscreen {
|
||||||
try!(switch_to_fullscreen(&mut rect, monitor));
|
try!(switch_to_fullscreen(&mut rect, monitor));
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
};
|
};
|
||||||
|
|
||||||
let fullscreen = window.fullscreen.get_monitor().is_some();
|
|
||||||
|
|
||||||
// computing the style and extended style of the window
|
// computing the style and extended style of the window
|
||||||
let (ex_style, style) = if fullscreen || !window.decorations {
|
let (ex_style, style) = if fullscreen || !window.decorations {
|
||||||
(winapi::WS_EX_APPWINDOW,
|
(winapi::WS_EX_APPWINDOW,
|
||||||
|
|
|
@ -108,7 +108,7 @@ impl WindowBuilder {
|
||||||
pub fn build(mut self, events_loop: &EventsLoop) -> Result<Window, CreationError> {
|
pub fn build(mut self, events_loop: &EventsLoop) -> Result<Window, CreationError> {
|
||||||
// resizing the window to the dimensions of the monitor when fullscreen
|
// resizing the window to the dimensions of the monitor when fullscreen
|
||||||
if self.window.dimensions.is_none() {
|
if self.window.dimensions.is_none() {
|
||||||
if let Some(monitor) = self.window.fullscreen.get_monitor() {
|
if let FullScreenState::Exclusive(ref monitor) = self.window.fullscreen {
|
||||||
self.window.dimensions = Some(monitor.get_dimensions());
|
self.window.dimensions = Some(monitor.get_dimensions());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue