[PATCH] ui/gtk: Fix the implicit mouse ungrabbing logic

Akihiko Odaki posted 1 patch 3 years, 4 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20221008140116.11473-1-akihiko.odaki@daynix.com
Maintainers: Gerd Hoffmann <kraxel@redhat.com>
ui/gtk.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
[PATCH] ui/gtk: Fix the implicit mouse ungrabbing logic
Posted by Akihiko Odaki 3 years, 4 months ago
Although the grab menu item represents the tabbed displays, the old
implicit mouse ungrabbing logic changes the grab menu item even for
an untabbed display.

Leave the grab menu item when implicitly ungrabbing mouse for an
untabbed display. The new ungrabbing logic introduced in
gd_mouse_mode_change() strictly follows the corresponding grabbing
logic found in gd_button_event().

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
 ui/gtk.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index 1467b8c7d7..6fc2e23963 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -681,9 +681,13 @@ static void gd_mouse_mode_change(Notifier *notify, void *data)
 
     s = container_of(notify, GtkDisplayState, mouse_mode_notifier);
     /* release the grab at switching to absolute mode */
-    if (qemu_input_is_absolute() && gd_is_grab_active(s)) {
-        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item),
-                                       FALSE);
+    if (qemu_input_is_absolute() && s->ptr_owner) {
+        if (!s->ptr_owner->window) {
+            gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item),
+                                           FALSE);
+        } else {
+            gd_ungrab_pointer(s);
+        }
     }
     for (i = 0; i < s->nb_vcs; i++) {
         VirtualConsole *vc = &s->vc[i];
-- 
2.37.3
Re: [PATCH] ui/gtk: Fix the implicit mouse ungrabbing logic
Posted by Gerd Hoffmann 3 years, 4 months ago
On Sat, Oct 08, 2022 at 11:01:16PM +0900, Akihiko Odaki wrote:
> Although the grab menu item represents the tabbed displays, the old
> implicit mouse ungrabbing logic changes the grab menu item even for
> an untabbed display.
> 
> Leave the grab menu item when implicitly ungrabbing mouse for an
> untabbed display. The new ungrabbing logic introduced in
> gd_mouse_mode_change() strictly follows the corresponding grabbing
> logic found in gd_button_event().

Added to queue.

thanks,
  Gerd