Exemplo n.º 1
0
/* Dump actors */
static void _xfdashboard_dump_actor_print(ClutterActor *inActor, gint inLevel)
{
	XfdashboardStylable		*stylable;
	ClutterActorBox			allocation;
	gint					i;

	g_return_if_fail(CLUTTER_IS_ACTOR(inActor));
	g_return_if_fail(inLevel>=0);

	/* Check if actor is stylable to retrieve style configuration */
	stylable=NULL;
	if(XFDASHBOARD_IS_STYLABLE(inActor)) stylable=XFDASHBOARD_STYLABLE(inActor);

	/* Dump actor */
	for(i=0; i<inLevel; i++) g_print("  ");
	clutter_actor_get_allocation_box(inActor, &allocation);
	g_print("+- %s@%p [%s%s%s%s%s%s] - geometry: %.2f,%.2f [%.2fx%.2f], mapped: %s, visible: %s, layout: %s, children: %d\n",
				G_OBJECT_TYPE_NAME(inActor), inActor,
				clutter_actor_get_name(inActor) ? " #" : "",
				clutter_actor_get_name(inActor) ? clutter_actor_get_name(inActor) : "",
				stylable && xfdashboard_stylable_get_classes(stylable) ? "." : "",
				stylable && xfdashboard_stylable_get_classes(stylable) ? xfdashboard_stylable_get_classes(stylable) : "",
				stylable && xfdashboard_stylable_get_pseudo_classes(stylable) ? ":" : "",
				stylable && xfdashboard_stylable_get_pseudo_classes(stylable) ? xfdashboard_stylable_get_pseudo_classes(stylable) : "",
				allocation.x1,
				allocation.y1,
				allocation.x2-allocation.x1,
				allocation.y2-allocation.y1,
				clutter_actor_is_mapped(inActor) ? "yes" : "no",
				clutter_actor_is_visible(inActor) ? "yes" : "no",
				clutter_actor_get_layout_manager(inActor) ? G_OBJECT_TYPE_NAME(clutter_actor_get_layout_manager(inActor)) : "none",
				clutter_actor_get_n_children(inActor));

}
Exemplo n.º 2
0
static void
clutter_clone_paint (ClutterActor *self)
{
  ClutterClone *clone = CLUTTER_CLONE (self);
  ClutterClonePrivate *priv = clone->priv;
  ClutterGeometry geom, clone_geom;
  gfloat x_scale, y_scale;
  gboolean was_unmapped = FALSE;

  if (G_UNLIKELY (priv->clone_source == NULL))
    return;

  CLUTTER_NOTE (PAINT,
                "painting clone actor '%s'",
		clutter_actor_get_name (self) ? clutter_actor_get_name (self)
                                              : "unknown");

  /* get our allocated size */
  clutter_actor_get_allocation_geometry (self, &geom);

  /* and get the allocated size of the source */
  clutter_actor_get_allocation_geometry (priv->clone_source, &clone_geom);

  /* We need to scale what the clone-source actor paints to fill our own
   * allocation...
   */
  x_scale = (gfloat) geom.width  / clone_geom.width;
  y_scale = (gfloat) geom.height / clone_geom.height;

  cogl_scale (x_scale, y_scale, 1.0);

  /* The final bits of magic:
   * - We need to make sure that when the clone-source actor's paint
   *   method calls clutter_actor_get_paint_opacity, it traverses to
   *   us and our parent not it's real parent.
   * - We need to stop clutter_actor_paint applying the model view matrix of
   *   the clone source actor.
   */
  _clutter_actor_set_opacity_parent (priv->clone_source, self);
  _clutter_actor_set_enable_model_view_transform (priv->clone_source, FALSE);

  if (!CLUTTER_ACTOR_IS_MAPPED (priv->clone_source))
    {
      _clutter_actor_set_enable_paint_unmapped (priv->clone_source, TRUE);
      was_unmapped = TRUE;
    }

  clutter_actor_paint (priv->clone_source);

  if (was_unmapped)
    _clutter_actor_set_enable_paint_unmapped (priv->clone_source, FALSE);

  _clutter_actor_set_enable_model_view_transform (priv->clone_source, TRUE);
  _clutter_actor_set_opacity_parent (priv->clone_source, NULL);
}
Exemplo n.º 3
0
/*
 * _clutter_input_device_update:
 * @device: a #ClutterInputDevice
 *
 * Updates the input @device by determining the #ClutterActor underneath the
 * pointer's cursor
 *
 * This function calls _clutter_input_device_set_actor() if needed.
 *
 * This function only works for #ClutterInputDevice of type
 * %CLUTTER_POINTER_DEVICE.
 *
 * Since: 1.2
 */
