Skip to content
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

[Fix] Fullscreen only works on primary monitor #1742

Merged
merged 3 commits into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion examples/todos/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use iced::alignment::{self, Alignment};
use iced::event::{self, Event};
use iced::keyboard;
use iced::keyboard::{self, KeyCode, Modifiers};
use iced::subscription;
use iced::theme::{self, Theme};
use iced::widget::{
Expand Down Expand Up @@ -50,6 +50,7 @@ enum Message {
FilterChanged(Filter),
TaskMessage(usize, TaskMessage),
TabPressed { shift: bool },
ToggleFullscreen(window::Mode),
}

impl Application for Todos {
Expand Down Expand Up @@ -156,6 +157,9 @@ impl Application for Todos {
widget::focus_next()
}
}
Message::ToggleFullscreen(mode) => {
window::change_mode(mode)
}
_ => Command::none(),
};

Expand Down Expand Up @@ -266,6 +270,21 @@ impl Application for Todos {
) => Some(Message::TabPressed {
shift: modifiers.shift(),
}),
(
Event::Keyboard(keyboard::Event::KeyPressed {
key_code,
modifiers: Modifiers::SHIFT,
}),
event::Status::Ignored,
) => match key_code {
KeyCode::Up => {
Some(Message::ToggleFullscreen(window::Mode::Fullscreen))
}
KeyCode::Down => {
Some(Message::ToggleFullscreen(window::Mode::Windowed))
}
_ => None,
},
_ => None,
})
}
Expand Down
1 change: 0 additions & 1 deletion src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ pub use icon::Icon;
pub use position::Position;
pub use settings::Settings;

#[cfg(not(target_arch = "wasm32"))]
pub use crate::runtime::window::*;
2 changes: 1 addition & 1 deletion winit/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ pub fn run_command<A, E>(
window::Action::ChangeMode(mode) => {
window.set_visible(conversion::visible(mode));
window.set_fullscreen(conversion::fullscreen(
window.primary_monitor(),
window.current_monitor(),
mode,
));
}
Expand Down