1
0
Fork 0

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:
Marco Trevisan (Treviño) 2023-05-22 15:56:08 +02:00 committed by Marge Bot
parent 8dc6115277
commit e005d035c0
3 changed files with 7 additions and 15 deletions

View file

@ -63,3 +63,5 @@ struct _MetaEdge
MetaSide side_type;
MetaEdgeType edge_type;
};
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MetaStrut, g_free);

View file

@ -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*
get_strut_list (int which)
{
@ -149,8 +143,8 @@ get_strut_list (int which)
static GList*
get_screen_region (int which)
{
g_autoslist (MetaStrut) struts = NULL;
GList *ret;
GSList *struts;
MtkRectangle basic_rect;
basic_rect = MTK_RECTANGLE_INIT (0, 0, 1600, 1200);
@ -158,7 +152,6 @@ get_screen_region (int which)
struts = get_strut_list (which);
ret = meta_rectangle_get_minimal_spanning_set_for_region (&basic_rect, struts);
free_strut_list (struts);
return ret;
}
@ -166,8 +159,8 @@ get_screen_region (int which)
static GList*
get_screen_edges (int which)
{
g_autoslist (MetaStrut) struts = NULL;
GList *ret;
GSList *struts;
MtkRectangle basic_rect;
basic_rect = MTK_RECTANGLE_INIT (0, 0, 1600, 1200);
@ -175,7 +168,6 @@ get_screen_edges (int which)
struts = get_strut_list (which);
ret = meta_rectangle_find_onscreen_edges (&basic_rect, struts);
free_strut_list (struts);
return ret;
}
@ -183,8 +175,8 @@ get_screen_edges (int which)
static GList*
get_monitor_edges (int which_monitor_set, int which_strut_set)
{
g_autoslist (MetaStrut) struts = NULL;
GList *ret;
GSList *struts;
GList *xins;
xins = NULL;
@ -214,7 +206,6 @@ get_monitor_edges (int which_monitor_set, int which_strut_set)
struts = get_strut_list (which_strut_set);
ret = meta_rectangle_find_nonintersected_monitor_edges (xins, struts);
free_strut_list (struts);
meta_rectangle_free_list_and_elements (xins);
return ret;

View file

@ -1552,7 +1552,7 @@ meta_window_x11_move_resize_internal (MetaWindow *window,
static gboolean
meta_window_x11_update_struts (MetaWindow *window)
{
GSList *old_struts;
g_autoslist (GSList) old_struts = NULL;
GSList *new_struts;
GSList *old_iter, *new_iter;
uint32_t *struts = NULL;
@ -1564,7 +1564,7 @@ meta_window_x11_update_struts (MetaWindow *window)
meta_verbose ("Updating struts for %s", window->desc);
Window xwindow = meta_window_x11_get_xwindow (window);
old_struts = window->struts;
old_struts = g_steal_pointer (&window->struts);
new_struts = NULL;
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);
/* Update appropriately */
g_slist_free_full (old_struts, g_free);
window->struts = new_struts;
return changed;
}