mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-24 22:31:30 +11:00
maximized/fullscreen as noops for other platforms
This commit is contained in:
parent
eff04394c9
commit
b35c4a5ee5
|
@ -24,7 +24,7 @@ pub struct Window {
|
|||
event_rx: Receiver<android_glue::Event>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub struct MonitorId;
|
||||
|
||||
mod ffi;
|
||||
|
@ -261,6 +261,10 @@ impl Window {
|
|||
unimplemented!();
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_maximized(&self, maximized: bool) {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_fullscreen_windowed(&self, fullscreen: bool) {
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ use self::ffi::{
|
|||
|
||||
static mut jmpbuf: [c_int;27] = [0;27];
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub struct MonitorId;
|
||||
|
||||
pub struct Window {
|
||||
|
@ -449,6 +449,13 @@ impl Window {
|
|||
WindowProxy
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_maximized(&self, maximized: bool) {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_fullscreen_windowed(&self, fullscreen: bool) {
|
||||
}
|
||||
}
|
||||
|
||||
impl WindowProxy {
|
||||
|
|
|
@ -2,7 +2,7 @@ use core_graphics::display;
|
|||
use std::collections::VecDeque;
|
||||
use native_monitor::NativeMonitorId;
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub struct MonitorId(u32);
|
||||
|
||||
pub fn get_available_monitors() -> VecDeque<MonitorId> {
|
||||
|
|
|
@ -383,7 +383,7 @@ impl Window {
|
|||
|
||||
fn create_window(attrs: &WindowAttributes) -> Option<IdRef> {
|
||||
unsafe {
|
||||
let screen = match attrs.monitor {
|
||||
let screen = match attrs.fullscreen.get_monitor() {
|
||||
Some(ref monitor_id) => {
|
||||
let native_id = match monitor_id.get_native_identifier() {
|
||||
NativeMonitorId::Numeric(num) => num,
|
||||
|
@ -637,6 +637,14 @@ impl Window {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_maximized(&self, maximized: bool) {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_fullscreen_windowed(&self, fullscreen: bool) {
|
||||
}
|
||||
}
|
||||
|
||||
// Convert the `cocoa::base::id` associated with a window to a usize to use as a unique identifier
|
||||
|
|
|
@ -34,6 +34,12 @@ pub struct MonitorId {
|
|||
dimensions: (u32, u32),
|
||||
}
|
||||
|
||||
impl PartialEq for MonitorId {
|
||||
fn eq(&self, other: &MonitorId) -> bool {
|
||||
self.monitor_name == other.monitor_name
|
||||
}
|
||||
}
|
||||
|
||||
struct DeviceEnumerator {
|
||||
parent_device: *const winapi::WCHAR,
|
||||
current_index: u32,
|
||||
|
|
|
@ -276,6 +276,14 @@ impl Window {
|
|||
pub fn id(&self) -> WindowId {
|
||||
WindowId(self.window.0)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_maximized(&self, maximized: bool) {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_fullscreen_windowed(&self, fullscreen: bool) {
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Window {
|
||||
|
@ -319,13 +327,14 @@ unsafe fn init(window: WindowAttributes, pl_attribs: PlatformSpecificWindowBuild
|
|||
// switching to fullscreen if necessary
|
||||
// this means adjusting the window's position so that it overlaps the right monitor,
|
||||
// and change the monitor's resolution if necessary
|
||||
if window.monitor.is_some() {
|
||||
let monitor = window.monitor.as_ref().unwrap();
|
||||
if let Some(ref monitor) = window.fullscreen.get_monitor() {
|
||||
try!(switch_to_fullscreen(&mut rect, monitor));
|
||||
}
|
||||
|
||||
let fullscreen = window.fullscreen.get_monitor().is_some();
|
||||
|
||||
// computing the style and extended style of the window
|
||||
let (ex_style, style) = if window.monitor.is_some() || !window.decorations {
|
||||
let (ex_style, style) = if fullscreen || !window.decorations {
|
||||
(winapi::WS_EX_APPWINDOW,
|
||||
//winapi::WS_POPUP is incompatible with winapi::WS_CHILD
|
||||
if pl_attribs.parent.is_some() {
|
||||
|
@ -345,13 +354,13 @@ unsafe fn init(window: WindowAttributes, pl_attribs: PlatformSpecificWindowBuild
|
|||
|
||||
// creating the real window this time, by using the functions in `extra_functions`
|
||||
let real_window = {
|
||||
let (width, height) = if window.monitor.is_some() || window.dimensions.is_some() {
|
||||
let (width, height) = if fullscreen || window.dimensions.is_some() {
|
||||
(Some(rect.right - rect.left), Some(rect.bottom - rect.top))
|
||||
} else {
|
||||
(None, None)
|
||||
};
|
||||
|
||||
let (x, y) = if window.monitor.is_some() {
|
||||
let (x, y) = if fullscreen {
|
||||
(Some(rect.left), Some(rect.top))
|
||||
} else {
|
||||
(None, None)
|
||||
|
@ -425,7 +434,7 @@ unsafe fn init(window: WindowAttributes, pl_attribs: PlatformSpecificWindowBuild
|
|||
}
|
||||
|
||||
// calling SetForegroundWindow if fullscreen
|
||||
if window.monitor.is_some() {
|
||||
if fullscreen {
|
||||
user32::SetForegroundWindow(real_window.0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue