[metacity/wip/muktupavels/work-areas-v3: 2/4] window: use MetaEdge for struts
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity/wip/muktupavels/work-areas-v3: 2/4] window: use MetaEdge for struts
- Date: Mon, 31 Dec 2018 15:07:55 +0000 (UTC)
commit 2dff13a2a02762deaa2a007d672854d1001631f7
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Sat Jun 16 20:46:55 2018 +0300
window: use MetaEdge for struts
src/core/boxes.c | 16 +++++------
src/core/testboxes.c | 77 ++++++++++++++++++++++++----------------------------
src/core/window.c | 29 ++++++++++++--------
src/core/workspace.c | 4 +--
src/include/boxes.h | 7 -----
src/include/common.h | 11 ++++----
6 files changed, 68 insertions(+), 76 deletions(-)
---
diff --git a/src/core/boxes.c b/src/core/boxes.c
index 6d156d6d..be8eacd7 100644
--- a/src/core/boxes.c
+++ b/src/core/boxes.c
@@ -580,7 +580,7 @@ meta_rectangle_get_minimal_spanning_set_for_region (
for (strut_iter = all_struts; strut_iter; strut_iter = strut_iter->next)
{
GList *rect_iter;
- MetaRectangle *strut_rect = &((MetaStrut*)strut_iter->data)->rect;
+ MetaRectangle *strut_rect = &((MetaEdge *)strut_iter->data)->rect;
tmp_list = ret;
ret = NULL;
@@ -722,7 +722,7 @@ meta_rectangle_expand_to_avoiding_struts (MetaRectangle *rect,
/* Run over all struts */
for (strut_iter = all_struts; strut_iter; strut_iter = strut_iter->next)
{
- MetaStrut *strut = (MetaStrut*) strut_iter->data;
+ MetaEdge *strut = (MetaEdge *) strut_iter->data;
/* Skip struts that don't overlap */
if (!meta_rectangle_overlap (&strut->rect, rect))
@@ -730,13 +730,13 @@ meta_rectangle_expand_to_avoiding_struts (MetaRectangle *rect,
if (direction == META_DIRECTION_HORIZONTAL)
{
- if (strut->side == META_SIDE_LEFT)
+ if (strut->side_type == META_SIDE_LEFT)
{
int offset = BOX_RIGHT(strut->rect) - BOX_LEFT(*rect);
rect->x += offset;
rect->width -= offset;
}
- else if (strut->side == META_SIDE_RIGHT)
+ else if (strut->side_type == META_SIDE_RIGHT)
{
int offset = BOX_RIGHT (*rect) - BOX_LEFT(strut->rect);
rect->width -= offset;
@@ -745,13 +745,13 @@ meta_rectangle_expand_to_avoiding_struts (MetaRectangle *rect,
}
else /* direction == META_DIRECTION_VERTICAL */
{
- if (strut->side == META_SIDE_TOP)
+ if (strut->side_type == META_SIDE_TOP)
{
int offset = BOX_BOTTOM(strut->rect) - BOX_TOP(*rect);
rect->y += offset;
rect->height -= offset;
}
- else if (strut->side == META_SIDE_BOTTOM)
+ else if (strut->side_type == META_SIDE_BOTTOM)
{
int offset = BOX_BOTTOM(*rect) - BOX_TOP(strut->rect);
rect->height -= offset;
@@ -1255,7 +1255,7 @@ get_disjoint_strut_rect_list_in_region (const GSList *old_struts,
strut_rects = NULL;
while (old_struts)
{
- MetaRectangle *cur = &((MetaStrut*)old_struts->data)->rect;
+ MetaRectangle *cur = &((MetaEdge *)old_struts->data)->rect;
MetaRectangle *copy = g_new (MetaRectangle, 1);
*copy = *cur;
if (meta_rectangle_intersect (copy, region, copy))
@@ -1855,7 +1855,7 @@ meta_rectangle_find_nonintersected_monitor_edges (
temp_rects = NULL;
for (; all_struts; all_struts = all_struts->next)
temp_rects = g_slist_prepend (temp_rects,
- &((MetaStrut*)all_struts->data)->rect);
+ &((MetaEdge *)all_struts->data)->rect);
ret = meta_rectangle_remove_intersections_with_boxes_from_edges (ret,
temp_rects);
g_slist_free (temp_rects);
diff --git a/src/core/testboxes.c b/src/core/testboxes.c
index f1ae214e..08f53862 100644
--- a/src/core/testboxes.c
+++ b/src/core/testboxes.c
@@ -56,19 +56,12 @@ new_meta_rect (int x, int y, int width, int height)
return temporary;
}
-static MetaStrut*
-new_meta_strut (int x, int y, int width, int height, int side)
-{
- MetaStrut* temporary;
- temporary = g_new (MetaStrut, 1);
- temporary->rect = meta_rect(x, y, width, height);
- temporary->side = side;
-
- return temporary;
-}
-
static MetaEdge*
-new_screen_edge (int x, int y, int width, int height, int side_type)
+new_screen_edge (int x,
+ int y,
+ int width,
+ int height,
+ MetaSide side_type)
{
MetaEdge* temporary;
temporary = g_new (MetaEdge, 1);
@@ -83,11 +76,11 @@ new_screen_edge (int x, int y, int width, int height, int side_type)
}
static MetaEdge *
-new_monitor_edge (int x,
- int y,
- int width,
- int height,
- int side_type)
+new_monitor_edge (int x,
+ int y,
+ int width,
+ int height,
+ MetaSide side_type)
{
MetaEdge* temporary;
temporary = g_new (MetaEdge, 1);
@@ -242,7 +235,7 @@ static GSList*
get_strut_list (int which)
{
GSList *ans;
- MetaDirection wc = 0; /* wc == who cares? ;-) */
+ MetaSide wc = 0; /* wc == who cares? ;-) */
ans = NULL;
@@ -252,32 +245,32 @@ get_strut_list (int which)
case 0:
break;
case 1:
- ans = g_slist_prepend (ans, new_meta_strut ( 0, 0, 1600, 20, wc));
- ans = g_slist_prepend (ans, new_meta_strut ( 400, 1160, 1600, 40, wc));
+ ans = g_slist_prepend (ans, new_screen_edge ( 0, 0, 1600, 20, wc));
+ ans = g_slist_prepend (ans, new_screen_edge ( 400, 1160, 1600, 40, wc));
break;
case 2:
- ans = g_slist_prepend (ans, new_meta_strut ( 0, 0, 1600, 20, wc));
- ans = g_slist_prepend (ans, new_meta_strut ( 800, 1100, 400, 100, wc));
- ans = g_slist_prepend (ans, new_meta_strut ( 300, 1150, 150, 50, wc));
+ ans = g_slist_prepend (ans, new_screen_edge ( 0, 0, 1600, 20, wc));
+ ans = g_slist_prepend (ans, new_screen_edge ( 800, 1100, 400, 100, wc));
+ ans = g_slist_prepend (ans, new_screen_edge ( 300, 1150, 150, 50, wc));
break;
case 3:
- ans = g_slist_prepend (ans, new_meta_strut ( 0, 0, 1600, 20, wc));
- ans = g_slist_prepend (ans, new_meta_strut ( 800, 1100, 400, 100, wc));
- ans = g_slist_prepend (ans, new_meta_strut ( 300, 1150, 80, 50, wc));
- ans = g_slist_prepend (ans, new_meta_strut ( 700, 525, 200, 150, wc));
+ ans = g_slist_prepend (ans, new_screen_edge ( 0, 0, 1600, 20, wc));
+ ans = g_slist_prepend (ans, new_screen_edge ( 800, 1100, 400, 100, wc));
+ ans = g_slist_prepend (ans, new_screen_edge ( 300, 1150, 80, 50, wc));
+ ans = g_slist_prepend (ans, new_screen_edge ( 700, 525, 200, 150, wc));
break;
case 4:
- ans = g_slist_prepend (ans, new_meta_strut ( 0, 0, 800, 1200, wc));
- ans = g_slist_prepend (ans, new_meta_strut ( 800, 0, 1600, 20, wc));
+ ans = g_slist_prepend (ans, new_screen_edge ( 0, 0, 800, 1200, wc));
+ ans = g_slist_prepend (ans, new_screen_edge ( 800, 0, 1600, 20, wc));
break;
case 5:
- ans = g_slist_prepend (ans, new_meta_strut ( 800, 0, 1600, 20, wc));
- ans = g_slist_prepend (ans, new_meta_strut ( 0, 0, 800, 1200, wc));
- ans = g_slist_prepend (ans, new_meta_strut ( 800, 10, 800, 1200, wc));
+ ans = g_slist_prepend (ans, new_screen_edge ( 800, 0, 1600, 20, wc));
+ ans = g_slist_prepend (ans, new_screen_edge ( 0, 0, 800, 1200, wc));
+ ans = g_slist_prepend (ans, new_screen_edge ( 800, 10, 800, 1200, wc));
break;
case 6:
- ans = g_slist_prepend (ans, new_meta_strut ( 0, 0, 1600, 40, wc));
- ans = g_slist_prepend (ans, new_meta_strut ( 0, 0, 1600, 20, wc));
+ ans = g_slist_prepend (ans, new_screen_edge ( 0, 0, 1600, 40, wc));
+ ans = g_slist_prepend (ans, new_screen_edge ( 0, 0, 1600, 20, wc));
break;
default:
break;
@@ -1030,10 +1023,10 @@ test_find_onscreen_edges (void)
GList* edges;
GList* tmp;
- int left = META_DIRECTION_LEFT;
- int right = META_DIRECTION_RIGHT;
- int top = META_DIRECTION_TOP;
- int bottom = META_DIRECTION_BOTTOM;
+ int left = META_SIDE_LEFT;
+ int right = META_SIDE_RIGHT;
+ int top = META_SIDE_TOP;
+ int bottom = META_SIDE_BOTTOM;
/*************************************************/
/* Make sure test region 0 has the correct edges */
@@ -1163,10 +1156,10 @@ test_find_nonintersected_monitor_edges (void)
GList* edges;
GList* tmp;
- int left = META_DIRECTION_LEFT;
- int right = META_DIRECTION_RIGHT;
- int top = META_DIRECTION_TOP;
- int bottom = META_DIRECTION_BOTTOM;
+ int left = META_SIDE_LEFT;
+ int right = META_SIDE_RIGHT;
+ int top = META_SIDE_TOP;
+ int bottom = META_SIDE_BOTTOM;
/*************************************************************************/
/* Make sure test monitor set 0 for with region 0 has the correct edges */
diff --git a/src/core/window.c b/src/core/window.c
index 3cd5c654..789048ec 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -6389,7 +6389,7 @@ meta_window_update_struts (MetaWindow *window)
int i;
for (i=0; i<4; i++)
{
- MetaStrut *temp;
+ MetaEdge *temp;
int thickness, strut_begin, strut_end;
thickness = struts[i];
@@ -6398,10 +6398,13 @@ meta_window_update_struts (MetaWindow *window)
strut_begin = struts[4+(i*2)];
strut_end = struts[4+(i*2)+1];
- temp = g_new (MetaStrut, 1);
- temp->side = 1 << i; /* See MetaSide def. Matches nicely, eh? */
+ temp = g_new (MetaEdge, 1);
+
+ temp->side_type = i;
+ temp->edge_type = META_EDGE_SCREEN;
+
temp->rect = window->screen->rect;
- switch (temp->side)
+ switch (temp->side_type)
{
case META_SIDE_RIGHT:
temp->rect.x = BOX_RIGHT(temp->rect) - thickness;
@@ -6460,17 +6463,20 @@ meta_window_update_struts (MetaWindow *window)
int i;
for (i=0; i<4; i++)
{
- MetaStrut *temp;
+ MetaEdge *temp;
int thickness;
thickness = struts[i];
if (thickness == 0)
continue;
- temp = g_new (MetaStrut, 1);
- temp->side = 1 << i;
+ temp = g_new (MetaEdge, 1);
+
+ temp->side_type = i;
+ temp->edge_type = META_EDGE_SCREEN;
+
temp->rect = window->screen->rect;
- switch (temp->side)
+ switch (temp->side_type)
{
case META_SIDE_RIGHT:
temp->rect.x = BOX_RIGHT(temp->rect) - thickness;
@@ -6510,10 +6516,11 @@ meta_window_update_struts (MetaWindow *window)
new_iter = new_struts;
while (old_iter && new_iter)
{
- MetaStrut *old_strut = (MetaStrut*) old_iter->data;
- MetaStrut *new_strut = (MetaStrut*) new_iter->data;
+ MetaEdge *old_strut = (MetaEdge *) old_iter->data;
+ MetaEdge *new_strut = (MetaEdge *) new_iter->data;
- if (old_strut->side != new_strut->side ||
+ if (old_strut->side_type != new_strut->side_type ||
+ old_strut->edge_type != new_strut->edge_type ||
!meta_rectangle_equal (&old_strut->rect, &new_strut->rect))
break;
diff --git a/src/core/workspace.c b/src/core/workspace.c
index da714063..ff353a21 100644
--- a/src/core/workspace.c
+++ b/src/core/workspace.c
@@ -624,8 +624,8 @@ ensure_work_areas_validated (MetaWorkspace *workspace)
GSList *s_iter;
for (s_iter = win->struts; s_iter != NULL; s_iter = s_iter->next) {
- MetaStrut *cpy = g_new (MetaStrut, 1);
- *cpy = *((MetaStrut *)s_iter->data);
+ MetaEdge *cpy = g_new (MetaEdge, 1);
+ *cpy = *((MetaEdge *)s_iter->data);
workspace->all_struts = g_slist_prepend (workspace->all_struts,
cpy);
}
diff --git a/src/include/boxes.h b/src/include/boxes.h
index 4b881753..4999595b 100644
--- a/src/include/boxes.h
+++ b/src/include/boxes.h
@@ -34,13 +34,6 @@ struct _MetaRectangle
int height;
};
-typedef struct _MetaStrut MetaStrut;
-struct _MetaStrut
-{
- MetaRectangle rect;
- MetaSide side;
-};
-
#define BOX_LEFT(box) ((box).x) /* Leftmost pixel of rect */
#define BOX_RIGHT(box) ((box).x + (box).width) /* One pixel past right */
#define BOX_TOP(box) ((box).y) /* Topmost pixel of rect */
diff --git a/src/include/common.h b/src/include/common.h
index 3af03351..223784d5 100644
--- a/src/include/common.h
+++ b/src/include/common.h
@@ -183,15 +183,14 @@ typedef enum
/* Sometimes we want to talk about sides instead of directions; note
* that the values must be as follows or meta_window_update_struts()
- * won't work. Using these values also is a safety blanket since
- * MetaDirection used to be used as a side.
+ * won't work.
*/
typedef enum
{
- META_SIDE_LEFT = META_DIRECTION_LEFT,
- META_SIDE_RIGHT = META_DIRECTION_RIGHT,
- META_SIDE_TOP = META_DIRECTION_TOP,
- META_SIDE_BOTTOM = META_DIRECTION_BOTTOM
+ META_SIDE_LEFT = 0,
+ META_SIDE_RIGHT = 1,
+ META_SIDE_TOP = 2,
+ META_SIDE_BOTTOM = 3
} MetaSide;
/* should investigate changing these to whatever most apps use */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]