ClutterActor *
_clutter_input_device_update (ClutterInputDevice *device,
                              gboolean            emit_crossing)
{
  ClutterStage *stage;
  ClutterActor *new_cursor_actor;
  ClutterActor *old_cursor_actor;
  gint x, y;

  if (device->device_type == CLUTTER_KEYBOARD_DEVICE)
    return NULL;

  stage = device->stage;
  if (G_UNLIKELY (stage == NULL))
    {
      CLUTTER_NOTE (EVENT, "No stage defined for device '%s'",
                    clutter_input_device_get_device_name (device));
      return NULL;
    }

  clutter_input_device_get_device_coords (device, &x, &y);

  old_cursor_actor = device->cursor_actor;
  new_cursor_actor = _clutter_do_pick (stage, x, y, CLUTTER_PICK_REACTIVE);

  /* if the pick could not find an actor then we do not update the
   * input device, to avoid ghost enter/leave events; the pick should
   * never fail, except for bugs in the glReadPixels() implementation
   * in which case this is the safest course of action anyway
   */
  if (new_cursor_actor == NULL)
    return NULL;

  CLUTTER_NOTE (EVENT,
                "Actor under cursor (device %d, at %d, %d): %s",
                clutter_input_device_get_device_id (device),
                x, y,
                clutter_actor_get_name (new_cursor_actor) != NULL
                  ? clutter_actor_get_name (new_cursor_actor)
                  : G_OBJECT_TYPE_NAME (new_cursor_actor));

  /* short-circuit here */
  if (new_cursor_actor == old_cursor_actor)
    return old_cursor_actor;

  _clutter_input_device_set_actor (device, new_cursor_actor, emit_crossing);

  return device->cursor_actor;
}
Exemplo n.º 4
0
static void
clutter_group_real_paint (ClutterActor *actor)
{
  ClutterGroupPrivate *priv = CLUTTER_GROUP (actor)->priv;

  CLUTTER_NOTE (PAINT, "ClutterGroup paint enter '%s'",
                clutter_actor_get_name (actor) ? clutter_actor_get_name (actor)
                                               : "unknown");

  g_list_foreach (priv->children, (GFunc) clutter_actor_paint, NULL);

  CLUTTER_NOTE (PAINT, "ClutterGroup paint leave '%s'",
                clutter_actor_get_name (actor) ? clutter_actor_get_name (actor)
                                               : "unknown");
}
Exemplo n.º 5
0
/* Dump actors */
static void _xfdashboard_dump_actor_internal(ClutterActor *inActor, gint inLevel)
{
	ClutterActorIter	iter;
	ClutterActor		*child;
	gint				i;

	g_return_if_fail(CLUTTER_IS_ACTOR(inActor));
	g_return_if_fail(inLevel>=0);

	clutter_actor_iter_init(&iter, CLUTTER_ACTOR(inActor));
	while(clutter_actor_iter_next(&iter, &child))
	{
		for(i=0; i<inLevel; i++) g_print("  ");
		g_print("+- %s@%p - name: %s - geometry: %.2f,%.2f [%.2fx%.2f], mapped: %s, visible: %s, children: %d\n",
					G_OBJECT_TYPE_NAME(child), child,
					clutter_actor_get_name(child),
					clutter_actor_get_x(child),
					clutter_actor_get_y(child),
					clutter_actor_get_width(child),
					clutter_actor_get_height(child),
					clutter_actor_is_mapped(child) ? "yes" : "no",
					clutter_actor_is_visible(child) ? "yes" : "no",
					clutter_actor_get_n_children(child));
		if(clutter_actor_get_n_children(child)>0) _xfdashboard_dump_actor_internal(child, inLevel+1);
	}
}
static void
mpl_panel_background_allocate (ClutterActor          *actor,
                               const ClutterActorBox *box,
                               ClutterAllocationFlags flags)
{
  MplPanelBackgroundPrivate *priv = MPL_PANEL_BACKGROUND (actor)->priv;
#if 0
  ClutterActor              *border;

  border = mx_widget_get_border_image (MX_WIDGET (actor));

  /*
   * We need to use different background asset based on the size allocated to us
   * -- basically, the panel cannot be smaller than the size of the borders of
   * its border image (see MB#702), so if it is smaller than the current asset
   * allows, we change the asset to simpler one.
   *
   * The code here assumes that we either have no name, or are called
   * 'too-small', but since this is a private widget of libmeego-panel, we can
   * enforce this assumption.
   */
  if (border)
    {
      const gchar *name = clutter_actor_get_name (actor);
      gboolean     too_small = FALSE;

      /*
       * Get the dimensions of the base texture (we are guaranteed to be called
       * first with name == NULL, so this works).
       */
      if (!priv->base_geom_known && !name)
        {
          mx_texture_frame_get_border_values (/*MX_TEXTURE_FRAME*/ (border),
                                              &priv->base_t,
                                              &priv->base_r,
                                              &priv->base_b,
                                              &priv->base_l);

          priv->base_geom_known = TRUE;
        }

      if (priv->base_l + priv->base_r > box->x2 - box->x1 ||
          priv->base_t + priv->base_b > box->y2 - box->y1)
        {
          too_small = TRUE;
        }

      if (!name && too_small)
        {
          clutter_actor_set_name (actor, "too-small");
        }
      else if (name && !too_small)
        {
          clutter_actor_set_name (actor, NULL);
        }
    }
#endif //DV
  CLUTTER_ACTOR_CLASS (
             mpl_panel_background_parent_class)->allocate (actor, box, flags);
}
Exemplo n.º 7
0
static void
droppable_group_drop (MxDroppable       *droppable,
                      MxDraggable       *draggable,
                      gfloat               event_x,
                      gfloat               event_y,
                      gint                 button,
                      ClutterModifierType  modifiers)
{
  ClutterActor *self = CLUTTER_ACTOR (droppable);
  ClutterActor *child = CLUTTER_ACTOR (draggable);

  g_debug ("%s: dropped %s on '%s' (%s) at %.2f, %.2f",
           G_STRLOC,
           G_OBJECT_TYPE_NAME (draggable),
           clutter_actor_get_name (self),
           G_OBJECT_TYPE_NAME (droppable),
           event_x, event_y);

  g_object_ref (draggable);

  clutter_actor_reparent (child, self);
  clutter_actor_set_position (CLUTTER_ACTOR (draggable),
                              (event_x < 100) ? 50 : 100,
                              (event_y < 100) ? 50 : 100);

  g_object_unref (draggable);
}
static gboolean
_pointer_motion_cb (ClutterActor *actor,
                    ClutterEvent *event,
                    gpointer      user_data)
{
  gfloat stage_x, stage_y;
  gfloat actor_x, actor_y;

  /* get the coordinates where the pointer crossed into the actor */
  clutter_event_get_coords (event, &stage_x, &stage_y);

  /*
   * as the coordinates are relative to the stage, rather than
   * the actor which emitted the signal, it can be useful to
   * transform them to actor-relative coordinates
   */
  clutter_actor_transform_stage_point (actor,
                                       stage_x, stage_y,
                                       &actor_x, &actor_y);

  g_debug ("pointer on actor %s @ x %.0f, y %.0f",
           clutter_actor_get_name (actor),
           actor_x, actor_y);

  return TRUE;
}
Exemplo n.º 9
0
void
clicked_cb (ClutterClickAction *action,
            ClutterActor       *actor,
            gpointer            user_data)
{
  g_print ("Pointer button %d clicked on actor %s\n",
           clutter_click_action_get_button (action),
           clutter_actor_get_name (actor));
}
Exemplo n.º 10
0
static void
on_transition_stopped (ClutterActor *actor,
                       const gchar  *transition_name,
                       gboolean      is_finished)
{
  g_print ("%s: transition stopped: %s (finished: %s)\n",
           clutter_actor_get_name (actor),
           transition_name,
           is_finished ? "yes" : "no");
}
Exemplo n.º 11
0
static gboolean
button_pressed_cb (ClutterActor *actor,
                   ClutterEvent *event,
                   gpointer      user_data)
{
  ClutterState *transitions = CLUTTER_STATE (user_data);

  /* set the state to the one with a name matching the actor's name */
  clutter_state_set_state (transitions, clutter_actor_get_name (actor));

  return TRUE;
}
Exemplo n.º 12
0
static void
draggable_rectangle_parent_set (ClutterActor *actor,
                                ClutterActor *old_parent)
{
  ClutterActor *new_parent = clutter_actor_get_parent (actor);

  g_debug ("%s: old_parent: %s, new_parent: %s (%s)",
           G_STRLOC,
           old_parent ? G_OBJECT_TYPE_NAME (old_parent) : "none",
           new_parent ? clutter_actor_get_name (new_parent) : "Unknown",
           new_parent ? G_OBJECT_TYPE_NAME (new_parent) : "none");
}
Exemplo n.º 13
0
/*
 * _clutter_meta_group_add_meta:
 * @group: a #ClutterMetaGroup
 * @meta: a #ClutterActorMeta to add
 *
 * Adds @meta to @group
 *
 * This function will remove the floating reference of @meta or, if the
 * floating reference has already been sunk, add a reference to it
 */
