diff mbox series

[1/8] sdl2: Fix broken display updating after the window is hidden

Message ID 20171112193032.9724-2-makovick@gmail.com
State New
Headers show
Series [1/8] sdl2: Fix broken display updating after the window is hidden | expand

Commit Message

Jindřich Makovička Nov. 12, 2017, 7:30 p.m. UTC
With SDL 2.0.6, calling SDL_ShowWindow during SDL_WINDOWEVENT_HIDDEN
blocks all subsequent display updates.

Instead of trying to override the change, just update the scon->hidden
flag.

Signed-off-by: Jindrich Makovicka <makovick@gmail.com>
---
 ui/sdl2.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

Gerd Hoffmann Nov. 13, 2017, 12:39 p.m. UTC | #1
On Sun, Nov 12, 2017 at 08:30:25PM +0100, Jindrich Makovicka wrote:
> With SDL 2.0.6, calling SDL_ShowWindow during SDL_WINDOWEVENT_HIDDEN
> blocks all subsequent display updates.
> 
> Instead of trying to override the change, just update the scon->hidden
> flag.

Has for me the side effect that sometimes I have to press ctrl-alt-2
twice.  Showing window first time works.  Hiding the window works too.
Showing it the second time needs the double keypress.

Added fprintfs to figure why [1].  Reason for that seems to be a suspious
SDL_WINDOWEVENT_SHOWN event from SDL, so qemu thinks the window is
visible even though it actually is hidden.

Have a slightly older SDL version (2.0.3).  Do you see that effect with
2.0.6 too?

cheers,
  Gerd

https://www.kraxel.org/cgit/qemu/commit/?h=testing/sdl&id=8235bfb66e7c82870ff1b1f47bdaaf4f522c5444
Gerd Hoffmann Nov. 13, 2017, 12:59 p.m. UTC | #2
On Mon, Nov 13, 2017 at 01:39:14PM +0100, Gerd Hoffmann wrote:
> On Sun, Nov 12, 2017 at 08:30:25PM +0100, Jindrich Makovicka wrote:
> > With SDL 2.0.6, calling SDL_ShowWindow during SDL_WINDOWEVENT_HIDDEN
> > blocks all subsequent display updates.
> > 
> > Instead of trying to override the change, just update the scon->hidden
> > flag.
> 
> Has for me the side effect that sometimes I have to press ctrl-alt-2
> twice.  Showing window first time works.  Hiding the window works too.
> Showing it the second time needs the double keypress.
> 
> Added fprintfs to figure why [1].  Reason for that seems to be a suspious
> SDL_WINDOWEVENT_SHOWN event from SDL, so qemu thinks the window is
> visible even though it actually is hidden.
> 
> Have a slightly older SDL version (2.0.3).  Do you see that effect with
> 2.0.6 too?

Oh, and I've just seen the current code has been added as attempt to
workaround that bug, see commit d3f3a0f453ea590be529079ae214c200bb5ecc1a.

