diff options
author | Elijah Newren <newren gmail com> | 2007-04-04 21:54:56 +0000 |
---|---|---|
committer | Elijah Newren <newren@src.gnome.org> | 2007-04-04 21:54:56 +0000 |
commit | 921661e91d8b4602a2903dee805a5505da052da9 (patch) | |
tree | f98f9073740bfbb415d3009da8636f51c1b3ee47 /src/window.c | |
parent | 7a799b3a6356be3b44dc249786fe31b7a4fb713d (diff) | |
download | metacity-921661e91d8b4602a2903dee805a5505da052da9.tar.gz |
Fix lots of little issues with min/max constraints and size increment
2004-04-04 Elijah Newren <newren gmail com>
Fix lots of little issues with min/max constraints and size
increment constraints. Fixes #329152, #418395, and possibly
others.
* src/window-props.c (meta_set_normal_hints):
Do more checking to make sure application specified constraints
are self-consistent, modifying the size_hints as necessary to
achieve self-consistency.
* src/constraints.c (setup_constraint_info): remove ugly
copy-pasto, (constrain_size_increments): be careful that fixing
violation of the constraints doesn't cause a violation of the
minimum size constraints.
* src/window.c (ensure_size_hints_satisfied): new function,
(meta_window_unmaximize, meta_window_unmake_fullscreen): the
saved_rect may no longer be valid (as in the case of #329152) so
call ensure_size_hints_satisfied to fix it up.
* doc/how-to-get-focus-right.txt: Some minor spacing and wording
fixes completely unrelated to the rest of this commit
svn path=/trunk/; revision=3155
Diffstat (limited to 'src/window.c')
-rw-r--r-- | src/window.c | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/src/window.c b/src/window.c index d670b31d..c00a6982 100644 --- a/src/window.c +++ b/src/window.c @@ -2233,6 +2233,39 @@ meta_window_unminimize (MetaWindow *window) } static void +ensure_size_hints_satisfied (MetaRectangle *rect, + const XSizeHints *size_hints) +{ + int minw, minh, maxw, maxh; /* min/max width/height */ + int basew, baseh, winc, hinc; /* base width/height, width/height increment */ + int extra_width, extra_height; + + minw = size_hints->min_width; minh = size_hints->min_height; + maxw = size_hints->max_width; maxh = size_hints->max_height; + basew = size_hints->base_width; baseh = size_hints->base_height; + winc = size_hints->width_inc; hinc = size_hints->height_inc; + + /* First, enforce min/max size constraints */ + rect->width = CLAMP (rect->width, minw, maxw); + rect->height = CLAMP (rect->height, minh, maxh); + + /* Now, verify size increment constraints are satisfied, or make them be */ + extra_width = (rect->width - basew) % winc; + extra_height = (rect->height - baseh) % hinc; + + rect->width -= extra_width; + rect->height -= extra_height; + + /* Adjusting width/height down, as done above, may violate minimum size + * constraints, so one last fix. + */ + if (rect->width < minw) + rect->width += ((minw - rect->width)/winc + 1)*winc; + if (rect->height < minh) + rect->height += ((minh - rect->height)/hinc + 1)*hinc; +} + +static void meta_window_save_rect (MetaWindow *window) { if (!(META_WINDOW_MAXIMIZED (window) || window->fullscreen)) @@ -2424,6 +2457,11 @@ meta_window_unmaximize (MetaWindow *window, target_rect.height = window->saved_rect.height; } + /* Window's size hints may have changed while maximized, making + * saved_rect invalid. #329152 + */ + ensure_size_hints_satisfied (&target_rect, &window->size_hints); + /* When we unmaximize, if we're doing a mouse move also we could * get the window suddenly jumping to the upper left corner of * the workspace, since that's where it was when the grab op @@ -2520,17 +2558,25 @@ meta_window_unmake_fullscreen (MetaWindow *window) { if (window->fullscreen) { + MetaRectangle target_rect; + meta_topic (META_DEBUG_WINDOW_OPS, "Unfullscreening %s\n", window->desc); window->fullscreen = FALSE; + target_rect = window->saved_rect; + + /* Window's size hints may have changed while maximized, making + * saved_rect invalid. #329152 + */ + ensure_size_hints_satisfied (&target_rect, &window->size_hints); meta_window_move_resize (window, FALSE, - window->saved_rect.x, - window->saved_rect.y, - window->saved_rect.width, - window->saved_rect.height); + target_rect.x, + target_rect.y, + target_rect.width, + target_rect.height); meta_window_update_layer (window); |