display: Use meta_device_grab() for pointer active grabs.

This commit is contained in:
Carlos Garnacho 2011-06-21 18:28:55 +02:00 committed by Jasper St. Pierre
parent df908e5256
commit 991fdeb9dd

View File

@ -3605,9 +3605,9 @@ meta_display_create_x_cursor (MetaDisplay *display,
return xcursor; return xcursor;
} }
static Cursor static MetaCursor
xcursor_for_op (MetaDisplay *display, cursor_for_op (MetaDisplay *display,
MetaGrabOp op) MetaGrabOp op)
{ {
MetaCursor cursor = META_CURSOR_DEFAULT; MetaCursor cursor = META_CURSOR_DEFAULT;
@ -3655,9 +3655,7 @@ xcursor_for_op (MetaDisplay *display,
break; break;
} }
if (cursor == META_CURSOR_DEFAULT) return cursor;
return None;
return meta_display_create_x_cursor (display, cursor);
} }
void void
@ -3670,9 +3668,9 @@ meta_display_set_grab_op_cursor (MetaDisplay *display,
guint32 timestamp) guint32 timestamp)
{ {
MetaGrabInfo *grab_info; MetaGrabInfo *grab_info;
Cursor cursor; MetaCursor cursor;
cursor = xcursor_for_op (display, op); cursor = cursor_for_op (display, op);
grab_info = meta_display_get_grab_info (display, device); grab_info = meta_display_get_grab_info (display, device);
#define GRAB_MASK (PointerMotionMask | \ #define GRAB_MASK (PointerMotionMask | \
@ -3681,6 +3679,10 @@ meta_display_set_grab_op_cursor (MetaDisplay *display,
if (change_pointer) if (change_pointer)
{ {
Cursor xcursor;
xcursor = meta_display_create_x_cursor (display, cursor);
meta_error_trap_push_with_return (display); meta_error_trap_push_with_return (display);
XChangeActivePointerGrab (display->xdisplay, XChangeActivePointerGrab (display->xdisplay,
GRAB_MASK, GRAB_MASK,
@ -3697,39 +3699,37 @@ meta_display_set_grab_op_cursor (MetaDisplay *display,
if (grab_info->grab_have_pointer) if (grab_info->grab_have_pointer)
grab_info->grab_have_pointer = FALSE; grab_info->grab_have_pointer = FALSE;
} }
if (xcursor != None)
XFreeCursor (display->xdisplay, xcursor);
} }
else else
{ {
g_assert (screen != NULL); g_assert (screen != NULL);
meta_error_trap_push (display); meta_error_trap_push (display);
if (XGrabPointer (display->xdisplay, if (meta_device_grab (grab_info->grab_pointer,
grab_xwindow, grab_xwindow,
False, GRAB_MASK,
GRAB_MASK, cursor,
GrabModeAsync, GrabModeAsync, FALSE,
screen->xroot, FALSE,
cursor, timestamp))
timestamp) == GrabSuccess)
{ {
grab_info->grab_have_pointer = TRUE; grab_info->grab_have_pointer = TRUE;
meta_topic (META_DEBUG_WINDOW_OPS, meta_topic (META_DEBUG_WINDOW_OPS,
"XGrabPointer() returned GrabSuccess time %u\n", "grabbing pointer succeeded time %u\n",
timestamp); timestamp);
} }
else else
{ {
meta_topic (META_DEBUG_WINDOW_OPS, meta_topic (META_DEBUG_WINDOW_OPS,
"XGrabPointer() failed time %u\n", "grabbing pointer failed time %u\n",
timestamp); timestamp);
} }
meta_error_trap_pop (display); meta_error_trap_pop (display);
} }
#undef GRAB_MASK #undef GRAB_MASK
if (cursor != None)
XFreeCursor (display->xdisplay, cursor);
} }
gboolean gboolean
@ -3815,7 +3815,7 @@ meta_display_begin_grab_op (MetaDisplay *display,
if (!grab_info->grab_have_pointer && !grab_op_is_keyboard (op)) if (!grab_info->grab_have_pointer && !grab_op_is_keyboard (op))
{ {
meta_topic (META_DEBUG_WINDOW_OPS, meta_topic (META_DEBUG_WINDOW_OPS,
"XGrabPointer() failed\n"); "grabbing pointer failed\n");
return FALSE; return FALSE;
} }
@ -3838,7 +3838,7 @@ meta_display_begin_grab_op (MetaDisplay *display,
{ {
meta_topic (META_DEBUG_WINDOW_OPS, meta_topic (META_DEBUG_WINDOW_OPS,
"grabbing all keys failed, ungrabbing pointer\n"); "grabbing all keys failed, ungrabbing pointer\n");
XUngrabPointer (display->xdisplay, timestamp); meta_device_ungrab (grab_info->grab_pointer, timestamp);
grab_info->grab_have_pointer = FALSE; grab_info->grab_have_pointer = FALSE;
return FALSE; return FALSE;
} }
@ -4053,7 +4053,7 @@ meta_display_end_grab_op (MetaDisplay *display,
{ {
meta_topic (META_DEBUG_WINDOW_OPS, meta_topic (META_DEBUG_WINDOW_OPS,
"Ungrabbing pointer with timestamp %u\n", timestamp); "Ungrabbing pointer with timestamp %u\n", timestamp);
XUngrabPointer (display->xdisplay, timestamp); meta_device_ungrab (grab_info->grab_pointer, timestamp);
} }
if (grab_info->grab_have_keyboard) if (grab_info->grab_have_keyboard)