Exemple #1
0
GdkGrabStatus
gdk_directfb_keyboard_grab (GdkDisplay *display,
                            GdkWindow  *window,
                            gint        owner_events,
                            guint32     time)
{
  GdkWindow             *toplevel;
  GdkWindowImplDirectFB *impl;

  g_return_val_if_fail (GDK_IS_WINDOW (window), 0);

  if (_gdk_directfb_keyboard_grab_window)
    gdk_keyboard_ungrab (time);

  toplevel = gdk_directfb_window_find_toplevel (window);
  impl = GDK_WINDOW_IMPL_DIRECTFB (GDK_WINDOW_OBJECT (toplevel)->impl);

  if (impl->window)
    {
      if (impl->window->GrabKeyboard (impl->window) == DFB_LOCKED)
        return GDK_GRAB_ALREADY_GRABBED;
    }

  _gdk_directfb_keyboard_grab_window = g_object_ref (window);
  _gdk_directfb_keyboard_grab_owner_events = owner_events;
  return GDK_GRAB_SUCCESS;
}
static void
shutdown_grab (void)
{
  gdk_keyboard_ungrab (gtk_get_current_event_time ());
  gdk_pointer_ungrab (gtk_get_current_event_time ());
  gtk_grab_remove (grab_widget);
}
Exemple #3
0
void end_key_grab(KeyGrabButton *self)
{
    KeyGrabButton* b = KEYGRAB_BUTTON(self);
    gdk_keyboard_ungrab(gtk_get_current_event_time());
    g_signal_handler_disconnect(b->popup, b->handler);
    gtk_widget_destroy(b->popup);
}
Exemple #4
0
void xmms_fullscreen_leave(GtkWidget * win)
{
	fullscreen_window_t *fwin;

	FULL_LOCK();
	fwin = getwindow(win);

	if (fwin->is_full && fwin->display->is_full)
	{
		/* Release our grabs */
		gdk_pointer_ungrab(GDK_CURRENT_TIME);
		gdk_keyboard_ungrab(GDK_CURRENT_TIME);

		/* Let the WM manage this window again */
		gdk_window_hide(fwin->window->window);
		gdk_window_set_override_redirect(fwin->window->window, FALSE);
		gdk_window_show(fwin->window->window);

		/* Restore size/position */
		gdk_window_move_resize(fwin->window->window, fwin->ox, fwin->oy,
				       fwin->owidth, fwin->oheight);

		XF86VidModeSwitchToMode(fwin->display->display,
					DefaultScreen(fwin->display->display),
					fwin->display->origmode);
		fwin->display->is_full = FALSE;
	}
	fwin->is_full = FALSE;
	FULL_UNLOCK();
}
Exemple #5
0
static void
gul_gestures_stop (GulGestures *as)
{
	GulGesturesPrivate *p = as->priv;

	/* ungrab the pointer if it's grabbed */
	if (gdk_pointer_is_grabbed ())
	{
		gdk_pointer_ungrab (gtk_get_current_event_time ());
	}

	gdk_keyboard_ungrab (gtk_get_current_event_time ());

	g_return_if_fail (p->widget);
	
	gtk_grab_remove (p->widget);

	/* disconnect all of the signals */
	g_signal_handlers_disconnect_matched (p->widget, G_SIGNAL_MATCH_DATA, 0, 0, 
					      NULL, NULL, as);

	g_object_unref (p->widget);
	p->widget = NULL;
	p->started = FALSE;

	g_object_unref (as);
}
Exemple #6
0
static void keyboard_grab(int grab)
{
#ifdef DEBUGNOKBDGRAB
    DBG(("keyboard_grab disabled (%d)", grab));
#else
    GtkWidget *widget;
    GdkWindow *window;

    DBG(("keyboard_grab (%d, was %d)", grab, keyboard_grabbed));

    if (grab == keyboard_grabbed) {
        return;
    }

    /*ui_dispatch_events();
    gdk_flush();*/

    if (grab) {
        widget = get_active_toplevel();
        window = widget ? widget->window : NULL;

        if ((widget == NULL) || (window == NULL)) {
            log_error(ui_log, "keyboard_grab: bad params");
            return;
        }

        gdk_keyboard_grab(window, 1, GDK_CURRENT_TIME);
        keyboard_grabbed = 1;
    } else {
        gdk_keyboard_ungrab(GDK_CURRENT_TIME);
        keyboard_grabbed = 0;
    }
#endif
}
Exemple #7
0
/*!
 *\brief	this handler will probably evolve into
 *		something better.
 */
