All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel]  [PATCH 1/2] SDL2: only show consoles by shortcuts and not hide.
@ 2016-08-23 20:36 Andrei Karas
  2016-09-07 11:27 ` Gerd Hoffmann
  0 siblings, 1 reply; 6+ messages in thread
From: Andrei Karas @ 2016-08-23 20:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

This fix issue with stuck keys in SDL2 if press one of shortcuts
for show/hide consoles.
For close any consoles except main window can be used default WM/DE
action for close window.

Signed-off-by: Andrei Karas <akaras@inbox.ru>
---
 ui/sdl2.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/ui/sdl2.c b/ui/sdl2.c
index 30d2a3c..4441e99 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -363,15 +363,17 @@ static void handle_keydown(SDL_Event *ev)
 
             win = ev->key.keysym.scancode - SDL_SCANCODE_1;
             if (win < sdl2_num_outputs) {
-                sdl2_console[win].hidden = !sdl2_console[win].hidden;
-                if (sdl2_console[win].real_window) {
-                    if (sdl2_console[win].hidden) {
-                        SDL_HideWindow(sdl2_console[win].real_window);
-                    } else {
-                        SDL_ShowWindow(sdl2_console[win].real_window);
+                if (sdl2_console[win].hidden == 1) {
+                    sdl2_console[win].hidden = !sdl2_console[win].hidden;
+                    if (sdl2_console[win].real_window) {
+                        if (sdl2_console[win].hidden) {
+                            SDL_HideWindow(sdl2_console[win].real_window);
+                        } else {
+                            SDL_ShowWindow(sdl2_console[win].real_window);
+                        }
                     }
+                    gui_keysym = 1;
                 }
-                gui_keysym = 1;
             }
             break;
         case SDL_SCANCODE_F:
@@ -566,9 +568,14 @@ static void handle_windowevent(SDL_Event *ev)
         update_displaychangelistener(&scon->dcl, 500);
         break;
     case SDL_WINDOWEVENT_CLOSE:
-        if (!no_quit) {
-            no_shutdown = 0;
-            qemu_system_shutdown_request();
+        if (scon->idx == 0) {
+            if (!no_quit) {
+                no_shutdown = 0;
+                qemu_system_shutdown_request();
+            }
+        } else {
+            scon->hidden = true;
+            SDL_HideWindow(scon->real_window);
         }
         break;
     case SDL_WINDOWEVENT_SHOWN:
-- 
2.9.3


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

* Re: [Qemu-devel] [PATCH 1/2] SDL2: only show consoles by shortcuts and not hide.
  2016-08-23 20:36 [Qemu-devel] [PATCH 1/2] SDL2: only show consoles by shortcuts and not hide Andrei Karas
@ 2016-09-07 11:27 ` Gerd Hoffmann
  2016-09-07 12:24   ` Andrei Karas
  0 siblings, 1 reply; 6+ messages in thread
From: Gerd Hoffmann @ 2016-09-07 11:27 UTC (permalink / raw)
  To: Andrei Karas; +Cc: qemu-devel

On Di, 2016-08-23 at 23:36 +0300, Andrei Karas wrote:
> This fix issue with stuck keys in SDL2 if press one of shortcuts
> for show/hide consoles.

More detailed description please.  How exactly do you end up with stuck
keys?

>              win = ev->key.keysym.scancode - SDL_SCANCODE_1;
>              if (win < sdl2_num_outputs) {
> -                sdl2_console[win].hidden = !sdl2_console[win].hidden;
> -                if (sdl2_console[win].real_window) {
> -                    if (sdl2_console[win].hidden) {
> -                        SDL_HideWindow(sdl2_console[win].real_window);
> -                    } else {
> -                        SDL_ShowWindow(sdl2_console[win].real_window);
> +                if (sdl2_console[win].hidden == 1) {
> +                    sdl2_console[win].hidden = !sdl2_console[win].hidden;
> +                    if (sdl2_console[win].real_window) {
> +                        if (sdl2_console[win].hidden) {
> +                            SDL_HideWindow(sdl2_console[win].real_window);
> +                        } else {
> +                            SDL_ShowWindow(sdl2_console[win].real_window);
> +                        }
>                      }
> +                    gui_keysym = 1;
>                  }
> -                gui_keysym = 1;

So, the hotkey works only in case the window is hidden, so you can't
hide windows with the shortcut any more.  Is that intentional?  Why?

>      case SDL_WINDOWEVENT_CLOSE:
> -        if (!no_quit) {
> -            no_shutdown = 0;
> -            qemu_system_shutdown_request();
> +        if (scon->idx == 0) {
> +            if (!no_quit) {
> +                no_shutdown = 0;
> +                qemu_system_shutdown_request();
> +            }
> +        } else {
> +            scon->hidden = true;
> +            SDL_HideWindow(scon->real_window);

Ok, for all but the primary window it is indeed useful to simply hide
the window instead of exiting.  Seems to be independent from the stuck
keys issue though.  If so send this as separate patch please.

cheers,
  Gerd

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

* Re: [Qemu-devel] [PATCH 1/2] SDL2: only show consoles by shortcuts and not hide.
  2016-09-07 11:27 ` Gerd Hoffmann
