Merge lp:~widelands-dev/widelands/fsmenu_fullscreen_0_flicker into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 8159
Proposed branch: lp:~widelands-dev/widelands/fsmenu_fullscreen_0_flicker
Merge into: lp:widelands
Diff against target: 46 lines (+13/-5)
2 files modified
src/wlapplication.cc (+10/-5)
src/wlapplication.h (+3/-0)
To merge this branch: bzr merge lp:~widelands-dev/widelands/fsmenu_fullscreen_0_flicker
Reviewer Review Type Date Requested Status
Tino Approve
Review via email: mp+309277@code.launchpad.net

Commit message

Stop fullscreen toggle from flickering.

Description of the change

The problem is that the SDL keypress event gets triggered multiple times for some reason, switching fullscreen mode on and off.

To post a comment you must log in.
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 1460. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/170500691.
Appveyor build 1303. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_fsmenu_fullscreen_0_flicker-1303.

Revision history for this message
Tino (tino79) wrote :

Compiles and works on win.

review: Approve
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 1538. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/171788191.
Appveyor build 1380. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_fsmenu_fullscreen_0_flicker-1380.

Revision history for this message
GunChleoc (gunchleoc) wrote :

@bunnybot merge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/wlapplication.cc'
2--- src/wlapplication.cc 2016-10-16 09:31:42 +0000
3+++ src/wlapplication.cc 2016-10-30 15:37:21 +0000
4@@ -289,7 +289,8 @@
5 #else
6 homedir_(FileSystem::get_homedir() + "/.widelands"),
7 #endif
8- redirected_stdio_(false) {
9+ redirected_stdio_(false),
10+ last_resolution_change_(0) {
11 g_fs = new LayeredFileSystem();
12
13 parse_commandline(argc, argv); // throws ParameterError, handled by main.cc
14@@ -519,10 +520,14 @@
15 return true;
16
17 case SDLK_f: {
18- // toggle fullscreen
19- bool value = !g_gr->fullscreen();
20- g_gr->set_fullscreen(value);
21- g_options.pull_section("global").set_bool("fullscreen", value);
22+ // Toggle fullscreen
23+ const uint32_t time = SDL_GetTicks();
24+ if (time - last_resolution_change_ > 250) {
25+ last_resolution_change_ = time;
26+ bool value = !g_gr->fullscreen();
27+ g_gr->set_fullscreen(value);
28+ g_options.pull_section("global").set_bool("fullscreen", value);
29+ }
30 return true;
31 }
32
33
34=== modified file 'src/wlapplication.h'
35--- src/wlapplication.h 2016-10-16 09:31:42 +0000
36+++ src/wlapplication.h 2016-10-30 15:37:21 +0000
37@@ -261,6 +261,9 @@
38 std::string datadir_;
39 std::string datadir_for_testing_;
40
41+ /// Prevent toggling fullscreen on and off from flickering
42+ uint32_t last_resolution_change_;
43+
44 /// Holds this process' one and only instance of WLApplication, if it was
45 /// created already. nullptr otherwise.
46 /// \note This is private on purpose. Read the class documentation.

Subscribers

People subscribed via source and target branches

to status/vote changes: