From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KxQiG-00026d-Ex for qemu-devel@nongnu.org; Tue, 04 Nov 2008 13:33:12 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KxQiF-00025o-09 for qemu-devel@nongnu.org; Tue, 04 Nov 2008 13:33:12 -0500 Received: from [199.232.76.173] (port=56054 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KxQiE-00025e-Hk for qemu-devel@nongnu.org; Tue, 04 Nov 2008 13:33:10 -0500 Received: from smtp.eu.citrix.com ([62.200.22.115]:25191) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KxQiE-00055v-I0 for qemu-devel@nongnu.org; Tue, 04 Nov 2008 13:33:10 -0500 Message-ID: <4910962B.1040902@eu.citrix.com> Date: Tue, 04 Nov 2008 18:36:27 +0000 From: Stefano Stabellini MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH 2 of 2] sdl hide pointer when not in focus Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Ian Jackson Hide the mouse pointer when the sdl window is not in focus. Signed-off-by: Stefano Stabellini 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) {