mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 17:40:40 -05:00
Cleanup: split MetaSide from MetaDirection
The MetaDirection enumeration had META_SIDE_* values in it that were used in some places where an enum with only four directions was needed. Split this off into a separate enum called MetaSide and use that enum name where appropriate.
This commit is contained in:
parent
f8153b84de
commit
0aace5230f
@ -1149,12 +1149,12 @@ meta_rectangle_edge_aligns (const MetaRectangle *rect, const MetaEdge *edge)
|
||||
*/
|
||||
switch (edge->side_type)
|
||||
{
|
||||
case META_DIRECTION_LEFT:
|
||||
case META_DIRECTION_RIGHT:
|
||||
case META_SIDE_LEFT:
|
||||
case META_SIDE_RIGHT:
|
||||
return BOX_TOP (*rect) <= BOX_BOTTOM (edge->rect) &&
|
||||
BOX_TOP (edge->rect) <= BOX_BOTTOM (*rect);
|
||||
case META_DIRECTION_TOP:
|
||||
case META_DIRECTION_BOTTOM:
|
||||
case META_SIDE_TOP:
|
||||
case META_SIDE_BOTTOM:
|
||||
return BOX_LEFT (*rect) <= BOX_RIGHT (edge->rect) &&
|
||||
BOX_LEFT (edge->rect) <= BOX_RIGHT (*rect);
|
||||
default:
|
||||
@ -1339,8 +1339,8 @@ meta_rectangle_edge_cmp_ignore_type (gconstpointer a, gconstpointer b)
|
||||
|
||||
a_compare = b_compare = 0; /* gcc-3.4.2 sucks at figuring initialized'ness */
|
||||
|
||||
if (a_edge_rect->side_type == META_DIRECTION_LEFT ||
|
||||
a_edge_rect->side_type == META_DIRECTION_RIGHT)
|
||||
if (a_edge_rect->side_type == META_SIDE_LEFT ||
|
||||
a_edge_rect->side_type == META_SIDE_RIGHT)
|
||||
{
|
||||
a_compare = a_edge_rect->rect.x;
|
||||
b_compare = b_edge_rect->rect.x;
|
||||
@ -1350,8 +1350,8 @@ meta_rectangle_edge_cmp_ignore_type (gconstpointer a, gconstpointer b)
|
||||
b_compare = b_edge_rect->rect.y;
|
||||
}
|
||||
}
|
||||
else if (a_edge_rect->side_type == META_DIRECTION_TOP ||
|
||||
a_edge_rect->side_type == META_DIRECTION_BOTTOM)
|
||||
else if (a_edge_rect->side_type == META_SIDE_TOP ||
|
||||
a_edge_rect->side_type == META_SIDE_BOTTOM)
|
||||
{
|
||||
a_compare = a_edge_rect->rect.y;
|
||||
b_compare = b_edge_rect->rect.y;
|
||||
@ -1447,7 +1447,7 @@ rectangle_and_edge_intersection (const MetaRectangle *rect,
|
||||
*/
|
||||
switch (edge->side_type)
|
||||
{
|
||||
case META_DIRECTION_LEFT:
|
||||
case META_SIDE_LEFT:
|
||||
if (result->x == rect->x)
|
||||
*handle_type = 1;
|
||||
else if (result->x == BOX_RIGHT (*rect))
|
||||
@ -1455,7 +1455,7 @@ rectangle_and_edge_intersection (const MetaRectangle *rect,
|
||||
else
|
||||
*handle_type = 0;
|
||||
break;
|
||||
case META_DIRECTION_RIGHT:
|
||||
case META_SIDE_RIGHT:
|
||||
if (result->x == rect->x)
|
||||
*handle_type = -1;
|
||||
else if (result->x == BOX_RIGHT (*rect))
|
||||
@ -1463,7 +1463,7 @@ rectangle_and_edge_intersection (const MetaRectangle *rect,
|
||||
else
|
||||
*handle_type = 0;
|
||||
break;
|
||||
case META_DIRECTION_TOP:
|
||||
case META_SIDE_TOP:
|
||||
if (result->y == rect->y)
|
||||
*handle_type = 1;
|
||||
else if (result->y == BOX_BOTTOM (*rect))
|
||||
@ -1471,7 +1471,7 @@ rectangle_and_edge_intersection (const MetaRectangle *rect,
|
||||
else
|
||||
*handle_type = 0;
|
||||
break;
|
||||
case META_DIRECTION_BOTTOM:
|
||||
case META_SIDE_BOTTOM:
|
||||
if (result->y == rect->y)
|
||||
*handle_type = -1;
|
||||
else if (result->y == BOX_BOTTOM (*rect))
|
||||
@ -1506,23 +1506,23 @@ add_edges (GList *cur_edges,
|
||||
{
|
||||
case 0:
|
||||
temp_edge->side_type =
|
||||
rect_is_internal ? META_DIRECTION_LEFT : META_DIRECTION_RIGHT;
|
||||
rect_is_internal ? META_SIDE_LEFT : META_SIDE_RIGHT;
|
||||
temp_edge->rect.width = 0;
|
||||
break;
|
||||
case 1:
|
||||
temp_edge->side_type =
|
||||
rect_is_internal ? META_DIRECTION_RIGHT : META_DIRECTION_LEFT;
|
||||
rect_is_internal ? META_SIDE_RIGHT : META_SIDE_LEFT;
|
||||
temp_edge->rect.x += temp_edge->rect.width;
|
||||
temp_edge->rect.width = 0;
|
||||
break;
|
||||
case 2:
|
||||
temp_edge->side_type =
|
||||
rect_is_internal ? META_DIRECTION_TOP : META_DIRECTION_BOTTOM;
|
||||
rect_is_internal ? META_SIDE_TOP : META_SIDE_BOTTOM;
|
||||
temp_edge->rect.height = 0;
|
||||
break;
|
||||
case 3:
|
||||
temp_edge->side_type =
|
||||
rect_is_internal ? META_DIRECTION_BOTTOM : META_DIRECTION_TOP;
|
||||
rect_is_internal ? META_SIDE_BOTTOM : META_SIDE_TOP;
|
||||
temp_edge->rect.y += temp_edge->rect.height;
|
||||
temp_edge->rect.height = 0;
|
||||
break;
|
||||
@ -1545,8 +1545,8 @@ split_edge (GList *cur_list,
|
||||
MetaEdge *temp_edge;
|
||||
switch (old_edge->side_type)
|
||||
{
|
||||
case META_DIRECTION_LEFT:
|
||||
case META_DIRECTION_RIGHT:
|
||||
case META_SIDE_LEFT:
|
||||
case META_SIDE_RIGHT:
|
||||
g_assert (meta_rectangle_vert_overlap (&old_edge->rect, &remove->rect));
|
||||
if (BOX_TOP (old_edge->rect) < BOX_TOP (remove->rect))
|
||||
{
|
||||
@ -1566,8 +1566,8 @@ split_edge (GList *cur_list,
|
||||
cur_list = g_list_prepend (cur_list, temp_edge);
|
||||
}
|
||||
break;
|
||||
case META_DIRECTION_TOP:
|
||||
case META_DIRECTION_BOTTOM:
|
||||
case META_SIDE_TOP:
|
||||
case META_SIDE_BOTTOM:
|
||||
g_assert (meta_rectangle_horiz_overlap (&old_edge->rect, &remove->rect));
|
||||
if (BOX_LEFT (old_edge->rect) < BOX_LEFT (remove->rect))
|
||||
{
|
||||
@ -1823,7 +1823,7 @@ meta_rectangle_find_nonintersected_xinerama_edges (
|
||||
/* Check if cur might be horizontally adjacent to compare */
|
||||
if (meta_rectangle_vert_overlap(cur_rect, compare_rect))
|
||||
{
|
||||
MetaDirection side_type;
|
||||
MetaSide side_type;
|
||||
int y = MAX (cur_rect->y, compare_rect->y);
|
||||
int height = MIN (BOX_BOTTOM (*cur_rect) - y,
|
||||
BOX_BOTTOM (*compare_rect) - y);
|
||||
@ -1834,13 +1834,13 @@ meta_rectangle_find_nonintersected_xinerama_edges (
|
||||
{
|
||||
/* compare_rect is to the left of cur_rect */
|
||||
x = BOX_LEFT (*cur_rect);
|
||||
side_type = META_DIRECTION_LEFT;
|
||||
side_type = META_SIDE_LEFT;
|
||||
}
|
||||
else if (BOX_RIGHT (*cur_rect) == BOX_LEFT (*compare_rect))
|
||||
{
|
||||
/* compare_rect is to the right of cur_rect */
|
||||
x = BOX_RIGHT (*cur_rect);
|
||||
side_type = META_DIRECTION_RIGHT;
|
||||
side_type = META_SIDE_RIGHT;
|
||||
}
|
||||
else
|
||||
/* These rectangles aren't adjacent after all */
|
||||
@ -1866,7 +1866,7 @@ meta_rectangle_find_nonintersected_xinerama_edges (
|
||||
/* Check if cur might be vertically adjacent to compare */
|
||||
if (meta_rectangle_horiz_overlap(cur_rect, compare_rect))
|
||||
{
|
||||
MetaDirection side_type;
|
||||
MetaSide side_type;
|
||||
int x = MAX (cur_rect->x, compare_rect->x);
|
||||
int width = MIN (BOX_RIGHT (*cur_rect) - x,
|
||||
BOX_RIGHT (*compare_rect) - x);
|
||||
@ -1877,13 +1877,13 @@ meta_rectangle_find_nonintersected_xinerama_edges (
|
||||
{
|
||||
/* compare_rect is to the top of cur_rect */
|
||||
y = BOX_TOP (*cur_rect);
|
||||
side_type = META_DIRECTION_TOP;
|
||||
side_type = META_SIDE_TOP;
|
||||
}
|
||||
else if (BOX_BOTTOM (*cur_rect) == BOX_TOP (*compare_rect))
|
||||
{
|
||||
/* compare_rect is to the bottom of cur_rect */
|
||||
y = BOX_BOTTOM (*cur_rect);
|
||||
side_type = META_DIRECTION_BOTTOM;
|
||||
side_type = META_SIDE_BOTTOM;
|
||||
}
|
||||
else
|
||||
/* These rectangles aren't adjacent after all */
|
||||
|
@ -294,15 +294,15 @@ find_nearest_position (const GArray *edges,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
movement_towards_edge (MetaDirection side, int increment)
|
||||
movement_towards_edge (MetaSide side, int increment)
|
||||
{
|
||||
switch (side)
|
||||
{
|
||||
case META_DIRECTION_LEFT:
|
||||
case META_DIRECTION_TOP:
|
||||
case META_SIDE_LEFT:
|
||||
case META_SIDE_TOP:
|
||||
return increment < 0;
|
||||
case META_DIRECTION_RIGHT:
|
||||
case META_DIRECTION_BOTTOM:
|
||||
case META_SIDE_RIGHT:
|
||||
case META_SIDE_BOTTOM:
|
||||
return increment > 0;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
@ -679,24 +679,24 @@ meta_display_cleanup_edges (MetaDisplay *display)
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
GArray *tmp = NULL;
|
||||
MetaDirection dir;
|
||||
MetaSide side;
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
tmp = edge_data->left_edges;
|
||||
dir = META_DIRECTION_LEFT;
|
||||
side = META_SIDE_LEFT;
|
||||
break;
|
||||
case 1:
|
||||
tmp = edge_data->right_edges;
|
||||
dir = META_DIRECTION_RIGHT;
|
||||
side = META_SIDE_RIGHT;
|
||||
break;
|
||||
case 2:
|
||||
tmp = edge_data->top_edges;
|
||||
dir = META_DIRECTION_TOP;
|
||||
side = META_SIDE_TOP;
|
||||
break;
|
||||
case 3:
|
||||
tmp = edge_data->bottom_edges;
|
||||
dir = META_DIRECTION_BOTTOM;
|
||||
side = META_SIDE_BOTTOM;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
@ -706,7 +706,7 @@ meta_display_cleanup_edges (MetaDisplay *display)
|
||||
{
|
||||
MetaEdge *edge = g_array_index (tmp, MetaEdge*, j);
|
||||
if (edge->edge_type == META_EDGE_WINDOW &&
|
||||
edge->side_type == dir)
|
||||
edge->side_type == side)
|
||||
{
|
||||
/* The same edge will appear in two arrays, and we can't free
|
||||
* it yet we still need to compare edge->side_type for the other
|
||||
@ -821,16 +821,16 @@ cache_edges (MetaDisplay *display,
|
||||
MetaEdge *edge = tmp->data;
|
||||
switch (edge->side_type)
|
||||
{
|
||||
case META_DIRECTION_LEFT:
|
||||
case META_SIDE_LEFT:
|
||||
num_left++;
|
||||
break;
|
||||
case META_DIRECTION_RIGHT:
|
||||
case META_SIDE_RIGHT:
|
||||
num_right++;
|
||||
break;
|
||||
case META_DIRECTION_TOP:
|
||||
case META_SIDE_TOP:
|
||||
num_top++;
|
||||
break;
|
||||
case META_DIRECTION_BOTTOM:
|
||||
case META_SIDE_BOTTOM:
|
||||
num_bottom++;
|
||||
break;
|
||||
default:
|
||||
@ -889,13 +889,13 @@ cache_edges (MetaDisplay *display,
|
||||
MetaEdge *edge = tmp->data;
|
||||
switch (edge->side_type)
|
||||
{
|
||||
case META_DIRECTION_LEFT:
|
||||
case META_DIRECTION_RIGHT:
|
||||
case META_SIDE_LEFT:
|
||||
case META_SIDE_RIGHT:
|
||||
g_array_append_val (edge_data->left_edges, edge);
|
||||
g_array_append_val (edge_data->right_edges, edge);
|
||||
break;
|
||||
case META_DIRECTION_TOP:
|
||||
case META_DIRECTION_BOTTOM:
|
||||
case META_SIDE_TOP:
|
||||
case META_SIDE_BOTTOM:
|
||||
g_array_append_val (edge_data->top_edges, edge);
|
||||
g_array_append_val (edge_data->bottom_edges, edge);
|
||||
break;
|
||||
@ -1029,7 +1029,7 @@ meta_display_compute_resistance_and_snapping_edges (MetaDisplay *display)
|
||||
new_edge = g_new (MetaEdge, 1);
|
||||
new_edge->rect = reduced;
|
||||
new_edge->rect.width = 0;
|
||||
new_edge->side_type = META_DIRECTION_RIGHT;
|
||||
new_edge->side_type = META_SIDE_RIGHT;
|
||||
new_edge->edge_type = META_EDGE_WINDOW;
|
||||
new_edges = g_list_prepend (new_edges, new_edge);
|
||||
|
||||
@ -1040,7 +1040,7 @@ meta_display_compute_resistance_and_snapping_edges (MetaDisplay *display)
|
||||
new_edge->rect = reduced;
|
||||
new_edge->rect.x += new_edge->rect.width;
|
||||
new_edge->rect.width = 0;
|
||||
new_edge->side_type = META_DIRECTION_LEFT;
|
||||
new_edge->side_type = META_SIDE_LEFT;
|
||||
new_edge->edge_type = META_EDGE_WINDOW;
|
||||
new_edges = g_list_prepend (new_edges, new_edge);
|
||||
|
||||
@ -1050,7 +1050,7 @@ meta_display_compute_resistance_and_snapping_edges (MetaDisplay *display)
|
||||
new_edge = g_new (MetaEdge, 1);
|
||||
new_edge->rect = reduced;
|
||||
new_edge->rect.height = 0;
|
||||
new_edge->side_type = META_DIRECTION_BOTTOM;
|
||||
new_edge->side_type = META_SIDE_BOTTOM;
|
||||
new_edge->edge_type = META_EDGE_WINDOW;
|
||||
new_edges = g_list_prepend (new_edges, new_edge);
|
||||
|
||||
@ -1061,7 +1061,7 @@ meta_display_compute_resistance_and_snapping_edges (MetaDisplay *display)
|
||||
new_edge->rect = reduced;
|
||||
new_edge->rect.y += new_edge->rect.height;
|
||||
new_edge->rect.height = 0;
|
||||
new_edge->side_type = META_DIRECTION_TOP;
|
||||
new_edge->side_type = META_SIDE_TOP;
|
||||
new_edge->edge_type = META_EDGE_WINDOW;
|
||||
new_edges = g_list_prepend (new_edges, new_edge);
|
||||
|
||||
|
@ -5884,7 +5884,7 @@ meta_window_update_struts (MetaWindow *window)
|
||||
strut_end = struts[4+(i*2)+1];
|
||||
|
||||
temp = g_new (MetaStrut, 1);
|
||||
temp->side = 1 << i; /* See MetaDirection def. Matches nicely, eh? */
|
||||
temp->side = 1 << i; /* See MetaSide def. Matches nicely, eh? */
|
||||
temp->rect = window->screen->rect;
|
||||
switch (temp->side)
|
||||
{
|
||||
|
@ -40,7 +40,7 @@ typedef struct _MetaStrut MetaStrut;
|
||||
struct _MetaStrut
|
||||
{
|
||||
MetaRectangle rect;
|
||||
MetaDirection side;
|
||||
MetaSide side;
|
||||
};
|
||||
|
||||
#define BOX_LEFT(box) ((box).x) /* Leftmost pixel of rect */
|
||||
@ -66,7 +66,7 @@ typedef struct _MetaEdge MetaEdge;
|
||||
struct _MetaEdge
|
||||
{
|
||||
MetaRectangle rect; /* width or height should be 1 */
|
||||
MetaDirection side_type; /* should only have 1 of the 4 directions set */
|
||||
MetaSide side_type;
|
||||
MetaEdgeType edge_type;
|
||||
};
|
||||
|
||||
|
@ -231,13 +231,20 @@ typedef enum
|
||||
/* A few more definitions using aliases */
|
||||
META_DIRECTION_HORIZONTAL = META_DIRECTION_LEFT | META_DIRECTION_RIGHT,
|
||||
META_DIRECTION_VERTICAL = META_DIRECTION_UP | META_DIRECTION_DOWN,
|
||||
} MetaDirection;
|
||||
|
||||
/* And a few more aliases */
|
||||
/* 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.
|
||||
*/
|
||||
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
|
||||
} MetaDirection;
|
||||
} MetaSide;
|
||||
|
||||
/* Function a window button can have. Note, you can't add stuff here
|
||||
* without extending the theme format to draw a new function and
|
||||
|
Loading…
Reference in New Issue
Block a user