[mutter/wip/xinput2r: 65/68] mouse mode focus
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/xinput2r: 65/68] mouse mode focus
- Date: Wed, 24 Oct 2012 16:14:46 +0000 (UTC)
commit bb31faf7ad76c7955d1d8da5cbfe7928dd99cde2
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Thu Oct 18 16:48:06 2012 -0400
mouse mode focus
src/core/display.c | 93 ++++++++++++++++++++++------------------------------
1 files changed, 39 insertions(+), 54 deletions(-)
---
diff --git a/src/core/display.c b/src/core/display.c
index 1d66fd9..d5ba3a8 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -135,6 +135,7 @@ typedef struct
{
MetaDisplay *display;
MetaWindow *window;
+ MetaDevice *device;
int pointer_x;
int pointer_y;
} MetaFocusData;
@@ -1588,8 +1589,16 @@ window_raise_with_delay_callback (void *data)
static void
meta_display_mouse_mode_focus (MetaDisplay *display,
+ MetaDevice *device,
MetaWindow *window,
- guint32 timestamp) {
+ guint32 timestamp)
+{
+ MetaFocusInfo *focus_info;
+ MetaDevice *keyboard;
+
+ keyboard = meta_device_get_paired_device (device);
+ focus_info = meta_display_get_focus_info (display, keyboard);
+
if (window->type != META_WINDOW_DESKTOP)
{
meta_topic (META_DEBUG_FOCUS,
@@ -1614,12 +1623,12 @@ meta_display_mouse_mode_focus (MetaDisplay *display,
* alternative mechanism works great.
*/
if (meta_prefs_get_focus_mode() == G_DESKTOP_FOCUS_MODE_MOUSE &&
- display->expected_focus_window != NULL)
+ focus_info->expected_focus_window != NULL)
{
meta_topic (META_DEBUG_FOCUS,
"Unsetting focus from %s due to mouse entering "
"the DESKTOP window\n",
- display->expected_focus_window->desc);
+ focus_info->expected_focus_window->desc);
meta_display_focus_the_no_focus_window (display,
window->screen,
timestamp);
@@ -1628,29 +1637,32 @@ meta_display_mouse_mode_focus (MetaDisplay *display,
}
static gboolean
-window_focus_on_pointer_rest_callback (gpointer data) {
+window_focus_on_pointer_rest_callback (gpointer data)
+{
MetaFocusData *focus_data;
MetaDisplay *display;
+ MetaDevice *device;
MetaScreen *screen;
MetaWindow *window;
- Window root, child;
- int root_x, root_y, x, y;
+ Window child;
+ int root_x, root_y;
guint32 timestamp;
- guint mask;
focus_data = data;
display = focus_data->display;
screen = focus_data->window->screen;
+ device = focus_data->device;
if (meta_prefs_get_focus_mode () == G_DESKTOP_FOCUS_MODE_CLICK)
goto out;
- meta_error_trap_push (display);
- XQueryPointer (display->xdisplay,
- screen->xroot,
- &root, &child,
- &root_x, &root_y, &x, &y, &mask);
- meta_error_trap_pop (display);
+ if (!meta_device_pointer_query_position (META_DEVICE_POINTER (device),
+ screen->xroot,
+ NULL,
+ &child,
+ &root_x, &root_y,
+ NULL, NULL, NULL))
+ goto out;
if (root_x != focus_data->pointer_x ||
root_y != focus_data->pointer_y)
@@ -1676,7 +1688,7 @@ window_focus_on_pointer_rest_callback (gpointer data) {
goto out;
timestamp = meta_display_get_current_time_roundtrip (display);
- meta_display_mouse_mode_focus (display, window, timestamp);
+ meta_display_mouse_mode_focus (display, device, window, timestamp);
out:
display->focus_timeout_id = 0;
@@ -1718,17 +1730,22 @@ meta_display_queue_autoraise_callback (MetaDisplay *display,
static void
meta_display_queue_focus_callback (MetaDisplay *display,
+ MetaDevice *device,
MetaWindow *window,
- int pointer_x,
- int pointer_y)
+ XEvent *event)
{
MetaFocusData *focus_data;
+ gdouble xroot, yroot;
+
+ if (!meta_input_event_get_coordinates (display, event, NULL, NULL, &xroot, &yroot))
+ return;
focus_data = g_new (MetaFocusData, 1);
focus_data->display = display;
focus_data->window = window;
- focus_data->pointer_x = pointer_x;
- focus_data->pointer_y = pointer_y;
+ focus_data->device = device;
+ focus_data->pointer_x = (int) xroot;
+ focus_data->pointer_y = (int) yroot;
if (display->focus_timeout_id != 0)
g_source_remove (display->focus_timeout_id);
@@ -2298,9 +2315,6 @@ event_callback (XEvent *event,
detail != NotifyInferior &&
meta_display_focus_sentinel_clear (display))
{
- MetaFocusInfo *focus_info;
- MetaDevice *keyboard;
-
switch (meta_prefs_get_focus_mode ())
{
case G_DESKTOP_FOCUS_MODE_SLOPPY:
@@ -2317,12 +2331,9 @@ event_callback (XEvent *event,
evtime);
if (meta_prefs_get_focus_change_on_pointer_rest())
- meta_display_queue_focus_callback (display, window,
- event->xcrossing.x_root,
- event->xcrossing.y_root);
+ meta_display_queue_focus_callback (display, device, window, event);
else
- meta_display_mouse_mode_focus (display, window,
- evtime);
+ meta_display_mouse_mode_focus (display, device, window, evtime);
/* stop ignoring stuff */
reset_ignored_crossing_serials (display);
@@ -2337,38 +2348,12 @@ event_callback (XEvent *event,
"Auto raise is disabled\n");
}
}
-
- keyboard = meta_device_get_paired_device (device);
- focus_info = meta_display_get_focus_info (display, keyboard);
-
- /* In mouse focus mode, we defocus when the mouse *enters*
- * the DESKTOP window, instead of defocusing on LeaveNotify.
- * This is because having the mouse enter override-redirect
- * child windows unfortunately causes LeaveNotify events that
- * we can't distinguish from the mouse actually leaving the
- * toplevel window as we expect. But, since we filter out
- * EnterNotify events on override-redirect windows, this
- * alternative mechanism works great.
- */
- if (window->type == META_WINDOW_DESKTOP &&
- meta_prefs_get_focus_mode() == META_FOCUS_MODE_MOUSE &&
- focus_info->expected_focus_window != NULL)
- {
- meta_topic (META_DEBUG_FOCUS,
- "Unsetting focus on device %d "
- "from %s due to mouse entering "
- "the DESKTOP window\n",
- meta_device_get_id (keyboard),
- focus_info->expected_focus_window->desc);
- meta_display_focus_the_no_focus_window (display,
- window->screen,
- evtime);
- }
break;
+
case G_DESKTOP_FOCUS_MODE_CLICK:
break;
}
-
+
if (window->type == META_WINDOW_DOCK)
meta_window_raise (window);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]