summaryrefslogtreecommitdiff
path: root/clutter
diff options
context:
space:
mode:
authorJonas Dreßler <verdre@v0yd.nl>2020-06-19 13:32:59 +0200
committerverdre <jonas@dressler.it>2020-07-07 16:47:00 +0000
commitdfa235aa5da14fddda837a5bd527773eabd0f895 (patch)
tree0d094c812519325be29c1cfddc2ca20ca9088967 /clutter
parentd722e59aacf2bec62d523992296a252974131304 (diff)
downloadmutter-dfa235aa5da14fddda837a5bd527773eabd0f895.tar.gz
clutter/actor: Add API to get fixed position
It's currently a bit hard to get the fixed position of an actor. It can be either done by using g_object_get() with the "fixed-x"/"fixed-y" properties or by calling clutter_actor_get_position(). Calling clutter_actor_get_position() can return the fixed position, but it might also return the allocated position if the allocation is valid. The latter is not the best behavior when querying the fixed position during an allocation, so introduce a new function clutter_actor_get_fixed_position() which always gets the fixed position and returns FALSE in case no fixed position is set. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1310
Diffstat (limited to 'clutter')
-rw-r--r--clutter/clutter/clutter-actor.c37
-rw-r--r--clutter/clutter/clutter-actor.h4
2 files changed, 41 insertions, 0 deletions
diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c
index 9bafacac5..c5ce7300f 100644
--- a/clutter/clutter/clutter-actor.c
+++ b/clutter/clutter/clutter-actor.c
@@ -10259,6 +10259,43 @@ clutter_actor_get_position (ClutterActor *self,
}
/**
+ * clutter_actor_get_fixed_position:
+ * @self: a #ClutterActor
+ * @x: (out) (allow-none): return location for the X coordinate, or %NULL
+ * @y: (out) (allow-none): return location for the Y coordinate, or %NULL
+ *
+ * This function gets the fixed position of the actor, if set. If there
+ * is no fixed position set, this function returns %FALSE and doesn't set
+ * the x and y coordinates.
+ *
+ * Returns: %TRUE if the fixed position is set, %FALSE if it isn't
+ */
+gboolean
+clutter_actor_get_fixed_position (ClutterActor *self,
+ float *x,
+ float *y)
+{
+ g_return_val_if_fail (CLUTTER_IS_ACTOR (self), FALSE);
+
+ if (self->priv->position_set)
+ {
+ const ClutterLayoutInfo *info;
+
+ info = _clutter_actor_get_layout_info_or_defaults (self);
+
+ if (x)
+ *x = info->fixed_pos.x;
+
+ if (y)
+ *y = info->fixed_pos.y;
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/**
* clutter_actor_get_transformed_position:
* @self: A #ClutterActor
* @x: (out) (allow-none): return location for the X coordinate, or %NULL
diff --git a/clutter/clutter/clutter-actor.h b/clutter/clutter/clutter-actor.h
index e5fa72bae..a9829f02d 100644
--- a/clutter/clutter/clutter-actor.h
+++ b/clutter/clutter/clutter-actor.h
@@ -454,6 +454,10 @@ void clutter_actor_set_position
gfloat x,
gfloat y);
CLUTTER_EXPORT
+gboolean clutter_actor_get_fixed_position (ClutterActor *self,
+ float *x,
+ float *y);
+CLUTTER_EXPORT
void clutter_actor_get_position (ClutterActor *self,
gfloat *x,
gfloat *y);