static void
emoticon_tool_button_popdown (EEmoticonToolButton *button)
{
	GtkToggleToolButton *tool_button;

	if (!gtk_widget_get_realized (GTK_WIDGET (button)))
		return;

	if (!button->priv->popup_shown)
		return;

	/* Hide the pop-up. */
	gtk_device_grab_remove (button->priv->window, button->priv->grab_mouse);
	gtk_widget_hide (button->priv->window);

	/* Deactivate the tool button. */
	tool_button = GTK_TOGGLE_TOOL_BUTTON (button);
	gtk_toggle_tool_button_set_active (tool_button, FALSE);

	if (button->priv->grab_keyboard)
		gdk_device_ungrab (button->priv->grab_keyboard, GDK_CURRENT_TIME);
	if (button->priv->grab_mouse)
		gdk_device_ungrab (button->priv->grab_mouse, GDK_CURRENT_TIME);

	button->priv->grab_keyboard = NULL;
	button->priv->grab_mouse = NULL;
}
Esempio n. 2
0
static void
remove_popup (GtkWidget *popup)
{
	GdkWindow        *root;
#if GTK_CHECK_VERSION (3, 0, 0)
	GdkDisplay       *display;
	GdkDevice        *pointer;
	GdkDevice        *keyboard;
	GdkDeviceManager *device_manager;
#endif

	root = gdk_screen_get_root_window (
			gtk_window_get_screen (GTK_WINDOW (popup)));
	gdk_window_remove_filter (root, (GdkFilterFunc) popup_filter, popup);

	gtk_widget_destroy (popup);

#if GTK_CHECK_VERSION (3, 0, 0)
	display = gdk_window_get_display (root);
	device_manager = gdk_display_get_device_manager (display);
	pointer = gdk_device_manager_get_client_pointer (device_manager);
	keyboard = gdk_device_get_associated_device (pointer);

	gdk_device_ungrab (pointer, GDK_CURRENT_TIME);
	gdk_device_ungrab (keyboard, GDK_CURRENT_TIME);
#else
	gdk_pointer_ungrab (GDK_CURRENT_TIME);
	gdk_keyboard_ungrab (GDK_CURRENT_TIME);
#endif
}
Esempio n. 3
0
void
cg_combo_flags_popdown(CgComboFlags *combo)
{
	CgComboFlagsPrivate *priv;
	priv = CG_COMBO_FLAGS_PRIVATE (combo);

	if (priv->window != NULL)
	{
		gtk_grab_remove (priv->window);
		gdk_device_ungrab (priv->pointer_device, GDK_CURRENT_TIME);
		gdk_device_ungrab (priv->keyboard_device, GDK_CURRENT_TIME);
		gtk_widget_hide (priv->window);

		g_object_unref (priv->column);
		g_idle_add (cg_combo_flags_popdown_idle, priv->window);

		priv->window = NULL;
		priv->treeview = NULL;
		priv->column = NULL;

		if (priv->editing_started)
		{
			priv->editing_started = FALSE;
			gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (combo));

			/* Seems like someone already calls _remove_widget when the
			 * cell renderer emits its edited signal (which we rely on if
			 * the editing was not canceled). */
			if (priv->editing_canceled)
				gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (combo));
		}
	}
}
Esempio n. 4
0
static void
shutdown_grab (void)
{
  GdkDeviceManager *manager = gdk_display_get_device_manager (gdk_display_get_default ());
  GdkDevice *device = gdk_device_manager_get_client_pointer (manager);

  gdk_device_ungrab (device, gtk_get_current_event_time ());
  gdk_device_ungrab (gdk_device_get_associated_device (device), gtk_get_current_event_time ());
  gtk_grab_remove (grab_widget);
}
Esempio n. 5
0
void release_grab (GromitData *data,
                   GdkDevice *dev)
{
    if(!dev) /* this means release all grabs */
    {
        GHashTableIter it;
        gpointer value;
        GromitDeviceData* devdata;
        g_hash_table_iter_init (&it, data->devdatatable);
        while (g_hash_table_iter_next (&it, NULL, &value))
        {
            devdata = value;
            if(devdata->is_grabbed)
            {
                gdk_error_trap_push();
                gdk_device_ungrab(devdata->device, GDK_CURRENT_TIME);
                XSync(GDK_DISPLAY_XDISPLAY(data->display), False);
                if(gdk_error_trap_pop())
                    g_printerr("WARNING: Ungrabbing device '%s' failed.\n", gdk_device_get_name(devdata->device));

                devdata->is_grabbed = 0;
                /* workaround buggy GTK3 ? */
                devdata->motion_time = 0;
            }
        }

        data->all_grabbed = 0;

        if(data->debug)
            g_printerr ("DEBUG: Ungrabbed all Devices.\n");

        return;
    }


    /* get the data for this device */
    GromitDeviceData *devdata = g_hash_table_lookup(data->devdatatable, dev);

    if (devdata->is_grabbed)
    {
        gdk_device_ungrab(devdata->device, GDK_CURRENT_TIME);
        devdata->is_grabbed = 0;
        /* workaround buggy GTK3 ? */
        devdata->motion_time = 0;


        if(data->debug)
            g_printerr ("DEBUG: Ungrabbed Device '%s'.\n", gdk_device_get_name(devdata->device));
    }

    if (!data->painted)
        hide_window (data);
}
Esempio n. 6
0
static void
shutdown_grab (void)
{
#if GTK_CHECK_VERSION (3, 0, 0)
  GdkDeviceManager *manager = gdk_display_get_device_manager (gdk_display_get_default ());
  GdkDevice *device = gdk_device_manager_get_client_pointer (manager);

  gdk_device_ungrab (device, gtk_get_current_event_time ());
  gdk_device_ungrab (gdk_device_get_associated_device (device), gtk_get_current_event_time ());
#else
  gdk_keyboard_ungrab (gtk_get_current_event_time ());
  gdk_pointer_ungrab (gtk_get_current_event_time ());
#endif
  gtk_grab_remove (grab_widget);
}
Esempio n. 7
0
/* Stolen from GtkMenu */
static gboolean popup_grab_on_window(GdkWindow *window,
                                     GdkDevice *keyboard,
                                     GdkDevice *pointer,
                                     guint32  activate_time)
{
        if (keyboard &&
        gdk_device_grab(keyboard, window,
                         GDK_OWNERSHIP_WINDOW, TRUE,
                         GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
                         NULL, activate_time) != GDK_GRAB_SUCCESS)
        return FALSE;

        if (pointer &&
                gdk_device_grab(pointer, window,
                                GDK_OWNERSHIP_WINDOW, TRUE,
                                GDK_SMOOTH_SCROLL_MASK |
                                GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
                                GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
                                GDK_POINTER_MOTION_MASK,
                                NULL, activate_time) != GDK_GRAB_SUCCESS) {
                if (keyboard)
                        gdk_device_ungrab (keyboard, activate_time);

                return FALSE;
        }

  return TRUE;
}
Esempio n. 8
0
void XAP_gdk_pointer_ungrab(guint32 t)
{
	GdkDeviceManager *manager
		= gdk_display_get_device_manager(gdk_display_get_default());
	GdkDevice *device = gdk_device_manager_get_client_pointer (manager);
	gdk_device_ungrab (device, t);
}
Esempio n. 9
0
static gboolean
gtk_window_button_release_callback(GtkWidget* widget, GdkEventButton* gdk_event, wxMiniFrame* win)
{
    if (gdk_event->window != gtk_widget_get_window(widget))
        return false;
    if (g_blockEventsOnDrag) return TRUE;
    if (g_blockEventsOnScroll) return TRUE;
    if (!win->m_isDragging) return TRUE;

    win->m_isDragging = false;

    int x = (int)gdk_event->x;
    int y = (int)gdk_event->y;

#ifdef __WXGTK3__
    gdk_device_ungrab(gdk_event->device, gdk_event->time);
#else
    gdk_pointer_ungrab(gdk_event->time);
#endif
    int org_x = 0;
    int org_y = 0;
    gdk_window_get_origin(gtk_widget_get_window(widget), &org_x, &org_y);
    x += org_x - win->m_diffX;
    y += org_y - win->m_diffY;
    gtk_window_move( GTK_WINDOW(win->m_widget), x, y );

    return TRUE;
}
static void
go_combo_box_popup_hide_unconditional (GOComboBox *combo_box)
{
	gboolean popup_info_destroyed = FALSE;
	GObject *pdc;

	g_return_if_fail (combo_box != NULL);
	g_return_if_fail (GO_IS_COMBO_BOX (combo_box));

	gtk_widget_hide (combo_box->priv->toplevel);
	gtk_widget_hide (combo_box->priv->popup);
	if (combo_box->priv->torn_off)
		go_combo_set_tearoff_state (combo_box, FALSE);

	do_focus_change (combo_box->priv->toplevel, FALSE);
	gtk_grab_remove (combo_box->priv->toplevel);
	gdk_device_ungrab (gtk_get_current_event_device (),
	                   GDK_CURRENT_TIME);

	pdc = g_object_ref (combo_box->priv->popdown_container);
	g_signal_emit (combo_box,
		       go_combo_box_signals [POP_DOWN_DONE], 0,
		       pdc, &popup_info_destroyed);

	if (popup_info_destroyed){
		gtk_container_remove (
			GTK_CONTAINER (combo_box->priv->frame),
			combo_box->priv->popdown_container);
		combo_box->priv->popdown_container = NULL;
	}
	g_object_unref (pdc);
	set_arrow_state (combo_box, FALSE);
}
Esempio n. 11
0
/**************************************************************************
  Button released when showing info label
**************************************************************************/
static gboolean popit_button_release(GtkWidget *w, GdkEventButton *event)
{
  gtk_grab_remove(w);
  gdk_device_ungrab(event->device, event->time);
  gtk_widget_destroy(w);
  return FALSE;
}
Esempio n. 12
0
static gboolean
popup_grab_on_window (GtkWidget *widget, guint32 activate_time)
{
	GdkDeviceManager *manager;
	GdkDevice *pointer;
	GdkWindow *window;
	window = gtk_widget_get_window (widget);
	manager = gdk_display_get_device_manager (gtk_widget_get_display (widget));
	pointer = gdk_device_manager_get_client_pointer (manager);
        if (gdk_device_grab (pointer, window, GDK_OWNERSHIP_WINDOW, TRUE,
			     GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
			     GDK_POINTER_MOTION_MASK,
			     NULL, activate_time) == GDK_GRAB_SUCCESS) {
		GdkDevice *keyb;
		keyb = gdk_device_get_associated_device (pointer);
                if (gdk_device_grab (keyb, window, GDK_OWNERSHIP_WINDOW, TRUE,
				     GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK, NULL, activate_time) ==
		    GDK_GRAB_SUCCESS)
                         return TRUE;
                 else {
                        gdk_device_ungrab (pointer, activate_time);
			return FALSE;
		 }
        }
        return FALSE;
}
Esempio n. 13
0
static gboolean
gtk_window_button_release_callback(GtkWidget* widget, GdkEventButton* gdk_event, wxMiniFrame* win)
{
    if (gdk_event->window != gtk_widget_get_window(widget))
        return false;
    if (g_blockEventsOnDrag) return TRUE;
    if (g_blockEventsOnScroll) return TRUE;
    if (!win->m_isDragging) return TRUE;

    win->m_isDragging = false;

    int x = (int)gdk_event->x;
    int y = (int)gdk_event->y;

#ifdef __WXGTK4__
    gdk_seat_ungrab(gdk_event_get_seat((GdkEvent*)gdk_event));
#elif defined(__WXGTK3__)
    wxGCC_WARNING_SUPPRESS(deprecated-declarations)
    gdk_device_ungrab(gdk_event->device, gdk_event->time);
    wxGCC_WARNING_RESTORE()
#else
    gdk_pointer_ungrab(gdk_event->time);
#endif
    int org_x = 0;
    int org_y = 0;
    gdk_window_get_origin(gtk_widget_get_window(widget), &org_x, &org_y);
    x += org_x - win->m_diffX;
    y += org_y - win->m_diffY;
    gtk_window_move( GTK_WINDOW(win->m_widget), x, y );

    return TRUE;
}
Esempio n. 14
0
File: testsocket.c Progetto: BYC/gtk
static void
grab_window_toggled (GtkToggleButton *button,
		     GtkWidget       *widget)
{
  GdkDevice *device = gtk_get_current_event_device ();

  if (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD)
    device = gdk_device_get_associated_device (device);

  if (gtk_toggle_button_get_active (button))
    {
      int status;

      status = gdk_device_grab (device,
                                gtk_widget_get_window (widget),
                                GDK_OWNERSHIP_NONE,
                                FALSE,
                                GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
                                NULL,
                                GDK_CURRENT_TIME);

      if (status != GDK_GRAB_SUCCESS)
	g_warning ("Could not grab keyboard!  (%s)", grab_string (status));

    } 
  else 
    {
      gdk_device_ungrab (device, GDK_CURRENT_TIME);
    }
}
Esempio n. 15
0
void ygtk_popup_window_popup (GtkWidget *widget, gint x, gint y, guint activate_time)
{
	ygtk_popup_window_frame_position (widget, &x, &y);

	gtk_grab_add (widget);
	gtk_window_move (GTK_WINDOW (widget), x, y);
	gtk_widget_grab_focus (widget);
	gtk_widget_show (widget);

	GdkWindow *window = gtk_widget_get_window (widget);
	GdkDisplay *display = gdk_window_get_display (window);
	GdkDeviceManager *device_manager = gdk_display_get_device_manager (display);
	GdkDevice *pointer = gdk_device_manager_get_client_pointer (device_manager);

	// grab this with your teeth
	if (gdk_device_grab (pointer, window, GDK_OWNERSHIP_NONE, TRUE,
	        GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK,
	        NULL, activate_time) == 0) {
				GdkDevice *keyboard;
				keyboard = gdk_device_get_associated_device (pointer);
                if (gdk_device_grab (keyboard, window, GDK_OWNERSHIP_NONE, TRUE,
					GDK_KEY_PRESS | GDK_KEY_RELEASE, NULL, activate_time) != 0)
					gdk_device_ungrab (pointer, activate_time);
	}
}
Esempio n. 16
0
// http://permalink.gmane.org/gmane.comp.gnome.svn/520942
void XAP_gdk_keyboard_ungrab(guint32 t)
{
	GdkDeviceManager *manager
		= gdk_display_get_device_manager(gdk_display_get_default());
	GdkDevice *device = gdk_device_manager_get_client_pointer (manager);
	gdk_device_ungrab (gdk_device_get_associated_device(device),
			   t);
}
Esempio n. 17
0
/*
 * gtk_bubble_window_ungrab:
 * @window: a #GtkBubbleWindow
 *
 * This functions undoes a grab added through gtk_bubble_window_grab()
 * in this @window,
 *
 * Since: 3.8
 */