Hmm.  Seems we are trading one issue for another here, due to bugs in
SDL :(

cheers,
  Gerd
Jindřich Makovička Nov. 13, 2017, 1:17 p.m. UTC | #3
On Mon, Nov 13, 2017 at 1:59 PM, Gerd Hoffmann <kraxel@redhat.com> wrote:
> On Mon, Nov 13, 2017 at 01:39:14PM +0100, Gerd Hoffmann wrote:
>> On Sun, Nov 12, 2017 at 08:30:25PM +0100, Jindrich Makovicka wrote:
>> > With SDL 2.0.6, calling SDL_ShowWindow during SDL_WINDOWEVENT_HIDDEN
>> > blocks all subsequent display updates.
>> >
>> > Instead of trying to override the change, just update the scon->hidden
>> > flag.
>>
>> Has for me the side effect that sometimes I have to press ctrl-alt-2
>> twice.  Showing window first time works.  Hiding the window works too.
>> Showing it the second time needs the double keypress.
>>
>> Added fprintfs to figure why [1].  Reason for that seems to be a suspious
>> SDL_WINDOWEVENT_SHOWN event from SDL, so qemu thinks the window is
>> visible even though it actually is hidden.
>>
>> Have a slightly older SDL version (2.0.3).  Do you see that effect with
>> 2.0.6 too?
>
> Oh, and I've just seen the current code has been added as attempt to
> workaround that bug, see commit d3f3a0f453ea590be529079ae214c200bb5ecc1a.
>
> Hmm.  Seems we are trading one issue for another here, due to bugs in
> SDL :(

Does this happen for you with the whole series applied, or just the
1st patch? Especially

[PATCH 8/8] sdl2: Ignore UI hotkeys after a focus change when GUI
modifier is held

can have an impact on the behavior you described.

Regards,
Gerd Hoffmann Nov. 13, 2017, 1:38 p.m. UTC | #4
Hi,

> >> Have a slightly older SDL version (2.0.3).  Do you see that effect with
> >> 2.0.6 too?
> >
> > Oh, and I've just seen the current code has been added as attempt to
> > workaround that bug, see commit d3f3a0f453ea590be529079ae214c200bb5ecc1a.
> >
> > Hmm.  Seems we are trading one issue for another here, due to bugs in
> > SDL :(
> 
> Does this happen for you with the whole series applied, or just the
> 1st patch? Especially

Same behavior here with only first patch and whole series applied.

cheers,
  Gerd
Max Reitz Nov. 13, 2017, 4:35 p.m. UTC | #5
On 2017-11-13 13:39, Gerd Hoffmann wrote:
> On Sun, Nov 12, 2017 at 08:30:25PM +0100, Jindrich Makovicka wrote:
>> With SDL 2.0.6, calling SDL_ShowWindow during SDL_WINDOWEVENT_HIDDEN
>> blocks all subsequent display updates.
>>
>> Instead of trying to override the change, just update the scon->hidden
>> flag.
> 
> Has for me the side effect that sometimes I have to press ctrl-alt-2
> twice.  Showing window first time works.  Hiding the window works too.
> Showing it the second time needs the double keypress.
> 
> Added fprintfs to figure why [1].  Reason for that seems to be a suspious
> SDL_WINDOWEVENT_SHOWN event from SDL, so qemu thinks the window is
> visible even though it actually is hidden.
> 
> Have a slightly older SDL version (2.0.3).  Do you see that effect with
> 2.0.6 too?
> 
> cheers,
>   Gerd
> 
> https://www.kraxel.org/cgit/qemu/commit/?h=testing/sdl&id=8235bfb66e7c82870ff1b1f47bdaaf4f522c5444

The only thing I can say is that I submitted
https://bugzilla.libsdl.org/show_bug.cgi?id=2818 as a result.  Nobody
has replied to that in three years, but when testing it on SDL 2.0.7,
the issue appears to be fixed.

Max
Gerd Hoffmann Nov. 14, 2017, 9:53 a.m. UTC | #6
> > Have a slightly older SDL version (2.0.3).  Do you see that effect with
> > 2.0.6 too?
> 
> The only thing I can say is that I submitted
> https://bugzilla.libsdl.org/show_bug.cgi?id=2818 as a result.  Nobody
> has replied to that in three years, but when testing it on SDL 2.0.7,
> the issue appears to be fixed.

Ok, good.  I think I'm fine with merging the patch as-is then.

cheers,
  Gerd
Max Reitz Nov. 14, 2017, 2:48 p.m. UTC | #7
On 2017-11-13 17:35, Max Reitz wrote:
> On 2017-11-13 13:39, Gerd Hoffmann wrote:
>> On Sun, Nov 12, 2017 at 08:30:25PM +0100, Jindrich Makovicka wrote:
>>> With SDL 2.0.6, calling SDL_ShowWindow during SDL_WINDOWEVENT_HIDDEN
>>> blocks all subsequent display updates.
>>>
>>> Instead of trying to override the change, just update the scon->hidden
>>> flag.
>>
>> Has for me the side effect that sometimes I have to press ctrl-alt-2
>> twice.  Showing window first time works.  Hiding the window works too.
>> Showing it the second time needs the double keypress.
>>
>> Added fprintfs to figure why [1].  Reason for that seems to be a suspious
>> SDL_WINDOWEVENT_SHOWN event from SDL, so qemu thinks the window is
>> visible even though it actually is hidden.
>>
>> Have a slightly older SDL version (2.0.3).  Do you see that effect with
>> 2.0.6 too?
>>
>> cheers,
>>   Gerd
>>
>> https://www.kraxel.org/cgit/qemu/commit/?h=testing/sdl&id=8235bfb66e7c82870ff1b1f47bdaaf4f522c5444
> 
> The only thing I can say is that I submitted
> https://bugzilla.libsdl.org/show_bug.cgi?id=2818 as a result.  Nobody
> has replied to that in three years, but when testing it on SDL 2.0.7,
> the issue appears to be fixed.

Having done a bisect, SDL2 revision 11151:7cfe088fafba seems to have
fixed the issue (for 2.0.6).  See also:

https://bugzilla.libsdl.org/show_bug.cgi?id=3410

Max
Gerd Hoffmann Nov. 14, 2017, 3:12 p.m. UTC | #8
> > The only thing I can say is that I submitted
> > https://bugzilla.libsdl.org/show_bug.cgi?id=2818 as a result.  Nobody
> > has replied to that in three years, but when testing it on SDL 2.0.7,
> > the issue appears to be fixed.
> 
> Having done a bisect, SDL2 revision 11151:7cfe088fafba seems to have
> fixed the issue (for 2.0.6).  See also:
> 
> https://bugzilla.libsdl.org/show_bug.cgi?id=3410

Thanks for the effort.  Adding a note to the commit message.

cheers,
  Gerd
diff mbox series

Patch

diff --git a/ui/sdl2.c b/ui/sdl2.c
index 53dd447fd2..774904cbf2 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -572,14 +572,10 @@  static void handle_windowevent(SDL_Event *ev)
         }
         break;
     case SDL_WINDOWEVENT_SHOWN:
-        if (scon->hidden) {
-            SDL_HideWindow(scon->real_window);
-        }
+        scon->hidden = false;
         break;
     case SDL_WINDOWEVENT_HIDDEN:
-        if (!scon->hidden) {
-            SDL_ShowWindow(scon->real_window);
-        }
+        scon->hidden = true;
         break;
     }
 }