diff --git a/examples/todos/src/main.rs b/examples/todos/src/main.rs index 6408f09c0b..6a87f58ce4 100644 --- a/examples/todos/src/main.rs +++ b/examples/todos/src/main.rs @@ -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::{ @@ -50,6 +50,7 @@ enum Message { FilterChanged(Filter), TaskMessage(usize, TaskMessage), TabPressed { shift: bool }, + ToggleFullscreen(window::Mode), } impl Application for Todos { @@ -156,6 +157,9 @@ impl Application for Todos { widget::focus_next() } } + Message::ToggleFullscreen(mode) => { + window::change_mode(mode) + } _ => Command::none(), }; @@ -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, }) } diff --git a/src/window.rs b/src/window.rs index 2018053fbb..5a199580bf 100644 --- a/src/window.rs +++ b/src/window.rs @@ -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::*; diff --git a/winit/src/application.rs b/winit/src/application.rs index 9781a453eb..b13b7214ea 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -762,7 +762,7 @@ pub fn run_command( window::Action::ChangeMode(mode) => { window.set_visible(conversion::visible(mode)); window.set_fullscreen(conversion::fullscreen( - window.primary_monitor(), + window.current_monitor(), mode, )); }