void
_clutter_meta_group_add_meta (ClutterMetaGroup *group,
                              ClutterActorMeta *meta)
{
  GList *prev = NULL, *l;

  if (meta->priv->actor != NULL)
    {
      g_warning ("The meta of type '%s' with name '%s' is "
                 "already attached to actor '%s'",
                 G_OBJECT_TYPE_NAME (meta),
                 meta->priv->name != NULL
                   ? meta->priv->name
                   : "<unknown>",
                 clutter_actor_get_name (meta->priv->actor) != NULL
                   ? clutter_actor_get_name (meta->priv->actor)
                   : G_OBJECT_TYPE_NAME (meta->priv->actor));
      return;
    }

  /* Find a meta that has lower priority and insert before that */
  for (l = group->meta; l; l = l->next)
    if (_clutter_actor_meta_get_priority (l->data) <
        _clutter_actor_meta_get_priority (meta))
      break;
    else
      prev = l;

  if (prev == NULL)
    group->meta = g_list_prepend (group->meta, meta);
  else
    {
      prev->next = g_list_prepend (prev->next, meta);
      prev->next->prev = prev;
    }

  g_object_ref_sink (meta);

  _clutter_actor_meta_set_actor (meta, group->actor);
}
Exemplo n.º 14
0
/*
 * _clutter_meta_group_remove_meta:
 * @group: a #ClutterMetaGroup
 * @meta: a #ClutterActorMeta to remove
 *
 * Removes @meta from @group and releases the reference being held on it
 */
void
_clutter_meta_group_remove_meta (ClutterMetaGroup *group,
                                 ClutterActorMeta *meta)
{
  if (meta->priv->actor != group->actor)
    {
      g_warning ("The meta of type '%s' with name '%s' is not "
                 "attached to the actor '%s'",
                 G_OBJECT_TYPE_NAME (meta),
                 meta->priv->name != NULL
                   ? meta->priv->name
                   : "<unknown>",
                 clutter_actor_get_name (group->actor) != NULL
                   ? clutter_actor_get_name (group->actor)
                   : G_OBJECT_TYPE_NAME (group->actor));
      return;
    }

  _clutter_actor_meta_set_actor (meta, NULL);

  group->meta = g_list_remove (group->meta, meta);
  g_object_unref (meta);
}
Exemplo n.º 15
0
/*
 * _clutter_meta_group_add_meta:
 * @group: a #ClutterMetaGroup
 * @meta: a #ClutterActorMeta to add
 *
 * Adds @meta to @group
 *
 * This function will remove the floating reference of @meta or, if the
 * floating reference has already been sunk, add a reference to it
 */
void
_clutter_meta_group_add_meta (ClutterMetaGroup *group,
                              ClutterActorMeta *meta)
{
  if (meta->priv->actor != NULL)
    {
      g_warning ("The meta of type '%s' with name '%s' is "
                 "already attached to actor '%s'",
                 G_OBJECT_TYPE_NAME (meta),
                 meta->priv->name != NULL
                   ? meta->priv->name
                   : "<unknown>",
                 clutter_actor_get_name (meta->priv->actor) != NULL
                   ? clutter_actor_get_name (meta->priv->actor)
                   : G_OBJECT_TYPE_NAME (meta->priv->actor));
      return;
    }

  group->meta = g_list_append (group->meta, meta);
  g_object_ref_sink (meta);

  _clutter_actor_meta_set_actor (meta, group->actor);
}
Exemplo n.º 16
0
/* Default implementation of virtual function "get_name" */
static const gchar* _xfdashboard_stylable_real_get_name(XfdashboardStylable *self)
{
	const gchar			*name;

	g_return_val_if_fail(XFDASHBOARD_IS_STYLABLE(self), NULL);

	name=NULL;

	/* If object implementing this interface is derived from ClutterActor
	 * get actor's name.
	 */
	if(CLUTTER_IS_ACTOR(self)) name=clutter_actor_get_name(CLUTTER_ACTOR(self));

	/* Return determined name for stylable object */
	return(name);
}
Exemplo n.º 17
0
/**
 * clutter_container_find_child_by_name:
 * @container: a #ClutterContainer
 * @child_name: the name of the requested child.
 *
 * Finds a child actor of a container by its name. Search recurses
 * into any child container.
 *
 * Return value: (transfer none): The child actor with the requested name,
 *   or %NULL if no actor with that name was found.
 *
 * Since: 0.6
 */
ClutterActor *
clutter_container_find_child_by_name (ClutterContainer *container,
                                      const gchar      *child_name)
{
  GList        *children;
  GList        *iter;
  ClutterActor *actor = NULL;

  g_return_val_if_fail (CLUTTER_IS_CONTAINER (container), NULL);
  g_return_val_if_fail (child_name != NULL, NULL);

  children = clutter_container_get_children (container);

  for (iter = children; iter; iter = g_list_next (iter))
    {
      ClutterActor *a;
      const gchar  *iter_name;

      a = CLUTTER_ACTOR (iter->data);
      iter_name = clutter_actor_get_name (a);

      if (iter_name && !strcmp (iter_name, child_name))
        {
          actor = a;
          break;
        }

      if (CLUTTER_IS_CONTAINER (a))
        {
          ClutterContainer *c = CLUTTER_CONTAINER (a);

          actor = clutter_container_find_child_by_name (c, child_name);
          if (actor)
            break;
	}
    }

  g_list_free (children);

  return actor;
}
Exemplo n.º 18
0
/**
 * st_widget_get_theme_node:
 * @widget: a #StWidget
 *
 * Gets the theme node holding style information for the widget.
 * The theme node is used to access standard and custom CSS
 * properties of the widget.
 *
 * Return value: (transfer none): the theme node for the widget.
 *   This is owned by the widget. When attributes of the widget
 *   or the environment that affect the styling change (for example
 *   the style_class property of the widget), it will be recreated,
 *   and the ::style-changed signal will be emitted on the widget.
 */
StThemeNode *
st_widget_get_theme_node (StWidget *widget)
{
  StWidgetPrivate *priv = widget->priv;

  if (priv->theme_node == NULL)
    {
      StThemeNode *parent_node = NULL;
      ClutterStage *stage = NULL;
      ClutterActor *parent;

      parent = clutter_actor_get_parent (CLUTTER_ACTOR (widget));
      while (parent != NULL)
        {
          if (parent_node == NULL && ST_IS_WIDGET (parent))
            parent_node = st_widget_get_theme_node (ST_WIDGET (parent));
          else if (CLUTTER_IS_STAGE (parent))
            stage = CLUTTER_STAGE (parent);

          parent = clutter_actor_get_parent (parent);
        }

      if (stage == NULL)
        {
          g_error ("st_widget_get_theme_node called on a widget not in a stage");
        }

      if (parent_node == NULL)
        parent_node = get_root_theme_node (CLUTTER_STAGE (stage));

      priv->theme_node = st_theme_node_new (st_theme_context_get_for_stage (stage),
                                            parent_node, priv->theme,
                                            G_OBJECT_TYPE (widget),
                                            clutter_actor_get_name (CLUTTER_ACTOR (widget)),
                                            priv->style_class,
                                            priv->pseudo_class,
                                            priv->inline_style);
    }

  return priv->theme_node;
}
Exemplo n.º 19
0
/**
 * Custom handler for the signals in the ClutterScript.
 * Slots are turned into Message instances
 */