void
_gtk_bubble_window_ungrab (GtkBubbleWindow *window)
{
  GtkBubbleWindowPrivate *priv;

  g_return_if_fail (GTK_IS_BUBBLE_WINDOW (window));

  priv = window->priv;

  if (!priv->device)
    return;

  gdk_device_ungrab (priv->device, GDK_CURRENT_TIME);
  gdk_device_ungrab (gdk_device_get_associated_device (priv->device),
                     GDK_CURRENT_TIME);
  gtk_device_grab_remove (GTK_WIDGET (window), priv->device);
  priv->device = NULL;
}
Esempio n. 18
0
static void
gtk_popup_button_popdown_real (GtkPopupButton *popup_button)
{
	GtkPopupButtonPrivate *priv = popup_button->priv;
	
	g_return_if_fail (GTK_IS_POPUP_BUTTON (popup_button));
	
	if (!gtk_widget_get_realized (GTK_WIDGET (popup_button)))
		return;
	
	gdk_device_ungrab (priv->grab_keyboard, GDK_CURRENT_TIME);
	gdk_device_ungrab (priv->grab_pointer, GDK_CURRENT_TIME);
	gtk_device_grab_remove (priv->dock, priv->grab_pointer);
	gtk_widget_hide (priv->dock);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (popup_button), FALSE);
	
	priv->grab_pointer = NULL;
	priv->grab_keyboard = NULL;
}
Esempio n. 19
0
static void
begin_area_grab (void)
{
  GdkWindow *window;
  GdkDeviceManager *manager;
  GdkDevice *device;

  if (grab_widget == NULL)
    {
      grab_widget = gtk_invisible_new ();

      gtk_widget_add_events (grab_widget,
                             GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK);

      gtk_widget_show (grab_widget);
    }

  window = gtk_widget_get_window (grab_widget);
  manager = gdk_display_get_device_manager (gdk_display_get_default ());
  device = gdk_device_manager_get_client_pointer (manager);

  if (gdk_device_grab (device,
                       window,
                       GDK_OWNERSHIP_NONE,
                       FALSE,
                       GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK,
                       NULL,
                       gtk_get_current_event_time ()) != GDK_GRAB_SUCCESS)
    {
      g_warning ("Failed to grab pointer to do eyedropper");
      return;
    }

  if (gdk_device_grab (gdk_device_get_associated_device (device),
                       window,
                       GDK_OWNERSHIP_NONE,
                       FALSE,
                       GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
                       NULL,
                       gtk_get_current_event_time ()) != GDK_GRAB_SUCCESS)
    {
      gdk_device_ungrab (device, gtk_get_current_event_time ());
      g_warning ("Failed to grab keyboard to do eyedropper");
      return;
    }

  gtk_grab_add (grab_widget);

  g_signal_connect (grab_widget, "button_press_event",
                    G_CALLBACK (mouse_press), NULL);
  g_signal_connect (grab_widget, "key_press_event",
                    G_CALLBACK (key_press), NULL);
}
Esempio n. 20
0
/*
 * gtk_bubble_window_grab:
 * @window: a #GtkBubbleWindow
 * @device: a master #GdkDevice
 * @activate_time: timestamp to perform the grab
 *
 * This function performs GDK and GTK+ grabs on @device and
 * its paired #GdkDevice. After this call all pointer/keyboard
 * events will be handled by @window.
 *
 * Calling this also brings in a #GtkMenu alike behavior, clicking
 * outside the #GtkBubbleWindow or pressing the Escape key will
 * popdown the menu by default.
 *
 * <note>
 *   If there was a previous grab, it will be undone before doing
 *   the requested grab.
 * </note>
 *
 * Returns: %TRUE if the grab was successful
 *
 * Since: 3.8
 */
