Skip to content

Commit

Permalink
gui: alt+enter - toggle fullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
JaCzekanski committed Aug 26, 2019
1 parent 55dc032 commit 74e34b9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/platform/windows/input/sdl_input_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ bool SdlInputManager::handleEvent(SDL_Event& event) {
}
break;
}
if ((event.key.keysym.mod & KMOD_ALT) && event.key.keysym.sym == SDLK_RETURN) {
bus.notify(Event::Gui::ToggleFullscreen{});
return true;
}
}

if ((!keyboardCaptured || waitingForKeyPress) && (type == SDL_KEYDOWN || type == SDL_KEYUP)) {
Expand Down
8 changes: 8 additions & 0 deletions src/platform/windows/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,14 @@ int main(int argc, char** argv) {
bool doHardReset = false;
bus.listen<Event::System::HardReset>(busToken, [&](auto) { doHardReset = true; });

bus.listen<Event::Gui::ToggleFullscreen>(busToken, [&](auto) {
if (SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN_DESKTOP) {
SDL_SetWindowFullscreen(window, 0);
} else {
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP);
}
});

// If argument given - open that file (same as drag and drop)
if (argc > 1) {
loadFile(sys, argv[1]);
Expand Down
1 change: 1 addition & 0 deletions src/utils/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace Gui {
struct Toast {
std::string message;
};
struct ToggleFullscreen {};
} // namespace Gui
}; // namespace Event

Expand Down

0 comments on commit 74e34b9

Please sign in to comment.