static void
set_success (CalibArea *area)
{
  ClutterImage *image;
  GdkPixbuf *icon = area->icon_success;

  if (icon == NULL)
    return;

  image = CLUTTER_IMAGE (clutter_actor_get_content (area->success_image));
  clutter_image_set_data (image,
                          gdk_pixbuf_get_pixels (icon),
                          gdk_pixbuf_get_has_alpha (icon)
                          ? COGL_PIXEL_FORMAT_RGBA_8888
                          : COGL_PIXEL_FORMAT_RGB_888,
                          gdk_pixbuf_get_width (icon),
                          gdk_pixbuf_get_height (icon),
                          gdk_pixbuf_get_rowstride (icon),
                          NULL);
  clutter_actor_set_size (area->success_image,
                          gdk_pixbuf_get_width (icon),
                          gdk_pixbuf_get_height (icon));

  clutter_actor_show (area->success_image);
  clutter_actor_hide (area->action_layer);
}
示例#2
0
/* Find live window actor by window */
static ClutterActor* _xfdashboard_live_workspace_find_by_window(XfdashboardLiveWorkspace *self,
																XfdashboardWindowTrackerWindow *inWindow)
{
	ClutterActor						*child;
	ClutterActorIter					iter;
	ClutterContent						*content;
	XfdashboardWindowTrackerWindow		*window;

	g_return_val_if_fail(XFDASHBOARD_IS_LIVE_WORKSPACE(self), NULL);
	g_return_val_if_fail(XFDASHBOARD_IS_WINDOW_TRACKER_WINDOW(inWindow), NULL);

	/* Iterate through list of current actors and find the one for requested window */
	clutter_actor_iter_init(&iter, CLUTTER_ACTOR(self));
	while(clutter_actor_iter_next(&iter, &child))
	{
		content=clutter_actor_get_content(child);
		if(!content || !XFDASHBOARD_IS_WINDOW_CONTENT(content)) continue;

		window=xfdashboard_window_content_get_window(XFDASHBOARD_WINDOW_CONTENT(content));
		if(window==inWindow) return(child);
	}

	/* If we get here we did not find the window and we return NULL */
	return(NULL);
}
示例#3
0
/* Allocate position and size of actor and its children */
static void _xfdashboard_live_workspace_allocate(ClutterActor *self,
												const ClutterActorBox *inBox,
												ClutterAllocationFlags inFlags)
{
	XfdashboardLiveWorkspacePrivate		*priv=XFDASHBOARD_LIVE_WORKSPACE(self)->priv;
	gfloat								availableWidth, availableHeight;
	gfloat								workspaceWidth, workspaceHeight;
	ClutterContent						*content;
	XfdashboardWindowTrackerWindow		*window;
	gint								x, y, w, h;
	ClutterActor						*child;
	ClutterActorIter					iter;
	ClutterActorBox						childAllocation={ 0, };

	/* Chain up to store the allocation of the actor */
	CLUTTER_ACTOR_CLASS(xfdashboard_live_workspace_parent_class)->allocate(self, inBox, inFlags);

	/* If we handle no workspace to not set allocation of children */
	if(!priv->workspace) return;

	/* Get size of workspace and this allocation as it is needed
	 * to calculate translated position and size
	 */
	clutter_actor_box_get_size(inBox, &availableWidth, &availableHeight);

	workspaceWidth=(gfloat)xfdashboard_window_tracker_workspace_get_width(priv->workspace);
	workspaceHeight=(gfloat)xfdashboard_window_tracker_workspace_get_height(priv->workspace);

	/* Iterate through window actors, calculate translated allocation of
	 * position and size to available size of this actor
	 */
	clutter_actor_iter_init(&iter, self);
	while(clutter_actor_iter_next(&iter, &child))
	{
		/* Get window actor */
		if(!CLUTTER_IS_ACTOR(child)) continue;

		/* Get associated window */
		content=clutter_actor_get_content(child);
		if(!content || !XFDASHBOARD_IS_WINDOW_CONTENT(content)) continue;

		window=xfdashboard_window_content_get_window(XFDASHBOARD_WINDOW_CONTENT(content));
		if(!window) continue;

		/* Get real size of child */
		xfdashboard_window_tracker_window_get_position_size(window, &x, &y, &w, &h);

		/* Calculate translated position and size of child */
		childAllocation.x1=ceil((x/workspaceWidth)*availableWidth);
		childAllocation.y1=ceil((y/workspaceHeight)*availableHeight);
		childAllocation.x2=childAllocation.x1+ceil((w/workspaceWidth)*availableWidth);
		childAllocation.y2=childAllocation.y1+ceil((h/workspaceHeight)*availableHeight);

		/* Set allocation of child */
		clutter_actor_allocate(child, &childAllocation, inFlags);
	}
}
示例#4
0
static void _set_highlight(MetaSwitcher* self, int id, gboolean highlight)
{
    if (id < 0) return;
    MetaSwitcherPrivate* priv = self->priv;

    MetaWindow* window = g_ptr_array_index(priv->apps, id);
    ClutterActor* win_actor = g_hash_table_lookup(priv->icons, window);
    WindowPrivate* win_priv = get_window_private(CLUTTER_ACTOR(win_actor));
    win_priv->highlight = highlight;

    ClutterActor* bg = clutter_container_find_child_by_name(CLUTTER_CONTAINER(win_actor), "bg");
    clutter_content_invalidate(clutter_actor_get_content(bg));
}
示例#5
0
static void
on_actor_resize (ClutterActor           *actor,
                 const ClutterActorBox  *allocation,
                 ClutterAllocationFlags  flags,
                 gpointer                user_data)
{
  float width, height;

  /* match the canvas size to the actor's */
  clutter_actor_get_size (actor, &width, &height);
  clutter_canvas_set_size (CLUTTER_CANVAS (clutter_actor_get_content (actor)),
                           ceilf (width),
                           ceilf (height));
}
示例#6
0
static void
on_destroy (ClutterActor *actor, gpointer data)
{
  ClutterContent *content;
  GFreenectDevice *device = GFREENECT_DEVICE (data);

  content = clutter_actor_get_content (depth_tex);
  if (content == depth_canvas)
    g_object_unref (depth_image);
  else
    g_object_unref (depth_canvas);

  gfreenect_device_stop_depth_stream (device, NULL);
  gfreenect_device_stop_video_stream (device, NULL);
  clutter_main_quit ();
}
示例#7
0
static void
on_track_joints (GObject      *obj,
                 GAsyncResult *res,
                 gpointer      user_data)
{
  guint i;
  BufferInfo *buffer_info;
  guint16 *reduced;
  gint width, height, reduced_width, reduced_height;
  ClutterContent *content;
  GError *error = NULL;

  buffer_info = (BufferInfo *) user_data;
  reduced = (guint16 *) buffer_info->reduced_buffer;
  width = buffer_info->width;
  height = buffer_info->height;
  reduced_width = buffer_info->reduced_width;
  reduced_height = buffer_info->reduced_height;

  list = skeltrack_skeleton_track_joints_finish (skeleton,
                                                 res,
                                                 &error);

  if (error == NULL)
    {
      if (SHOW_SKELETON)
        {
          content = clutter_actor_get_content (depth_tex);
          clutter_content_invalidate (content);
        }
    }
  else
    {
      g_warning ("%s\n", error->message);
      g_error_free (error);
    }

  g_slice_free1 (reduced_width * reduced_height * sizeof (guint16), reduced);

  g_slice_free (BufferInfo, buffer_info);

  skeltrack_joint_list_free (list);
}
示例#8
0
gboolean meta_switcher_show(MetaSwitcher* self)
{
    MetaSwitcherPrivate* priv = self->priv;
    int screen_width, screen_height;

    MetaScreen* screen = meta_plugin_get_screen(priv->plugin);
    priv->workspace = meta_screen_get_active_workspace(screen);

    meta_screen_get_size(screen, &screen_width, &screen_height);

    meta_switcher_present_list(self);
    if (priv->apps == NULL || priv->apps->len == 0) goto _end;

    _capture_desktop(self);
    clutter_content_invalidate(clutter_actor_get_content(priv->top));

    ClutterActor* stage = meta_get_stage_for_screen(screen);
    clutter_actor_insert_child_above(stage, priv->top, NULL);
    clutter_actor_show(priv->top);

    if (!meta_plugin_begin_modal(priv->plugin, 0, clutter_get_current_event_time())) {
        if (!meta_plugin_begin_modal(priv->plugin, META_MODAL_POINTER_ALREADY_GRABBED,
                    clutter_get_current_event_time())) {
            g_warning("can not be modal");
            goto _end;
        }
    }

    meta_disable_unredirect_for_screen(screen);
    priv->modaled = TRUE;

    priv->previous_focused = clutter_stage_get_key_focus(CLUTTER_STAGE(stage));
    if (priv->previous_focused == stage) priv->previous_focused = NULL;
    clutter_stage_set_key_focus(CLUTTER_STAGE(stage), priv->top);
    clutter_actor_grab_key_focus(priv->top);

    return TRUE;

_end:
    clutter_actor_hide(priv->top);
    return FALSE;
}
示例#9
0
static void
meta_background_actor_get_preferred_width (ClutterActor *actor,
                                           gfloat        for_height,
                                           gfloat       *min_width_p,
                                           gfloat       *natural_width_p)
{
  ClutterContent *content;
  gfloat width;

  content = clutter_actor_get_content (actor);

  if (content)
    clutter_content_get_preferred_size (content, &width, NULL);
  else
    width = 0;

  if (min_width_p)
    *min_width_p = width;
  if (natural_width_p)
    *natural_width_p = width;
}
示例#10
0
static void
meta_background_actor_get_preferred_height (ClutterActor *actor,
                                            gfloat        for_width,
                                            gfloat       *min_height_p,
                                            gfloat       *natural_height_p)