gboolean
_gtk_bubble_window_grab (GtkBubbleWindow *window,
                         GdkDevice       *device,
                         guint32          activate_time)
{
  GtkBubbleWindowPrivate *priv;
  GdkDevice *other_device;
  GdkWindow *grab_window;
  GdkGrabStatus status;

  g_return_val_if_fail (GTK_IS_BUBBLE_WINDOW (window), FALSE);
  g_return_val_if_fail (GDK_IS_DEVICE (device), FALSE);
  g_return_val_if_fail (gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_MASTER, FALSE);

  priv = window->priv;

  if (!priv->has_pointing_to ||
      gdk_window_is_destroyed (priv->relative_to))
    return FALSE;

  if (priv->device)
    _gtk_bubble_window_ungrab (window);

  gtk_widget_realize (GTK_WIDGET (window));
  grab_window = gtk_widget_get_window (GTK_WIDGET (window));
  other_device = gdk_device_get_associated_device (device);

  status = gdk_device_grab (device, grab_window,
                            GDK_OWNERSHIP_WINDOW, TRUE, GRAB_EVENT_MASK,
                            NULL, activate_time);

  if (status == GDK_GRAB_SUCCESS)
    {
      status = gdk_device_grab (other_device, grab_window,
                                GDK_OWNERSHIP_WINDOW, TRUE, GRAB_EVENT_MASK,
                                NULL, activate_time);

      /* Ungrab the first device on error */
      if (status != GDK_GRAB_SUCCESS)
        gdk_device_ungrab (device, activate_time);
    }

  if (status == GDK_GRAB_SUCCESS)
    {
      gtk_device_grab_add (GTK_WIDGET (window), device, TRUE);
      priv->device = device;
    }

  return status == GDK_GRAB_SUCCESS;
}
/**
 * go_combo_popup_tear_off
 * @combo:         Combo box
 * @set_position:  Set to position of popup shell if true
 *
 * Tear off the popup
 *
 * FIXME:
 * Gtk popup menus are toplevel windows, not dialogs. I think this is wrong,
 * and make the popups dialogs. But may be there should be a way to make
 * them toplevel. We can do this after creating:
 * GTK_WINDOW (tearoff)->type = GTK_WINDOW_TOPLEVEL;
 */