static void crash_handler(int sig)
{
    pid_t pid;
    static volatile unsigned long crashed_ = 0;

    /*
     * let's hope argv0 aren't trashed.
     * both are defined in main.c.
     */
    extern gchar *argv0;


    /*
     * besides guarding entrancy it's probably also better
     * to mask off signals
     */
    if (crashed_) return;

    crashed_++;

#ifdef SIGTERM
    if (sig == SIGTERM)
        clean_quit(NULL);
#endif

    /*
     * gnome ungrabs focus, and flushes gdk. mmmh, good idea.
     */
    gdk_pointer_ungrab(GDK_CURRENT_TIME);
    gdk_keyboard_ungrab(GDK_CURRENT_TIME);
    gdk_flush();

    if (0 == (pid = fork())) {
        char buf[50];
        char *args[5];

        /*
         * probably also some other parameters (like GTK+ ones).
         * also we pass the full startup dir and the real command
         * line typed in (argv0)
         */
        args[0] = argv0;
        args[1] = "--debug";
        args[2] = "--crash";
        sprintf(buf, "%d,%d,%s", getppid(), sig, argv0);
        args[3] = buf;
        args[4] = NULL;

        chdir(sylpheed_get_startup_dir());
        setgid(getgid());
        setuid(getuid());
        execvp(argv0, args);
    } else {
        waitpid(pid, NULL, 0);
        crash_cleanup_exit();
        _exit(253);
    }

    _exit(253);
}
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
}
/* Remove grab.  */
static void
ungrab_keyboard (GtkWidget *win, GdkEvent *event, gpointer data)
{
    gdk_keyboard_ungrab (gdk_event_get_time (event));
    /* Unmake window transient for the root window.  */
    gdk_window_set_transient_for (win->window, NULL);
}
Exemple #10
0
/**
 * Release the display grab.
 */
