-
Notifications
You must be signed in to change notification settings - Fork 904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move fullscreen modes to not touch physical resolutions #270
Conversation
bbb92fd
to
c4bf208
Compare
Has this been tested on a multi-monitor system? In particular, we should be working in terms of XRandR "outputs," not X11 screens. |
Haven't tested on multiscreen yet but I have a few external screens I can test this with. I assumed MonitorId was all we needed given all the functions take that as input but maybe it's not so simple. |
This now has the basics needed for proper multiscreen and the resolution changes seem to work. I still need to place the window in the correct place and figure out why in some cases it will segfault. |
54ea27a
to
a0d929f
Compare
@tomaka after discussions on IRC with @Ralith and looking at Wayland it seems much cleaner to just never change the physical hardware resolution. With LCD panels there's no actual resolution change and GPU scaling is cheap enough that apps should just scale to whatever the physical resolution is and not do any mode switching. So the proposed semantics are:
The X11 code for this ends up very clean and should even make it easy to support weird setups like videowalls and MST monitors. |
Implemented XRandR 1.5 now so even MST/videowalls should work fine. |
src/lib.rs
Outdated
None, | ||
Windowed, | ||
Exclusive(MonitorId), | ||
/// Set fullscreen in whatever monitor the window happens to be right now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's a bad design. The user should just have a way to retrieve the monitor of the window instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case we can just get rid of the enum and do .set_/.with_fullscreen(Option<MonitorId>)
and do a Window::get_monitor()
. How does that sound?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it's good.
I've implemented the interface as discussed but I'm not too sure of it. |
6b7bd9a
to
fbbd347
Compare
The basics should be done and the remaining issues are:
|
ac29dd8
to
c824e14
Compare
@tomaka From my point of view this is ready to merge. Let me know if you want something else. |
src/platform/linux/x11/xdisplay.rs
Outdated
xinput2: xinput2, | ||
xlib_xcb: xlib_xcb, | ||
display: display, | ||
xlib, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep compatibility with older Rust versions if we can. Please don't use that new syntax.
} | ||
|
||
#[inline] | ||
pub fn set_fullscreen(&self, state: FullScreenState) { | ||
pub fn set_fullscreen(&self, _monitor: Option<RootMonitorId>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should contain unimplemented!()
.
@@ -280,11 +279,16 @@ impl Window { | |||
} | |||
|
|||
#[inline] | |||
pub fn set_maximized(&self, maximized: bool) { | |||
pub fn set_maximized(&self, _maximized: bool) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should contain unimplemented!()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't set these as unimplemented because they're safe as no-ops. No need to panic the app just because we can't set it as maximized/fullscreen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using no-ops means that these functions will likely be left unimplemented for years.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, done now
src/platform/macos/window.rs
Outdated
} | ||
|
||
#[inline] | ||
pub fn set_fullscreen(&self, state: FullScreenState) { | ||
pub fn set_fullscreen(&self, _monitor: Option<RootMonitorId>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should contain unimplemented!()
.
@@ -636,11 +636,16 @@ impl Window { | |||
} | |||
|
|||
#[inline] | |||
pub fn set_maximized(&self, maximized: bool) { | |||
pub fn set_maximized(&self, _maximized: bool) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should contain unimplemented!()
.
|
||
use super::XConnection; | ||
|
||
#[derive(Clone)] | ||
pub struct MonitorId(pub Arc<XConnection>, pub u32); | ||
pub struct MonitorId { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong indentation
src/platform/android/mod.rs
Outdated
|
||
#[inline] | ||
pub fn get_current_monitor(&self) -> RootMonitorId { | ||
unimplemented!() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Android provides only one dummy monitor. This function should return RootMonitorId(MonitorId)
.
src/platform/ios/mod.rs
Outdated
|
||
#[inline] | ||
pub fn get_current_monitor(&self) -> RootMonitorId { | ||
unimplemented!() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iOS provides only one dummy monitor. This function should return RootMonitorId(MonitorId)
.
src/platform/ios/mod.rs
Outdated
|
||
#[inline] | ||
pub fn get_position(&self) -> (u32, u32) { | ||
unimplemented!() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(0, 0)
src/platform/android/mod.rs
Outdated
|
||
#[inline] | ||
pub fn get_position(&self) -> (u32, u32) { | ||
unimplemented!() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(0, 0)
20be37c
to
3b422c1
Compare
3b422c1
to
4198011
Compare
The previous XF86 resolution switching was broken and everything seems to have moved on to xrandr. Use that instead while cleaning up the code a bit as well.
Wayland has made the decision that apps shouldn't change screen resolutions and just take the screens as they've been setup. In the modern world where GPU scaling is cheap and LCD panels are scaling anyway it makes no sense to make "physical" resolution changes when software should be taking care of it. This massively simplifies the code and makes it easier to extend to more niche setups like MST and videowalls.
Moving to just having two states None and Some(MonitorId) and then being able to set full screen in the current monitor with something like: window.set_fullscreen(Some(window.current_monitor()));
Do it by iterating over the available monitors and finding which has the biggest overlap with the window. For this MonitorId needs a new get_position() that needs to be implemented for all platforms.
Since we're no longer using XF86 there's no need to keep the package around for CI.
On Android and iOS we can assume single screen apps that are already fullscreen and maximized so there are a few methods that are implemented by just returning a fixed value or not doing anything.
These would be safe as no-ops but we should make it explicit so there is more of an incentive to actually implement them.
4198011
to
47a65db
Compare
Thanks for all the trouble |
No trouble, hope it helps. Do ping me if you need help with any of this code or with anything on X11. |
The previous XF86 resolution switching was broken and everything seems to have moved on to xrandr. Use that instead while cleaning up the code a bit as well. Right now everything seems to work fine. The only bug I've noticed is that at least in Unity after the resolution change the top bar is still there. Doing an alt-tab from and to the app again makes
_NET_WM_STATE_FULLSCREEN
take effect. Don't know how to fix that right now but this is already much better than what was before.