boxes: Define cleanup function for MetaStrut and use auto-pointers
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3701>
This commit is contained in:
parent
8dc6115277
commit
e005d035c0
@ -63,3 +63,5 @@ struct _MetaEdge
|
|||||||
MetaSide side_type;
|
MetaSide side_type;
|
||||||
MetaEdgeType edge_type;
|
MetaEdgeType edge_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MetaStrut, g_free);
|
||||||
|
@ -94,12 +94,6 @@ new_monitor_edge (int x, int y, int width, int height, int side_type)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
free_strut_list (GSList *struts)
|
|
||||||
{
|
|
||||||
g_slist_free_full (struts, g_free);
|
|
||||||
}
|
|
||||||
|
|
||||||
static GSList*
|
static GSList*
|
||||||
get_strut_list (int which)
|
get_strut_list (int which)
|
||||||
{
|
{
|
||||||
@ -149,8 +143,8 @@ get_strut_list (int which)
|
|||||||
static GList*
|
static GList*
|
||||||
get_screen_region (int which)
|
get_screen_region (int which)
|
||||||
{
|
{
|
||||||
|
g_autoslist (MetaStrut) struts = NULL;
|
||||||
GList *ret;
|
GList *ret;
|
||||||
GSList *struts;
|
|
||||||
MtkRectangle basic_rect;
|
MtkRectangle basic_rect;
|
||||||
|
|
||||||
basic_rect = MTK_RECTANGLE_INIT (0, 0, 1600, 1200);
|
basic_rect = MTK_RECTANGLE_INIT (0, 0, 1600, 1200);
|
||||||
@ -158,7 +152,6 @@ get_screen_region (int which)
|
|||||||
|
|
||||||
struts = get_strut_list (which);
|
struts = get_strut_list (which);
|
||||||
ret = meta_rectangle_get_minimal_spanning_set_for_region (&basic_rect, struts);
|
ret = meta_rectangle_get_minimal_spanning_set_for_region (&basic_rect, struts);
|
||||||
free_strut_list (struts);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -166,8 +159,8 @@ get_screen_region (int which)
|
|||||||
static GList*
|
static GList*
|
||||||
get_screen_edges (int which)
|
get_screen_edges (int which)
|
||||||
{
|
{
|
||||||
|
g_autoslist (MetaStrut) struts = NULL;
|
||||||
GList *ret;
|
GList *ret;
|
||||||
GSList *struts;
|
|
||||||
MtkRectangle basic_rect;
|
MtkRectangle basic_rect;
|
||||||
|
|
||||||
basic_rect = MTK_RECTANGLE_INIT (0, 0, 1600, 1200);
|
basic_rect = MTK_RECTANGLE_INIT (0, 0, 1600, 1200);
|
||||||
@ -175,7 +168,6 @@ get_screen_edges (int which)
|
|||||||
|
|
||||||
struts = get_strut_list (which);
|
struts = get_strut_list (which);
|
||||||
ret = meta_rectangle_find_onscreen_edges (&basic_rect, struts);
|
ret = meta_rectangle_find_onscreen_edges (&basic_rect, struts);
|
||||||
free_strut_list (struts);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -183,8 +175,8 @@ get_screen_edges (int which)
|
|||||||
static GList*
|
static GList*
|
||||||
get_monitor_edges (int which_monitor_set, int which_strut_set)
|
get_monitor_edges (int which_monitor_set, int which_strut_set)
|
||||||
{
|
{
|
||||||
|
g_autoslist (MetaStrut) struts = NULL;
|
||||||
GList *ret;
|
GList *ret;
|
||||||
GSList *struts;
|
|
||||||
GList *xins;
|
GList *xins;
|
||||||
|
|
||||||
xins = NULL;
|
xins = NULL;
|
||||||
@ -214,7 +206,6 @@ get_monitor_edges (int which_monitor_set, int which_strut_set)
|
|||||||
struts = get_strut_list (which_strut_set);
|
struts = get_strut_list (which_strut_set);
|
||||||
ret = meta_rectangle_find_nonintersected_monitor_edges (xins, struts);
|
ret = meta_rectangle_find_nonintersected_monitor_edges (xins, struts);
|
||||||
|
|
||||||
free_strut_list (struts);
|
|
||||||
meta_rectangle_free_list_and_elements (xins);
|
meta_rectangle_free_list_and_elements (xins);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1552,7 +1552,7 @@ meta_window_x11_move_resize_internal (MetaWindow *window,
|
|||||||
static gboolean
|
static gboolean
|
||||||
meta_window_x11_update_struts (MetaWindow *window)
|
meta_window_x11_update_struts (MetaWindow *window)
|
||||||
{
|
{
|
||||||
GSList *old_struts;
|
g_autoslist (GSList) old_struts = NULL;
|
||||||
GSList *new_struts;
|
GSList *new_struts;
|
||||||
GSList *old_iter, *new_iter;
|
GSList *old_iter, *new_iter;
|
||||||
uint32_t *struts = NULL;
|
uint32_t *struts = NULL;
|
||||||
@ -1564,7 +1564,7 @@ meta_window_x11_update_struts (MetaWindow *window)
|
|||||||
meta_verbose ("Updating struts for %s", window->desc);
|
meta_verbose ("Updating struts for %s", window->desc);
|
||||||
|
|
||||||
Window xwindow = meta_window_x11_get_xwindow (window);
|
Window xwindow = meta_window_x11_get_xwindow (window);
|
||||||
old_struts = window->struts;
|
old_struts = g_steal_pointer (&window->struts);
|
||||||
new_struts = NULL;
|
new_struts = NULL;
|
||||||
|
|
||||||
if (meta_prop_get_cardinal_list (window->display->x11_display,
|
if (meta_prop_get_cardinal_list (window->display->x11_display,
|
||||||
@ -1710,7 +1710,6 @@ meta_window_x11_update_struts (MetaWindow *window)
|
|||||||
changed = (old_iter != NULL || new_iter != NULL);
|
changed = (old_iter != NULL || new_iter != NULL);
|
||||||
|
|
||||||
/* Update appropriately */
|
/* Update appropriately */
|
||||||
g_slist_free_full (old_struts, g_free);
|
|
||||||
window->struts = new_struts;
|
window->struts = new_struts;
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user