Esempio n. 1
0
/* Called by gdk_x11_display_finalize to flush any cached cursors
 * for a dead display.
 */
void
_gdk_x11_cursor_display_finalize (GdkDisplay *display)
{
  GSList* item;
  GSList** itemp; /* Pointer to the thing to fix when we delete an item */
  item = cursor_cache;
  itemp = &cursor_cache;
  while (item)
    {
      GdkX11Cursor* cursor = (GdkX11Cursor*)(item->data);
      if (gdk_cursor_get_display (GDK_CURSOR (cursor)) == display)
        {
          GSList* olditem;
          gdk_cursor_unref ((GdkCursor*) cursor);
          /* Remove this item from the list */
          *(itemp) = item->next;
          olditem = item;
          item = g_slist_next (item);
          g_slist_free_1 (olditem);
        } 
      else 
        {
          itemp = &(item->next);
          item = g_slist_next (item);
        }
    }
}
Esempio n. 2
0
static int
gdk_object_cursor_destructor(ClipMachine * ClipMachineMemory, C_object * ccur)
{
   if (ccur && GDK_IS_CURSOR(ccur) && ccur->ref_count >= 0)
      gdk_cursor_destroy(GDK_CURSOR(ccur->object));
   return 0;
}
Esempio n. 3
0
/* Returns 0 on a match
 */
static gint
cache_compare_func (gconstpointer listelem, 
                    gconstpointer target)
{
  GdkX11Cursor* cursor = (GdkX11Cursor*)listelem;
  struct cursor_cache_key* key = (struct cursor_cache_key*)target;

  if ((cursor->cursor.type != key->type) ||
      (gdk_cursor_get_display (GDK_CURSOR (cursor)) != key->display))
    return 1; /* No match */
  
  /* Elements marked as pixmap must be named cursors 
   * (since we don't store normal pixmap cursors 
   */
  if (key->type == GDK_CURSOR_IS_PIXMAP)
    return strcmp (key->name, cursor->name);

  return 0; /* Match */
}
Esempio n. 4
0
static void
gdk_cursor_get_property (GObject    *object,
                         guint       prop_id,
                         GValue     *value,
                         GParamSpec *pspec)
{
  GdkCursor *cursor = GDK_CURSOR (object);

  switch (prop_id)
    {
    case PROP_CURSOR_TYPE:
      g_value_set_enum (value, cursor->type);
      break;
    case PROP_DISPLAY:
      g_value_set_object (value, cursor->display);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}
Esempio n. 5
0
/* Grabs the pointer (usually a mouse) so that all events are passed to this
 * application until the pointer is ungrabbed with gdk_pointer_ungrab(), or
 * the grab window becomes unviewable. This overrides any previous pointer
 * grab by this client.

 * Pointer grabs are used for operations which need complete control over mouse
 * events, even if the mouse leaves the application. For example in GTK+ it is
 * used for Drag and Drop, for dragging the handle in the GtkHPaned and GtkVPaned
 * widgets, and for resizing columns in GtkCList widgets.

 * Note that if the event mask of an X window has selected both button press and
 * button release events, then a button press event will cause an automatic pointer
 * grab until the button is released. X does this automatically since most
 * applications expect to receive button press and release events in pairs.
 * It is equivalent to a pointer grab on the window with owner_events set to TRUE. */
int
clip_GDK_POINTERGRAB(ClipMachine * ClipMachineMemory)
{
   C_widget *cwin = _fetch_cw_arg(ClipMachineMemory);

   GdkWindow *win = NULL;

   gboolean  owner_events = _clip_parl(ClipMachineMemory, 2);

   GdkEventMask event_mask = _clip_parnl(ClipMachineMemory, 3);

   C_widget *cconfine_to = _fetch_cwidget(ClipMachineMemory, _clip_spar(ClipMachineMemory, 4));

   GdkWindow *confine_to = NULL;

   C_object *ccursor = _fetch_cobject(ClipMachineMemory, _clip_spar(ClipMachineMemory, 5));

   GdkCursor *cursor = NULL;

   CHECKCWID(cwin, GTK_IS_WIDGET);
   CHECKOPT(2, LOGICAL_type_of_ClipVarType);
   CHECKOPT(3, NUMERIC_type_of_ClipVarType);
   CHECKOPT2(4, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType);
   CHECKCWIDOPT(cwin, GTK_IS_WIDGET);
   CHECKOPT2(5, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType);
   CHECKCOBJOPT(ccursor, GDK_IS_CURSOR(ccursor));

   if (cwin && cwin->widget)
      win = cwin->widget->window;
   if (cconfine_to && cconfine_to->widget)
      confine_to = cconfine_to->widget->window;
   if (ccursor)
      cursor = GDK_CURSOR(ccursor->object);

   _clip_retni(ClipMachineMemory, gdk_pointer_grab(win, owner_events, event_mask, confine_to, cursor, GDK_CURRENT_TIME));

   return 0;
 err:
   return 1;
}
Esempio n. 6
0
static void
gdk_cursor_set_property (GObject      *object,
                         guint         prop_id,
                         const GValue *value,
                         GParamSpec   *pspec)
{
  GdkCursor *cursor = GDK_CURSOR (object);

  switch (prop_id)
    {
    case PROP_CURSOR_TYPE:
      cursor->type = g_value_get_enum (value);
      break;
    case PROP_DISPLAY:
      cursor->display = g_value_get_object (value);
      /* check that implementations actually provide the display when constructing */
      g_assert (cursor->display != NULL);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}
Esempio n. 7
0
    }
}

/*** GdkX11Cursor ***/

G_DEFINE_TYPE (GdkX11Cursor, gdk_x11_cursor, GDK_TYPE_CURSOR)

static GdkPixbuf* gdk_x11_cursor_get_image (GdkCursor *cursor);

static void
gdk_x11_cursor_finalize (GObject *object)
{
  GdkX11Cursor *private = GDK_X11_CURSOR (object);
  GdkDisplay *display;

  display = gdk_cursor_get_display (GDK_CURSOR (object));
  if (private->xcursor && !gdk_display_is_closed (display))
    XFreeCursor (GDK_DISPLAY_XDISPLAY (display), private->xcursor);

  g_free (private->name);

  G_OBJECT_CLASS (gdk_x11_cursor_parent_class)->finalize (object);
}

static void
gdk_x11_cursor_class_init (GdkX11CursorClass *xcursor_class)
{
  GdkCursorClass *cursor_class = GDK_CURSOR_CLASS (xcursor_class);
  GObjectClass *object_class = G_OBJECT_CLASS (xcursor_class);

  object_class->finalize = gdk_x11_cursor_finalize;