Skip to content

Commit

Permalink
Merge pull request iced-rs#1742 from bungoboingo/fix/fullscreen
Browse files Browse the repository at this point in the history
[Fix] Fullscreen only works on primary monitor
  • Loading branch information
hecrj authored Mar 3, 2023
2 parents 86b85d1 + 12781c7 commit d73ca4d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
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

0 comments on commit d73ca4d

Please sign in to comment.