summaryrefslogtreecommitdiff
path: root/src/core/place.c
diff options
context:
space:
mode:
authorVictor Kareh <[email protected]>2019-04-12 07:58:30 -0400
committerraveit65 <[email protected]>2019-06-16 18:12:44 +0200
commitcfd49bdf68ef48fcd53a084c74626372fc169688 (patch)
tree4f20be7afc95f063f04bb6114a90c5aa7c650c6b /src/core/place.c
parent147a9bd1e56201bb93879627cd186c235e050ca4 (diff)
downloadmarco-cfd49bdf68ef48fcd53a084c74626372fc169688.tar.bz2
marco-cfd49bdf68ef48fcd53a084c74626372fc169688.tar.xz
Replace public MetaFrameGeometry with MetaFrameBorders
There were actually *two* MetaFrameGeometry structs: one in theme-private.h, one in frame.h. The latter public struct was populated by a mix of (void*) casting and int pointers, usually pulling directly from the data in the private struct. Remove the public struct, replace it with MetaFrameBorders and scrap all the pointer hacks to populate it, instead relying on both structs being used in common code. This commit should be relatively straightforward, and it should not do any tricky logic at all, just a sophisticated find and replace. https://bugzilla.gnome.org/show_bug.cgi?id=644930 upstream commit: https://gitlab.gnome.org/GNOME/metacity/commit/72224a165 NOTE: Patch copied from metacity and adapted for marco.
Diffstat (limited to 'src/core/place.c')
-rw-r--r--src/core/place.c136
1 files changed, 68 insertions, 68 deletions
diff --git a/src/core/place.c b/src/core/place.c
index bcfafe42..b3fa6569 100644
--- a/src/core/place.c
+++ b/src/core/place.c
@@ -88,8 +88,8 @@ northwestcmp (gconstpointer a, gconstpointer b)
}
static gboolean
-place_by_pointer(MetaWindow *window,
- MetaFrameGeometry *fgeom,
+place_by_pointer(MetaWindow *window,
+ MetaFrameBorders *borders,
MetaPlacementMode placement_mode,
int *new_x,
int *new_y)
@@ -113,9 +113,9 @@ place_by_pointer(MetaWindow *window,
window_width = window->frame ? window->frame->rect.width : window->rect.width;
window_height = window->frame ? window->frame->rect.height : window->rect.height;
- if (fgeom) {
- *new_x = root_x_return + fgeom->left_width - window_width / 2;
- *new_y = root_y_return + fgeom->top_height - window_height / 2;
+ if (borders) {
+ *new_x = root_x_return + borders->visible.left - window_width / 2;
+ *new_y = root_y_return + borders->visible.top - window_height / 2;
}
else {
*new_x = root_x_return - window_width / 2;
@@ -129,14 +129,14 @@ place_by_pointer(MetaWindow *window,
}
static void
-find_next_cascade (MetaWindow *window,
- MetaFrameGeometry *fgeom,
+find_next_cascade (MetaWindow *window,
+ MetaFrameBorders *borders,
/* visible windows on relevant workspaces */
- GList *windows,
- int x,
- int y,
- int *new_x,
- int *new_y)
+ GList *windows,
+ int x,
+ int y,
+ int *new_x,
+ int *new_y)
{
GList *tmp;
GList *sorted;
@@ -160,10 +160,10 @@ find_next_cascade (MetaWindow *window,
* manually cascade.
*/
#define CASCADE_FUZZ 15
- if (fgeom)
+ if (borders)
{
- x_threshold = MAX (fgeom->left_width, CASCADE_FUZZ);
- y_threshold = MAX (fgeom->top_height, CASCADE_FUZZ);
+ x_threshold = MAX (borders->visible.left, CASCADE_FUZZ);
+ y_threshold = MAX (borders->visible.top, CASCADE_FUZZ);
}
else
{
@@ -264,27 +264,27 @@ find_next_cascade (MetaWindow *window,
g_list_free (sorted);
/* Convert coords to position of window, not position of frame. */
- if (fgeom == NULL)
+ if (borders == NULL)
{
*new_x = cascade_x;
*new_y = cascade_y;
}
else
{
- *new_x = cascade_x + fgeom->left_width;
- *new_y = cascade_y + fgeom->top_height;
+ *new_x = cascade_x + borders->visible.left;
+ *new_y = cascade_y + borders->visible.top;
}
}
static void
-find_most_freespace (MetaWindow *window,
- MetaFrameGeometry *fgeom,
+find_most_freespace (MetaWindow *window,
+ MetaFrameBorders *borders,
/* visible windows on relevant workspaces */
- MetaWindow *focus_window,
- int x,
- int y,
- int *new_x,
- int *new_y)
+ MetaWindow *focus_window,
+ int x,
+ int y,
+ int *new_x,
+ int *new_y)
{
MetaWindowDirection side;
int max_area;
@@ -295,8 +295,8 @@ find_most_freespace (MetaWindow *window,
MetaRectangle avoid;
MetaRectangle outer;
- frame_size_left = fgeom ? fgeom->left_width : 0;
- frame_size_top = fgeom ? fgeom->top_height : 0;
+ frame_size_left = borders ? borders->visible.left : 0;
+ frame_size_top = borders ? borders->visible.top : 0;
meta_window_get_work_area_current_xinerama (focus_window, &work_area);
meta_window_get_outer_rect (focus_window, &avoid);
@@ -375,10 +375,10 @@ find_most_freespace (MetaWindow *window,
}
static void
-avoid_being_obscured_as_second_modal_dialog (MetaWindow *window,
- MetaFrameGeometry *fgeom,
- int *x,
- int *y)
+avoid_being_obscured_as_second_modal_dialog (MetaWindow *window,
+ MetaFrameBorders *borders,
+ int *x,
+ int *y)
{
/* We can't center this dialog if it was denied focus and it
* overlaps with the focus window and this dialog is modal and this
@@ -406,7 +406,7 @@ avoid_being_obscured_as_second_modal_dialog (MetaWindow *window,
&focus_window->rect,
&overlap))
{
- find_most_freespace (window, fgeom, focus_window, *x, *y, x, y);
+ find_most_freespace (window, borders, focus_window, *x, *y, x, y);
meta_topic (META_DEBUG_PLACEMENT,
"Dialog window %s was denied focus but may be modal "
"to the focus window; had to move it to avoid the "
@@ -545,15 +545,15 @@ center_rect_in_area (MetaRectangle *rect,
* don't want to create a 1x1 Emacs.
*/
static gboolean
-find_first_fit (MetaWindow *window,
- MetaFrameGeometry *fgeom,
+find_first_fit (MetaWindow *window,
+ MetaFrameBorders *borders,
/* visible windows on relevant workspaces */
- GList *windows,
- int xinerama,
- int x,
- int y,
- int *new_x,
- int *new_y)
+ GList *windows,
+ int xinerama,
+ int x,
+ int y,
+ int *new_x,
+ int *new_y)
{
/* This algorithm is limited - it just brute-force tries
* to fit the window in a small number of locations that are aligned
@@ -584,10 +584,10 @@ find_first_fit (MetaWindow *window,
rect.width = window->rect.width;
rect.height = window->rect.height;
- if (fgeom)
+ if (borders)
{
- rect.width += fgeom->left_width + fgeom->right_width;
- rect.height += fgeom->top_height + fgeom->bottom_height;
+ rect.width += borders->visible.left + borders->visible.right;
+ rect.height += borders->visible.top + borders->visible.bottom;
}
#ifdef WITH_VERBOSE_MODE
@@ -614,10 +614,10 @@ find_first_fit (MetaWindow *window,
{
*new_x = rect.x;
*new_y = rect.y;
- if (fgeom)
+ if (borders)
{
- *new_x += fgeom->left_width;
- *new_y += fgeom->top_height;
+ *new_x += borders->visible.left;
+ *new_y += borders->visible.top;
}
retval = TRUE;
@@ -642,10 +642,10 @@ find_first_fit (MetaWindow *window,
{
*new_x = rect.x;
*new_y = rect.y;
- if (fgeom)
+ if (borders)
{
- *new_x += fgeom->left_width;
- *new_y += fgeom->top_height;
+ *new_x += borders->visible.left;
+ *new_y += borders->visible.top;
}
retval = TRUE;
@@ -673,10 +673,10 @@ find_first_fit (MetaWindow *window,
{
*new_x = rect.x;
*new_y = rect.y;
- if (fgeom)
+ if (borders)
{
- *new_x += fgeom->left_width;
- *new_y += fgeom->top_height;
+ *new_x += borders->visible.left;
+ *new_y += borders->visible.top;
}
retval = TRUE;
@@ -695,19 +695,19 @@ find_first_fit (MetaWindow *window,
}
void
-meta_window_place (MetaWindow *window,
- MetaFrameGeometry *fgeom,
- int x,
- int y,
- int *new_x,
- int *new_y)
+meta_window_place (MetaWindow *window,
+ MetaFrameBorders *borders,
+ int x,
+ int y,
+ int *new_x,
+ int *new_y)
{
GList *windows;
const MetaXineramaScreenInfo *xi;
MetaPlacementMode placement_mode;
/* frame member variables should NEVER be used in here, only
- * MetaFrameGeometry. But remember fgeom == NULL
+ * MetaFrameBorders. But remember borders == NULL
* for undecorated windows. Also, this function should
* NEVER have side effects other than computing the
* placement coordinates.
@@ -785,7 +785,7 @@ meta_window_place (MetaWindow *window,
{
meta_topic (META_DEBUG_PLACEMENT,
"Not placing window with PPosition or USPosition set\n");
- avoid_being_obscured_as_second_modal_dialog (window, fgeom, &x, &y);
+ avoid_being_obscured_as_second_modal_dialog (window, borders, &x, &y);
goto done_no_constraints;
}
}
@@ -820,13 +820,13 @@ meta_window_place (MetaWindow *window,
y += (parent->rect.height - window->rect.height)/3;
/* put top of child's frame, not top of child's client */
- if (fgeom)
- y += fgeom->top_height;
+ if (borders)
+ y += borders->visible.top;
meta_topic (META_DEBUG_PLACEMENT, "Centered window %s over transient parent\n",
window->desc);
- avoid_being_obscured_as_second_modal_dialog (window, fgeom, &x, &y);
+ avoid_being_obscured_as_second_modal_dialog (window, borders, &x, &y);
goto done;
}
@@ -901,11 +901,11 @@ meta_window_place (MetaWindow *window,
if (placement_mode == META_PLACEMENT_MODE_POINTER ||
placement_mode == META_PLACEMENT_MODE_MANUAL)
{
- if (place_by_pointer (window, fgeom, placement_mode, &x, &y))
+ if (place_by_pointer (window, borders, placement_mode, &x, &y))
goto done_check_denied_focus;
}
- if (find_first_fit (window, fgeom, windows,
+ if (find_first_fit (window, borders, windows,
xi->number,
x, y, &x, &y))
goto done_check_denied_focus;
@@ -939,7 +939,7 @@ meta_window_place (MetaWindow *window,
* fully overlapping window (e.g. starting multiple terminals)
* */
if (!meta_prefs_get_center_new_windows() && (x == xi->rect.x && y == xi->rect.y))
- find_next_cascade (window, fgeom, windows, x, y, &x, &y);
+ find_next_cascade (window, borders, windows, x, y, &x, &y);
done_check_denied_focus:
/* If the window is being denied focus and isn't a transient of the
@@ -973,7 +973,7 @@ meta_window_place (MetaWindow *window,
x = xi->rect.x;
y = xi->rect.y;
- found_fit = find_first_fit (window, fgeom, focus_window_list,
+ found_fit = find_first_fit (window, borders, focus_window_list,
xi->number,
x, y, &x, &y);
g_list_free (focus_window_list);
@@ -983,7 +983,7 @@ meta_window_place (MetaWindow *window,
* as possible.
*/
if (!found_fit)
- find_most_freespace (window, fgeom, focus_window, x, y, &x, &y);
+ find_most_freespace (window, borders, focus_window, x, y, &x, &y);
}
done: