summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2005-11-19 00:40:59 +0000
committerElijah Newren <newren@src.gnome.org>2005-11-19 00:40:59 +0000
commite395f9c66efd14f307b283bf0f28d510e3d58d5d (patch)
tree0874ffc1cabd8b7fcad86cf93be16bb15cacda1a
parent1ab66784ec08ac8358d1dce5fd2b74111ef35918 (diff)
downloadmetacity-e395f9c66efd14f307b283bf0f28d510e3d58d5d.tar.gz
Fix the breakage all these constraints_experiments changes caused to
2005-11-18 Elijah Newren <newren@gmail.com> Fix the breakage all these constraints_experiments changes caused to reduced resources mode. Also fixes #304857 (wireframe can move off the top of the screen despite the fact that the window won't be allowed to) * src/edge-resistance.c: (apply_edge_resistance): if two edges are at the same location then the keyboard buildup ought to count towards both (otherwise the user can't move past that edge with the keyboard), be careful to not clear keyboard_buildup from edges that don't even align (meta_window_edge_resistance_for_move): (meta_window_edge_resistance_for_resize): need to use meta_window_get_xor_rect() instead of meta_window_get_outer_rect() for wireframe mode * src/keybindings.c: (process_keyboard_move_grab): (process_keyboard_resize_grab): apply edge resistance for wireframe moving/resizing too since it was there in the old code I replaced * src/window.c: (update_move): (update_resize): ignore operation if no movement was specified (happens for keyboard operations due to pointer warp), old position must be obtained differently for wireframe mode (warp_grab_pointer): grab_anchor_window_pos must be set differently in wireframe mode
-rw-r--r--ChangeLog38
-rw-r--r--src/edge-resistance.c61
-rw-r--r--src/keybindings.c57
-rw-r--r--src/window.c75
4 files changed, 174 insertions, 57 deletions
diff --git a/ChangeLog b/ChangeLog
index 3842066c..4c9a9861 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,41 @@
+2005-11-18 Elijah Newren <newren@gmail.com>
+
+ Fix the breakage all these constraints_experiments changes caused
+ to reduced resources mode. Also fixes #304857 (wireframe can move
+ off the top of the screen despite the fact that the window won't
+ be allowed to)
+
+ * src/edge-resistance.c:
+
+ (apply_edge_resistance):
+ if two edges are at the same location then the keyboard buildup
+ ought to count towards both (otherwise the user can't move past
+ that edge with the keyboard), be careful to not clear
+ keyboard_buildup from edges that don't even align
+
+ (meta_window_edge_resistance_for_move):
+ (meta_window_edge_resistance_for_resize):
+ need to use meta_window_get_xor_rect() instead of
+ meta_window_get_outer_rect() for wireframe mode
+
+ * src/keybindings.c:
+
+ (process_keyboard_move_grab):
+ (process_keyboard_resize_grab):
+ apply edge resistance for wireframe moving/resizing too since it
+ was there in the old code I replaced
+
+ * src/window.c:
+
+ (update_move):
+ (update_resize):
+ ignore operation if no movement was specified (happens for
+ keyboard operations due to pointer warp), old position must be
+ obtained differently for wireframe mode
+
+ (warp_grab_pointer):
+ grab_anchor_window_pos must be set differently in wireframe mode
+
2005-11-16 Elijah Newren <newren@gmail.com>
* src/window.c (meta_window_show_menu): special case DOCK and
diff --git a/src/edge-resistance.c b/src/edge-resistance.c
index 4d5a6b5b..a9a1a95a 100644
--- a/src/edge-resistance.c
+++ b/src/edge-resistance.c
@@ -329,6 +329,8 @@ apply_edge_resistance (MetaWindow *window,
gboolean keyboard_op)
{
int i, begin, end;
+ gboolean okay_to_clear_keyboard_buildup = FALSE;
+ int keyboard_buildup_edge = G_MAXINT;
gboolean increasing = new_pos > old_pos;
int increment = increasing ? 1 : -1;
@@ -415,7 +417,7 @@ apply_edge_resistance (MetaWindow *window,
}
/* Rest is easier to read if we split on keyboard vs. mouse op */
- if (keyboard_op)
+ if (keyboard_op && edges_align)
{
/* KEYBOARD ENERGY BUILDUP RESISTANCE: If the user has is moving
* fast enough or has already built up enough "energy", then let
@@ -423,27 +425,35 @@ apply_edge_resistance (MetaWindow *window,
* user was previously stopped at this edge, add movement amount
* to the built up energy.
*/
+ if (okay_to_clear_keyboard_buildup &&
+ compare != keyboard_buildup_edge)
+ {
+ okay_to_clear_keyboard_buildup = FALSE;
+ resistance_data->keyboard_buildup = 0;
+ }
int threshold = EDGE_RESISTANCE_THRESHOLD
- resistance_data->keyboard_buildup;
- if (edges_align &&
- ABS (compare - new_pos) < threshold)
+ if (ABS (compare - new_pos) < threshold)
{
if (resistance_data->keyboard_buildup != 0)
resistance_data->keyboard_buildup += ABS (new_pos - compare);
else
- resistance_data->keyboard_buildup = 1; /* Can't be 0 or stuck forever */
+ resistance_data->keyboard_buildup = 1; /* 0 causes stuckage */
return compare;
}
else
{
- /* Let the user past the edge; remove any built up energy
- * from this edge (note that there better not be any left
- * over from previous edges either...)
+ /* It may be the case that there are two windows with edges
+ * at the same location. If so, the buildup ought to count
+ * towards both edges. So we just not that it's okay to
+ * clear the buildup once we find an edge at a different
+ * location.
*/
- resistance_data->keyboard_buildup = 0;
+ okay_to_clear_keyboard_buildup = TRUE;
+ keyboard_buildup_edge = compare;
}
}
- else
+ else if (!keyboard_op && edges_align)
{
/* PIXEL DISTANCE MOUSE RESISTANCE: If the edge matters and the
* user hasn't moved at least EDGE_RESISTANCE_THRESHOLD pixels
@@ -454,8 +464,7 @@ apply_edge_resistance (MetaWindow *window,
* and mouse position is an absolute quantity rather than a
* relative quantity)
*/
- if (edges_align &&
- ABS (compare - new_pos) < EDGE_RESISTANCE_THRESHOLD)
+ if (ABS (compare - new_pos) < EDGE_RESISTANCE_THRESHOLD)
return compare;
}
@@ -463,6 +472,12 @@ apply_edge_resistance (MetaWindow *window,
i += increment;
}
+ /* If we didn't run into any new edges in keyboard buildup but had moved
+ * far enough to get past the last one, clear the buildup
+ */
+ if (okay_to_clear_keyboard_buildup && new_pos != keyboard_buildup_edge)
+ resistance_data->keyboard_buildup = 0;
+
return new_pos;
}
@@ -1079,7 +1094,17 @@ meta_window_edge_resistance_for_move (MetaWindow *window,
{
MetaRectangle old_outer, proposed_outer, new_outer;
- meta_window_get_outer_rect (window, &old_outer);
+ if (window == window->display->grab_window &&
+ window->display->grab_wireframe_active)
+ {
+ meta_window_get_xor_rect (window,
+ &window->display->grab_wireframe_rect,
+ &old_outer);
+ }
+ else
+ {
+ meta_window_get_outer_rect (window, &old_outer);
+ }
proposed_outer = old_outer;
proposed_outer.x += (*new_x - old_x);
proposed_outer.y += (*new_y - old_y);
@@ -1155,7 +1180,17 @@ meta_window_edge_resistance_for_resize (MetaWindow *window,
MetaRectangle old_outer, new_outer;
int new_outer_width, new_outer_height;
- meta_window_get_outer_rect (window, &old_outer);
+ if (window == window->display->grab_window &&
+ window->display->grab_wireframe_active)
+ {
+ meta_window_get_xor_rect (window,
+ &window->display->grab_wireframe_rect,
+ &old_outer);
+ }
+ else
+ {
+ meta_window_get_outer_rect (window, &old_outer);
+ }
new_outer_width = old_outer.width + (*new_width - old_width);
new_outer_height = old_outer.height + (*new_height - old_height);
meta_rectangle_resize_with_gravity (&old_outer,
diff --git a/src/keybindings.c b/src/keybindings.c
index c92f8528..b75017df 100644
--- a/src/keybindings.c
+++ b/src/keybindings.c
@@ -1783,9 +1783,28 @@ process_keyboard_move_grab (MetaDisplay *display,
if (handled)
{
+ MetaRectangle old_rect;
meta_topic (META_DEBUG_KEYBINDINGS,
"Computed new window location %d,%d due to keypress\n",
x, y);
+
+ if (display->grab_wireframe_active)
+ old_rect = display->grab_wireframe_rect;
+ else
+ {
+ old_rect = window->rect;
+ meta_window_get_position (window, &old_rect.x, &old_rect.y);
+ }
+
+ meta_window_edge_resistance_for_move (window,
+ old_rect.x,
+ old_rect.y,
+ &x,
+ &y,
+ NULL,
+ smart_snap,
+ TRUE);
+
if (display->grab_wireframe_active)
{
meta_window_update_wireframe (window, x, y,
@@ -1794,16 +1813,6 @@ process_keyboard_move_grab (MetaDisplay *display,
}
else
{
- int old_x, old_y;
- meta_window_get_position (window, &old_x, &old_y);
- meta_window_edge_resistance_for_move (window,
- old_x,
- old_y,
- &x,
- &y,
- NULL,
- smart_snap,
- TRUE);
meta_window_move (window, TRUE, x, y);
}
@@ -2150,12 +2159,29 @@ process_keyboard_resize_grab (MetaDisplay *display,
if (handled)
{
+ MetaRectangle old_rect;
meta_topic (META_DEBUG_KEYBINDINGS,
"Computed new window size due to keypress: "
"%dx%d, gravity %s\n",
width, height, meta_gravity_to_string (gravity));
if (display->grab_wireframe_active)
+ old_rect = display->grab_wireframe_rect;
+ else
+ old_rect = window->rect; /* Don't actually care about x,y */
+
+ /* Do any edge resistance/snapping */
+ meta_window_edge_resistance_for_resize (window,
+ old_rect.width,
+ old_rect.height,
+ &width,
+ &height,
+ gravity,
+ NULL,
+ smart_snap,
+ TRUE);
+
+ if (display->grab_wireframe_active)
{
MetaRectangle new_position;
meta_rectangle_resize_with_gravity (&display->grab_wireframe_rect,
@@ -2171,17 +2197,6 @@ process_keyboard_resize_grab (MetaDisplay *display,
}
else
{
- /* Do any edge resistance/snapping */
- meta_window_edge_resistance_for_resize (window,
- window->rect.width,
- window->rect.height,
- &width,
- &height,
- gravity,
- NULL,
- smart_snap,
- TRUE);
-
/* We don't need to update unless the specified width and height
* are actually different from what we had before.
*/
diff --git a/src/window.c b/src/window.c
index e534251b..8d377c7c 100644
--- a/src/window.c
+++ b/src/window.c
@@ -6505,7 +6505,7 @@ update_move (MetaWindow *window,
{
int dx, dy;
int new_x, new_y;
- int old_x, old_y;
+ MetaRectangle old;
int shake_threshold;
window->display->grab_latest_motion_x = x;
@@ -6524,7 +6524,14 @@ update_move (MetaWindow *window,
window->display->grab_anchor_window_pos.x,
window->display->grab_anchor_window_pos.y,
dx, dy);
-
+
+ /* Don't bother doing anything if no move has been specified. (This
+ * happens often, even in keyboard moving, due to the warping of the
+ * pointer.
+ */
+ if (dx == 0 && dy == 0)
+ return;
+
/* shake loose (unmaximize) maximized window if dragged beyond the threshold
* in the Y direction. You can't pull a window loose via X motion.
*/
@@ -6613,18 +6620,24 @@ update_move (MetaWindow *window,
}
}
- meta_window_get_position (window, &old_x, &old_y);
+ if (window->display->grab_wireframe_active)
+ old = window->display->grab_wireframe_rect;
+ else
+ {
+ old = window->rect;
+ meta_window_get_position (window, &old.x, &old.y);
+ }
/* Don't allow movement in the maximized directions */
if (window->maximized_horizontally)
- new_x = old_x;
+ new_x = old.x;
if (window->maximized_vertically)
- new_y = old_y;
+ new_y = old.y;
/* Do any edge resistance/snapping */
meta_window_edge_resistance_for_move (window,
- old_x,
- old_y,
+ old.x,
+ old.y,
&new_x,
&new_y,
update_move_timeout,
@@ -6674,6 +6687,13 @@ update_resize (MetaWindow *window,
new_w = window->display->grab_anchor_window_pos.width;
new_h = window->display->grab_anchor_window_pos.height;
+ /* Don't bother doing anything if no move has been specified. (This
+ * happens often, even in keyboard resizing, due to the warping of the
+ * pointer.
+ */
+ if (dx == 0 && dy == 0)
+ return;
+
/* FIXME this is only used in wireframe mode */
new_x = window->display->grab_anchor_window_pos.x;
new_y = window->display->grab_anchor_window_pos.y;
@@ -6799,7 +6819,10 @@ update_resize (MetaWindow *window,
window->display->grab_resize_timeout_id = 0;
}
- old = window->rect;
+ if (window->display->grab_wireframe_active)
+ old = window->display->grab_wireframe_rect;
+ else
+ old = window->rect; /* Don't actually care about x,y */
/* One sided resizing ought to actually be one-sided, despite the fact that
* aspect ratio windows don't interact nicely with the above stuff. So,
@@ -6825,6 +6848,17 @@ update_resize (MetaWindow *window,
gravity = meta_resize_gravity_from_grab_op (window->display->grab_op);
g_assert (gravity >= 0);
+ /* Do any edge resistance/snapping */
+ meta_window_edge_resistance_for_resize (window,
+ old.width,
+ old.height,
+ &new_w,
+ &new_h,
+ gravity,
+ update_resize_timeout,
+ snap,
+ FALSE);
+
if (window->display->grab_wireframe_active)
{
if ((new_x + new_w <= new_x) || (new_y + new_h <= new_y))
@@ -6841,17 +6875,6 @@ update_resize (MetaWindow *window,
}
else
{
- /* Do any edge resistance/snapping */
- meta_window_edge_resistance_for_resize (window,
- old.width,
- old.height,
- &new_w,
- &new_h,
- gravity,
- update_resize_timeout,
- snap,
- FALSE);
-
/* We don't need to update unless the specified width and height
* are actually different from what we had before.
*/
@@ -7509,10 +7532,16 @@ warp_grab_pointer (MetaWindow *window,
window->display->grab_anchor_root_y = *y;
window->display->grab_latest_motion_x = *x;
window->display->grab_latest_motion_y = *y;
- window->display->grab_anchor_window_pos = window->rect;
- meta_window_get_position (window,
- &window->display->grab_anchor_window_pos.x,
- &window->display->grab_anchor_window_pos.y);
+ if (window->display->grab_wireframe_active)
+ window->display->grab_anchor_window_pos =
+ window->display->grab_wireframe_rect;
+ else
+ {
+ window->display->grab_anchor_window_pos = window->rect;
+ meta_window_get_position (window,
+ &window->display->grab_anchor_window_pos.x,
+ &window->display->grab_anchor_window_pos.y);
+ }
XWarpPointer (window->display->xdisplay,
None,