Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement set_maximized, get_current_monitor, set_fullscreen and set_decorations for MacOS #465
Conversation
and others
added some commits
Apr 14, 2018
This comment has been minimized.
This comment has been minimized.
|
I installed High Sierra in preparation for this! I'll review it as soon as I get a chance. |
edwin0cheng
referenced this pull request
Apr 15, 2018
Closed
Expected behavior of fullscreen and maximized in MacOS #460
This comment has been minimized.
This comment has been minimized.
|
This implementation is quite straight forward, which is just calling However,
|
This comment has been minimized.
This comment has been minimized.
servo/core-foundation-rs#204 will give us some more options (literally), though nothing that it looks like we presently need. |
francesca64
requested changes
Apr 16, 2018
| win_attribs: RefCell<WindowAttributes>, | ||
| standard_frame: Cell<Option<NSRect>>, | ||
|
|
||
| handle_with_fullscreen: bool, |
This comment has been minimized.
This comment has been minimized.
francesca64
Apr 16, 2018
Collaborator
It would be good to have a comment explaining what handle_with_fullscreen represents.
| // We set a normal style to it temporary. | ||
| // It will clean up at window_did_exit_fullscreen. | ||
| if current.is_none() && !win_attribs.decorations { | ||
| state.window.setStyleMask_(NSWindowStyleMask::NSTitledWindowMask|NSWindowStyleMask::NSResizableWindowMask); |
This comment has been minimized.
This comment has been minimized.
| /// due to being in the midst of handling some other animation or user gesture. | ||
| /// This method indicates that there was an error, and you should clean up any | ||
| /// work you may have done to prepare to enter full-screen mode. | ||
| extern "C" fn window_did_fail_to_enter_fullscreen(this: &Object, _: Sel, _: id) { |
This comment has been minimized.
This comment has been minimized.
francesca64
Apr 16, 2018
Collaborator
When handle_with_fullscreen is false, this should restore the window state to what it was prior to attempting to enter fullscreen.
(Also, none of the other callbacks explicitly specified "C". It doesn't make a difference, since C is the default, but consistency is nice.)
|
|
||
| use super::events_loop::Shared; | ||
| use super::events_loop::{EventsLoop,Shared}; |
This comment has been minimized.
This comment has been minimized.
francesca64
Apr 16, 2018
Collaborator
There should be a space after the comma (also applies to your cell import).
| @@ -33,6 +35,77 @@ struct DelegateState { | |||
| view: IdRef, | |||
| window: IdRef, | |||
| shared: Weak<Shared>, | |||
|
|
|||
| win_attribs: RefCell<WindowAttributes>, | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
edwin0cheng
Apr 17, 2018
Author
Contributor
It should be not used in an async callback, or do i miss something??
This comment has been minimized.
This comment has been minimized.
| return; | ||
| } | ||
| (Some(_), Some(_)) => { | ||
| return; |
This comment has been minimized.
This comment has been minimized.
francesca64
Apr 16, 2018
Collaborator
When the two monitors aren't the same, this should be unimplemented!().
| let win_attribs = state.win_attribs.borrow_mut(); | ||
|
|
||
| let current = win_attribs.fullscreen.clone(); | ||
| match (current.clone(), monitor.clone()) { |
This comment has been minimized.
This comment has been minimized.
| use cocoa::appkit::{self, NSApplication, NSColor, NSView, NSWindow, NSWindowStyleMask, NSWindowButton}; | ||
| use cocoa::foundation::{NSDictionary, NSPoint, NSRect, NSSize, NSString}; | ||
| use cocoa::appkit::{self, NSApplication, NSColor, NSScreen, NSView, NSWindow, NSWindowButton, | ||
| NSWindowStyleMask}; |
This comment has been minimized.
This comment has been minimized.
mitchmindtree
referenced this pull request
Apr 17, 2018
Closed
Fix bug where macOS crashes on fullscreen shortcut `CMD + F` #104
This comment has been minimized.
This comment has been minimized.
We can use msg_send! macro to send the selector to use it, i will give it a try. And we could expose the fullscreen options in WindowExt and WindowBuilderExt, but i think i would recommend to create another PR to address it.
I want to use this but it is absent in current CoreFoundation binding which is c api which i cannot use
Indeed, we would make another PR to address this too.
We do have some comment about this issue in WindowExt, but i don't know it is enough to indicate that. |
This comment has been minimized.
This comment has been minimized.
|
Ok, seem to be we cannot use |
This comment has been minimized.
This comment has been minimized.
These bugs should be fixed. |
This comment has been minimized.
This comment has been minimized.
|
@francesca64 That's it, except for the points i mentioned in previous comments, we need to wait upstream cocoa crate to add corresponding binding. And i think we could add another PRs for these improvement. |
francesca64
reviewed
Apr 17, 2018
| } | ||
|
|
||
| // Make key have to be after set fullscreen | ||
| // to prevent normal zie window brefly appears |
This comment has been minimized.
This comment has been minimized.
francesca64
reviewed
Apr 17, 2018
This comment has been minimized.
This comment has been minimized.
|
Thanks, and addressing the rest in a later PR seems reasonable. Two more nitpicks and we should be good to merge. |
This comment has been minimized.
This comment has been minimized.
|
Fixed, and thank you so much. |
francesca64
approved these changes
Apr 17, 2018
francesca64
merged commit 0474dc9
into
rust-windowing:master
Apr 17, 2018
5 checks passed
edwin0cheng
deleted the
edwin0cheng:macos-fullscreen
branch
Apr 17, 2018
This was referenced Apr 17, 2018
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
No, i just tested it and it only take 1 try. Could you mind to detail step to reproduce it? |
This comment has been minimized.
This comment has been minimized.
|
Okay, I've tried a bit more, and I think I know what's happening. I run the fullscreen example, press F twice, then quit, and I get this event log:
As you can see, the first F press never generates a
|
This comment has been minimized.
This comment has been minimized.
|
Interesting, that does seem like the likely culprit. I guess since full screen doesn't invoke the modal tracking loop, so it doesn't eat the MouseDown event? |
This comment has been minimized.
This comment has been minimized.
|
I'm actually seeing other weird downstream effects related to the hidpifactorchanged event that goes away once i revert that commit. we may want to revert and rethink that? |
edwin0cheng
restored the
edwin0cheng:macos-fullscreen
branch
Apr 17, 2018
This comment has been minimized.
This comment has been minimized.
|
I checked my code, and didn't think of some special problem. However, maybe i dont know how the discard event work. How do you make sure if window_did_resize called, and the next event must be the event you want discard? |
This comment has been minimized.
This comment has been minimized.
|
@edwin0cheng I don't believe this is your fault, but rather an unforeseen interaction between this and the other PR. We didn't notice it before because your branch is based prior to that PR being merged (which is also why I ended up thinking it was a problem in one of your later commits, since switching back to your branch to test that meant the issue was no longer present). The moral of the story is that we should always rebase before testing. But anyway, I don't think you need to take any further action. @sodiumjoe oh geeze, but I guess it's not surprising; #466 is admittedly a hack. The other moral of the story is that we should have some sort of test suite. I guess it should be reverted, and them maybe we should glob fixing it into a larger "what are we going to do about the fundamental conflicts between Cocoa and winit's design" issue? Assuming I'm correct in interpreting that the disparity is the reason we have to deal with this. |
This comment has been minimized.
This comment has been minimized.
|
I'd be interested to hear @swiftcoder 's opinion. It seems like we could keep the hack contained by checking the event type here and only discarding MouseUp events? |
This comment has been minimized.
This comment has been minimized.
|
Alright, I agree that we should wait for @swiftcoder. Just please make some note in #468 in case tomaka swoops in and merges it. |
This comment has been minimized.
This comment has been minimized.
|
I just closed it, I'll reopen once we figure this out. I can also try the filtering thing I mentioned real quick. |
This comment has been minimized.
This comment has been minimized.
|
i just tried a really naive filtering:
and that doesn't appear to fix anything, so I'll wait for @swiftcoder |
francesca64
referenced this pull request
Apr 17, 2018
Closed
[META] Feature parity between platforms #252
This comment has been minimized.
This comment has been minimized.
|
Your filtering would work, but you need to restrict to pressed events, not release. That said, we are now layering a hack on top of a hack. I hadn't anticipated that |
francesca64
added a commit
that referenced
this pull request
Apr 18, 2018
This comment has been minimized.
This comment has been minimized.
|
Derp, you're right. Changing that to It also appears to be causing some weird issues with the relatively new WindowBuilder I think it makes the most sense to back that change out for now. |
edwin0cheng commentedApr 14, 2018
•
edited
This PR implemented following functions in MacOS:
Window::get_current_monitorWindow::set_fullscreenWindow::set_maximizedWindow::set_decorationsWindowBuilder::with_maximizedAnd the maximized and fullscreen behaviors are following safari's conventions. (See #460).
This PR should f-ixed #300, #72, #66, #129, and Part of #252