void ChromeClient::setCursor(const Cursor& cursor)
{
    // [GTK] Widget::setCursor() gets called frequently
    // http://bugs.webkit.org/show_bug.cgi?id=16388
    // Setting the cursor may be an expensive operation in some backends,
    // so don't re-set the cursor if it's already set to the target value.
    GdkWindow* window = gtk_widget_get_window(platformPageClient());
    GdkCursor* currentCursor = gdk_window_get_cursor(window);
    GdkCursor* newCursor = cursor.platformCursor().get();
    if (currentCursor != newCursor)
        gdk_window_set_cursor(window, newCursor);
}
Ejemplo n.º 2
0
static void chatroom_enable_hand_cursor(GdkWindow *window, gboolean hand_cursor_enabled) {
#if GTK_CHECK_VERSION(2,22,0)
	GdkCursor *cursor = gdk_window_get_cursor(window);
	GdkCursor *new_cursor = NULL;
	if(!hand_cursor_enabled && gdk_cursor_get_cursor_type(cursor) != GDK_XTERM) {
		new_cursor = gdk_cursor_new(GDK_XTERM);
	} else if(hand_cursor_enabled && gdk_cursor_get_cursor_type(cursor) != GDK_HAND1) {
		new_cursor = gdk_cursor_new(GDK_HAND1);
	}
	if(new_cursor) {
		gdk_window_set_cursor(window, new_cursor);
		gdk_cursor_unref(new_cursor);
	}
#endif
}
Ejemplo n.º 3
0
void trace_put_cursor(void)
{
	GdkWindow *window;
	GdkCursor *cursor;

	if (!parent_window)
		return;

	window = GTK_WIDGET(parent_window)->window;
	cursor = gdk_window_get_cursor(window);
	if (cursor)
		gdk_cursor_unref(cursor);

	cursor = pop_cursor();
	gdk_window_set_cursor(window, cursor);
}
Ejemplo n.º 4
0
void trace_set_cursor(GdkCursorType type)
{
	GdkWindow *window;
	GdkCursor *cursor;

	if (!parent_window)
		return;

	window = GTK_WIDGET(parent_window)->window;

	/* save the previous cursor */
	cursor = gdk_window_get_cursor(window);
	push_cursor(cursor);

	cursor = gdk_cursor_new(type);
	if (!cursor)
		die("Can't create cursor");
	gdk_window_set_cursor(window, cursor);
}
Ejemplo n.º 5
0
/**
 * glade_cursor_set:
 * @window: a #GdkWindow
 * @type: a #GladeCursorType
 *
 * Sets the cursor for @window to something appropriate based on @type.
 * (also sets the cursor on all visible project widgets)
 */
void
glade_cursor_set (GladeProject    *project,
                  GdkWindow       *window, 
                  GladeCursorType  type)
{
  GladeWidgetAdaptor *adaptor;
  GdkCursor *the_cursor = NULL;
  g_return_if_fail (cursor != NULL);

  switch (type)
    {
      case GLADE_CURSOR_SELECTOR:
        the_cursor = cursor->selector;
        break;
      case GLADE_CURSOR_ADD_WIDGET:
        if ((adaptor =
             glade_project_get_add_item (project)) != NULL)
          {
            g_object_get (adaptor, "cursor", &the_cursor, NULL);

            if (the_cursor == NULL)
              the_cursor = cursor->add_widget;
          }
        else
          the_cursor = cursor->add_widget;
        break;
      case GLADE_CURSOR_RESIZE_TOP_LEFT:
        the_cursor = cursor->resize_top_left;
        break;
      case GLADE_CURSOR_RESIZE_TOP_RIGHT:
        the_cursor = cursor->resize_top_right;
        break;
      case GLADE_CURSOR_RESIZE_BOTTOM_LEFT:
        the_cursor = cursor->resize_bottom_left;
        break;
      case GLADE_CURSOR_RESIZE_BOTTOM_RIGHT:
        the_cursor = cursor->resize_bottom_right;
        break;
      case GLADE_CURSOR_RESIZE_LEFT:
        the_cursor = cursor->resize_left;
        break;
      case GLADE_CURSOR_RESIZE_RIGHT:
        the_cursor = cursor->resize_right;
        break;
      case GLADE_CURSOR_RESIZE_TOP:
        the_cursor = cursor->resize_top;
        break;
      case GLADE_CURSOR_RESIZE_BOTTOM:
        the_cursor = cursor->resize_bottom;
        break;
      case GLADE_CURSOR_DRAG:
        the_cursor = cursor->drag;
        break;
      default:
        break;
    }

  if (the_cursor != gdk_window_get_cursor (window))
    {
      set_cursor (project, cursor->selector);
      gdk_window_set_cursor (window, the_cursor);
    }
}