[mutter] clutter/actor: Add API to get fixed position
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] clutter/actor: Add API to get fixed position
- Date: Tue, 7 Jul 2020 16:57:35 +0000 (UTC)
commit dfa235aa5da14fddda837a5bd527773eabd0f895
Author: Jonas Dreßler <verdre v0yd nl>
Date: Fri Jun 19 13:32:59 2020 +0200
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
clutter/clutter/clutter-actor.c | 37 +++++++++++++++++++++++++++++++++++++
clutter/clutter/clutter-actor.h | 4 ++++
2 files changed, 41 insertions(+)
---
diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c
index 9bafacac52..c5ce7300f3 100644
--- a/clutter/clutter/clutter-actor.c
+++ b/clutter/clutter/clutter-actor.c
@@ -10258,6 +10258,43 @@ clutter_actor_get_position (ClutterActor *self,
*y = clutter_actor_get_y (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
diff --git a/clutter/clutter/clutter-actor.h b/clutter/clutter/clutter-actor.h
index e5fa72baed..a9829f02d3 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]