static void
go_combo_popup_tear_off (GOComboBox *combo, gboolean set_position)
{
	int x, y;

	if (!combo->priv->tearoff_window) {
		GtkWidget *tearoff;
		gchar const *title;

		/* FIXME: made this a toplevel, not a dialog ! */
		tearoff = gtk_window_new (GTK_WINDOW_TOPLEVEL);
		g_object_ref_sink (tearoff);
		combo->priv->tearoff_window = tearoff;
		gtk_widget_set_app_paintable (tearoff, TRUE);
		g_signal_connect (tearoff, "key_press_event",
				  G_CALLBACK (cb_combo_keypress),
				  combo);
		gtk_widget_realize (tearoff);
		title = go_combo_box_get_title (combo);
		if (title)
			gdk_window_set_title (gtk_widget_get_window (tearoff), title);
		gtk_window_set_transient_for
			(GTK_WINDOW (tearoff),
			 GTK_WINDOW (gtk_widget_get_toplevel
				     GTK_WIDGET (combo)));
	}

	if (gtk_widget_get_visible (combo->priv->popup)) {
		gtk_widget_hide (combo->priv->toplevel);

		gtk_grab_remove (combo->priv->toplevel);
			gdk_device_ungrab (gtk_get_current_event_device (),
					   GDK_CURRENT_TIME);
	}

	go_combo_popup_reparent (combo->priv->popup,
				  combo->priv->tearoff_window, FALSE);

	/* It may have got confused about size */
	gtk_widget_queue_resize (GTK_WIDGET (combo->priv->popup));

	if (set_position) {
		go_combo_box_get_pos (combo, &x, &y);
		gtk_window_move (GTK_WINDOW (combo->priv->tearoff_window), x, y);
	}
	gtk_widget_show (GTK_WIDGET (combo->priv->popup));
	gtk_widget_show (combo->priv->tearoff_window);

}
Esempio n. 22
0
static gboolean
property_query_event (GtkWidget *widget,
                      GdkEvent  *event,
                      gpointer   data)
{
  GtkInspectorWindow *iw = (GtkInspectorWindow *)data;

  if (event->type == GDK_BUTTON_RELEASE)
    {
      g_signal_handlers_disconnect_by_func (widget, property_query_event, data);
      gtk_grab_remove (widget);
      gdk_device_ungrab (gdk_event_get_device (event), GDK_CURRENT_TIME);
      on_inspect_widget (widget, event, data);
    }
  else if (event->type == GDK_MOTION_NOTIFY)
    {
      on_highlight_widget (widget, event, data);
    }
  else if (event->type == GDK_KEY_PRESS)
    {
      GdkEventKey *ke = (GdkEventKey*)event;
      GdkDevice *device;

      if (ke->keyval == GDK_KEY_Escape)
        {
          g_signal_handlers_disconnect_by_func (widget, property_query_event, data);
          gtk_grab_remove (widget);
          device = gdk_device_get_associated_device (gdk_event_get_device (event));
          gdk_device_ungrab (device, GDK_CURRENT_TIME);
          gdk_window_raise (gtk_widget_get_window (GTK_WIDGET (iw)));
          clear_flash (iw);
        }
    }

  return TRUE;
}
Esempio n. 23
0
static gboolean
on_widget_button_release (GtkWidget *widget,
			  GdkEventButton *event,
			  char *item_id)
{
  GdkDevice *device = gdk_event_get_device ((GdkEvent*) event);

  g_print ("%s received 'button-release' signal\n", item_id);

  if (device && strstr (item_id, "explicit"))
    {
      gdk_device_ungrab (device, event->time);
      g_print ("released pointer grab\n");
    }

  return TRUE;
}
Esempio n. 24
0
static void on_pointer_press(GtkWidget *widget, GdkEventButton *event, gpointer data)
{
    // Hide the volume scale
    hide_volume_scale();

    // Find the pointer device, if possible
    GdkDevice *device = gtk_get_current_event_device();
    if (device && gdk_device_get_source(device) == GDK_SOURCE_KEYBOARD)
        device = gdk_device_get_associated_device(device);
    if (!device) {
        g_printerr("Failed to find the pointer device\n");
        return;
    }

    // Ungrab it
    gdk_device_ungrab(device, GDK_CURRENT_TIME);
    gdk_flush();
}
Esempio n. 25
0
static void gstroke_cancel(GdkEvent *event)
{
	last_mouse_position.invalid = TRUE;

	if (timer_id > 0)
	    g_source_remove (timer_id);

	timer_id = 0;

	if( event != NULL )
		gdk_device_ungrab(gdk_event_get_device(event), event->button.time);

	if (gstroke_draw_strokes() && gstroke_disp != NULL) {
	    /* get rid of the invisible stroke window */
	    XUnmapWindow (gstroke_disp, gstroke_window);
	    XFlush (gstroke_disp);
	}

}
Esempio n. 26
0
/* Pulled from gtkcombobox.c */
static gboolean
popup_grab_on_window (GdkWindow *window,
                      GdkDevice *keyboard,
                      GdkDevice *pointer,
                      guint32    activate_time)
{

#if GTK_CHECK_VERSION(3,20,0)
    GdkDisplay *display = gdk_display_get_default ();
    GdkSeat *seat = gdk_display_get_default_seat (display);
    GdkEvent *event = gtk_get_current_event ();

    if (keyboard && gdk_seat_grab (seat, window, GDK_SEAT_CAPABILITY_KEYBOARD, TRUE, NULL,
                                   event, NULL, NULL) != GDK_GRAB_SUCCESS )
#else
    if (keyboard && gdk_device_grab (keyboard, window,
                                     GDK_OWNERSHIP_WINDOW, TRUE,
                                     GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
                                     NULL, activate_time) != GDK_GRAB_SUCCESS)
#endif
        return FALSE;

#if GTK_CHECK_VERSION(3,20,0)
    if (pointer && gdk_seat_grab (seat, window, GDK_SEAT_CAPABILITY_POINTER, TRUE, NULL,
                                  event, NULL, NULL) != GDK_GRAB_SUCCESS )
#else
    if (pointer && gdk_device_grab (pointer, window,
                                    GDK_OWNERSHIP_WINDOW, TRUE,
                                    GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
                                    GDK_POINTER_MOTION_MASK,
                                    NULL, activate_time) != GDK_GRAB_SUCCESS)
#endif
    {
        if (keyboard)
#if GTK_CHECK_VERSION(3,20,0)
            gdk_seat_ungrab (seat);
#else
            gdk_device_ungrab (keyboard, activate_time);
#endif
        return FALSE;
    }
    return TRUE;
}
Esempio n. 27
0
JS_EXPORT_API
void guide_enable_keyboard()
{
    // gdk_keyboard_ungrab(GDK_CURRENT_TIME);
    GdkWindow* window = gtk_widget_get_window(get_container());
    GdkDisplay* display = gdk_window_get_display(window);
    GdkDeviceManager* manager = gdk_display_get_device_manager(display);
    GList* devices = gdk_device_manager_list_devices(manager, GDK_DEVICE_TYPE_MASTER);
    GdkDevice* device = NULL;
    for (GList* dev = devices; dev != NULL; dev = dev->next) {
        device = GDK_DEVICE(dev->data);

        if (gdk_device_get_source(device) != GDK_SOURCE_KEYBOARD) {
            continue;
        }

        gdk_device_ungrab(device, GDK_CURRENT_TIME);
    }
    g_list_free(devices);
}
Esempio n. 28
0
void budgie_popover_hide(BudgiePopover *self)
{
        __attribute__ ((unused)) gboolean ret;
        /* tear us down */
        if (self->pointer) {
                gdk_device_ungrab(self->pointer, GDK_CURRENT_TIME);
                self->pointer = NULL;
        }
        gtk_widget_hide(GTK_WIDGET(self));
        if (self->con_id > 0 && self->parent_widget) {
                g_signal_handler_disconnect(self->parent_widget, self->con_id);
                self->parent_widget = NULL;
        }
        g_signal_handler_block(self, self->focus_id);
        g_signal_emit_by_name(self, "focus-out-event", NULL, &ret);
        g_signal_handler_unblock(self, self->focus_id);
        if (gtk_widget_get_realized(GTK_WIDGET(self)))
                gtk_widget_unrealize(GTK_WIDGET(self));
        self->con_id = 0;
}
Esempio n. 29
0
static gboolean
ungrab_keyboard (GtkWidget *win, GdkEvent *event, gpointer data)
{
#if GTK_CHECK_VERSION (3,0,0)
	if (grabbed_device) {
		g_signal_handler_disconnect (win, grab_broken_id);
		gdk_device_ungrab (grabbed_device, grabbed_at);
		gtk_device_grab_remove (win, grabbed_device);
		grabbed_device = NULL;
		grabbed_at = 0;
		grab_broken_id = 0;
	}
#else
	if (keyboard_grabbed)
		gdk_keyboard_ungrab (gdk_event_get_time (event));
	keyboard_grabbed = FALSE;
#endif

	/* Always return false, so event is handled elsewhere */
	return FALSE;
}
Esempio n. 30
0
static gboolean
on_widget_button_release (GtkWidget *widget,
			  GdkEventButton *event,
			  char *item_id)
{
  GdkDevice *device = gdk_event_get_device ((GdkEvent*) event);

  g_print ("%s received 'button-release' signal\n", item_id);

  if (device && strstr (item_id, "explicit"))
    {
#if GTK_CHECK_VERSION(3,20,0)
      gdk_seat_ungrab (gdk_device_get_seat (device));
#else
      gdk_device_ungrab (device, event->time);
#endif
      g_print ("released pointer grab\n");
    }

  return TRUE;
}