* [Qemu-devel] [PATCH v4] SDL2 various fixes
@ 2017-11-17 11:22 Jindrich Makovicka
2017-11-17 11:22 ` [Qemu-devel] [PATCH 1/3] sdl2: Do not hide the cursor on auxilliary windows Jindrich Makovicka
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Jindrich Makovicka @ 2017-11-17 11:22 UTC (permalink / raw)
To: qemu-devel, Gerd Hoffmann
Hi,
here is a respin of the three remaining patches, with checkpatch errors
corrected.
Also added the Fixes: line for "sdl2 uses surface relative coordinates",
and an explaining comment to "sdl2: Ignore UI hotkeys".
Regards, Jindrich
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 1/3] sdl2: Do not hide the cursor on auxilliary windows
2017-11-17 11:22 [Qemu-devel] [PATCH v4] SDL2 various fixes Jindrich Makovicka
@ 2017-11-17 11:22 ` Jindrich Makovicka
2017-11-17 11:22 ` [Qemu-devel] [PATCH 2/3] sdl2 uses surface relative coordinates Jindrich Makovicka
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Jindrich Makovicka @ 2017-11-17 11:22 UTC (permalink / raw)
To: qemu-devel, Gerd Hoffmann; +Cc: Jindrich Makovicka
Signed-off-by: Jindrich Makovicka <makovick@gmail.com>
---
ui/sdl2.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/ui/sdl2.c b/ui/sdl2.c
index 53dd447fd2..290b57b1b3 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -463,6 +463,10 @@ static void handle_mousemotion(SDL_Event *ev)
int max_x, max_y;
struct sdl2_console *scon = get_scon_from_window(ev->key.windowID);
+ if (!qemu_console_is_graphic(scon->dcl.con)) {
+ return;
+ }
+
if (qemu_input_is_absolute() || absolute_enabled) {
int scr_w, scr_h;
SDL_GetWindowSize(scon->real_window, &scr_w, &scr_h);
@@ -490,6 +494,10 @@ static void handle_mousebutton(SDL_Event *ev)
SDL_MouseButtonEvent *bev;
struct sdl2_console *scon = get_scon_from_window(ev->key.windowID);
+ if (!qemu_console_is_graphic(scon->dcl.con)) {
+ return;
+ }
+
bev = &ev->button;
if (!gui_grab && !qemu_input_is_absolute()) {
if (ev->type == SDL_MOUSEBUTTONUP && bev->button == SDL_BUTTON_LEFT) {
@@ -512,6 +520,10 @@ static void handle_mousewheel(SDL_Event *ev)
SDL_MouseWheelEvent *wev = &ev->wheel;
InputButton btn;
+ if (!qemu_console_is_graphic(scon->dcl.con)) {
+ return;
+ }
+
if (wev->y > 0) {
btn = INPUT_BUTTON_WHEEL_UP;
} else if (wev->y < 0) {
@@ -652,6 +664,11 @@ static void sdl_mouse_warp(DisplayChangeListener *dcl,
int x, int y, int on)
{
struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl);
+
+ if (!qemu_console_is_graphic(scon->dcl.con)) {
+ return;
+ }
+
if (on) {
if (!guest_cursor) {
sdl_show_cursor();
--
2.15.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 2/3] sdl2 uses surface relative coordinates
2017-11-17 11:22 [Qemu-devel] [PATCH v4] SDL2 various fixes Jindrich Makovicka
2017-11-17 11:22 ` [Qemu-devel] [PATCH 1/3] sdl2: Do not hide the cursor on auxilliary windows Jindrich Makovicka
@ 2017-11-17 11:22 ` Jindrich Makovicka
2017-11-17 11:22 ` [Qemu-devel] [PATCH 3/3] sdl2: Ignore UI hotkeys after a focus change when GUI modifier is held Jindrich Makovicka
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Jindrich Makovicka @ 2017-11-17 11:22 UTC (permalink / raw)
To: qemu-devel, Gerd Hoffmann; +Cc: Jindrich Makovicka
This patch fixes mouse positioning with -device usb-tablet and fullscreen
or resized window.
Fixes: 46522a82236ea0cf9011b89896d2d8f8ddaf2443
Signed-off-by: Jindrich Makovicka <makovick@gmail.com>
---
ui/sdl2.c | 30 ++++--------------------------
1 file changed, 4 insertions(+), 26 deletions(-)
diff --git a/ui/sdl2.c b/ui/sdl2.c
index 290b57b1b3..4810f1fc43 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -274,32 +274,10 @@ static void sdl_send_mouse_event(struct sdl2_console *scon, int dx, int dy,
}
if (qemu_input_is_absolute()) {
- int scr_w, scr_h;
- int max_w = 0, max_h = 0;
- int off_x = 0, off_y = 0;
- int cur_off_x = 0, cur_off_y = 0;
- int i;
-
- for (i = 0; i < sdl2_num_outputs; i++) {
- struct sdl2_console *thiscon = &sdl2_console[i];
- if (thiscon->real_window && thiscon->surface) {
- SDL_GetWindowSize(thiscon->real_window, &scr_w, &scr_h);
- cur_off_x = thiscon->x;
- cur_off_y = thiscon->y;
- if (scr_w + cur_off_x > max_w) {
- max_w = scr_w + cur_off_x;
- }
- if (scr_h + cur_off_y > max_h) {
- max_h = scr_h + cur_off_y;
- }
- if (i == scon->idx) {
- off_x = cur_off_x;
- off_y = cur_off_y;
- }
- }
- }
- qemu_input_queue_abs(scon->dcl.con, INPUT_AXIS_X, off_x + x, 0, max_w);
- qemu_input_queue_abs(scon->dcl.con, INPUT_AXIS_Y, off_y + y, 0, max_h);
+ qemu_input_queue_abs(scon->dcl.con, INPUT_AXIS_X,
+ x, 0, surface_width(scon->surface));
+ qemu_input_queue_abs(scon->dcl.con, INPUT_AXIS_Y,
+ y, 0, surface_height(scon->surface));
} else {
if (guest_cursor) {
x -= guest_x;
--
2.15.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 3/3] sdl2: Ignore UI hotkeys after a focus change when GUI modifier is held
2017-11-17 11:22 [Qemu-devel] [PATCH v4] SDL2 various fixes Jindrich Makovicka
2017-11-17 11:22 ` [Qemu-devel] [PATCH 1/3] sdl2: Do not hide the cursor on auxilliary windows Jindrich Makovicka
2017-11-17 11:22 ` [Qemu-devel] [PATCH 2/3] sdl2 uses surface relative coordinates Jindrich Makovicka
@ 2017-11-17 11:22 ` Jindrich Makovicka
2018-01-01 20:16 ` [Qemu-devel] [PATCH v4] SDL2 various fixes Jindřich Makovička
2018-01-12 13:48 ` Gerd Hoffmann
4 siblings, 0 replies; 7+ messages in thread
From: Jindrich Makovicka @ 2017-11-17 11:22 UTC (permalink / raw)
To: qemu-devel, Gerd Hoffmann; +Cc: Jindrich Makovicka
When SDL2 windows change focus while a key is held, the window that
receives the focus also receives a new KeyDown event, without an
autorepeat flag. This means that if a WM places the qemu console
over the main window after Ctrl-Alt-2, the console closes immediately
after opening. Then, the main window receives the KeyDown event again
and the whole process repeats.
This patch makes the SDL2 UI ignore the KeyDown events on a window that
just received the focus, if the GUI modifier was held. The ignore flag
is reset on a first KeyUp event. This effectively works around the issue
above.
Signed-off-by: Jindrich Makovicka <makovick@gmail.com>
---
include/ui/sdl2.h | 1 +
ui/sdl2.c | 32 ++++++++++++++++++++++++--------
2 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/include/ui/sdl2.h b/include/ui/sdl2.h
index b29cf803c9..51084e6320 100644
--- a/include/ui/sdl2.h
+++ b/include/ui/sdl2.h
@@ -24,6 +24,7 @@ struct sdl2_console {
int opengl;
int updates;
int idle_counter;
+ int ignore_hotkeys;
SDL_GLContext winctx;
#ifdef CONFIG_OPENGL
QemuGLShader *gls;
diff --git a/ui/sdl2.c b/ui/sdl2.c
index 4810f1fc43..414b1c71d9 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -310,22 +310,28 @@ static void toggle_full_screen(struct sdl2_console *scon)
sdl2_redraw(scon);
}
-static void handle_keydown(SDL_Event *ev)
+static int get_mod_state(void)
{
- int mod_state, win;
- struct sdl2_console *scon = get_scon_from_window(ev->key.windowID);
+ SDL_Keymod mod = SDL_GetModState();
if (alt_grab) {
- mod_state = (SDL_GetModState() & (gui_grab_code | KMOD_LSHIFT)) ==
+ return (mod & (gui_grab_code | KMOD_LSHIFT)) ==
(gui_grab_code | KMOD_LSHIFT);
} else if (ctrl_grab) {
- mod_state = (SDL_GetModState() & KMOD_RCTRL) == KMOD_RCTRL;
+ return (mod & KMOD_RCTRL) == KMOD_RCTRL;
} else {
- mod_state = (SDL_GetModState() & gui_grab_code) == gui_grab_code;
+ return (mod & gui_grab_code) == gui_grab_code;
}
- gui_key_modifier_pressed = mod_state;
+}
- if (gui_key_modifier_pressed) {
+static void handle_keydown(SDL_Event *ev)
+{
+ int win;
+ struct sdl2_console *scon = get_scon_from_window(ev->key.windowID);
+
+ gui_key_modifier_pressed = get_mod_state();
+
+ if (!scon->ignore_hotkeys && gui_key_modifier_pressed && !ev->key.repeat) {
switch (ev->key.keysym.scancode) {
case SDL_SCANCODE_2:
case SDL_SCANCODE_3:
@@ -399,6 +405,8 @@ static void handle_keyup(SDL_Event *ev)
int mod_state;
struct sdl2_console *scon = get_scon_from_window(ev->key.windowID);
+ scon->ignore_hotkeys = false;
+
if (!alt_grab) {
mod_state = (ev->key.keysym.mod & gui_grab_code);
} else {
@@ -543,6 +551,14 @@ static void handle_windowevent(SDL_Event *ev)
if (!gui_grab && (qemu_input_is_absolute() || absolute_enabled)) {
absolute_mouse_grab(scon);
}
+ /* If a new console window opened using a hotkey receives the
+ * focus, SDL sends another KEYDOWN event to the new window,
+ * closing the console window immediately after.
+ *
+ * Work around this by ignoring further hotkey events until a
+ * key is released.
+ */
+ scon->ignore_hotkeys = get_mod_state();
break;
case SDL_WINDOWEVENT_FOCUS_LOST:
if (gui_grab && !gui_fullscreen) {
--
2.15.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH v4] SDL2 various fixes
2017-11-17 11:22 [Qemu-devel] [PATCH v4] SDL2 various fixes Jindrich Makovicka
` (2 preceding siblings ...)
2017-11-17 11:22 ` [Qemu-devel] [PATCH 3/3] sdl2: Ignore UI hotkeys after a focus change when GUI modifier is held Jindrich Makovicka
@ 2018-01-01 20:16 ` Jindřich Makovička
2018-01-08 10:45 ` Gerd Hoffmann
2018-01-12 13:48 ` Gerd Hoffmann
4 siblings, 1 reply; 7+ messages in thread
From: Jindřich Makovička @ 2018-01-01 20:16 UTC (permalink / raw)
To: qemu-devel, Gerd Hoffmann
On Fri, 17 Nov 2017 12:22:55 +0100
Jindrich Makovicka <makovick@gmail.com> wrote:
> Hi,
>
> here is a respin of the three remaining patches, with checkpatch
> errors corrected.
>
> Also added the Fixes: line for "sdl2 uses surface relative
> coordinates", and an explaining comment to "sdl2: Ignore UI hotkeys".
>
> Regards, Jindrich
>
Hi,
these changes somehow got lost. Any chance to have them merged into the
next minor?
Regards,
--
Jindrich Makovicka
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH v4] SDL2 various fixes
2018-01-01 20:16 ` [Qemu-devel] [PATCH v4] SDL2 various fixes Jindřich Makovička
@ 2018-01-08 10:45 ` Gerd Hoffmann
0 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2018-01-08 10:45 UTC (permalink / raw)
To: Jindřich Makovička; +Cc: qemu-devel
On Mon, Jan 01, 2018 at 09:16:00PM +0100, Jindřich Makovička wrote:
> On Fri, 17 Nov 2017 12:22:55 +0100
> Jindrich Makovicka <makovick@gmail.com> wrote:
>
> > Hi,
> >
> > here is a respin of the three remaining patches, with checkpatch
> > errors corrected.
> >
> > Also added the Fixes: line for "sdl2 uses surface relative
> > coordinates", and an explaining comment to "sdl2: Ignore UI hotkeys".
> >
> > Regards, Jindrich
> >
>
> Hi,
>
> these changes somehow got lost. Any chance to have them merged into the
> next minor?
First master, then possibly backport into -stable.
Just back from a few weeks of sick leave due to broken finger.
Will have to go through my email backlog, then I'll go handle
pending patches. Will probably take some days though ...
cheers,
Gerd
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH v4] SDL2 various fixes
2017-11-17 11:22 [Qemu-devel] [PATCH v4] SDL2 various fixes Jindrich Makovicka
` (3 preceding siblings ...)
2018-01-01 20:16 ` [Qemu-devel] [PATCH v4] SDL2 various fixes Jindřich Makovička
@ 2018-01-12 13:48 ` Gerd Hoffmann
4 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2018-01-12 13:48 UTC (permalink / raw)
To: Jindrich Makovicka; +Cc: qemu-devel
On Fri, Nov 17, 2017 at 12:22:55PM +0100, Jindrich Makovicka wrote:
> Hi,
>
> here is a respin of the three remaining patches, with checkpatch errors
> corrected.
>
> Also added the Fixes: line for "sdl2 uses surface relative coordinates",
> and an explaining comment to "sdl2: Ignore UI hotkeys".
Series queued up now.
thanks,
Gerd
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-01-12 13:49 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-17 11:22 [Qemu-devel] [PATCH v4] SDL2 various fixes Jindrich Makovicka
2017-11-17 11:22 ` [Qemu-devel] [PATCH 1/3] sdl2: Do not hide the cursor on auxilliary windows Jindrich Makovicka
2017-11-17 11:22 ` [Qemu-devel] [PATCH 2/3] sdl2 uses surface relative coordinates Jindrich Makovicka
2017-11-17 11:22 ` [Qemu-devel] [PATCH 3/3] sdl2: Ignore UI hotkeys after a focus change when GUI modifier is held Jindrich Makovicka
2018-01-01 20:16 ` [Qemu-devel] [PATCH v4] SDL2 various fixes Jindřich Makovička
2018-01-08 10:45 ` Gerd Hoffmann
2018-01-12 13:48 ` 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).