Skip to content

Commit

Permalink
Implement set_maximized, get_current_monitor, set_fullscreen and set…
Browse files Browse the repository at this point in the history
…_decorations for MacOS (#465)

* Added helper function for make monitor from display.

* Implement get_current_monitor  for macos

* Implemented with_fullscreen and set_fullscreen for macos

* Implemented set_decorations for macos

* Implement set_maximized and with_maximized for macos

* Changed fullscreen example fullscreen keypress from F11 to F

* Update CHANGELOG.md

* Add and fixed some comments

* Reformat and add more comments

* Better handling window and maximized state

* Reformat and typo fix
  • Loading branch information
edwin0cheng authored and francesca64 committed Apr 17, 2018
1 parent 8fd49a4 commit 0474dc9
Show file tree
Hide file tree
Showing 4 changed files with 318 additions and 45 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Unreleased

- Implement `WindowBuilder::with_maximized`, `Window::set_fullscreen`, `Window::set_maximized` and `Window::set_decorations` for MacOS.
- Implement `WindowBuilder::with_maximized`, `Window::set_fullscreen`, `Window::set_maximized` and `Window::set_decorations` for Windows.
- On Windows, `WindowBuilder::with_dimensions` no longer changing monitor display resolution.
- Overhauled X11 window geometry calculations. `get_position` and `set_position` are more universally accurate across different window managers, and `get_outer_size` actually works now.
Expand Down
2 changes: 1 addition & 1 deletion examples/fullscreen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fn main() {
..
} => match (virtual_code, state) {
(winit::VirtualKeyCode::Escape, _) => return ControlFlow::Break,
(winit::VirtualKeyCode::F11, winit::ElementState::Pressed) => {
(winit::VirtualKeyCode::F, winit::ElementState::Pressed) => {
is_fullscreen = !is_fullscreen;
if !is_fullscreen {
window.set_fullscreen(None);
Expand Down
7 changes: 6 additions & 1 deletion src/platform/macos/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::collections::VecDeque;
use super::EventsLoop;
use super::window::IdRef;

#[derive(Clone)]
#[derive(Clone, PartialEq)]
pub struct MonitorId(CGDirectDisplayID);

impl EventsLoop {
Expand All @@ -25,6 +25,11 @@ impl EventsLoop {
let id = MonitorId(CGDisplay::main().id);
id
}

pub fn make_monitor_from_display(id: CGDirectDisplayID) -> MonitorId {
let id = MonitorId(id);
id
}
}

impl MonitorId {
Expand Down
Loading

0 comments on commit 0474dc9

Please sign in to comment.