Merge lp:~peter.waller/widelands/toggle-fullscreen-rewrite into lp:widelands

Proposed by Peter Waller
Status: Rejected
Rejected by: SirVer
Proposed branch: lp:~peter.waller/widelands/toggle-fullscreen-rewrite
Merge into: lp:widelands
Diff against target: 93 lines (+33/-18)
2 files modified
src/graphic/graphic.cc (+29/-18)
src/graphic/graphic.h (+4/-0)
To merge this branch: bzr merge lp:~peter.waller/widelands/toggle-fullscreen-rewrite
Reviewer Review Type Date Requested Status
Widelands Developers Pending
Review via email: mp+103558@code.launchpad.net

Description of the change

Hi. I'm _certain_ there are things wrong with this, but it appears to work and not leak memory, so I thought I would propose merging to have a review.

I was expecting there to be problems due to some relationship between Pictures and the m_sdl_screen, but I haven't seen them.

Tested: switching hundreds of times repeatedly (removing the keydown check so that the 'f' key toggles as fast as possible), no visible memory increase.

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

Unfortunately, this no longer works. I feel this merge request somehow slipped by and noone did properly look at it. I am very sorry for this Peter!

Setting to rejected for now.

Revision history for this message
Peter Waller (peter.waller) wrote :

Hey, no worries sirver.

Regarding "the right way to do it", I think it would be good if whilst in full screen we don't break alt-tab, which is currently the case. It just means if you happy to be in the multiplayer lobby waiting for someone to connect to you (say, you're hosting), you can't do anything else with your computer.. which might be irritating if the person trying to connect has a problem connecting and is trying to communicate it to you.

If it is the case that alt-tab is still broken, I will make a bug and investigate fixing that instead at some point.

Revision history for this message
SirVer (sirver) wrote :

I am not sure if widelands does this or if this is an SDL issue.

However, the graphic system should now be able to handle Reintialize() in the fullscreen handler given there are no InMemoryImages constructed (which should be in most cases). So you can try and go for that too and make the implementation proper.

Unmerged revisions

6358. By Peter Waller

Experimental: Remove use of SDL_WM_ToggleFullScreen

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/graphic/graphic.cc'
2--- src/graphic/graphic.cc 2012-03-09 16:57:20 +0000
3+++ src/graphic/graphic.cc 2012-04-25 20:10:39 +0000
4@@ -62,9 +62,6 @@
5 uint32_t luminance_table_g[0x100];
6 uint32_t luminance_table_b[0x100];
7
8-/**
9- * Initialize the SDL video mode.
10-*/
11 Graphic::Graphic
12 (int32_t const w, int32_t const h,
13 int32_t const bpp,
14@@ -76,6 +73,30 @@
15 m_update_fullscreen(false),
16 m_roadtextures (0)
17 {
18+ Initialize(w, h, bpp, fullscreen, opengl);
19+}
20+
21+/**
22+ * Free the surface
23+*/
24+Graphic::~Graphic()
25+{
26+ delete m_rendertarget;
27+ delete m_roadtextures;
28+
29+ // Remove traces of cached pictures
30+ UI::g_fh->flush_cache();
31+}
32+
33+/**
34+ * Initialize the SDL video mode.
35+*/
36+void Graphic::Initialize
37+ (int32_t const w, int32_t const h,
38+ int32_t const bpp,
39+ bool const fullscreen,
40+ bool const opengl)
41+{
42 // Initialize the table used to create grayed pictures
43 for
44 (uint32_t i = 0, r = 0, g = 0, b = 0;
45@@ -312,18 +333,6 @@
46 }
47
48 /**
49- * Free the surface
50-*/
51-Graphic::~Graphic()
52-{
53- delete m_rendertarget;
54- delete m_roadtextures;
55-
56- // Remove traces of cached pictures
57- UI::g_fh->flush_cache();
58-}
59-
60-/**
61 * Return the screen x resolution
62 */
63 int32_t Graphic::get_xres() const
64@@ -354,9 +363,11 @@
65 */
66 void Graphic::toggle_fullscreen()
67 {
68- log("Try DL_WM_ToggleFullScreen...\n");
69- //ToDo Make this work again
70- SDL_WM_ToggleFullScreen(m_sdl_screen);
71+ log("Graphic::toggle_fullscreen trying to reinitialize graphics");
72+ bool fullscreen = !(m_sdl_screen->flags & SDL_FULLSCREEN); // Toggle current state
73+ bool opengl = m_sdl_screen->flags & SDL_OPENGL;
74+
75+ Initialize(get_xres(), get_yres(), m_sdl_screen->format->BitsPerPixel, fullscreen, opengl);
76 }
77
78 /**
79
80=== modified file 'src/graphic/graphic.h'
81--- src/graphic/graphic.h 2012-02-21 13:42:13 +0000
82+++ src/graphic/graphic.h 2012-04-25 20:10:39 +0000
83@@ -121,6 +121,10 @@
84 (int32_t w, int32_t h, int32_t bpp,
85 bool fullscreen, bool opengl);
86 ~Graphic();
87+
88+ void Initialize
89+ (int32_t w, int32_t h, int32_t bpp,
90+ bool fullscreen, bool opengl);
91
92 int32_t get_xres() const;
93 int32_t get_yres() const;

Subscribers

People subscribed via source and target branches

to status/vote changes: