Example #1
0
static gboolean
gs_grab_move_keyboard (GSGrab    *grab,
                       GdkWindow *window,
                       GdkScreen *screen)
{
    gboolean   result;
    GdkWindow *old_window;
    GdkScreen *old_screen;

    if (grab->priv->keyboard_grab_window == window)
    {
        gs_debug ("Window %X is already grabbed, skipping",
                  (guint32) GDK_WINDOW_XID (grab->priv->keyboard_grab_window));
        return TRUE;
    }

    if (grab->priv->keyboard_grab_window != NULL)
    {
        gs_debug ("Moving keyboard grab from %X to %X",
                  (guint32) GDK_WINDOW_XID (grab->priv->keyboard_grab_window),
                  (guint32) GDK_WINDOW_XID (window));
    }
    else
    {
        gs_debug ("Getting keyboard grab on %X",
                  (guint32) GDK_WINDOW_XID (window));

    }

    gs_debug ("*** doing X server grab");
    gdk_x11_grab_server ();

    old_window = grab->priv->keyboard_grab_window;
    old_screen = grab->priv->keyboard_grab_screen;

    if (old_window)
    {
        gs_grab_release_keyboard (grab);
    }

    result = gs_grab_get_keyboard (grab, window, screen);

    if (result != GDK_GRAB_SUCCESS)
    {
        sleep (1);
        result = gs_grab_get_keyboard (grab, window, screen);
    }

    if ((result != GDK_GRAB_SUCCESS) && old_window)
    {
        gs_debug ("Could not grab keyboard for new window.  Resuming previous grab.");
        gs_grab_get_keyboard (grab, old_window, old_screen);
    }

    gs_debug ("*** releasing X server grab");
    gdk_x11_ungrab_server ();
    gdk_flush ();

    return (result == GDK_GRAB_SUCCESS);
}
Example #2
0
static void
on_screen_monitors_changed (GdkScreen *screen,
                            GSManager *manager)
{
        GSList *l;
        int     n_monitors;
        int     n_windows;
        int     i;

        n_monitors = gdk_screen_get_n_monitors (screen);
        n_windows = g_slist_length (manager->priv->windows);

        gs_debug ("Monitors changed for screen %d: num=%d",
                  gdk_screen_get_number (screen),
                  n_monitors);

        if (n_monitors > n_windows) {

                /* add more windows */
                for (i = n_windows; i < n_monitors; i++) {
                        gs_manager_create_window_for_monitor (manager, screen, i);
                }
        } else {

                gdk_x11_grab_server ();

                /* remove the extra windows */
                l = manager->priv->windows;
                while (l != NULL) {
                        GdkScreen *this_screen;
                        int        this_monitor;
                        GSList    *next = l->next;

                        this_screen = gs_window_get_screen (GS_WINDOW (l->data));
                        this_monitor = gs_window_get_monitor (GS_WINDOW (l->data));
                        if (this_screen == screen && this_monitor >= n_monitors) {
                                gs_window_destroy (GS_WINDOW (l->data));
                                manager->priv->windows = g_slist_delete_link (manager->priv->windows, l);
                        }
                        l = next;
                }

                gdk_flush ();
                gdk_x11_ungrab_server ();
        }

	for (l = manager->priv->windows; l != NULL; l = l->next) {
		GdkScreen *this_screen;

		this_screen = gs_window_get_screen (GS_WINDOW (l->data));
		if (this_screen == screen) {
			gtk_widget_queue_resize (GTK_WIDGET (l->data));
		}
	}
}
Example #3
0
static void
on_display_monitor_removed (GdkDisplay *display,
                            GdkMonitor *monitor,
                            GSManager  *manager)
{
	GSList     *l;
	int         n_monitors;

	n_monitors = gdk_display_get_n_monitors (display);

	gs_debug ("Monitor removed on display %s, now there are %d",
	          gdk_display_get_name (display), n_monitors);

	gdk_x11_grab_server ();

	/* remove the now extra window */
	l = manager->priv->windows;
	while (l != NULL)
	{
		GdkDisplay *this_display;
		GdkMonitor *this_monitor;
		GSList     *next = l->next;

		this_display = gs_window_get_display (GS_WINDOW (l->data));
		this_monitor = gs_window_get_monitor (GS_WINDOW (l->data));
		if (this_display == display && this_monitor == monitor)
		{
			manager_maybe_stop_job_for_window (manager,
			                                   GS_WINDOW (l->data));
			g_hash_table_remove (manager->priv->jobs, l->data);
			gs_window_destroy (GS_WINDOW (l->data));
			manager->priv->windows = g_slist_delete_link (manager->priv->windows, l);
		}
		l = next;
	}

	gdk_display_flush (display);
	gdk_x11_ungrab_server ();
}
Example #4
0
static gboolean
gs_grab_move_mouse (GSGrab    *grab,
                    GdkWindow *window,
                    GdkScreen *screen,
                    gboolean   hide_cursor)
{
        gboolean   result;
        GdkWindow *old_window;
        GdkScreen *old_screen;
        gboolean   old_hide_cursor;

        /* if the pointer is not grabbed and we have a
           mouse_grab_window defined then we lost the grab */
        if (! gdk_pointer_is_grabbed ()) {
                gs_grab_mouse_reset (grab);
        }

        if (grab->priv->mouse_grab_window == window) {
                gs_debug ("Window %X is already grabbed, skipping",
                          (guint32) GDK_WINDOW_XID (grab->priv->mouse_grab_window));
                return TRUE;
        }

#if 0
        gs_debug ("Intentionally skipping move pointer grabs");
        /* FIXME: GTK doesn't like having the pointer grabbed */
        return TRUE;
#else
        if (grab->priv->mouse_grab_window) {
                gs_debug ("Moving pointer grab from %X to %X",
                          (guint32) GDK_WINDOW_XID (grab->priv->mouse_grab_window),
                          (guint32) GDK_WINDOW_XID (window));
        } else {
                gs_debug ("Getting pointer grab on %X",
                          (guint32) GDK_WINDOW_XID (window));
        }
#endif

        gs_debug ("*** doing X server grab");
        gdk_x11_grab_server ();

        old_window = grab->priv->mouse_grab_window;
        old_screen = grab->priv->mouse_grab_screen;
        old_hide_cursor = grab->priv->mouse_hide_cursor;

        if (old_window) {
                gs_grab_release_mouse (grab);
        }

        result = gs_grab_get_mouse (grab, window, screen, hide_cursor);

        if (result != GDK_GRAB_SUCCESS) {
                sleep (1);
                result = gs_grab_get_mouse (grab, window, screen, hide_cursor);
        }

        if ((result != GDK_GRAB_SUCCESS) && old_window) {
                gs_debug ("Could not grab mouse for new window.  Resuming previous grab.");
                gs_grab_get_mouse (grab, old_window, old_screen, old_hide_cursor);
        }

        gs_debug ("*** releasing X server grab");
        gdk_x11_ungrab_server ();
        gdk_flush ();

        return (result == GDK_GRAB_SUCCESS);
}
Example #5
0
static VALUE
rg_s_ungrab_server(G_GNUC_UNUSED VALUE self)
{
    gdk_x11_ungrab_server();
    return Qnil;
}
Example #6
0
static void
on_screen_monitors_changed (GdkScreen *screen,
                            GSManager *manager)
{
	GSList *l;
	int     n_monitors;
	int     n_windows;
	int     i;

	n_monitors = gdk_screen_get_n_monitors (screen);
	n_windows = g_slist_length (manager->priv->windows);

	gs_debug ("Monitors changed for screen %d: num=%d",
	          gdk_screen_get_number (screen),
	          n_monitors);

	if (n_monitors > n_windows)
	{

		/* Tear down unlock dialog in case we want to move it
		 * to a new monitor
		 */
		l = manager->priv->windows;
		while (l != NULL)
		{
			gs_window_cancel_unlock_request (GS_WINDOW (l->data));
			l = l->next;
		}

		/* add more windows */
		for (i = n_windows; i < n_monitors; i++)
		{
			gs_manager_create_window_for_monitor (manager, screen, i);
		}

		/* And put unlock dialog up where ever it's supposed to be
		 */
		gs_manager_request_unlock (manager);
	}
	else
	{

		gdk_x11_grab_server ();

		/* remove the extra windows */
		l = manager->priv->windows;
		while (l != NULL)
		{
			GdkScreen *this_screen;
			int        this_monitor;
			GSList    *next = l->next;

			this_screen = gs_window_get_screen (GS_WINDOW (l->data));
			this_monitor = gs_window_get_monitor (GS_WINDOW (l->data));
			if (this_screen == screen && this_monitor >= n_monitors)
			{
				manager_maybe_stop_job_for_window (manager, GS_WINDOW (l->data));
				g_hash_table_remove (manager->priv->jobs, l->data);
				gs_window_destroy (GS_WINDOW (l->data));
				manager->priv->windows = g_slist_delete_link (manager->priv->windows, l);
			}
			l = next;
		}

		/* make sure there is a lock dialog on a connected monitor,
		 * and that the keyboard is still properly grabbed after all
		 * the windows above got destroyed*/
		if (n_windows > n_monitors)
		{
			gs_manager_request_unlock (manager);
		}

		gdk_flush ();
		gdk_x11_ungrab_server ();
	}
}
Example #7
0
static VALUE
rbx11_ungrab_server(VALUE self)
{
    gdk_x11_ungrab_server();
    return Qnil;
}