static void tempi_clutter_connect_signals(
    ClutterScript *script,
    GObject *object,
    const gchar *signal_name,
    const gchar *handler_name,
    GObject *connect_object,
    GConnectFlags flags,
    gpointer user_data)
{
    SignalConnection::ptr conn(new SignalConnection);
    //std::cout << __FUNCTION__ << ": sig:" << signal_name << ", handler:" << handler_name << std::endl;

    // store info about the signal we are connecting to:
    //std::cout << "set signal name to " << signal_name << " length:" << strlen(signal_name) << std::endl;
    conn->signal_name_.assign(signal_name, strlen(signal_name));

    //std::cout << "set handler name to " << handler_name << " length:" << strlen(handler_name) << std::endl;
    conn->handler_name_.assign(handler_name, strlen(handler_name));

    if (CLUTTER_IS_ACTOR(object))
    {
        //std::cout << "set actor name to " << clutter_actor_get_name(CLUTTER_ACTOR(object)) << std::endl;
        const char *actor_name = clutter_actor_get_name(CLUTTER_ACTOR(object));
        if (actor_name != NULL)
            conn->actor_name_.assign(actor_name, strlen(actor_name));
    }
    else
        std::cout << "Not an ClutterActor." << std::endl;
    // Store the connection object in the app:
    StageManager *manager = static_cast<StageManager *>(user_data);
    conn->manager_ = manager;
    manager->connections_.push_back(conn);

    // connect the signal to our generic callback:
    if (! g_signal_connect(object, signal_name, G_CALLBACK(tempi_clutter_event_cb), conn.get()))
    {
        g_critical("%s: Couldn't connect to signal %s", __FUNCTION__, signal_name);
    }
}
Exemplo n.º 20
0
/**
 * xfdashboard_find_actor_by_name:
 * @inActor: The root #ClutterActor where to begin searching
 * @inName: A string containg the name of the #ClutterActor to lookup
 *
 * Iterates through all children of @inActor recursively and looks for
 * the child having the name as specified at @inName.
 *
 * Return value: (transfer none): The #ClutterActor matching the name
 *   to lookup or %NULL if none was found.
 */
ClutterActor* xfdashboard_find_actor_by_name(ClutterActor *inActor, const gchar *inName)
{
	ClutterActorIter	iter;
	ClutterActor		*child;
	ClutterActor		*result;

	g_return_val_if_fail(CLUTTER_IS_ACTOR(inActor), NULL);
	g_return_val_if_fail(inName && *inName, NULL);

	/* Check if given actor is the one we should lookup */
	if(g_strcmp0(clutter_actor_get_name(inActor), inName)==0) return(inActor);

	/* For each child of actor call ourselve recursive */
	clutter_actor_iter_init(&iter, inActor);
	while(clutter_actor_iter_next(&iter, &child))
	{
		result=xfdashboard_find_actor_by_name(child, inName);
		if(result) return(result);
	}

	/* If we get here you could not find actor having this name set */
	return(NULL);
}
Exemplo n.º 21
0
static gboolean 
on_input (ClutterStage *stage,
	  ClutterEvent *event,
	  gpointer      user_data)
{
  App *app = (App*)user_data;

  if (event->type == CLUTTER_BUTTON_PRESS)
    {
      ClutterActor *actor = clutter_event_get_source (event);
      const gchar  *label = clutter_actor_get_name (actor);
      int          label_val;

      if (app->dialing_state == TRUE)
	    {
	      call_deactivate(app);
	      return TRUE;
	    }

      /* retrieve button id (stored in the Actor's name) */
      if ( !label )
        return FALSE;
      label_val = atoi(label);
      if ( label_val < 1 || label_val > 12 )
        return FALSE;
      --label_val;

      if (label_val == 11) /* 'dial' key */
        call_activate (app);
      else
        button_activate (app, app->buttons[label_val]);

      return TRUE;
    }

  return FALSE;
}
Exemplo n.º 22
0
/*
 * _clutter_input_device_set_actor:
 * @device: a #ClutterInputDevice
 * @actor: a #ClutterActor
 *
 * Sets the actor under the pointer coordinates of @device
 *
 * This function is called by _clutter_input_device_update()
 * and it will:
 *
 *   - queue a %CLUTTER_LEAVE event on the previous pointer actor
 *     of @device, if any
 *   - set to %FALSE the :has-pointer property of the previous
 *     pointer actor of @device, if any
 *   - queue a %CLUTTER_ENTER event on the new pointer actor
 *   - set to %TRUE the :has-pointer property of the new pointer
 *     actor
 */