void video_window_ungrab_display( main_window_t win )
{
    gdk_pointer_ungrab(GDK_CURRENT_TIME);
    gdk_keyboard_ungrab(GDK_CURRENT_TIME);
    win->is_grabbed = FALSE;
    main_window_set_running(win, dreamcast_is_running());
}
Exemple #11
0
static gboolean
grab_key_callback (GtkWidget    *widget,
                   GdkEventKey  *event,
                   void         *data)
{
  char *path;
  CellRendererKey* key = CELL_RENDERER_KEY(data);
  guint scancode = event->hardware_keycode;

  gdk_keyboard_ungrab (event->time);
  gdk_pointer_ungrab (event->time);

  path = g_strdup (g_object_get_data (G_OBJECT (key->edit_widget), CELL_RENDERER_TEXT_PATH));

  gtk_cell_editable_editing_done(GTK_CELL_EDITABLE (key->edit_widget));
  gtk_cell_editable_remove_widget(GTK_CELL_EDITABLE (key->edit_widget));
  key->edit_widget = NULL;
  key->grab_widget = NULL;

  cell_renderer_key_set_scancode(key, scancode);
  g_signal_emit_by_name (G_OBJECT(key), "accel_edited", path, scancode);

  g_free (path);
  return TRUE;
}
Exemple #12
0
gboolean hotkey_released(GtkWidget   *dialog,
			 GdkEventKey *ev,
			 PrefsData   *data) {
  gdk_keyboard_ungrab (GDK_CURRENT_TIME);
  gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
  return FALSE;
}
static void
popup_button_popdown (PlannerPopupButton *button,
		      gboolean            ok)
{
	PlannerPopupButtonPriv *priv;

	priv = GET_PRIV (button);

	if (!priv->popup_widget) {
		return;
	}

	gtk_widget_hide (priv->popup_window);

	g_object_ref (priv->popup_widget);
	gtk_container_remove (GTK_CONTAINER (priv->popup_window),
			      priv->popup_widget);

	g_signal_emit (button, signals[POPDOWN], 0, priv->popup_widget, ok);

	g_object_unref (priv->popup_widget);
	priv->popup_widget = NULL;

	if (gtk_widget_has_grab (priv->popup_window)) {
		gtk_grab_remove (priv->popup_window);
		gdk_keyboard_ungrab (GDK_CURRENT_TIME);
		gdk_pointer_ungrab (GDK_CURRENT_TIME);
	}
}
/**
* win: ignored
* event: the event that triggered ungrabbing
* data: ignored
*
* Will ungrab the keyboard
*
* Returns FALSE
**/
static gboolean
ungrab_keyboard (GtkWidget *win, GdkEvent *event, gpointer data)
{
	if (keyboard_grabbed)
		gdk_keyboard_ungrab (gdk_event_get_time (event));
	keyboard_grabbed = FALSE;
	return FALSE;
}
Exemple #15
0
void
uni_nav_release (UniNav * nav)
{
    gdk_pointer_ungrab (GDK_CURRENT_TIME);

    /* Release keyboard focus. */
    gdk_keyboard_ungrab (GDK_CURRENT_TIME);
    gtk_grab_remove (nav->preview);
}
static void ungrab_stuff(GtkWidget* widget, gpointer data)
{
	EggCellRendererKeys* keys = EGG_CELL_RENDERER_KEYS(data);

	gdk_keyboard_ungrab(GDK_CURRENT_TIME);
	gdk_pointer_ungrab(GDK_CURRENT_TIME);

	g_signal_handlers_disconnect_by_func(G_OBJECT(keys->grab_widget), G_CALLBACK(grab_key_callback), data);
}
Exemple #17
0
void aquire_hotkey(const char* widget_name,
		   PrefsData *data) {
  gint resp, action;
  GtkWidget  *diag = data->hotkey_dialog;

  action = 
    (!strcmp(widget_name,"mute_eventbox"))?
    0:
    (!strcmp(widget_name,"up_eventbox"))?
    1:
    (!strcmp(widget_name,"down_eventbox"))?
    2:-1;

  if (action < 0) {
    report_error("Invalid widget passed to aquire_hotkey: %s",widget_name);
    return;
  }

  switch(action) {
  case 0:
    gtk_label_set_text(GTK_LABEL(data->hotkey_key_label),_("Mute/Unmute"));
    break;
  case 1:
    gtk_label_set_text(GTK_LABEL(data->hotkey_key_label),_("Volume Up"));
    break;
  case 2:
    gtk_label_set_text(GTK_LABEL(data->hotkey_key_label),_("Volume Down"));
    break;
  default:
    break;
  }

  // grab keyboard
  if (G_LIKELY(gdk_keyboard_grab(gtk_widget_get_root_window(GTK_WIDGET(diag)), TRUE, GDK_CURRENT_TIME) == GDK_GRAB_SUCCESS)) {
    resp = gtk_dialog_run(GTK_DIALOG(diag));
    gdk_keyboard_ungrab (GDK_CURRENT_TIME);
    if (resp == GTK_RESPONSE_OK) {
      const gchar* key_name = gtk_label_get_text(GTK_LABEL(data->hotkey_key_label));
      switch(action) {
      case 0:
	gtk_label_set_text(GTK_LABEL(data->mute_hotkey_label),key_name);
	break;
      case 1:
	gtk_label_set_text(GTK_LABEL(data->up_hotkey_label),key_name);
	break;
      case 2:
	gtk_label_set_text(GTK_LABEL(data->down_hotkey_label),key_name);
	break;
      default:
	break;
      }
    }
  }
  else
    report_error("%s", _("Could not grab the keyboard."));
  gtk_widget_hide(diag);
}
Exemple #18
0
static gboolean
gs_grab_release_keyboard (GSGrab *grab)
{
        gs_debug ("Ungrabbing keyboard");
        gdk_keyboard_ungrab (GDK_CURRENT_TIME);

        gs_grab_keyboard_reset (grab);

        return TRUE;
}
/* ungrab_keyboard - remove grab */
static gboolean
ungrab_keyboard (GtkWidget *win, GdkEvent *event, gpointer data)
{
#ifndef _DEBUG
	if (g_object_get_data (G_OBJECT (win), "keyboard-grabbed"))
		gdk_keyboard_ungrab (gdk_event_get_time (event));
	g_object_set_data (G_OBJECT (win), "keyboard-grabbed", NULL);
#endif
	return FALSE;
}
Exemple #20
0
gint switch_fullscreen(GtkWidget *gl_area)
{
  static GtkWidget *fullscreenwidget = NULL;

  if (!fullscreenwidget)
    {
      /* Grab keyboard and pointer so that user does not wander off the game
	 window while in fullscreen mode.
      */
      if (gdk_keyboard_grab(gl_area->window, FALSE, GDK_CURRENT_TIME) == 0)
	{
	  if (gdk_pointer_grab(gl_area->window, FALSE, 0, NULL, NULL, GDK_CURRENT_TIME) == 0)
	    {
	      gtk_widget_grab_focus(gl_area);
	      if (gtk_gl_area_make_current(GTK_GL_AREA(gl_area)))
		{
		  if (XMesaSetFXmode((XMESA_FX_FULLSCREEN)))
		    {
		      fullscreenwidget = gl_area;
		      return TRUE;
		    }
		}
	      gdk_pointer_ungrab(GDK_CURRENT_TIME);
	    }
	  gdk_keyboard_ungrab(GDK_CURRENT_TIME);
	}
      return FALSE;
    }

  if (fullscreenwidget == gl_area)
    {
      if (gtk_gl_area_make_current(GTK_GL_AREA(gl_area)))
	XMesaSetFXmode(XMESA_FX_WINDOW);

      gdk_keyboard_ungrab(GDK_CURRENT_TIME);
      gdk_pointer_ungrab(GDK_CURRENT_TIME);
      fullscreenwidget = NULL;
      return TRUE;
    }

  return FALSE;
}
Exemple #21
0
/* Remove grab.  */
static void
ungrab_keyboard (GtkWidget *win, GdkEvent *event, gpointer data)
{
  gdk_keyboard_ungrab (gdk_event_get_time (event));
  /* Unmake window transient for the root window.  */
  /* gdk_window_set_transient_for cannot be used with parent = NULL to
     unset transient hint (unlike gtk_ version which can).  Replacement
     code is taken from gtk_window_transient_parent_unrealized.  */
  gdk_property_delete (win->window,
                       gdk_atom_intern_static_string ("WM_TRANSIENT_FOR"));
}
static gint
history_popup_clicked_cb(GtkWidget *widget, gpointer data)
{
    gdk_pointer_ungrab(GDK_CURRENT_TIME);
    gdk_keyboard_ungrab(GDK_CURRENT_TIME);
    gtk_grab_remove(GTK_WIDGET(widget));
    gtk_widget_destroy(GTK_WIDGET(widget));
    widget = NULL;
     
    /* go on */
    return (FALSE);
}
Exemple #23
0
static void
remove_popup (GtkWidget *popup)
{
	GdkWindow *root;

	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);
	gdk_pointer_ungrab (GDK_CURRENT_TIME);
	gdk_keyboard_ungrab (GDK_CURRENT_TIME);
}
static gboolean
history_key_press_cb (GtkWidget *widget, GdkEventKey *event, gpointer data)
{
    if (event->keyval == GDK_Escape) {
        gdk_pointer_ungrab(GDK_CURRENT_TIME);
        gdk_keyboard_ungrab(GDK_CURRENT_TIME);
        gtk_grab_remove(GTK_WIDGET(widget));
        gtk_widget_destroy(GTK_WIDGET(widget));
        widget = NULL;
    }

    return FALSE;
    
}
Exemple #25
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);
}
void VNCCanvas::ungrab_keyboard()
{
#ifdef __WXGTK__
  // ungrab
  gdk_keyboard_ungrab(GDK_CURRENT_TIME);
  // restore to saved values
  GtkSettings *settings = gtk_settings_get_for_screen(gdk_screen_get_default());
  g_object_set(settings, "gtk-enable-mnemonics", saved_enable_mnemonics, NULL);
  g_object_set(settings, "gtk-enable-accels", saved_enable_accels, NULL);
  g_object_set(settings, "gtk-menu-bar-accel", saved_menubar_accel, NULL);

#endif

  keyboard_grabbed = false;
  wxLogDebug(wxT("VNCCanvas %p: ungrabbed keyboard"), this);
}
Exemple #27
0
static gboolean
release_grabs (void)
{
        /* Make sure we release grabs */
        gdk_pointer_ungrab(GDK_CURRENT_TIME);
        gdk_keyboard_ungrab(GDK_CURRENT_TIME);

        /* TODO: can we replace this with gdk_x11_ungrab_server ()?
         * see http://bugzilla.gnome.org/show_bug.cgi?id=550135.
         */
	XUngrabServer (GDK_DISPLAY ());

        gdk_flush();

	return TRUE;
}
Exemple #28
0
static gboolean
grab_available (GdkWindow *win, guint32 timestamp)
{
    GdkEventMask mask;
    GdkGrabStatus g1;
    GdkGrabStatus g2;
    gboolean grab_failed;
    gint i;

    TRACE ("entering grab_available");

    mask = GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
           GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
           GDK_POINTER_MOTION_MASK;
    g1 = gdk_pointer_grab (win, TRUE, mask, NULL, NULL, timestamp);
    g2 = gdk_keyboard_grab (win, TRUE, timestamp);
    grab_failed = FALSE;

    i = 0;
    while ((i++ < 100) && (grab_failed = ((g1 != GDK_GRAB_SUCCESS)
                || (g2 != GDK_GRAB_SUCCESS))))
    {
        TRACE ("grab not available yet, waiting... (%i)", i);
        g_usleep (100);
        if (g1 != GDK_GRAB_SUCCESS)
        {
            g1 = gdk_pointer_grab (win, TRUE, mask, NULL, NULL, timestamp);
        }
        if (g2 != GDK_GRAB_SUCCESS)
        {
            g2 = gdk_keyboard_grab (win, TRUE, timestamp);
        }
    }

    if (g1 == GDK_GRAB_SUCCESS)
    {
        gdk_pointer_ungrab (timestamp);
    }
    if (g2 == GDK_GRAB_SUCCESS)
    {
        gdk_keyboard_ungrab (timestamp);
    }

    return (!grab_failed);
}
Exemple #29
0
static void
grab_window_toggled (GtkToggleButton *button,
		     GtkWidget       *widget)
{

  if (gtk_toggle_button_get_active (button))
    {
      int status;

      status = gdk_keyboard_grab (widget->window, FALSE, GDK_CURRENT_TIME);

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

    } 
  else 
    {
      gdk_keyboard_ungrab (GDK_CURRENT_TIME);
    }
}
Exemple #30
0
static void
clear_key_callback(GtkButton *widget, gpointer data)
{
  char *path;
  CellRendererKey* key = CELL_RENDERER_KEY(data);

  gdk_keyboard_ungrab(GDK_CURRENT_TIME);
  gdk_pointer_ungrab(GDK_CURRENT_TIME);

  path = g_strdup (g_object_get_data (G_OBJECT (key->edit_widget), CELL_RENDERER_TEXT_PATH));

  gtk_cell_editable_editing_done(GTK_CELL_EDITABLE (key->edit_widget));
  gtk_cell_editable_remove_widget(GTK_CELL_EDITABLE (key->edit_widget));
  key->edit_widget = NULL;
  key->grab_widget = NULL;

  cell_renderer_key_set_scancode(key, 0);
  g_signal_emit_by_name (G_OBJECT(key), "accel_cleared", path);

  g_free (path);
}