summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHavoc Pennington <hp@pobox.com>2003-06-28 16:12:32 +0000
committerHavoc Pennington <hp@src.gnome.org>2003-06-28 16:12:32 +0000
commitfa075eb8f1427c98d3a77e51b0543e5ac558d305 (patch)
treecbfc572ca749d385b8ab56ea64036b239270adf8
parente1102bc6ff071b3ebaa14f80879a334738c8a003 (diff)
downloadmetacity-fa075eb8f1427c98d3a77e51b0543e5ac558d305.tar.gz
nuke the lists of struts here, to improve confidence that we never try to
2003-06-26 Havoc Pennington <hp@pobox.com> * 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
-rw-r--r--ChangeLog16
-rw-r--r--src/constraints.c27
-rw-r--r--src/window.c18
-rw-r--r--src/workspace.c23
4 files changed, 61 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index 005caf01..6dd0edeb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2003-06-26 Havoc Pennington <hp@pobox.com>
+
+ * 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 <robadams@ucla.edu>
Add keybinding to allow the user to toggle _NET_WM_STATE_ABOVE on
diff --git a/src/constraints.c b/src/constraints.c
index abf0b650..74fefcb0 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 8ff177ee..8d11b8fa 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 d84539e2..09dc25a5 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);