void
_clutter_input_device_set_actor (ClutterInputDevice *device,
                                 ClutterActor       *actor)
{
  ClutterActor *old_actor;
  ClutterEvent cev;

  g_return_if_fail (CLUTTER_IS_INPUT_DEVICE (device));

  if (actor == device->cursor_actor)
    return;

  old_actor = device->cursor_actor;
  if (old_actor != NULL)
    {
      cev.crossing.type = CLUTTER_LEAVE;
      cev.crossing.time = device->current_time;
      cev.crossing.flags = 0;
      cev.crossing.stage = device->stage;
      cev.crossing.source = device->cursor_actor;
      cev.crossing.x = device->current_x;
      cev.crossing.y = device->current_y;
      cev.crossing.device = device;
      cev.crossing.related = actor;

      /* we need to make sure that this event is processed before
       * any other event we might have queued up until now, so we
       * go on and synthesize the event emission
       */
      _clutter_process_event (&cev);

      _clutter_actor_set_has_pointer (device->cursor_actor, FALSE);
      g_object_weak_unref (G_OBJECT (device->cursor_actor),
                           cursor_weak_unref,
                           device);

      device->cursor_actor = NULL;
    }

  if (actor != NULL)
    {
      cev.crossing.type = CLUTTER_ENTER;
      cev.crossing.time = device->current_time;
      cev.crossing.flags = 0;
      cev.crossing.stage = device->stage;
      cev.crossing.x = device->current_x;
      cev.crossing.y = device->current_y;
      cev.crossing.device = device;

      CLUTTER_NOTE (EVENT, "Device '%s' entering '%s' at %d, %d",
                    device->device_name,
                    clutter_actor_get_name (actor) != NULL
                      ? clutter_actor_get_name (actor)
                      : G_OBJECT_TYPE_NAME (actor),
                    device->current_x,
                    device->current_y);

      /* if there is an actor overlapping the Stage boundary and we
       * don't do this check then we'll emit an ENTER event only on
       * the actor instead of emitting it on the Stage *and* the
       * actor
       */
      if (old_actor == NULL && actor != CLUTTER_ACTOR (device->stage))
        {
          cev.crossing.source = CLUTTER_ACTOR (device->stage);
          cev.crossing.related = NULL;

          CLUTTER_NOTE (EVENT, "Adding Crossing[Enter] event for Stage");

          _clutter_process_event (&cev);

          cev.crossing.source = actor;
          cev.crossing.related = CLUTTER_ACTOR (device->stage);
        }
      else
        {
          cev.crossing.source = actor;
          cev.crossing.related = old_actor;
        }

      /* as above: we need to make sure that this event is processed
       * before any other event we might have queued up until now, so
       * we go on and synthesize the event emission
       */
      _clutter_process_event (&cev);
    }

  device->cursor_actor = actor;

  if (device->cursor_actor != NULL)
    {
      g_object_weak_ref (G_OBJECT (device->cursor_actor),
                         cursor_weak_unref,
                         device);
      _clutter_actor_set_has_pointer (device->cursor_actor, TRUE);
    }
}
static void
clutter_x11_texture_pixmap_paint (ClutterActor *self)
{
  ClutterX11TexturePixmap *texture = CLUTTER_X11_TEXTURE_PIXMAP (self);
  ClutterX11TexturePixmapPrivate *priv = texture->priv;
  gint            x_1, y_1, x_2, y_2;
  ClutterColor    col = { 0xff, 0xff, 0xff, 0xff };
  ClutterFixed    t_w, t_h;
  GList           *shape;
  CoglHandle      cogl_texture;

  g_return_if_fail (CLUTTER_X11_IS_TEXTURE_PIXMAP (texture));

  /* If we have no shapes, just call what we had before */
  if (priv->shapes==0)
    {
      CLUTTER_ACTOR_CLASS(clutter_x11_texture_pixmap_parent_class)->paint(self);
      return;
    }

  if (!CLUTTER_ACTOR_IS_REALIZED (CLUTTER_ACTOR(texture)))
    clutter_actor_realize (CLUTTER_ACTOR(texture));

  CLUTTER_NOTE (PAINT,
                "painting X11 texture '%s'",
                clutter_actor_get_name (self) ? clutter_actor_get_name (self)
                                              : "unknown");
  col.alpha = clutter_actor_get_paint_opacity (self);
  cogl_color (&col);

  clutter_actor_get_allocation_coords (self, &x_1, &y_1, &x_2, &y_2);

  CLUTTER_NOTE (PAINT, "paint to x1: %i, y1: %i x2: %i, y2: %i "
                       "opacity: %i",
                x_1, y_1, x_2, y_2,
                clutter_actor_get_opacity (self));

  t_w = CFX_ONE;
  t_h = CFX_ONE;

  cogl_texture = clutter_texture_get_cogl_texture(CLUTTER_TEXTURE(self));
  if (cogl_texture == COGL_INVALID_HANDLE)
    return;

  /* so now we go through our shapes and render */
  for (shape = priv->shapes; shape; shape = shape->next)
    {
      gint w = x_2 - x_1;
      gint h = y_2 - y_1;
      ClutterGeometry *geo = (ClutterGeometry*)shape->data;
      cogl_texture_rectangle (
          cogl_texture,
          CLUTTER_INT_TO_FIXED(w * geo->x / priv->pixmap_width),
          CLUTTER_INT_TO_FIXED(h * geo->y / priv->pixmap_height),
          CLUTTER_INT_TO_FIXED(w * (geo->x+geo->width) / priv->pixmap_width),
          CLUTTER_INT_TO_FIXED(h * (geo->y+geo->height) / priv->pixmap_height),
          t_w * geo->x / priv->pixmap_width,
          t_h * geo->y / priv->pixmap_height,
          t_w * (geo->x+geo->width) / priv->pixmap_width,
          t_h * (geo->y+geo->height) / priv->pixmap_height);
    }
}
Exemplo n.º 24
0
static gboolean
input_cb (ClutterActor *actor,
	  ClutterEvent *event,
	  gpointer      data)
{
  ClutterActor *stage = clutter_actor_get_stage (actor); 
  ClutterActor *source_actor = clutter_event_get_source (event);
  gchar keybuf[128];

  switch (event->type)
    {
    case CLUTTER_KEY_PRESS:
      fill_keybuf (keybuf, &event->key);
      printf ("[%s] KEY PRESS %s",
              clutter_actor_get_name (source_actor),
              keybuf);
      break;
    case CLUTTER_KEY_RELEASE:
      fill_keybuf (keybuf, &event->key);
      printf ("[%s] KEY RELEASE %s",
              clutter_actor_get_name (source_actor),
              keybuf);
      break;
    case CLUTTER_MOTION:
      {
        ClutterMotionEvent *motion = (ClutterMotionEvent *) event;

        g_print ("[%s] MOTION (%.02f,%.02f)",
                 clutter_actor_get_name (source_actor), motion->x, motion->y);
      }
      break;
    case CLUTTER_ENTER:
      g_print ("[%s] ENTER (from:%s)",
               clutter_actor_get_name (source_actor),
               clutter_event_get_related (event) != NULL
                 ? clutter_actor_get_name (clutter_event_get_related (event))
                 : "<out of stage>");
      break;
    case CLUTTER_LEAVE:
      g_print ("[%s] LEAVE (to:%s)",
               clutter_actor_get_name (source_actor),
               clutter_event_get_related (event) != NULL
                 ? clutter_actor_get_name (clutter_event_get_related (event))
                 : "<out of stage>");
      break;
    case CLUTTER_BUTTON_PRESS:
      g_print ("[%s] BUTTON PRESS (button:%i, click count:%i)",
	       clutter_actor_get_name (source_actor),
               clutter_event_get_button (event),
               clutter_event_get_click_count (event));
      break;
    case CLUTTER_BUTTON_RELEASE:
      g_print ("[%s] BUTTON RELEASE (button:%i, click count:%i)",
	       clutter_actor_get_name (source_actor),
               clutter_event_get_button (event),
               clutter_event_get_click_count (event));

      if (source_actor == stage)
        clutter_stage_set_key_focus (CLUTTER_STAGE (stage), NULL);
      else if (source_actor == actor &&
               clutter_actor_get_parent (actor) == stage)
	clutter_stage_set_key_focus (CLUTTER_STAGE (stage), actor);
      break;
    case CLUTTER_SCROLL:
      g_print ("[%s] BUTTON SCROLL (direction:%s)",
	       clutter_actor_get_name (source_actor),
               clutter_event_get_scroll_direction (event) == CLUTTER_SCROLL_UP
                 ? "up"
                 : "down");
      break;
    case CLUTTER_STAGE_STATE:
      g_print ("[%s] STAGE STATE", clutter_actor_get_name (source_actor));
      break;
    case CLUTTER_DESTROY_NOTIFY:
      g_print ("[%s] DESTROY NOTIFY", clutter_actor_get_name (source_actor));
      break;
    case CLUTTER_CLIENT_MESSAGE:
      g_print ("[%s] CLIENT MESSAGE", clutter_actor_get_name (source_actor));
      break;
    case CLUTTER_DELETE:
      g_print ("[%s] DELETE", clutter_actor_get_name (source_actor));
      break;
    case CLUTTER_NOTHING:
      return FALSE;
    }

  if (source_actor == actor)
    g_print (" *source*");
  
  g_print ("\n");

  return FALSE;
}
Exemplo n.º 25
0
static void
clutter_rectangle_paint (ClutterActor *self)
{
  ClutterRectangle        *rectangle = CLUTTER_RECTANGLE(self);
  ClutterRectanglePrivate *priv;
  ClutterGeometry          geom;
  ClutterColor             tmp_col;

  rectangle = CLUTTER_RECTANGLE(self);
  priv = rectangle->priv;

  CLUTTER_NOTE (PAINT,
                "painting rect '%s'",
		clutter_actor_get_name (self) ? clutter_actor_get_name (self)
                                              : "unknown");
  clutter_actor_get_allocation_geometry (self, &geom);

  CLUTTER_NOTE (PAINT, "paint to x1: %i, y1: %i x2: %i, y2: %i "
                       "opacity: %i",
                geom.x, geom.y, geom.x+geom.width, geom.y+geom.height,
                clutter_actor_get_opacity (self));

  /* parent paint call will have translated us into position so
   * paint from 0, 0
   */
  if (priv->has_border)
    {
      tmp_col.red   = priv->border_color.red;
      tmp_col.green = priv->border_color.green;
      tmp_col.blue  = priv->border_color.blue;
      tmp_col.alpha = clutter_actor_get_paint_opacity (self)
                      * priv->border_color.alpha
                      / 255;

      cogl_color (&tmp_col);

      /* this sucks, but it's the only way to make a border */
      cogl_rectangle (priv->border_width, 0,
                      geom.width - priv->border_width,
                      priv->border_width);

      cogl_rectangle (geom.width - priv->border_width,
                      priv->border_width,
                      priv->border_width,
                      geom.height - priv->border_width);

      cogl_rectangle (0, geom.height - priv->border_width,
                      geom.width - priv->border_width,
                      priv->border_width);

      cogl_rectangle (0, 0,
                      priv->border_width,
                      geom.height - priv->border_width);

      tmp_col.red   = priv->color.red;
      tmp_col.green = priv->color.green;
      tmp_col.blue  = priv->color.blue;
      tmp_col.alpha = clutter_actor_get_paint_opacity (self)
                      * priv->color.alpha
                      / 255;

      cogl_color (&tmp_col);

      cogl_rectangle (priv->border_width, priv->border_width,
                      geom.width - priv->border_width * 2,
                      geom.height - priv->border_width * 2);
    }
  else
    {
      tmp_col.red   = priv->color.red;
      tmp_col.green = priv->color.green;
      tmp_col.blue  = priv->color.blue;
      tmp_col.alpha = clutter_actor_get_paint_opacity (self)
                      * priv->color.alpha
                      / 255;

      cogl_color (&tmp_col);

      cogl_rectangle (0, 0, geom.width, geom.height);
    }
}
Exemplo n.º 26
0
/* Get stylable name of actor */
static const gchar* _xfdashboard_actor_stylable_get_name(XfdashboardStylable *inStylable)
{
	g_return_val_if_fail(CLUTTER_IS_ACTOR(inStylable), NULL);

	return(clutter_actor_get_name(CLUTTER_ACTOR(inStylable)));
}
Exemplo n.º 27
0
static void
clutter_rectangle_paint (ClutterActor *self)
{
  ClutterRectanglePrivate *priv = CLUTTER_RECTANGLE (self)->priv;
  ClutterGeometry geom;
  guint8 tmp_alpha;

  CLUTTER_NOTE (PAINT,
                "painting rect '%s'",
		clutter_actor_get_name (self) ? clutter_actor_get_name (self)
                                              : "unknown");
  clutter_actor_get_allocation_geometry (self, &geom);

  /* parent paint call will have translated us into position so
   * paint from 0, 0
   */
  if (priv->has_border)
    {
      /* compute the composited opacity of the actor taking into
       * account the opacity of the color set by the user
       */
      tmp_alpha = clutter_actor_get_paint_opacity (self)
                * priv->border_color.alpha
                / 255;

      /* paint the border */
      cogl_set_source_color4ub (priv->border_color.red,
                                priv->border_color.green,
                                priv->border_color.blue,
                                tmp_alpha);

      /* this sucks, but it's the only way to make a border */
      cogl_rectangle (priv->border_width, 0,
                      geom.width,
                      priv->border_width);

      cogl_rectangle (geom.width - priv->border_width,
                      priv->border_width,
                      geom.width,
                      geom.height);

      cogl_rectangle (0, geom.height - priv->border_width,
                      geom.width - priv->border_width,
                      geom.height);

      cogl_rectangle (0, 0,
                      priv->border_width,
                      geom.height - priv->border_width);

      tmp_alpha = clutter_actor_get_paint_opacity (self)
                * priv->color.alpha
                / 255;

      /* now paint the rectangle */
      cogl_set_source_color4ub (priv->color.red,
                                priv->color.green,
                                priv->color.blue,
                                tmp_alpha);

      cogl_rectangle (priv->border_width, priv->border_width,
                      geom.width - priv->border_width,
                      geom.height - priv->border_width);
    }
  else
    {
      /* compute the composited opacity of the actor taking into
       * account the opacity of the color set by the user
       */
      tmp_alpha = clutter_actor_get_paint_opacity (self)
                * priv->color.alpha
                / 255;

      cogl_set_source_color4ub (priv->color.red,
                                priv->color.green,
                                priv->color.blue,
                                tmp_alpha);

      cogl_rectangle (0, 0, geom.width, geom.height);
    }
}
Exemplo n.º 28
0
IO_METHOD(IoClutterActor, getName) {
  return IOSYMBOL(clutter_actor_get_name(IOCACTOR(self)));
}
Exemplo n.º 29
0
static void
clutter_rectangle_paint (ClutterActor *self)
{
  ClutterRectanglePrivate *priv = CLUTTER_RECTANGLE (self)->priv;
  ClutterGeometry geom;
  guint8 tmp_alpha;

  CLUTTER_NOTE (PAINT,
                "painting rect '%s'",
		clutter_actor_get_name (self) ? clutter_actor_get_name (self)
                                              : "unknown");
  clutter_actor_get_allocation_geometry (self, &geom);

  if (priv->has_border)
    {
      /* We paint the border and the content only if the rectangle
       * is big enough to show them
       */
      if ((priv->border_width * 2) < geom.width &&
          (priv->border_width * 2) < geom.height)
        {
          /* compute the composited opacity of the actor taking into
           * account the opacity of the color set by the user
           */
          tmp_alpha = clutter_actor_get_paint_opacity (self)
                    * priv->border_color.alpha
                    / 255;

          /* paint the border */
          cogl_set_source_color4ub (priv->border_color.red,
                                    priv->border_color.green,
                                    priv->border_color.blue,
                                    tmp_alpha);

          /* this sucks, but it's the only way to make a border */
          cogl_rectangle (priv->border_width, 0,
                          geom.width,
                          priv->border_width);

          cogl_rectangle (geom.width - priv->border_width,
                          priv->border_width,
                          geom.width,
                          geom.height);

          cogl_rectangle (0, geom.height - priv->border_width,
                          geom.width - priv->border_width,
                          geom.height);

          cogl_rectangle (0, 0,
                          priv->border_width,
                          geom.height - priv->border_width);

          tmp_alpha = clutter_actor_get_paint_opacity (self)
                    * priv->color.alpha
                    / 255;

          /* now paint the rectangle */
          cogl_set_source_color4ub (priv->color.red,
                                    priv->color.green,
                                    priv->color.blue,
                                    tmp_alpha);

          cogl_rectangle (priv->border_width, priv->border_width,
                          geom.width - priv->border_width,
                          geom.height - priv->border_width);
        }
      else
        {
          /* Otherwise, we draw a rectangle with the same color
           * as the border, since we can only fit that into the
           * allocation.
           */
          tmp_alpha = clutter_actor_get_paint_opacity (self)
                    * priv->border_color.alpha
                    / 255;

          cogl_set_source_color4ub (priv->border_color.red,
                                    priv->border_color.green,
                                    priv->border_color.blue,
                                    tmp_alpha);

          cogl_rectangle (0, 0, geom.width, geom.height);
        }
    }
  else
    {
      /* compute the composited opacity of the actor taking into
       * account the opacity of the color set by the user
       */
      tmp_alpha = clutter_actor_get_paint_opacity (self)
                * priv->color.alpha
                / 255;

      cogl_set_source_color4ub (priv->color.red,
                                priv->color.green,
                                priv->color.blue,
                                tmp_alpha);

      cogl_rectangle (0, 0, geom.width, geom.height);
    }
}