widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #04064
[Merge] lp:~widelands-dev/widelands/bug-1459529 into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1459529 into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1459529 in widelands: "Fullscreen toggle with the f button doesn't work properly"
https://bugs.launchpad.net/widelands/+bug/1459529
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1459529/+merge/260632
WLApplication::handle_key can now distinguish between key_down and key_up events. This fixed problems with hotkeys for fullscreen mode and screenshots etc.
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1459529 into lp:widelands.
=== modified file 'src/wlapplication.cc'
--- src/wlapplication.cc 2015-05-11 20:43:27 +0000
+++ src/wlapplication.cc 2015-05-29 21:26:17 +0000
@@ -501,46 +501,48 @@
return true;
}
-bool WLApplication::handle_key(const SDL_Keycode& keycode, int modifiers) {
- const bool ctrl = (modifiers & KMOD_LCTRL) || (modifiers & KMOD_RCTRL);
- switch (keycode) {
- case SDLK_F10:
- // exits the game.
- if (ctrl) {
- m_should_die = true;
- }
- return true;
-
- case SDLK_F11:
- // Takes a screenshot.
- if (ctrl) {
- if (g_fs->disk_space() < MINIMUM_DISK_SPACE) {
- log("Omitting screenshot because diskspace is lower than %luMB\n",
- MINIMUM_DISK_SPACE / (1000 * 1000));
- break;
- }
- g_fs->ensure_directory_exists(SCREENSHOT_DIR);
- for (uint32_t nr = 0; nr < 10000; ++nr) {
- const std::string filename = (boost::format(SCREENSHOT_DIR "/shot%04u.png") % nr).str();
- if (g_fs->file_exists(filename)) {
- continue;
- }
- g_gr->screenshot(filename);
- break;
- }
- }
- return true;
-
- case SDLK_f: {
- // toggle fullscreen
- bool value = !g_gr->fullscreen();
- g_gr->set_fullscreen(value);
- g_options.pull_section("global").set_bool("fullscreen", value);
- return true;
- }
-
- default:
- break;
+bool WLApplication::handle_key(bool down, const SDL_Keycode& keycode, int modifiers) {
+ if (down) {
+ const bool ctrl = (modifiers & KMOD_LCTRL) || (modifiers & KMOD_RCTRL);
+ switch (keycode) {
+ case SDLK_F10:
+ // exits the game.
+ if (ctrl) {
+ m_should_die = true;
+ }
+ return true;
+
+ case SDLK_F11:
+ // Takes a screenshot.
+ if (ctrl) {
+ if (g_fs->disk_space() < MINIMUM_DISK_SPACE) {
+ log("Omitting screenshot because diskspace is lower than %luMB\n",
+ MINIMUM_DISK_SPACE / (1000 * 1000));
+ break;
+ }
+ g_fs->ensure_directory_exists(SCREENSHOT_DIR);
+ for (uint32_t nr = 0; nr < 10000; ++nr) {
+ const std::string filename = (boost::format(SCREENSHOT_DIR "/shot%04u.png") % nr).str();
+ if (g_fs->file_exists(filename)) {
+ continue;
+ }
+ g_gr->screenshot(filename);
+ break;
+ }
+ }
+ return true;
+
+ case SDLK_f: {
+ // toggle fullscreen
+ bool value = !g_gr->fullscreen();
+ g_gr->set_fullscreen(value);
+ g_options.pull_section("global").set_bool("fullscreen", value);
+ return true;
+ }
+
+ default:
+ break;
+ }
}
return false;
}
@@ -557,7 +559,7 @@
handled = cb->key(ev.type == SDL_KEYDOWN, ev.key.keysym);
}
if (!handled) {
- handle_key(ev.key.keysym.sym, ev.key.keysym.mod);
+ handle_key(ev.type == SDL_KEYDOWN, ev.key.keysym.sym, ev.key.keysym.mod);
}
} break;
=== modified file 'src/wlapplication.h'
--- src/wlapplication.h 2014-12-06 12:22:35 +0000
+++ src/wlapplication.h 2015-05-29 21:26:17 +0000
@@ -207,7 +207,7 @@
// Handle the given pressed key. Returns true when key was
// handled.
- bool handle_key(const SDL_Keycode& keycode, int modifiers);
+ bool handle_key(bool down, const SDL_Keycode& keycode, int modifiers);
/**
* The commandline, conveniently repackaged.
Follow ups