From fa075eb8f1427c98d3a77e51b0543e5ac558d305 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Sat, 28 Jun 2003 16:12:32 +0000 Subject: [PATCH] nuke the lists of struts here, to improve confidence that we never try to 2003-06-26 Havoc Pennington * src/workspace.c (meta_workspace_invalidate_work_area): nuke the lists of struts here, to improve confidence that we never try to use them after a window with rects in the list gets freed. (it wasn't broken before I don't think, just making the code more robust against future mods) * src/window.c (meta_window_update_struts): replace magic "75" with a macro * src/constraints.c (constraint_hints_applies_func): don't apply hints to maximized or fullscreen, rather than only fullscreen (constrain_move): add paranoia max number of iterations to the heuristic loop --- ChangeLog | 16 ++++++++++++++++ src/constraints.c | 27 +++++++++++++++++++++------ src/window.c | 18 ++++++++++-------- src/workspace.c | 23 ++++++++++++++--------- 4 files changed, 61 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 005caf010..6dd0edeb5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2003-06-26 Havoc Pennington + + * src/workspace.c (meta_workspace_invalidate_work_area): nuke the + lists of struts here, to improve confidence that we never try to + use them after a window with rects in the list gets freed. + (it wasn't broken before I don't think, just making the + code more robust against future mods) + + * src/window.c (meta_window_update_struts): replace magic "75" + with a macro + + * src/constraints.c (constraint_hints_applies_func): don't apply + hints to maximized or fullscreen, rather than only fullscreen + (constrain_move): add paranoia max number of iterations to the + heuristic loop + 2003-06-26 Rob Adams Add keybinding to allow the user to toggle _NET_WM_STATE_ABOVE on diff --git a/src/constraints.c b/src/constraints.c index abf0b650b..74fefcb03 100644 --- a/src/constraints.c +++ b/src/constraints.c @@ -364,9 +364,8 @@ get_outermost_onscreen_positions (MetaWindow *window, /* to handle struts, we get the list of workspaces for the window * and traverse all the struts in each of the cached strut lists for * the workspaces. Note that because the workarea has already been - * computed, these strut lists should already be up to date. No - * memory allocation should take place in this function for - * performance. + * computed, these strut lists should already be up to date. This function + * should have good performance since we call it a lot. */ current = *orig; @@ -681,10 +680,12 @@ static const Constraint constraint_onscreen = { * */ +#define USE_HINTS_FOR_WINDOW_STATE(window) (!((window)->fullscreen || (window)->maximized)) + static gboolean constraint_hints_applies_func (MetaWindow *window) { - return (!window->fullscreen); + return USE_HINTS_FOR_WINDOW_STATE (window); } static void @@ -912,8 +913,12 @@ constrain_move (MetaWindow *window, { const Constraint **cp; int old_x, old_y; + int paranoia; - + /* Evidence that we can't actually prove this algorithm is right */ +#define MAX_ITERATIONS 10 + paranoia = 0; + do { old_x = x_delta; old_y = y_delta; @@ -936,10 +941,16 @@ constrain_move (MetaWindow *window, ++cp; } - } while ((old_x != x_delta) || (old_y != y_delta)); + ++paranoia; + } while (((old_x != x_delta) || (old_y != y_delta)) && paranoia < MAX_ITERATIONS); new->x = orig->x + x_delta; new->y = orig->y + y_delta; + + if (paranoia >= MAX_ITERATIONS) + meta_topic (META_DEBUG_GEOMETRY, + "Constraints were never satisfied for window %s\n", + window->desc); } static void @@ -1154,6 +1165,10 @@ update_position_limits (MetaWindow *window, int nw_x, nw_y; int se_x, se_y; + /* For maximized windows the limits are the work area, for + * other windows we see which struts apply based on the + * window's position later on + */ if (window->maximized) { nw_x = MIN (info->work_area_xinerama.x, info->work_area_screen.x); diff --git a/src/window.c b/src/window.c index 8ff177ee6..8d11b8faa 100644 --- a/src/window.c +++ b/src/window.c @@ -4842,6 +4842,8 @@ meta_window_update_struts (MetaWindow *window) MetaRectangle new_right; MetaRectangle new_top; MetaRectangle new_bottom; + +#define MIN_EMPTY (75) meta_verbose ("Updating struts for %s\n", window->desc); @@ -4893,13 +4895,13 @@ meta_window_update_struts (MetaWindow *window) { new_has_struts = TRUE; new_left.width = MIN ((int)struts[0], - window->screen->width/2 - 75); + window->screen->width/2 - MIN_EMPTY); new_right.width = MIN ((int)struts[1], - window->screen->width/2 - 75); + window->screen->width/2 - MIN_EMPTY); new_top.height = MIN ((int)struts[2], - window->screen->height/2 - 75); + window->screen->height/2 - MIN_EMPTY); new_bottom.height = MIN ((int)struts[3], - window->screen->height/2 - 75); + window->screen->height/2 - MIN_EMPTY); new_right.x = window->screen->width - new_right.width; new_bottom.y = window->screen->height - @@ -4945,13 +4947,13 @@ meta_window_update_struts (MetaWindow *window) { new_has_struts = TRUE; new_left.width = MIN ((int)struts[0], - window->screen->width/2 - 75); + window->screen->width/2 - MIN_EMPTY); new_right.width = MIN ((int)struts[1], - window->screen->width/2 - 75); + window->screen->width/2 - MIN_EMPTY); new_top.height = MIN ((int)struts[2], - window->screen->height/2 - 75); + window->screen->height/2 - MIN_EMPTY); new_bottom.height = MIN ((int)struts[3], - window->screen->height/2 - 75); + window->screen->height/2 - MIN_EMPTY); new_left.x = 0; new_right.x = window->screen->width - new_right.width; diff --git a/src/workspace.c b/src/workspace.c index d84539e25..09dc25a51 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -348,6 +348,15 @@ meta_workspace_invalidate_work_area (MetaWorkspace *workspace) g_free (workspace->work_areas); workspace->work_areas = NULL; + + g_slist_free (workspace->left_struts); + workspace->left_struts = NULL; + g_slist_free (workspace->right_struts); + workspace->right_struts = NULL; + g_slist_free (workspace->top_struts); + workspace->top_struts = NULL; + g_slist_free (workspace->bottom_struts); + workspace->bottom_struts = NULL; workspace->work_areas_invalid = TRUE; @@ -385,16 +394,12 @@ ensure_work_areas_validated (MetaWorkspace *workspace) if (!workspace->work_areas_invalid) return; - - g_slist_free (workspace->left_struts); - workspace->left_struts = NULL; - g_slist_free (workspace->right_struts); - workspace->right_struts = NULL; - g_slist_free (workspace->top_struts); - workspace->top_struts = NULL; - g_slist_free (workspace->bottom_struts); - workspace->bottom_struts = NULL; + g_assert (workspace->top_struts == NULL); + g_assert (workspace->bottom_struts == NULL); + g_assert (workspace->left_struts == NULL); + g_assert (workspace->right_struts == NULL); + windows = meta_workspace_list_windows (workspace); g_free (workspace->work_areas);