@ 2016-09-07 12:24   ` Andrei Karas
  2016-09-08  6:10     ` Gerd Hoffmann
  0 siblings, 1 reply; 6+ messages in thread
From: Andrei Karas @ 2016-09-07 12:24 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel


>Среда,  7 сентября 2016, 14:27 +03:00 от Gerd Hoffmann <kraxel@redhat.com>:
>
>On Di, 2016-08-23 at 23:36 +0300, Andrei Karas wrote:
>> This fix issue with stuck keys in SDL2 if press one of shortcuts
>> for show/hide consoles.
>
>More detailed description please.  How exactly do you end up with stuck
>keys?
For example i using ctrl_grab=on option.
Without patch if press rctrl+2 cosole window can be drawed and hidden at same time many times.
Console drawed or hidden depend only how long keys was pressed.
If add logging for press, release events, this event may happened in main and in console window
randomly and no normal way to detect is possible show console window or need to hide it.
I think this is because press event at first happened in main window, and after may happened in
child window.

>
>>              win = ev->key.keysym.scancode - SDL_SCANCODE_1;
>>              if (win < sdl2_num_outputs) {
>> -                sdl2_console[win].hidden = !sdl2_console[win].hidden;
>> -                if (sdl2_console[win].real_window) {
>> -                    if (sdl2_console[win].hidden) {
>> -                        SDL_HideWindow(sdl2_console[win].real_window);
>> -                    } else {
>> -                        SDL_ShowWindow(sdl2_console[win].real_window);
>> +                if (sdl2_console[win].hidden == 1) {
>> +                    sdl2_console[win].hidden = !sdl2_console[win].hidden;
>> +                    if (sdl2_console[win].real_window) {
>> +                        if (sdl2_console[win].hidden) {
>> +                            SDL_HideWindow(sdl2_console[win].real_window);
>> +                        } else {
>> +                            SDL_ShowWindow(sdl2_console[win].real_window);
>> +                        }
>>                      }
>> +                    gui_keysym = 1;
>>                  }
>> -                gui_keysym = 1;
>
>So, the hotkey works only in case the window is hidden, so you can't
>hide windows with the shortcut any more.  Is that intentional?  Why?
Because previous explanation i found only solution is limit this keys to
always show windows.

>
>>      case SDL_WINDOWEVENT_CLOSE:
>> -        if (!no_quit) {
>> -            no_shutdown = 0;
>> -            qemu_system_shutdown_request();
>> +        if (scon->idx == 0) {
>> +            if (!no_quit) {
>> +                no_shutdown = 0;
>> +                qemu_system_shutdown_request();
>> +            }
>> +        } else {
>> +            scon->hidden = true;
>> +            SDL_HideWindow(scon->real_window);
>
>Ok, for all but the primary window it is indeed useful to simply hide
>the window instead of exiting.  Seems to be independent from the stuck
>keys issue though.  If so send this as separate patch please.
Ok, will send

>
>cheers,
>  Gerd
>




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

* Re: [Qemu-devel] [PATCH 1/2] SDL2: only show consoles by shortcuts and not hide.
  2016-09-07 12:24   ` Andrei Karas
@ 2016-09-08  6:10     ` Gerd Hoffmann
  2016-09-08 18:50       ` Andrei Karas
  0 siblings, 1 reply; 6+ messages in thread
From: Gerd Hoffmann @ 2016-09-08  6:10 UTC (permalink / raw)
  To: Andrei Karas; +Cc: qemu-devel

On Mi, 2016-09-07 at 15:24 +0300, Andrei Karas wrote:
> >Среда,  7 сентября 2016, 14:27 +03:00 от Gerd Hoffmann <kraxel@redhat.com>:
> >
> >On Di, 2016-08-23 at 23:36 +0300, Andrei Karas wrote:
> >> This fix issue with stuck keys in SDL2 if press one of shortcuts
> >> for show/hide consoles.
> >
> >More detailed description please.  How exactly do you end up with stuck
> >keys?
> For example i using ctrl_grab=on option.
> Without patch if press rctrl+2 cosole window can be drawed and hidden at same time many times.
> Console drawed or hidden depend only how long keys was pressed.

Ah, so you hold down the hotkey and key autorepeat will show/hide the
window?

> >So, the hotkey works only in case the window is hidden, so you can't
> >hide windows with the shortcut any more.  Is that intentional?  Why?
> Because previous explanation i found only solution is limit this keys to
> always show windows.

You can check ev->key.repeat to detect whenever the keypress is a real
one or autorepeat event.

cheers,
  Gerd

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

* Re: [Qemu-devel] [PATCH 1/2] SDL2: only show consoles by shortcuts and not hide.
  2016-09-08  6:10     ` Gerd Hoffmann
@ 2016-09-08 18:50       ` Andrei Karas
  0 siblings, 0 replies; 6+ messages in thread
From: Andrei Karas @ 2016-09-08 18:50 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel

>Четверг,  8 сентября 2016, 9:10 +03:00 от Gerd Hoffmann <kraxel@redhat.com>:
>
>On Mi, 2016-09-07 at 15:24 +0300, Andrei Karas wrote:
>> >Среда,  7 сентября 2016, 14:27 +03:00 от Gerd Hoffmann < kraxel@redhat.com >:
>> >
>> >On Di, 2016-08-23 at 23:36 +0300, Andrei Karas wrote:
>> >> This fix issue with stuck keys in SDL2 if press one of shortcuts
>> >> for show/hide consoles.
>> >
>> >More detailed description please.  How exactly do you end up with stuck
>> >keys?
>> For example i using ctrl_grab=on option.
>> Without patch if press rctrl+2 cosole window can be drawed and hidden at same time many times.
>> Console drawed or hidden depend only how long keys was pressed.
>
>Ah, so you hold down the hotkey and key autorepeat will show/hide the
>window?
Yes, and no stable events for press/release for each of window or for all windows.

>
>> >So, the hotkey works only in case the window is hidden, so you can't
>> >hide windows with the shortcut any more.  Is that intentional?  Why?
>> Because previous explanation i found only solution is limit this keys to
>> always show windows.
>
>You can check ev->key.repeat to detect whenever the keypress is a real
>one or autorepeat event.
I think it not works. I did this tests some time ago, but i think repeat always zero and no way to detect is need show or hide window.
Probably this is because multy windows application.

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

* [Qemu-devel] [PATCH 1/2] SDL2: only show consoles by shortcuts and not hide.
@ 2016-08-23 20:28 Andrei Karas
  0 siblings, 0 replies; 6+ messages in thread
From: Andrei Karas @ 2016-08-23 20:28 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

This fix issue with stuck keys in SDL2 if press one of shortcuts
for show/hide consoles.
For close any consoles except main window can be used default WM/DE
action for close window.

Signed-off-by: Andrei Karas <akaras@inbox.ru>
---
 ui/sdl2.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/ui/sdl2.c b/ui/sdl2.c
index 30d2a3c..4441e99 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -363,15 +363,17 @@ static void handle_keydown(SDL_Event *ev)
 
             win = ev->key.keysym.scancode - SDL_SCANCODE_1;
             if (win < sdl2_num_outputs) {
-                sdl2_console[win].hidden = !sdl2_console[win].hidden;
-                if (sdl2_console[win].real_window) {
-                    if (sdl2_console[win].hidden) {
-                        SDL_HideWindow(sdl2_console[win].real_window);
-                    } else {
-                        SDL_ShowWindow(sdl2_console[win].real_window);
+                if (sdl2_console[win].hidden == 1) {
+                    sdl2_console[win].hidden = !sdl2_console[win].hidden;
+                    if (sdl2_console[win].real_window) {
+                        if (sdl2_console[win].hidden) {
+                            SDL_HideWindow(sdl2_console[win].real_window);
+                        } else {
+                            SDL_ShowWindow(sdl2_console[win].real_window);
+                        }
                     }
+                    gui_keysym = 1;
                 }
-                gui_keysym = 1;
             }
             break;
         case SDL_SCANCODE_F:
@@ -566,9 +568,14 @@ static void handle_windowevent(SDL_Event *ev)
         update_displaychangelistener(&scon->dcl, 500);
         break;
     case SDL_WINDOWEVENT_CLOSE:
-        if (!no_quit) {
-            no_shutdown = 0;
-            qemu_system_shutdown_request();
+        if (scon->idx == 0) {
+            if (!no_quit) {
+                no_shutdown = 0;
+                qemu_system_shutdown_request();
+            }
+        } else {
+            scon->hidden = true;
+            SDL_HideWindow(scon->real_window);
         }
         break;
     case SDL_WINDOWEVENT_SHOWN:
-- 
2.9.3


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

end of thread, other threads:[~2016-09-08 18:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-23 20:36 [Qemu-devel] [PATCH 1/2] SDL2: only show consoles by shortcuts and not hide Andrei Karas
2016-09-07 11:27 ` Gerd Hoffmann
2016-09-07 12:24   ` Andrei Karas
2016-09-08  6:10     ` Gerd Hoffmann
2016-09-08 18:50       ` Andrei Karas
  -- strict thread matches above, loose matches on Subject: below --
2016-08-23 20:28 Andrei Karas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.