From 2c7d33bad2653b9ad9bce090b5b8227cd6393ad1 Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Sat, 6 Jun 2009 13:07:41 -0400 Subject: [PATCH] Port gnome-shell to the Clutter-1.0 API - clutter_actor_get_transformed_position()/size() return floats - clutter_stage_get_actor_at_pos() takes a pick mode - ClutterTimeline no longer has a concept of frames - ClutterUnit is now replaced by float - cogl_texture_new_from_data() signature changed http://bugzilla.gnome.org/show_bug.cgi?id=585013 --- js/ui/chrome.js | 4 ++++ js/ui/dnd.js | 7 +++++-- js/ui/genericDisplay.js | 3 ++- js/ui/tweener.js | 26 +++++++++----------------- src/shell-gtk-embed.c | 20 ++++++++++---------- src/shell-recorder.c | 6 +++--- src/shell-status-menu.c | 6 +++--- src/shell-texture-cache.c | 3 +-- 8 files changed, 37 insertions(+), 38 deletions(-) diff --git a/js/ui/chrome.js b/js/ui/chrome.js index 7a50c29f4..8a962425f 100644 --- a/js/ui/chrome.js +++ b/js/ui/chrome.js @@ -289,6 +289,10 @@ Chrome.prototype = { let [x, y] = actorData.actor.get_transformed_position(); let [w, h] = actorData.actor.get_transformed_size(); + x = Math.round(x); + y = Math.round(y); + w = Math.round(w); + h = Math.round(h); let rect = new Meta.Rectangle({ x: x, y: y, width: w, height: h}); if (actorData.inputRegion && actorData.actor.get_paint_visibility()) diff --git a/js/ui/dnd.js b/js/ui/dnd.js index 940433940..300aeed7d 100644 --- a/js/ui/dnd.js +++ b/js/ui/dnd.js @@ -122,7 +122,9 @@ _Draggable.prototype = { // Because we want to find out what other actor is located at the current position of this._dragActor, // we have to temporarily hide this._dragActor. this._dragActor.hide(); - let target = actor.get_stage().get_actor_at_pos(stageX + this._dragOffsetX, stageY + this._dragOffsetY); + let target = actor.get_stage().get_actor_at_pos(Clutter.PickMode.ALL, + stageX + this._dragOffsetX, + stageY + this._dragOffsetY); this._dragActor.show(); while (target) { if (target._delegate && target._delegate.handleDragOver) { @@ -156,7 +158,8 @@ _Draggable.prototype = { // Find a drop target actor.hide(); let [dropX, dropY] = event.get_coords(); - let target = actor.get_stage().get_actor_at_pos(dropX, dropY); + let target = actor.get_stage().get_actor_at_pos(Clutter.PickMode.ALL, + dropX, dropY); actor.show(); while (target) { if (target._delegate && target._delegate.acceptDrop) { diff --git a/js/ui/genericDisplay.js b/js/ui/genericDisplay.js index d4d2c5af8..4ddaf0688 100644 --- a/js/ui/genericDisplay.js +++ b/js/ui/genericDisplay.js @@ -648,7 +648,8 @@ GenericDisplay.prototype = { // Check if the pointer is over one of the items and display the preview pop-up if it is. let [child, x, y, mask] = Gdk.Screen.get_default().get_root_window().get_pointer(); let global = Shell.Global.get(); - let actor = global.stage.get_actor_at_pos(x, y); + let actor = global.stage.get_actor_at_pos(Clutter.PickMode.REACTIVE, + x, y); if (actor != null) { let item = this._findDisplayedByActor(actor.get_parent()); if (item != null) { diff --git a/js/ui/tweener.js b/js/ui/tweener.js index 87d929231..74cab9651 100644 --- a/js/ui/tweener.js +++ b/js/ui/tweener.js @@ -204,10 +204,9 @@ ClutterFrameTicker.prototype = { _init : function() { // We don't have a finite duration; tweener will tell us to stop // when we need to stop, so use 1000 seconds as "infinity" - this._timeline = new Clutter.Timeline({ fps: this.FRAME_RATE, - duration: 1000*1000 }); - this._currentTime = 0; - this._frame = 0; + this._timeline = new Clutter.Timeline({ duration: 1000*1000 }); + this._startTime = -1; + this._currentTime = -1; let me = this; this._timeline.connect('new-frame', @@ -220,20 +219,13 @@ ClutterFrameTicker.prototype = { // If there is a lot of setup to start the animation, then // first frame number we get from clutter might be a long ways // into the animation (or the animation might even be done). - // That looks bad, so we always start one frame into the + // That looks bad, so we always start at the first frame of the // animation then only do frame dropping from there. - let delta; - if (this._frame == 0) - delta = 1; - else - delta = frame - this._frame; - - if (delta == 0) // protect against divide-by-0 if we get a frame twice - delta = 1; + if (this._startTime < 0) + this._startTime = this._timeline.get_elapsed_time(); // currentTime is in milliseconds - this._currentTime += (1000 * delta) / this.FRAME_RATE; - this._frame = frame; + this._currentTime = this._timeline.get_elapsed_time() - this._startTime; this.emit('prepare-frame'); }, @@ -247,8 +239,8 @@ ClutterFrameTicker.prototype = { stop : function() { this._timeline.stop(); - this._frame = 0; - this._currentTime = 0; + this._startTime = -1; + this._currentTime = -1; } }; diff --git a/src/shell-gtk-embed.c b/src/shell-gtk-embed.c index 998651c09..0d5f2978e 100644 --- a/src/shell-gtk-embed.c +++ b/src/shell-gtk-embed.c @@ -147,9 +147,9 @@ shell_gtk_embed_get_property (GObject *object, static void shell_gtk_embed_get_preferred_width (ClutterActor *actor, - ClutterUnit for_height, - ClutterUnit *min_width_p, - ClutterUnit *natural_width_p) + float for_height, + float *min_width_p, + float *natural_width_p) { ShellGtkEmbed *embed = SHELL_GTK_EMBED (actor); @@ -166,9 +166,9 @@ shell_gtk_embed_get_preferred_width (ClutterActor *actor, static void shell_gtk_embed_get_preferred_height (ClutterActor *actor, - ClutterUnit for_width, - ClutterUnit *min_height_p, - ClutterUnit *natural_height_p) + float for_width, + float *min_height_p, + float *natural_height_p) { ShellGtkEmbed *embed = SHELL_GTK_EMBED (actor); @@ -186,13 +186,13 @@ shell_gtk_embed_get_preferred_height (ClutterActor *actor, static void shell_gtk_embed_allocate (ClutterActor *actor, const ClutterActorBox *box, - gboolean absolute_origin_changed) + ClutterAllocationFlags flags) { ShellGtkEmbed *embed = SHELL_GTK_EMBED (actor); - int wx = 0, wy = 0, x, y, ax, ay; + float wx = 0.0, wy = 0.0, x, y, ax, ay; CLUTTER_ACTOR_CLASS (shell_gtk_embed_parent_class)-> - allocate (actor, box, absolute_origin_changed); + allocate (actor, box, flags); /* Find the actor's new coordinates in terms of the stage (which is * priv->window's parent window. @@ -209,7 +209,7 @@ shell_gtk_embed_allocate (ClutterActor *actor, } _shell_embedded_window_allocate (embed->priv->window, - wx, wy, + (int)(0.5 + wx), (int)(0.5 + wy), box->x2 - box->x1, box->y2 - box->y1); } diff --git a/src/shell-recorder.c b/src/shell-recorder.c index b80b7db75..134c0e550 100644 --- a/src/shell-recorder.c +++ b/src/shell-recorder.c @@ -188,7 +188,7 @@ create_recording_icon (void) cairo_destroy (cr); - texture = cogl_texture_new_from_data (32, 32, 63, + texture = cogl_texture_new_from_data (32, 32, COGL_TEXTURE_NONE, COGL_PIXEL_FORMAT_BGRA_8888, COGL_PIXEL_FORMAT_ANY, @@ -576,11 +576,11 @@ static void recorder_queue_redraw (ShellRecorder *recorder) { /* If we just queue a redraw on every mouse motion (for example), we - * starve ClutterTimeline, which operates at a very low priority. So + * starve Clutter, which operates at a very low priority. So * we need to queue a "low priority redraw" after timeline updates */ if (recorder->state == RECORDER_STATE_RECORDING && recorder->redraw_idle == 0) - recorder->redraw_idle = g_idle_add_full (CLUTTER_PRIORITY_TIMELINE + 1, + recorder->redraw_idle = g_idle_add_full (CLUTTER_PRIORITY_REDRAW + 1, recorder_idle_redraw, recorder, NULL); } diff --git a/src/shell-status-menu.c b/src/shell-status-menu.c index ab4fb5a4d..bfe9b41a2 100644 --- a/src/shell-status-menu.c +++ b/src/shell-status-menu.c @@ -598,12 +598,12 @@ static void position_menu (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data) { ShellStatusMenu *status = SHELL_STATUS_MENU (user_data); - int src_x, src_y; + float src_x, src_y; clutter_actor_get_transformed_position (CLUTTER_ACTOR (status), &src_x, &src_y); - *x = src_x; - *y = src_y; + *x = (gint)(0.5 + src_x); + *y = (gint)(0.5 + src_y); } void diff --git a/src/shell-texture-cache.c b/src/shell-texture-cache.c index db03c0a5c..c5930877f 100644 --- a/src/shell-texture-cache.c +++ b/src/shell-texture-cache.c @@ -434,8 +434,7 @@ pixbuf_to_cogl_handle (GdkPixbuf *pixbuf) { return cogl_texture_new_from_data (gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), - 63, /* taken from clutter-texture.c default */ - COGL_TEXTURE_AUTO_MIPMAP, + COGL_TEXTURE_NONE, gdk_pixbuf_get_has_alpha (pixbuf) ? COGL_PIXEL_FORMAT_RGBA_8888 : COGL_PIXEL_FORMAT_RGB_888, COGL_PIXEL_FORMAT_ANY, gdk_pixbuf_get_rowstride (pixbuf),