qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/2] sdl2: Work around SDL2 SDL_ShowWindow() bug
@ 2014-12-12  9:52 Max Reitz
  2014-12-12  9:52 ` [Qemu-devel] [PATCH 1/2] sdl2: Use correct sdl2_console for window events Max Reitz
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Max Reitz @ 2014-12-12  9:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Anthony Liguori, Max Reitz

For the bug (it at least seems to me like one), see:
https://bugzilla.libsdl.org/show_bug.cgi?id=2818

To reproduce it in qemu, try pressing ctrl-alt-2 five times (or
whichever your key combination for showing/hiding the monitor window
is).

Normally, the window should be shown, hidden, shown, hidden and shown
again. However, it will instead be shown, hidden, stay hidden, stay
hidden and then be shown. This series fixes this.

This series depends on Gerd's series
"sdl2: fixes, cleanups and opengl preparation."


Max Reitz (2):
  sdl2: Use correct sdl2_console for window events
  sdl2: Work around SDL2 SDL_ShowWindow() bug

 ui/sdl2.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

-- 
1.9.3

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH 1/2] sdl2: Use correct sdl2_console for window events
  2014-12-12  9:52 [Qemu-devel] [PATCH 0/2] sdl2: Work around SDL2 SDL_ShowWindow() bug Max Reitz
@ 2014-12-12  9:52 ` Max Reitz
  2014-12-12  9:52 ` [Qemu-devel] [PATCH 2/2] sdl2: Work around SDL2 SDL_ShowWindow() bug Max Reitz
  2014-12-12 11:17 ` [Qemu-devel] [PATCH 0/2] " Gerd Hoffmann
  2 siblings, 0 replies; 4+ messages in thread
From: Max Reitz @ 2014-12-12  9:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Anthony Liguori, Max Reitz

SDL_PollEvent() polls events for all windows; therefore,
sdl2_poll_events() will poll the events for all windows and not only for
the one identified by the given sdl2_console.

This should be considered in handle_windowevent(): The window affected
by the event is not necessarily the one identified by the sdl2_console
object given to sdl2_poll_events(), but the one identified by
ev->window.windowID.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 ui/sdl2.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/ui/sdl2.c b/ui/sdl2.c
index a1def81..fdc762f 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -507,8 +507,10 @@ static void handle_mousewheel(SDL_Event *ev)
     qemu_input_event_sync();
 }
 
-static void handle_windowevent(struct sdl2_console *scon, SDL_Event *ev)
+static void handle_windowevent(SDL_Event *ev)
 {
+    struct sdl2_console *scon = get_scon_from_window(ev->window.windowID);
+
     switch (ev->window.event) {
     case SDL_WINDOWEVENT_RESIZED:
         {
@@ -586,7 +588,7 @@ void sdl2_poll_events(struct sdl2_console *scon)
             handle_mousewheel(ev);
             break;
         case SDL_WINDOWEVENT:
-            handle_windowevent(scon, ev);
+            handle_windowevent(ev);
             break;
         default:
             break;
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH 2/2] sdl2: Work around SDL2 SDL_ShowWindow() bug
  2014-12-12  9:52 [Qemu-devel] [PATCH 0/2] sdl2: Work around SDL2 SDL_ShowWindow() bug Max Reitz
  2014-12-12  9:52 ` [Qemu-devel] [PATCH 1/2] sdl2: Use correct sdl2_console for window events Max Reitz
@ 2014-12-12  9:52 ` Max Reitz
  2014-12-12 11:17 ` [Qemu-devel] [PATCH 0/2] " Gerd Hoffmann
  2 siblings, 0 replies; 4+ messages in thread
From: Max Reitz @ 2014-12-12  9:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Anthony Liguori, Max Reitz

Apparently it is possible for X to send an event to a hidden SDL2
window, leading to SDL2 believing it is now shown. SDL2 will pass the
SDL_WINDOWEVENT_SHOWN message to the application without actually
showing the window; the problem is that the next SDL_ShowWindow() will
be a no-op because SDL2 assumes the window is already shown.

The correct way to react to SDL_WINDOWEVENT_SHOWN would be to clear
scon->hidden (analogous for SDL_WINDOWEVENT_HIDDEN). However, due to the
window not actually being shown, this will somehow not be correct after
all.

Therefore, just hide the window on SDL_WINDOWEVENT_SHOWN if it is
supposed to be hidden (and analogous for SDL_WINDOWEVENT_HIDDEN).

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 ui/sdl2.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/ui/sdl2.c b/ui/sdl2.c
index fdc762f..7297c02 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -548,6 +548,16 @@ static void handle_windowevent(SDL_Event *ev)
             qemu_system_shutdown_request();
         }
         break;
+    case SDL_WINDOWEVENT_SHOWN:
+        if (scon->hidden) {
+            SDL_HideWindow(scon->real_window);
+        }
+        break;
+    case SDL_WINDOWEVENT_HIDDEN:
+        if (!scon->hidden) {
+            SDL_ShowWindow(scon->real_window);
+        }
+        break;
     }
 }
 
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] sdl2: Work around SDL2 SDL_ShowWindow() bug
  2014-12-12  9:52 [Qemu-devel] [PATCH 0/2] sdl2: Work around SDL2 SDL_ShowWindow() bug Max Reitz
  2014-12-12  9:52 ` [Qemu-devel] [PATCH 1/2] sdl2: Use correct sdl2_console for window events Max Reitz
  2014-12-12  9:52 ` [Qemu-devel] [PATCH 2/2] sdl2: Work around SDL2 SDL_ShowWindow() bug Max Reitz
@ 2014-12-12 11:17 ` Gerd Hoffmann
  2 siblings, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2014-12-12 11:17 UTC (permalink / raw)
  To: Max Reitz; +Cc: qemu-devel, Anthony Liguori

On Fr, 2014-12-12 at 10:52 +0100, Max Reitz wrote:
> For the bug (it at least seems to me like one), see:
> https://bugzilla.libsdl.org/show_bug.cgi?id=2818
> 
> To reproduce it in qemu, try pressing ctrl-alt-2 five times (or
> whichever your key combination for showing/hiding the monitor window
> is).
> 
> Normally, the window should be shown, hidden, shown, hidden and shown
> again. However, it will instead be shown, hidden, stay hidden, stay
> hidden and then be shown. This series fixes this.
> 
> This series depends on Gerd's series
> "sdl2: fixes, cleanups and opengl preparation."

Added to sdl queue.

thanks,
  Gerd

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-12-12 11:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-12  9:52 [Qemu-devel] [PATCH 0/2] sdl2: Work around SDL2 SDL_ShowWindow() bug Max Reitz
2014-12-12  9:52 ` [Qemu-devel] [PATCH 1/2] sdl2: Use correct sdl2_console for window events Max Reitz
2014-12-12  9:52 ` [Qemu-devel] [PATCH 2/2] sdl2: Work around SDL2 SDL_ShowWindow() bug Max Reitz
2014-12-12 11:17 ` [Qemu-devel] [PATCH 0/2] " Gerd Hoffmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).