All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: qemu-devel@nongnu.org
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>
Subject: [Qemu-devel] [PATCH 2 of 2] sdl hide pointer when not in focus
Date: Tue, 04 Nov 2008 18:36:27 +0000	[thread overview]
Message-ID: <4910962B.1040902@eu.citrix.com> (raw)

Hide the mouse pointer when the sdl window is not in focus.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

diff -r e42ba25a7313 sdl.c
--- a/sdl.c	Tue Nov 04 18:11:03 2008 +0000
+++ b/sdl.c	Tue Nov 04 18:11:23 2008 +0000
@@ -50,6 +50,7 @@
 static int guest_cursor = 0;
 static int guest_x, guest_y;
 static SDL_Cursor *guest_sprite = 0;
+static int mouse_active = SDL_ENABLE;
 
 static void sdl_update(DisplayState *ds, int x, int y, int w, int h)
 {
@@ -514,7 +515,8 @@
                         dz = 1;
                     }
 #endif
-                    sdl_send_mouse_event(0, 0, dz, bev->x, bev->y, buttonstate);
+                    if (mouse_active == SDL_ENABLE)
+                        sdl_send_mouse_event(0, 0, dz, bev->x, bev->y, buttonstate);
                 }
             }
             break;
@@ -522,6 +524,14 @@
             if (gui_grab && ev->active.state == SDL_APPINPUTFOCUS &&
                 !ev->active.gain && !gui_fullscreen_initial_grab) {
                 sdl_grab_end();
+            }
+            /* Send mouse pointer to oblivion on focus change */
+            if ((ev->active.state == SDL_APPINPUTFOCUS) ||
+                (ev->active.state == SDL_APPMOUSEFOCUS))
+            {
+                mouse_active = ev->active.gain;
+                if (mouse_active != SDL_ENABLE)
+                    kbd_mouse_event(0x7FFF, 0x7FFF, 0, 0);
             }
             if (ev->active.state & SDL_APPACTIVE) {
                 if (ev->active.gain) {

             reply	other threads:[~2008-11-04 18:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-04 18:36 Stefano Stabellini [this message]
2008-11-04 19:11 ` [Qemu-devel] [PATCH 2 of 2] sdl hide pointer when not in focus Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4910962B.1040902@eu.citrix.com \
    --to=stefano.stabellini@eu.citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.