static void uninstall_grabs_mouse( void ) { int i; int num_devices; XIDeviceInfo *info; assert( x11display.dpy && x11display.win ); if( !mouse_active ) return; XUndefineCursor(x11display.dpy, x11display.win); info = XIQueryDevice(x11display.dpy, XIAllDevices, &num_devices); for(i = 0; i < num_devices; i++) { if(info[i].use == XIFloatingSlave) { XIUngrabDevice(x11display.dpy, info[i].deviceid, CurrentTime); } else if(info[i].use == XIMasterPointer) { XIWarpPointer(x11display.dpy, info[i].deviceid, None, x11display.win, 0, 0, 0, 0, x11display.win_width/2, x11display.win_height/2); } } XIFreeDeviceInfo(info); mouse_active = qfalse; mx = my = 0; }
static gboolean meta_backend_x11_ungrab_device (MetaBackend *backend, int device_id, uint32_t timestamp) { MetaBackendX11 *x11 = META_BACKEND_X11 (backend); MetaBackendX11Private *priv = meta_backend_x11_get_instance_private (x11); int ret; ret = XIUngrabDevice (priv->xdisplay, device_id, timestamp); return (ret == Success); }
void GrabPointerRelease(void) { #if USE_XI2 XIUngrabDevice(disp, DEV_PTR, CurrentTime); #else XUngrabPointer(disp, CurrentTime); #endif if (EDebug(EDBUG_TYPE_GRABS)) Eprintf("%s: %#x\n", __func__, Mode.grabs.pointer_grab_window); Mode.grabs.pointer_grab_active = 0; Mode.grabs.pointer_grab_window = NoXID; }
int GrabKeyboardRelease(void) { int rc; #if USE_XI2 rc = XIUngrabDevice(disp, DEV_KBD, CurrentTime); #else rc = XUngrabKeyboard(disp, CurrentTime); #endif #if 0 Eprintf("%s: %d\n", __func__, rc); #endif return rc; }
void xfwm_device_ungrab (XfwmDevices *devices, XfwmDevice *device, Display *display, Time time) { #ifdef HAVE_XI2 if (device->xi2_device != None) { XIUngrabDevice (display, device->xi2_device, time); } else #endif if (device->keyboard) { XUngrabKeyboard (display, time); } else { XUngrabPointer (display, time); } }
void test_sync_grab(Display *display, Window win) { int loop = 3; int rc; XIEventMask mask; /* Select for motion events */ mask.deviceid = XIAllDevices; mask.mask_len = 2; mask.mask = calloc(2, sizeof(char)); XISetMask(mask.mask, XI_ButtonPress); if ((rc = XIGrabDevice(display, 2, win, CurrentTime, None, GrabModeSync, GrabModeAsync, False, &mask)) != GrabSuccess) { fprintf(stderr, "Grab failed with %d\n", rc); return; } free(mask.mask); XSync(display, True); XIAllowEvents(display, 2, SyncPointer, CurrentTime); XFlush(display); printf("Holding sync grab for %d button presses.\n", loop); while(loop--) { XIEvent ev; XNextEvent(display, (XEvent*)&ev); if (ev.type == GenericEvent && ev.extension == xi_opcode ) { XIDeviceEvent *event = (XIDeviceEvent*)&ev; print_deviceevent(event); XIAllowEvents(display, 2, SyncPointer, CurrentTime); } } XIUngrabDevice(display, 2, CurrentTime); printf("Done\n"); }
gboolean meta_begin_modal_for_plugin (MetaCompositor *compositor, MetaPlugin *plugin, MetaModalOptions options, guint32 timestamp) { /* To some extent this duplicates code in meta_display_begin_grab_op(), but there * are significant differences in how we handle grabs that make it difficult to * merge the two. */ MetaDisplay *display = compositor->display; if (is_modal (display) || display->grab_op != META_GRAB_OP_NONE) return FALSE; /* XXX: why is this needed? */ XIUngrabDevice (display->xdisplay, META_VIRTUAL_CORE_POINTER_ID, timestamp); XSync (display->xdisplay, False); if (!grab_devices (options, timestamp)) return FALSE; display->grab_op = META_GRAB_OP_COMPOSITOR; display->event_route = META_EVENT_ROUTE_COMPOSITOR_GRAB; display->grab_window = NULL; display->grab_have_pointer = TRUE; display->grab_have_keyboard = TRUE; g_signal_emit_by_name (display, "grab-op-begin", meta_plugin_get_screen (plugin), display->grab_window, display->grab_op); if (meta_is_wayland_compositor ()) { meta_display_sync_wayland_input_focus (display); meta_display_cancel_touch (display); } return TRUE; }
static void uninstall_grabs_keyboard( void ) { int i; int num_devices; XIDeviceInfo *info; assert( x11display.dpy && x11display.win ); if( !input_active ) return; info = XIQueryDevice(x11display.dpy, XIAllDevices, &num_devices); for(i = 0; i < num_devices; i++) { if(info[i].use == XIMasterKeyboard) { XIUngrabDevice(x11display.dpy, info[i].deviceid, CurrentTime); } } XIFreeDeviceInfo(info); input_active = qfalse; }
/* Ungrab the device so input can be handled by application directly */ void ungrab(Display* display, int grabDeviceID) { /* Experiments with X MT support, not working yet */ // XIGrabModifiers modifiers[1] = { { 0, 0 } }; // XIUngrabButton(display, grabDeviceID, 1, root, 1, modifiers); XIUngrabDevice(display, grabDeviceID, CurrentTime); }
void doppelganger_set_image (Doppelganger *dg, GdkPixbuf *pixbuf) { GdkPixbuf *scaled = NULL; GdkPixdata black_arrow_data; GdkPixbuf *black_arrow; GdkPixbuf *cursor_image; gboolean preexisting = dg->cursor!=NULL; if (!gdk_pixdata_deserialize (&black_arrow_data, -1, black_cursor, NULL) || black_cursor == NULL) { /* This won't happen in practice, so it can be fatal */ g_error ("Failed to deseralise pointer."); } black_arrow = gdk_pixbuf_from_pixdata (&black_arrow_data, TRUE, NULL); if (pixbuf) { scaled = gdk_pixbuf_scale_simple (pixbuf, 64, 64, GDK_INTERP_BILINEAR); /* * Composite a black arrow onto the top left-hand * corner. */ gdk_pixbuf_composite (black_arrow, scaled, 0, 0, 13, 21, 0.0, 0.0, 1.0, 1.0, GDK_INTERP_NEAREST, 255); gdk_pixbuf_unref (black_arrow); cursor_image = scaled; } else { cursor_image = black_arrow; } if (preexisting) { gdk_cursor_unref (dg->cursor); } dg->cursor = gdk_cursor_new_from_pixbuf (gdk_display_get_default (), cursor_image, 1, 1); gdk_pixbuf_unref (cursor_image); #if 0 if (preexisting) { XIEventMask mask = { dg->mpx, 0, "" }; if (XIUngrabDevice (gdk_x11_get_default_xdisplay (), dg->mpx, CurrentTime) != GrabSuccess) { g_warning ("Ungrab failed."); } if (XIGrabDevice (gdk_x11_get_default_xdisplay (), dg->mpx, GDK_ROOT_WINDOW(), CurrentTime, gdk_x11_cursor_get_xcursor (dg->cursor), GrabModeAsync, GrabModeAsync, True, &mask) != GrabSuccess) { g_warning ("Grab failed."); } } #endif }