Пример #1
0
void
panel_force_quit (GdkScreen *screen,
		  guint      time)
{
	GdkGrabStatus  status;
	GdkCursor     *cross;
	GtkWidget     *popup;
	GdkWindow     *root;

	popup = display_popup_window (screen);

	root = gdk_screen_get_root_window (screen);

	gdk_window_add_filter (root, (GdkFilterFunc) popup_filter, popup);

	cross = gdk_cursor_new (GDK_CROSS);
	status = gdk_pointer_grab (root, FALSE, GDK_BUTTON_PRESS_MASK,
				   NULL, cross, time);
	gdk_cursor_unref (cross);
	if (status != GDK_GRAB_SUCCESS) {
		g_warning ("Pointer grab failed\n");
		remove_popup (popup);
		return;
	}

	status = gdk_keyboard_grab (root, FALSE, time);
	if (status != GDK_GRAB_SUCCESS) {
		g_warning ("Keyboard grab failed\n");
		remove_popup (popup);
		return;
	}

	gdk_flush ();
}
Пример #2
0
void
panel_force_quit (GdkScreen *screen,
                  guint      time)
{
    GdkGrabStatus  status;
    GdkCursor     *cross;
    GtkWidget     *popup;
    GdkWindow     *root;
    GdkDisplay    *display;
    GdkDevice     *pointer;
    GdkDevice     *keyboard;
    GdkDeviceManager *device_manager;

    popup = display_popup_window (screen);

    root = gdk_screen_get_root_window (screen);

    gdk_window_add_filter (root, (GdkFilterFunc) popup_filter, popup);

    cross = gdk_cursor_new (GDK_CROSS);

    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);

    status = gdk_device_grab (pointer, root,
                              GDK_OWNERSHIP_NONE, FALSE,
                              GDK_BUTTON_PRESS_MASK,
                              cross, time);

    g_object_unref (cross);

    if (status != GDK_GRAB_SUCCESS) {
        g_warning ("Pointer grab failed\n");
        remove_popup (popup);
        return;
    }

    status = gdk_device_grab (keyboard, root,
                              GDK_OWNERSHIP_NONE, FALSE,
                              GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
                              NULL, time);
    if (status != GDK_GRAB_SUCCESS) {
        g_warning ("Keyboard grab failed\n");
        remove_popup (popup);
        return;
    }

    gdk_flush ();
}