{
  ClutterContent *content;
  gfloat height;

  content = clutter_actor_get_content (actor);

  if (content)
    clutter_content_get_preferred_size (content, NULL, &height);
  else
    height = 0;

  if (min_height_p)
    *min_height_p = height;
  if (natural_height_p)
    *natural_height_p = height;
}
示例#11
0
static void
on_video_frame (GFreenectDevice *kinect, gpointer user_data)
{
  guchar *buffer;
  GError *error = NULL;
  GFreenectFrameMode frame_mode;
  ClutterContent *content;

  buffer = gfreenect_device_get_video_frame_rgb (kinect, NULL, &frame_mode);
  content = clutter_actor_get_content (video_tex);

  if (! clutter_image_set_data (CLUTTER_IMAGE (content),
                                buffer,
                                COGL_PIXEL_FORMAT_RGB_888,
                                frame_mode.width, frame_mode.height,
                                0,
                                &error))
    {
      g_debug ("Error setting texture area: %s", error->message);
      g_error_free (error);
    }
}
示例#12
0
static void
on_depth_frame (GFreenectDevice *kinect, gpointer user_data)
{
  gboolean smoothing_enabled;
  gint width, height;
  gint dimension_factor;
  guchar *grayscale_buffer;
  guint16 *depth;
  BufferInfo *buffer_info;
  gsize len;
  GError *error = NULL;
  GFreenectFrameMode frame_mode;
  ClutterContent *content;

  depth = (guint16 *) gfreenect_device_get_depth_frame_raw (kinect,
                                                            &len,
                                                            &frame_mode);

  width = frame_mode.width;
  height = frame_mode.height;

  g_object_get (skeleton, "dimension-reduction", &dimension_factor, NULL);

  buffer_info = process_buffer (depth,
                                width,
                                height,
                                dimension_factor,
                                THRESHOLD_BEGIN,
                                THRESHOLD_END);

  skeltrack_skeleton_track_joints (skeleton,
                                   buffer_info->reduced_buffer,
                                   buffer_info->reduced_width,
                                   buffer_info->reduced_height,
                                   NULL,
                                   on_track_joints,
                                   buffer_info);


  content = clutter_actor_get_content (depth_tex);
  if (!SHOW_SKELETON)
    {
      grayscale_buffer = create_grayscale_buffer (buffer_info,
                                                  dimension_factor);

      if (depth_image == NULL)
        depth_image = clutter_image_new ();

      /* ref because we don't want it to be freed */
      if (depth_canvas == content)
        g_object_ref (depth_canvas);

      clutter_actor_set_content (depth_tex, depth_image);
      if (! clutter_image_set_data (CLUTTER_IMAGE (depth_image),
                                    grayscale_buffer,
                                    COGL_PIXEL_FORMAT_RGB_888,
                                    width, height,
                                    0,
                                    &error))
        {
          g_debug ("Error setting texture area: %s", error->message);
          g_error_free (error);
        }
      g_slice_free1 (width * height * sizeof (guchar) * 3, grayscale_buffer);
    }
  else {
    /* ref because we don't want it to be freed */
    if (depth_image && depth_image == content)
      g_object_ref (depth_image);

    clutter_actor_set_content (depth_tex, depth_canvas);
  }
}
示例#13
0
void xfdashboard_live_workspace_set_workspace(XfdashboardLiveWorkspace *self, XfdashboardWindowTrackerWorkspace *inWorkspace)
{
	XfdashboardLiveWorkspacePrivate		*priv;
	ClutterContent						*content;
	XfdashboardWindowTrackerWindow		*window;
	ClutterActor						*child;
	ClutterActorIter					iter;
	GList								*windows;
	ClutterActor						*actor;

	g_return_if_fail(XFDASHBOARD_IS_LIVE_WORKSPACE(self));
	g_return_if_fail(XFDASHBOARD_IS_WINDOW_TRACKER_WORKSPACE(inWorkspace));

	priv=self->priv;

	/* Only set value if it changes */
	if(inWorkspace==priv->workspace) return;

	/* Release old value */
	if(priv->workspace)
	{
		g_signal_handlers_disconnect_by_data(priv->workspace, self);
		priv->workspace=NULL;
	}

	/* Set new value
	 * Window tracker objects should never be refed or unrefed, so just set new value
	 */
	priv->workspace=inWorkspace;

	/* Destroy all window actors */
	clutter_actor_iter_init(&iter, CLUTTER_ACTOR(self));
	while(clutter_actor_iter_next(&iter, &child))
	{
		/* Get window actor */
		if(!CLUTTER_IS_ACTOR(child)) continue;

		/* Check if it is really a window actor by retrieving associated window */
		content=clutter_actor_get_content(child);
		if(!content || !XFDASHBOARD_IS_WINDOW_CONTENT(content)) continue;

		/* Destroy window actor */
		clutter_actor_destroy(child);
	}

	/* Create windows for new workspace in stacked order */
	windows=xfdashboard_window_tracker_get_windows_stacked(priv->windowTracker);
	for( ; windows; windows=g_list_next(windows))
	{
		/* Get window */
		window=XFDASHBOARD_WINDOW_TRACKER_WINDOW(windows->data);
		if(!window) continue;

		/* Create window actor if window is visible */
		if(!_xfdashboard_live_workspace_is_visible_window(self, window)) continue;

		actor=clutter_actor_new();
		content=xfdashboard_window_content_new_for_window(window);
		clutter_actor_set_content(actor, content);
		g_object_unref(content);

		/* Insert new actor at bottom */
		clutter_actor_insert_child_above(CLUTTER_ACTOR(self), actor, NULL);
	}

	/* Notify about property change */
	g_object_notify_by_pspec(G_OBJECT(self), XfdashboardLiveWorkspaceProperties[PROP_WORKSPACE]);
}