[gnome-shell] util: Remove shell_util_get_transformed_allocation
- From: verdre <jonasd src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] util: Remove shell_util_get_transformed_allocation
- Date: Wed, 29 Jul 2020 16:44:16 +0000 (UTC)
commit 71d37bffdfdea2e00980e564d24ba5c0fb87d539
Author: Daniel GarcĂa Moreno <daniel endlessm com>
Date: Wed Jul 29 12:50:47 2020 +0200
util: Remove shell_util_get_transformed_allocation
This helper function could be replaced with the new
clutter_actor_get_transformed_extents, that does the same.
See https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1386
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1380
js/ui/appDisplay.js | 9 ++-------
js/ui/boxpointer.js | 38 ++++++++++++++++++------------------
js/ui/dnd.js | 11 +++++------
src/shell-util.c | 55 -----------------------------------------------------
src/shell-util.h | 3 ---
5 files changed, 27 insertions(+), 89 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 4c8678777b..861db5d5ab 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -2335,13 +2335,8 @@ var AppFolderDialog = GObject.registerClass({
}
_withinDialog(x, y) {
- const childAllocation =
- Shell.util_get_transformed_allocation(this.child);
-
- return x > childAllocation.x1 &&
- x < childAllocation.x2 &&
- y > childAllocation.y1 &&
- y < childAllocation.y2;
+ const childExtents = this.child.get_transformed_extents();
+ return childExtents.contains_point(new Graphene.Point({ x, y }));
}
_setupDragMonitor() {
diff --git a/js/ui/boxpointer.js b/js/ui/boxpointer.js
index 5fe6943a95..b8c2f09b65 100644
--- a/js/ui/boxpointer.js
+++ b/js/ui/boxpointer.js
@@ -1,7 +1,7 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
/* exported BoxPointer */
-const { Clutter, GObject, Shell, St } = imports.gi;
+const { Clutter, GObject, St } = imports.gi;
const Main = imports.ui.main;
@@ -453,15 +453,16 @@ var BoxPointer = GObject.registerClass({
let alignment = this._arrowAlignment;
let monitorIndex = Main.layoutManager.findIndexForActor(sourceActor);
- this._sourceAllocation = Shell.util_get_transformed_allocation(sourceActor);
+ this._sourceExtents = sourceActor.get_transformed_extents();
this._workArea = Main.layoutManager.getWorkAreaForMonitor(monitorIndex);
// Position correctly relative to the sourceActor
let sourceNode = sourceActor.get_theme_node();
let sourceContentBox = sourceNode.get_content_box(sourceActor.get_allocation_box());
- let sourceAllocation = this._sourceAllocation;
- let sourceCenterX = sourceAllocation.x1 + sourceContentBox.x1 + (sourceContentBox.x2 -
sourceContentBox.x1) * this._sourceAlignment;
- let sourceCenterY = sourceAllocation.y1 + sourceContentBox.y1 + (sourceContentBox.y2 -
sourceContentBox.y1) * this._sourceAlignment;
+ let sourceTopLeft = this._sourceExtents.get_top_left();
+ let sourceBottomRight = this._sourceExtents.get_bottom_right();
+ let sourceCenterX = sourceTopLeft.x + sourceContentBox.x1 + (sourceContentBox.x2 -
sourceContentBox.x1) * this._sourceAlignment;
+ let sourceCenterY = sourceTopLeft.y + sourceContentBox.y1 + (sourceContentBox.y2 -
sourceContentBox.y1) * this._sourceAlignment;
let [, , natWidth, natHeight] = this.get_preferred_size();
// We also want to keep it onscreen, and separated from the
@@ -481,16 +482,16 @@ var BoxPointer = GObject.registerClass({
switch (this._arrowSide) {
case St.Side.TOP:
- resY = sourceAllocation.y2 + gap;
+ resY = sourceBottomRight.y + gap;
break;
case St.Side.BOTTOM:
- resY = sourceAllocation.y1 - natHeight - gap;
+ resY = sourceTopLeft.y - natHeight - gap;
break;
case St.Side.LEFT:
- resX = sourceAllocation.x2 + gap;
+ resX = sourceBottomRight.x + gap;
break;
case St.Side.RIGHT:
- resX = sourceAllocation.x1 - natWidth - gap;
+ resX = sourceTopLeft.x - natWidth - gap;
break;
}
@@ -586,29 +587,30 @@ var BoxPointer = GObject.registerClass({
}
_calculateArrowSide(arrowSide) {
- let sourceAllocation = this._sourceAllocation;
+ let sourceTopLeft = this._sourceExtents.get_top_left();
+ let sourceBottomRight = this._sourceExtents.get_bottom_right();
let [, , boxWidth, boxHeight] = this.get_preferred_size();
let workarea = this._workArea;
switch (arrowSide) {
case St.Side.TOP:
- if (sourceAllocation.y2 + boxHeight > workarea.y + workarea.height &&
- boxHeight < sourceAllocation.y1 - workarea.y)
+ if (sourceBottomRight.y + boxHeight > workarea.y + workarea.height &&
+ boxHeight < sourceTopLeft.y - workarea.y)
return St.Side.BOTTOM;
break;
case St.Side.BOTTOM:
- if (sourceAllocation.y1 - boxHeight < workarea.y &&
- boxHeight < workarea.y + workarea.height - sourceAllocation.y2)
+ if (sourceTopLeft.y - boxHeight < workarea.y &&
+ boxHeight < workarea.y + workarea.height - sourceBottomRight.y)
return St.Side.TOP;
break;
case St.Side.LEFT:
- if (sourceAllocation.x2 + boxWidth > workarea.x + workarea.width &&
- boxWidth < sourceAllocation.x1 - workarea.x)
+ if (sourceBottomRight.x + boxWidth > workarea.x + workarea.width &&
+ boxWidth < sourceTopLeft.x - workarea.x)
return St.Side.RIGHT;
break;
case St.Side.RIGHT:
- if (sourceAllocation.x1 - boxWidth < workarea.x &&
- boxWidth < workarea.x + workarea.width - sourceAllocation.x2)
+ if (sourceTopLeft.x - boxWidth < workarea.x &&
+ boxWidth < workarea.x + workarea.width - sourceBottomRight.x)
return St.Side.LEFT;
break;
}
diff --git a/js/ui/dnd.js b/js/ui/dnd.js
index 464d61bb83..b1e1680f43 100644
--- a/js/ui/dnd.js
+++ b/js/ui/dnd.js
@@ -388,17 +388,16 @@ var _Draggable = class _Draggable {
const [, newAllocatedWidth] = this._dragActor.get_preferred_width(-1);
const [, newAllocatedHeight] = this._dragActor.get_preferred_height(-1);
- const transformedAllocation =
- Shell.util_get_transformed_allocation(this._dragActor);
+ const transformedExtents = this._dragActor.get_transformed_extents();
// Set the actor's scale such that it will keep the same
// transformed size when it's reparented to the uiGroup
this._dragActor.set_scale(
- transformedAllocation.get_width() / newAllocatedWidth,
- transformedAllocation.get_height() / newAllocatedHeight);
+ transformedExtents.get_width() / newAllocatedWidth,
+ transformedExtents.get_height() / newAllocatedHeight);
- this._dragOffsetX = transformedAllocation.x1 - this._dragStartX;
- this._dragOffsetY = transformedAllocation.y1 - this._dragStartY;
+ this._dragOffsetX = transformedExtents.origin.x - this._dragStartX;
+ this._dragOffsetY = transformedExtents.origin.y - this._dragStartY;
this._dragOrigParent.remove_actor(this._dragActor);
Main.uiGroup.add_child(this._dragActor);
diff --git a/src/shell-util.c b/src/shell-util.c
index 5fe2dfcaf5..4a6e1d706d 100644
--- a/src/shell-util.c
+++ b/src/shell-util.c
@@ -77,61 +77,6 @@ shell_util_set_hidden_from_pick (ClutterActor *actor,
}
}
-/**
- * shell_util_get_transformed_allocation:
- * @actor: a #ClutterActor
- * @box: (out): location to store returned box in stage coordinates
- *
- * This function is similar to a combination of clutter_actor_get_transformed_position(),
- * and clutter_actor_get_transformed_size(), but unlike
- * clutter_actor_get_transformed_size(), it always returns a transform
- * of the current allocation, while clutter_actor_get_transformed_size() returns
- * bad values (the transform of the requested size) if a relayout has been
- * queued.
- *
- * This function is more convenient to use than
- * clutter_actor_get_abs_allocation_vertices() if no transformation is in effect
- * and also works around limitations in the GJS binding of arrays.
- */
-void
-shell_util_get_transformed_allocation (ClutterActor *actor,
- ClutterActorBox *box)
-{
- /* Code adapted from clutter-actor.c:
- * Copyright 2006, 2007, 2008 OpenedHand Ltd
- */
- graphene_point3d_t v[4];
- gfloat x_min, x_max, y_min, y_max;
- guint i;
-
- g_return_if_fail (CLUTTER_IS_ACTOR (actor));
-
- clutter_actor_get_abs_allocation_vertices (actor, v);
-
- x_min = x_max = v[0].x;
- y_min = y_max = v[0].y;
-
- for (i = 1; i < G_N_ELEMENTS (v); ++i)
- {
- if (v[i].x < x_min)
- x_min = v[i].x;
-
- if (v[i].x > x_max)
- x_max = v[i].x;
-
- if (v[i].y < y_min)
- y_min = v[i].y;
-
- if (v[i].y > y_max)
- y_max = v[i].y;
- }
-
- box->x1 = x_min;
- box->y1 = y_min;
- box->x2 = x_max;
- box->y2 = y_max;
-}
-
/**
* shell_util_get_week_start:
*
diff --git a/src/shell-util.h b/src/shell-util.h
index 00127ca957..29b9a64789 100644
--- a/src/shell-util.h
+++ b/src/shell-util.h
@@ -14,9 +14,6 @@ G_BEGIN_DECLS
void shell_util_set_hidden_from_pick (ClutterActor *actor,
gboolean hidden);
-void shell_util_get_transformed_allocation (ClutterActor *actor,
- ClutterActorBox *box);
-
int shell_util_get_week_start (void);
const char *shell_util_translate_time_string (const char *str);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]