gboolean gb_player_show_controls (GbPlayer *self) { ClutterEffectTemplate *effect_template; gint x, y; ClutterKnot t_knot[2]; ClutterKnot b_knot[2]; ClutterKnot c_knot[2]; if ((!self->priv->playing) || (clutter_timeline_is_playing (self->priv->show_hide_timeline))) return FALSE; clutter_timeline_start(self->priv->show_hide_timeline); effect_template = clutter_effect_template_new (self->priv->show_hide_timeline, &on_alpha); clutter_actor_get_position (self->priv->title_group, &x, &y); t_knot[0].x = x; t_knot[0].y = y; t_knot[1].x= -20; t_knot[1].y= 20; clutter_actor_get_position (self->priv->window_buttons_group, &x, &y); b_knot[0].x = x; b_knot[0].y = y; b_knot[1].x= 640 - 200; b_knot[1].y= 20; clutter_actor_get_position (self->priv->window_buttons_group, &x, &y); c_knot[0].x = x; c_knot[0].y = y; c_knot[1].x= ((640 / 2) - (400 / 2)); c_knot[1].y= 480 - 70 - 30; clutter_effect_fade (effect_template, self->priv->title_group, 0xff, NULL, NULL); clutter_effect_fade (effect_template, self->priv->window_buttons_group, 0xff, NULL, NULL); clutter_effect_fade (effect_template, self->priv->controls_group, 0xff, NULL, NULL); g_object_unref (effect_template); return FALSE; }
static gint gnibbles_worm_get_tail_direction (GnibblesWorm *worm) { gfloat x1,y1,x2,y2; gfloat xdiff, ydiff; ClutterActor *next = NULL; ClutterActor *tail = gnibbles_worm_get_tail_actor (worm); if (g_list_length (worm->list) >= 2) next = CLUTTER_ACTOR (g_list_previous (g_list_last (worm->list))->data); else return worm->direction; clutter_actor_get_position (CLUTTER_ACTOR (next), &x2, &y2); clutter_actor_get_position (CLUTTER_ACTOR (tail), &x1, &y1); xdiff = MAX (x2,x1) - MIN (x2,x1); ydiff = MAX (y2,y1) - MIN (y2,y1); if (x2 > x1 && fabs (y1 - y2) < 0.0001) return xdiff > properties->tilesize ? WORMLEFT : WORMRIGHT; else if (x2 < x1 && fabs (y1 - y2) < 0.0001) return xdiff > properties->tilesize ? WORMRIGHT : WORMLEFT; else if (y2 > y1 && fabs (x1 - x2) < 0.0001) return ydiff > properties->tilesize ? WORMUP: WORMDOWN; else if (y2 < y1 && fabs (x1 - x2) < 0.0001) return ydiff > properties->tilesize ? WORMDOWN : WORMUP; else return -1; }
static void shell_gtk_window_actor_allocate (ClutterActor *actor, const ClutterActorBox *box, gboolean absolute_origin_changed) { ShellGtkWindowActor *wactor = SHELL_GTK_WINDOW_ACTOR (actor); int wx = 0, wy = 0, x, y, ax, ay; CLUTTER_ACTOR_CLASS (shell_gtk_window_actor_parent_class)-> allocate (actor, box, absolute_origin_changed); /* Find the actor's new coordinates in terms of the stage (which is * priv->window's parent window. */ while (actor) { clutter_actor_get_position (actor, &x, &y); clutter_actor_get_anchor_point (actor, &ax, &ay); wx += x - ax; wy += y - ay; actor = clutter_actor_get_parent (actor); } gtk_window_move (GTK_WINDOW (wactor->priv->window), wx, wy); }
/* * The Nature of Maximize operation is such that it is difficult to do a visual * effect that would work well. Scaling, the obvious effect, does not work that * well, because at the end of the effect we end up with window content bigger * and differently laid out than in the real window; this is a proof concept. * * (Something like a sound would be more appropriate.) */ static void maximize (MetaPlugin *plugin, MetaWindowActor *window_actor, gint end_x, gint end_y, gint end_width, gint end_height) { MetaWindowType type; ClutterActor *actor = CLUTTER_ACTOR (window_actor); MetaWindow *meta_window = meta_window_actor_get_meta_window (window_actor); gdouble scale_x = 1.0; gdouble scale_y = 1.0; gfloat anchor_x = 0; gfloat anchor_y = 0; type = meta_window_get_window_type (meta_window); if (type == META_WINDOW_NORMAL) { ClutterAnimation *animation; EffectCompleteData *data = g_new0 (EffectCompleteData, 1); ActorPrivate *apriv = get_actor_private (window_actor); gfloat width, height; gfloat x, y; apriv->is_maximized = TRUE; clutter_actor_get_size (actor, &width, &height); clutter_actor_get_position (actor, &x, &y); /* * Work out the scale and anchor point so that the window is expanding * smoothly into the target size. */ scale_x = (gdouble)end_width / (gdouble) width; scale_y = (gdouble)end_height / (gdouble) height; anchor_x = (gdouble)(x - end_x)*(gdouble)width / ((gdouble)(end_width - width)); anchor_y = (gdouble)(y - end_y)*(gdouble)height / ((gdouble)(end_height - height)); clutter_actor_move_anchor_point (actor, anchor_x, anchor_y); animation = clutter_actor_animate (actor, CLUTTER_EASE_IN_SINE, MAXIMIZE_TIMEOUT, "scale-x", scale_x, "scale-y", scale_y, NULL); apriv->tml_maximize = clutter_animation_get_timeline (animation); data->plugin = plugin; data->actor = actor; g_signal_connect (apriv->tml_maximize, "completed", G_CALLBACK (on_maximize_effect_complete), data); return; } meta_plugin_maximize_completed (plugin, window_actor); }
void gnome_app_actor_add_background (ClutterActor *actor, gchar *filename) { ClutterActor *texture; ClutterActor *parent; GError *error; gfloat width, height; gfloat x, y; error = NULL; texture = clutter_texture_new_from_file (filename, &error); clutter_actor_set_opacity (texture, 128); if (error) { g_error ("Error in add background: %s\n", error->message); g_error_free (error); return; } clutter_actor_get_size (actor, &width, &height); clutter_actor_set_size (texture, width, height); if (CLUTTER_IS_CONTAINER (actor)) { clutter_container_add_actor (CLUTTER_CONTAINER (actor), texture); clutter_actor_set_position (texture, 0, 0); } else { parent = clutter_actor_get_parent (actor); clutter_container_add_actor (CLUTTER_CONTAINER (parent), texture); clutter_actor_get_position (actor, &x, &y); clutter_actor_set_position (texture, x, y); } /*This make it real background ... * TODO: how about both par/child actor with background */ clutter_actor_lower_bottom (texture); }
static gboolean glide_image_button_press (ClutterActor *actor, ClutterButtonEvent *event) { GlideStageManager *m; GlideActor *ga = GLIDE_ACTOR (actor); GlideImage *image = GLIDE_IMAGE (actor); gfloat ax, ay; m = glide_actor_get_stage_manager (ga); glide_stage_manager_set_selection (m, ga); clutter_actor_get_position (actor, &ax, &ay); image->priv->drag_center_x = event->x - ax; image->priv->drag_center_y = event->y - ay; image->priv->dragging = TRUE; image->priv->motion_since_press = FALSE; clutter_grab_pointer (actor); glide_undo_manager_start_actor_action (glide_actor_get_undo_manager (GLIDE_ACTOR (actor)), GLIDE_ACTOR (actor), "Move object"); return TRUE; }
static void _capture_desktop(MetaSwitcher* self) { MetaSwitcherPrivate* priv = self->priv; MetaScreen* screen = meta_plugin_get_screen(priv->plugin); ClutterActor* stage = meta_get_stage_for_screen(screen); gfloat tx, ty, w, h; clutter_actor_get_position(priv->top, &tx, &ty); clutter_actor_get_size(priv->top, &w, &h); g_debug("%s: %f, %f, %f, %f", __func__, tx, ty, w, h); if (priv->snapshot) { cairo_surface_destroy(priv->snapshot); priv->snapshot = NULL; } priv->snapshot_offset = 20.0; w += priv->snapshot_offset*3; clutter_stage_ensure_redraw(CLUTTER_STAGE(stage)); guchar* data = g_malloc(w*h*4); cogl_framebuffer_read_pixels(cogl_get_draw_framebuffer(), tx-priv->snapshot_offset, ty, w, h, CLUTTER_CAIRO_FORMAT_ARGB32, data); /*guchar* data = clutter_stage_read_pixels(CLUTTER_STAGE(stage), */ /*tx-priv->snapshot_offset, ty, w, h);*/ priv->snapshot = cairo_image_surface_create_for_data(data, CAIRO_FORMAT_ARGB32, w, h, w*4); g_free(data); }
void gnibbles_board_rescale (GnibblesBoard *board, gint tilesize) { gint i, count; gfloat x_pos, y_pos; ClutterActor *tmp; if (!board->level) return; if (!board->surface) return; board->width = BOARDWIDTH * tilesize; board->height = BOARDHEIGHT * tilesize; clutter_actor_set_size (CLUTTER_ACTOR (board->surface), board->width, board->height); count = clutter_group_get_n_children (CLUTTER_GROUP (board->level)); for (i = 0; i < count; i++) { tmp = clutter_group_get_nth_child (CLUTTER_GROUP (board->level), i); clutter_actor_get_position (CLUTTER_ACTOR (tmp), &x_pos, &y_pos); clutter_actor_set_position (CLUTTER_ACTOR (tmp), (x_pos / properties->tilesize) * tilesize, (y_pos / properties->tilesize) * tilesize); clutter_actor_set_size (CLUTTER_ACTOR (tmp), tilesize, tilesize); } }
static void on_drag_begin (ClutterDragAction *action, ClutterActor *actor, gfloat event_x, gfloat event_y, ClutterModifierType modifiers) { ClutterActor *handle; gfloat x_pos, y_pos; clutter_actor_get_position (actor, &x_pos, &y_pos); handle = clutter_actor_new (); clutter_actor_set_background_color (handle, CLUTTER_COLOR_DarkSkyBlue); clutter_actor_set_size (handle, 128, 128); clutter_actor_set_position (handle, event_x - x_pos, event_y - y_pos); clutter_actor_add_child (stage, handle); clutter_drag_action_set_drag_handle (action, handle); clutter_actor_save_easing_state (actor); clutter_actor_set_easing_mode (actor, CLUTTER_LINEAR); clutter_actor_set_opacity (actor, 128); clutter_actor_restore_easing_state (actor); drop_successful = FALSE; }
void gnibbles_board_resize (GnibblesBoard *board, gint newtile) { int i; int x_pos; int y_pos; int count; ClutterActor *tmp; ClutterActor *stage = gnibbles_board_get_stage (board); clutter_actor_set_size (stage, BOARDWIDTH * newtile, BOARDHEIGHT * newtile); clutter_actor_set_size (board->surface, BOARDWIDTH * newtile, BOARDHEIGHT * newtile); if (!board->level) return; count = clutter_group_get_n_children (CLUTTER_GROUP (board->level)); for (i = 0; i < count; i++) { tmp = clutter_group_get_nth_child (CLUTTER_GROUP (board->level), i); clutter_actor_get_position (tmp, &x_pos, &y_pos); clutter_actor_set_position (tmp, (x_pos / properties->tilesize) * newtile, (y_pos / properties->tilesize) * newtile); clutter_actor_set_size (tmp ,newtile, newtile); } }
void gnibbles_worm_rescale (GnibblesWorm *worm, gint tilesize) { int i; gfloat x_pos, y_pos; gint count; ClutterActor *tmp; GError *err = NULL; if (!worm) return; if (!worm->actors) return; count = clutter_group_get_n_children (CLUTTER_GROUP (worm->actors)); for (i = 0; i < count; i++) { tmp = clutter_group_get_nth_child (CLUTTER_GROUP (worm->actors), i); clutter_actor_get_position (tmp, &x_pos, &y_pos); clutter_actor_set_position (tmp, (x_pos / properties->tilesize) * tilesize, (y_pos / properties->tilesize) * tilesize); gtk_clutter_texture_set_from_pixbuf ( CLUTTER_TEXTURE (tmp), worm_pixmaps[properties->wormprops[worm->number]->color - 12], &err); if (err) gnibbles_error (err->message); } }
void gnibbles_worm_reduce_tail (GnibblesWorm *worm, gint erasesize) { gint i; gfloat x,y; ClutterActor *tmp = NULL; ClutterActor *group = clutter_group_new (); if (erasesize) { if (g_list_length (worm->list) <= erasesize) { gnibbles_worm_reset (worm); return; } for (i = 0; i < erasesize; i++) { tmp = gtk_clutter_texture_new_from_pixbuf ( worm_pixmaps[properties->wormprops[worm->number]->color - 12]); clutter_actor_get_position (CLUTTER_ACTOR (g_list_last (worm->list)->data), &x, &y); clutter_actor_set_position (CLUTTER_ACTOR (tmp), x, y); clutter_actor_set_size (CLUTTER_ACTOR (tmp), properties->tilesize, properties->tilesize); clutter_container_add_actor (CLUTTER_CONTAINER (group), tmp); gnibbles_worm_move_tail_pointer (worm); } worm->length -= erasesize; clutter_container_add_actor (CLUTTER_CONTAINER (stage), group); clutter_actor_animate (group, CLUTTER_EASE_OUT_ELASTIC, 850, "opacity", 0, NULL); } }
static void cinnamon_gtk_embed_allocate (ClutterActor *actor, const ClutterActorBox *box, ClutterAllocationFlags flags) { CinnamonGtkEmbed *embed = CINNAMON_GTK_EMBED (actor); float wx = 0.0, wy = 0.0, x, y, ax, ay; CLUTTER_ACTOR_CLASS (cinnamon_gtk_embed_parent_class)-> allocate (actor, box, flags); /* Find the actor's new coordinates in terms of the stage (which is * priv->window's parent window. */ while (actor) { clutter_actor_get_position (actor, &x, &y); clutter_actor_get_anchor_point (actor, &ax, &ay); wx += x - ax; wy += y - ay; actor = clutter_actor_get_parent (actor); } _cinnamon_embedded_window_allocate (embed->priv->window, (int)(0.5 + wx), (int)(0.5 + wy), box->x2 - box->x1, box->y2 - box->y1); }
static void overview_animated_destroy(MosesOverview* self, MosesOverviewQuitReason reason, gboolean animate) { MosesOverviewPrivate* priv = self->priv; gboolean just_destroy = !animate; if (reason == MOSES_OV_REASON_ACTIVATE_WINDOW && !priv->selected_actor) { just_destroy = TRUE; } else if (reason == MOSES_OV_REASON_ACTIVATE_WORKSPACE && !priv->selected_workspace) { just_destroy = TRUE; } else if (reason == MOSES_OV_REASON_NORMAL) { just_destroy = TRUE; } if (just_destroy) { clutter_actor_destroy(CLUTTER_ACTOR(self)); return; } gfloat x, y, w, h; ClutterActor* target = NULL; if (reason == MOSES_OV_REASON_ACTIVATE_WINDOW) { target = self->priv->selected_actor; ClutterActor* orig = clutter_clone_get_source(CLUTTER_CLONE(target)); clutter_actor_get_position(orig, &x, &y); clutter_actor_get_size(orig, &w, &h); g_signal_handlers_disconnect_by_func(target, on_effect_complete, self); } else if (reason == MOSES_OV_REASON_ACTIVATE_WORKSPACE) { g_assert(priv->selected_actor == NULL); MetaScreen* screen = meta_plugin_get_screen(priv->plugin); target = overview_head_get_actor_for_workspace(priv->ov_head, priv->selected_workspace); MetaRectangle geom; int focused_monitor = meta_screen_get_current_monitor(screen); meta_screen_get_monitor_geometry(screen, focused_monitor, &geom); x = geom.x, y = geom.y, w = geom.width, h = geom.height; } if (target) { clutter_actor_remove_all_transitions(target); clutter_actor_set_child_above_sibling(clutter_actor_get_parent(target), target, NULL); clutter_actor_save_easing_state(target); clutter_actor_set_easing_mode(target, CLUTTER_LINEAR); clutter_actor_set_easing_duration(target, 150); clutter_actor_set_position(target, x, y); clutter_actor_set_scale(target, w / clutter_actor_get_width(target), h / clutter_actor_get_height(target)); clutter_actor_restore_easing_state(target); g_object_connect(target, "signal::transitions-completed", G_CALLBACK(on_restore_position_effect_complete), self, NULL); } }
static void prepare_workspace_content(MosesOverview *self, MetaWorkspace *ws) { MosesOverviewPrivate* priv = self->priv; GList* l = meta_workspace_list_windows(ws); if (!priv->clones) { priv->clones = g_ptr_array_new(); } while (l) { MetaWindow* win = l->data; MetaWindowActor* win_actor = META_WINDOW_ACTOR(meta_window_get_compositor_private(win)); if (meta_window_get_window_type(win) == META_WINDOW_DESKTOP) { g_debug("%s: got desktop actor", __func__); priv->background_actor = clutter_clone_new(CLUTTER_ACTOR(win_actor)); } else if (meta_window_get_window_type(win) == META_WINDOW_NORMAL && !meta_window_is_hidden(win)) { ClutterActor* clone = clutter_clone_new(CLUTTER_ACTOR(win_actor)); clutter_actor_set_reactive(clone, TRUE); float x = 0.0, y = 0.0; clutter_actor_get_position(CLUTTER_ACTOR(win_actor), &x, &y); clutter_actor_set_position(clone, x, y); clutter_actor_hide(CLUTTER_ACTOR(win_actor)); g_ptr_array_add(priv->clones, clone); clutter_actor_add_child(CLUTTER_ACTOR(self), clone); g_object_connect(clone, "signal::transitions-completed", G_CALLBACK(on_effect_complete), self, "signal::button-press-event", on_thumb_button_press, self, "signal::enter-event", on_thumb_enter, self, "signal::leave-event", on_thumb_leave, self, NULL); } l = l->next; } ClutterColor clr = CLUTTER_COLOR_INIT(0xff, 0xff, 0xff, 0xff); clutter_actor_set_background_color(CLUTTER_ACTOR(self), &clr); if (priv->background_actor) { #if 0 ClutterEffect* blur = moses_blur_effect_new(); clutter_actor_add_effect_with_name(priv->background_actor, "blur", blur); clutter_actor_insert_child_below(CLUTTER_ACTOR(self), priv->background_actor, NULL); clutter_actor_hide(clutter_clone_get_source(CLUTTER_CLONE(priv->background_actor))); clutter_actor_set_reactive(priv->background_actor, TRUE); #endif } g_object_connect(priv->background_actor ? priv->background_actor: CLUTTER_ACTOR(self), "signal::button-press-event", on_bg_button_press, self, NULL); }
static int mp_get_viewport_geometry(TPMediaPlayer * mp,int * left,int * top,int * width,int * height) { USERDATA(mp); CM(ud); gfloat x,y,w,h; clutter_actor_get_position(CLUTTER_ACTOR(cm),&x,&y); clutter_actor_get_size(CLUTTER_ACTOR(cm),&w,&h); *left=x; *top=y; *width=w; *height=h; return 0; }
static void clutter_align_constraint_update_allocation (ClutterConstraint *constraint, ClutterActor *actor, ClutterActorBox *allocation) { ClutterAlignConstraint *align = CLUTTER_ALIGN_CONSTRAINT (constraint); gfloat source_width, source_height; gfloat actor_width, actor_height; gfloat source_x, source_y; if (align->source == NULL) return; clutter_actor_box_get_size (allocation, &actor_width, &actor_height); clutter_actor_get_position (align->source, &source_x, &source_y); clutter_actor_get_size (align->source, &source_width, &source_height); switch (align->align_axis) { case CLUTTER_ALIGN_X_AXIS: allocation->x1 = ((source_width - actor_width) * align->factor) + source_x; allocation->x1 = floorf (allocation->x1 + 0.5); allocation->x2 = allocation->x1 + actor_width; break; case CLUTTER_ALIGN_Y_AXIS: allocation->y1 = ((source_height - actor_height) * align->factor) + source_y; allocation->y1 = floorf (allocation->y1 + 0.5); allocation->y2 = allocation->y1 + actor_height; break; case CLUTTER_ALIGN_BOTH: allocation->x1 = ((source_width - actor_width) * align->factor) + source_x; allocation->y1 = ((source_height - actor_height) * align->factor) + source_y; allocation->x1 = floorf (allocation->x1 + 0.5f); allocation->y1 = floorf (allocation->y1 + 0.5f); allocation->x2 = allocation->x1 + actor_width; allocation->y2 = allocation->y1 + actor_height; break; default: g_assert_not_reached (); break; } }
static void gnibbles_worm_animate_death (GnibblesWorm *worm) { ClutterActor *group = clutter_group_new (); ClutterActor *tmp = NULL; int i; gfloat x,y; for (i = 0; i < g_list_length (worm->list); i++) { tmp = gtk_clutter_texture_new_from_pixbuf ( worm_pixmaps [properties->wormprops[worm->number]->color - 12]); clutter_actor_get_position (CLUTTER_ACTOR (g_list_nth_data (worm->list, i)), &x, &y); clutter_actor_set_position (CLUTTER_ACTOR (tmp), x, y); clutter_actor_set_size (CLUTTER_ACTOR (tmp), properties->tilesize, properties->tilesize); clutter_container_add_actor (CLUTTER_CONTAINER (group), tmp); } worm->length = g_list_length (worm->list); for (i = 0; i < worm->length ; i++) worm->list = g_list_remove (worm->list, g_list_nth_data (worm->list, i)); clutter_actor_set_opacity (CLUTTER_ACTOR (worm->actors), 0x00); clutter_group_remove_all (CLUTTER_GROUP (worm->actors)); g_list_free (worm->list); worm->list = NULL; clutter_container_add_actor (CLUTTER_CONTAINER (stage), group); clutter_actor_animate (group, CLUTTER_EASE_OUT_QUAD, 310, "opacity", 0, "scale-x", 2.0, "scale-y", 2.0, "fixed::scale-center-x", (gfloat) worm->xhead * properties->tilesize, "fixed::scale-center-y", (gfloat) worm->yhead * properties->tilesize, NULL); }
void gnibbles_warpmanager_rescale (GnibblesWarpManager *warpmanager, gint tilesize) { int i; gfloat x_pos, y_pos; GError *err = NULL; for (i = 0; i < warpmanager->numwarps; i++) { clutter_actor_get_position (warpmanager->warps[i]->actor, &x_pos, &y_pos); clutter_actor_set_position (warpmanager->warps[i]->actor, (x_pos / properties->tilesize) * tilesize, (y_pos / properties->tilesize) * tilesize); gtk_clutter_texture_set_from_pixbuf (CLUTTER_TEXTURE (warpmanager->warps[i]->actor), boni_pixmaps[WARP], &err); if (err) gnibbles_error (err->message); } }
void on_timeline_new_frame(ClutterTimeline *timeline, gint frame_num, gpointer data) { HandCar *all = (HandCar *)data; gint x, y, actor_width, actor_height; clutter_actor_get_position(all->label_actor, &x, &y); clutter_actor_get_size(all->label_actor, &actor_width, &actor_height); if (x < (actor_width * -1)) x = STAGE_WIDTH; else x -= 10; clutter_actor_set_position(all->label_actor, x, y); }
/** * meta_cullable_cull_out_children: * @cullable: The #MetaCullable * @unobscured_region: The unobscured region, as passed into cull_out() * @clip_region: The clip region, as passed into cull_out() * * This is a helper method for actors that want to recurse over their * child actors, and cull them out. * * See #MetaCullable and meta_cullable_cull_out() for more details. */ void meta_cullable_cull_out_children (MetaCullable *cullable, cairo_region_t *unobscured_region, cairo_region_t *clip_region) { ClutterActor *actor = CLUTTER_ACTOR (cullable); ClutterActor *child; ClutterActorIter iter; clutter_actor_iter_init (&iter, actor); while (clutter_actor_iter_prev (&iter, &child)) { float x, y; gboolean needs_culling; if (!META_IS_CULLABLE (child)) continue; needs_culling = (unobscured_region != NULL && clip_region != NULL); if (needs_culling && !CLUTTER_ACTOR_IS_VISIBLE (child)) needs_culling = FALSE; /* If an actor has effects applied, then that can change the area * it paints and the opacity, so we no longer can figure out what * portion of the actor is obscured and what portion of the screen * it obscures, so we skip the actor. * * This has a secondary beneficial effect: if a ClutterOffscreenEffect * is applied to an actor, then our clipped redraws interfere with the * caching of the FBO - even if we only need to draw a small portion * of the window right now, ClutterOffscreenEffect may use other portions * of the FBO later. So, skipping actors with effects applied also * prevents these bugs. * * Theoretically, we should check clutter_actor_get_offscreen_redirect() * as well for the same reason, but omitted for simplicity in the * hopes that no-one will do that. */ if (needs_culling && clutter_actor_has_effects (child)) needs_culling = FALSE; if (needs_culling && !meta_actor_is_untransformed (child, NULL, NULL)) needs_culling = FALSE; if (needs_culling) { clutter_actor_get_position (child, &x, &y); /* Temporarily move to the coordinate system of the actor */ cairo_region_translate (unobscured_region, - x, - y); cairo_region_translate (clip_region, - x, - y); meta_cullable_cull_out (META_CULLABLE (child), unobscured_region, clip_region); cairo_region_translate (unobscured_region, x, y); cairo_region_translate (clip_region, x, y); } else { meta_cullable_cull_out (META_CULLABLE (child), NULL, NULL); } } }
static void on_clicked (ClutterClickAction *action, ClutterActor *actor, gpointer dummy G_GNUC_UNUSED) { ClutterAnimation *animation; gfloat old_x, old_y, new_x, new_y; gfloat old_width, old_height, new_width, new_height; gdouble new_angle; ClutterVertex vertex = { 0, }; ClutterColor new_color = { 0, }; clutter_actor_get_position (actor, &old_x, &old_y); clutter_actor_get_size (actor, &old_width, &old_height); /* determine the final state of the animation depending on * the state of the actor */ if (!is_expanded) { new_x = old_x - 100; new_y = old_y - 100; new_width = old_width + 200; new_height = old_height + 200; new_angle = 360.0; new_color.red = 0xdd; new_color.green = 0x44; new_color.blue = 0xdd; new_color.alpha = 0xff; } else { new_x = old_x + 100; new_y = old_y + 100; new_width = old_width - 200; new_height = old_height - 200; new_angle = 0.0; new_color.red = 0x44; new_color.green = 0xdd; new_color.blue = 0x44; new_color.alpha = 0x88; } vertex.x = new_width / 2; vertex.y = new_height / 2; vertex.z = 0.0; animation = clutter_actor_animate (actor, CLUTTER_EASE_IN_EXPO, 2000, "x", new_x, "y", new_y, "width", new_width, "height", new_height, "color", &new_color, "rotation-angle-z", new_angle, "fixed::rotation-center-z", &vertex, "fixed::reactive", FALSE, NULL); g_signal_connect (animation, "completed", G_CALLBACK (on_animation_complete), actor); }
static void on_gesture_end(ClutterGestureAction *action, ClutterActor *stage, gpointer data) { ClutterActor *new_actor, *texture, *actor; gfloat x, y, w, h; GError *error = NULL; GdkColor color; guint16 alpha; gint iw = 125; gint ih = 126; gboolean repeat_x = FALSE; gboolean repeat_y = TRUE; guint bgr; new_actor = tmpRect; gtk_color_button_get_color(GTK_COLOR_BUTTON(app.colorpicker), &color); alpha = gtk_color_button_get_alpha(GTK_COLOR_BUTTON(app.colorpicker)); ClutterColor col = { CLAMP(((color.red / 65535.0) * 255), 0, 255), CLAMP(((color.green / 65535.0) * 255), 0, 255), CLAMP(((color.blue / 65535.0) * 255), 0, 255), CLAMP(((alpha / 65535.0) * 255), 0, 255), }; clutter_rectangle_set_color(CLUTTER_RECTANGLE(new_actor), &col); clutter_rectangle_set_border_width(CLUTTER_RECTANGLE(new_actor), 0); tmpRect = NULL; clutter_actor_get_position(new_actor, &x, &y); clutter_actor_get_size(new_actor, &w, &h); if (background_image_file != NULL){ texture = clutter_texture_new_from_file(background_image_file, &error); if (error != NULL){ g_print("Loading image failed\n"); g_error_free(error); } clutter_actor_set_position(texture, x, y); clutter_actor_set_size(texture, w, h); clutter_actor_add_child(stage, texture); clutter_actor_show(texture); bgr = gtk_combo_box_get_active(GTK_COMBO_BOX(app.background_repeat_select)); switch (bgr){ case 0: repeat_x = repeat_y = FALSE; break; case 1: repeat_x = TRUE; repeat_y = FALSE; break; case 2: repeat_x = FALSE; repeat_y = TRUE; break; case 3: repeat_x = repeat_y = TRUE; break; } clutter_texture_get_base_size(CLUTTER_TEXTURE(texture), &iw, &ih); clutter_actor_set_clip(texture, 0, 0, repeat_x ? w : iw, repeat_y ? h : ih); clutter_texture_set_sync_size(CLUTTER_TEXTURE(texture), TRUE); clutter_texture_set_repeat(CLUTTER_TEXTURE(texture), TRUE, TRUE); clutter_texture_set_keep_aspect_ratio(CLUTTER_TEXTURE(texture), TRUE); actor = texture; clutter_actor_destroy(new_actor); } else { actor = new_actor; } tool = TOOL_SELECT; clutter_actor_add_action(actor, clutter_drag_action_new()); clutter_actor_set_reactive(actor, TRUE); actors = g_list_append(actors, actor); GdkWindow *gdk_window; gdk_window = gtk_widget_get_window(app.stage); gdk_window_set_cursor(gdk_window, NULL); }
static void clutter_snap_constraint_update_allocation (ClutterConstraint *constraint, ClutterActor *actor, ClutterActorBox *allocation) { ClutterSnapConstraint *self = CLUTTER_SNAP_CONSTRAINT (constraint); gfloat source_width, source_height; gfloat source_x, source_y; gfloat actor_width, actor_height; if (self->source == NULL) return; clutter_actor_get_position (self->source, &source_x, &source_y); clutter_actor_get_size (self->source, &source_width, &source_height); clutter_actor_box_get_size (allocation, &actor_width, &actor_height); switch (self->to_edge) { case CLUTTER_SNAP_EDGE_LEFT: if (self->from_edge == CLUTTER_SNAP_EDGE_LEFT) allocation->x1 = source_x + self->offset; else if (self->from_edge == CLUTTER_SNAP_EDGE_RIGHT) allocation->x2 = source_x + self->offset; else warn_horizontal_edge ("left", self->actor, self->source); break; case CLUTTER_SNAP_EDGE_RIGHT: if (self->from_edge == CLUTTER_SNAP_EDGE_RIGHT) allocation->x2 = source_x + source_width + self->offset; else if (self->from_edge == CLUTTER_SNAP_EDGE_LEFT) allocation->x1 = source_x + source_width + self->offset; else warn_horizontal_edge ("right", self->actor, self->source); break; break; case CLUTTER_SNAP_EDGE_TOP: if (self->from_edge == CLUTTER_SNAP_EDGE_TOP) allocation->y1 = source_y + self->offset; else if (self->from_edge == CLUTTER_SNAP_EDGE_BOTTOM) allocation->y2 = source_y + self->offset; else warn_vertical_edge ("top", self->actor, self->source); break; case CLUTTER_SNAP_EDGE_BOTTOM: if (self->from_edge == CLUTTER_SNAP_EDGE_BOTTOM) allocation->y2 = source_y + source_height + self->offset; else if (self->from_edge == CLUTTER_SNAP_EDGE_TOP) allocation->y1 = source_y + source_height + self->offset; else warn_vertical_edge ("bottom", self->actor, self->source); break; default: g_assert_not_reached (); break; } if (allocation->x2 - allocation->x1 < 0) allocation->x2 = allocation->x1; if (allocation->y2 - allocation->y1 < 0) allocation->y2 = allocation->y1; }
static gboolean actor_manipulator_press (ClutterActor *stage, ClutterEvent *event, gpointer data) { ClutterActor *actor; actor = clutter_stage_get_actor_at_pos (CLUTTER_STAGE (stage), CLUTTER_PICK_ALL, event->button.x, event->button.y); if (actor == stage || CLUTTER_IS_GROUP (actor)) { if (event->button.button == 3) { popup_nuke (stage, event->button.x, event->button.y); popup_add ("+rectangle", "bar", G_CALLBACK ( action_add_rectangle), scene_get_group ()); popup_add ("+circle", "bar", G_CALLBACK ( action_add_circle), scene_get_group ()); popup_add ("+triangle", "bar", G_CALLBACK ( action_add_triangle), scene_get_group ()); popup_add ("+text", "bar", G_CALLBACK ( action_add_text), scene_get_group ()); popup_add ("+image", "bar", G_CALLBACK ( action_add_image), scene_get_group ()); #if 0 popup_add ("+block-tree", "bar", G_CALLBACK ( action_add_block_tree), scene_get_group ()); #endif popup_add ("zero gravity", "bar", G_CALLBACK ( action_zero_gravity), scene_get_group ()); } return TRUE; } if (actor == NULL) { return FALSE; } if (event->button.button == 3) { popup_nuke (stage, event->button.x, event->button.y); popup_add ("remove", "bar", G_CALLBACK (action_remove), actor); popup_add ("set linear velocity", "bar", G_CALLBACK (action_set_linear_velocity), actor); popup_add ("set dynamic", "bar", G_CALLBACK (action_set_dynamic), actor); popup_add ("set static", "bar", G_CALLBACK (action_set_static), actor); popup_add_slider ("opacity", "hm", 0.0, 255.0, clutter_actor_get_opacity (actor) * 1.0, G_CALLBACK (set_opacity), actor); popup_add_slider ("rotation", "hm", 0.0, 360.0, clutter_actor_get_rotation (actor, CLUTTER_Z_AXIS, NULL, NULL, NULL), G_CALLBACK (set_rotation), actor); popup_add ("ok", "bar", NULL, NULL); return TRUE; } if (!should_be_manipulated (actor)) return FALSE; manipulated_actor = actor; clutter_actor_get_position (actor, &orig_x, &orig_y); orig_rotation = clutter_actor_get_rotation (actor, CLUTTER_Z_AXIS, NULL, NULL, NULL); start_x = (event->button.x); start_y = (event->button.y); clutter_actor_transform_stage_point ( clutter_actor_get_parent (manipulated_actor), start_x, start_y, &start_x, &start_y); mode = Direct; #ifdef BOX2D_MANIPULATION /* Use Box2D manipulation if the actor is dynamic, and the physics * engine is running */ if (CLUTTER_IS_BOX2D (scene_get_group ()) && clutter_box2d_get_simulating (CLUTTER_BOX2D (scene_get_group ()))) { ClutterBox2D *box2d = CLUTTER_BOX2D (scene_get_group ()); /*ClutterVertex target = { start_x, start_y };*/ gint type; clutter_container_child_get (CLUTTER_CONTAINER (box2d), manipulated_actor, "mode", &type, NULL); if (type == CLUTTER_BOX2D_DYNAMIC) { #if 0 mouse_joint = clutter_box2d_add_mouse_joint (CLUTTER_BOX2D ( scene_get_group ()), manipulated_actor, &target); #endif mode = None; /*Box2D;*/ manipulated_actor = NULL; return FALSE; } } #endif clutter_set_motion_events_enabled (FALSE); return TRUE; }
/** * shell_screenshot_screenshot_window: * @screenshot: the #ShellScreenshot * @include_frame: Whether to include the frame or not * @include_cursor: Whether to include the cursor or not * @filename: The filename for the screenshot * @callback: (scope async): function to call returning success or failure * of the async grabbing * * Takes a screenshot of the focused window (optionally omitting the frame) * in @filename as png image. * */ void shell_screenshot_screenshot_window (ShellScreenshot *screenshot, gboolean include_frame, gboolean include_cursor, const char *filename, ShellScreenshotCallback callback) { GSimpleAsyncResult *result; GSettings *settings; _screenshot_data *screenshot_data = g_new0 (_screenshot_data, 1); MetaScreen *screen = shell_global_get_screen (screenshot->global); MetaCursorTracker *tracker; MetaDisplay *display = meta_screen_get_display (screen); MetaWindow *window = meta_display_get_focus_window (display); ClutterActor *window_actor; gfloat actor_x, actor_y; MetaShapedTexture *stex; MetaRectangle rect; cairo_rectangle_int_t clip; screenshot_data->screenshot = g_object_ref (screenshot); screenshot_data->filename = g_strdup (filename); screenshot_data->callback = callback; if (!window) { screenshot_data->filename_used = g_strdup (""); result = g_simple_async_result_new (NULL, on_screenshot_written, (gpointer)screenshot_data, shell_screenshot_screenshot_window); g_simple_async_result_set_op_res_gboolean (result, FALSE); g_simple_async_result_complete (result); g_object_unref (result); return; } window_actor = CLUTTER_ACTOR (meta_window_get_compositor_private (window)); clutter_actor_get_position (window_actor, &actor_x, &actor_y); if (include_frame || !meta_window_get_frame (window)) { meta_window_get_outer_rect (window, &rect); screenshot_data->screenshot_area.x = rect.x; screenshot_data->screenshot_area.y = rect.y; clip.x = rect.x - (gint) actor_x; clip.y = rect.y - (gint) actor_y; } else { rect = *meta_window_get_rect (window); screenshot_data->screenshot_area.x = (gint) actor_x + rect.x; screenshot_data->screenshot_area.y = (gint) actor_y + rect.y; clip.x = rect.x; clip.y = rect.y; } clip.width = screenshot_data->screenshot_area.width = rect.width; clip.height = screenshot_data->screenshot_area.height = rect.height; stex = META_SHAPED_TEXTURE (meta_window_actor_get_texture (META_WINDOW_ACTOR (window_actor))); screenshot_data->image = meta_shaped_texture_get_image (stex, &clip); settings = g_settings_new (A11Y_APPS_SCHEMA); if (include_cursor && !g_settings_get_boolean (settings, MAGNIFIER_ACTIVE_KEY)) { tracker = meta_cursor_tracker_get_for_screen (screen); _draw_cursor_image (tracker, screenshot_data->image, screenshot_data->screenshot_area); } g_object_unref (settings); result = g_simple_async_result_new (NULL, on_screenshot_written, (gpointer)screenshot_data, shell_screenshot_screenshot_window); g_simple_async_result_run_in_thread (result, write_screenshot_thread, G_PRIORITY_DEFAULT, NULL); g_object_unref (result); }