Improve the behavior of keyboard move/resize and edge snapping. Still not

2005-08-03  Ray Strode  <rstrode@redhat.com>

	Improve the behavior of keyboard move/resize and edge
	snapping.  Still not perfect, bug 310888.

	* src/effects.c (draw_xor_rect): Make the outside of a
	wireframe rectangle line up with the outside edge of its
	window, instead of centering the wireframe edges on the
	window edges.

	* src/keybindings.c (process_keyboard_move_grab): allow
	edge snapping in wireframe mode.  Adjust code to take
	into account changed semantics of find_next_*_edge
	functions.
	(process_keyboard_resize_grab_op_change): new function
	to take some orthogonal logic out of
	process_keyboard_resize_grab_op.  Only allow keyboard
	resize cursor to go to flat edges, not corners.
	(process_keyboard_resize_grab):  allow edge snapping in
	wireframe mode.  Fix up snapping logic.

	* src/place.c (get_{vertical,horizontal}_edges): use
	GArray instead of int *, since the number of output
	edges isn't known until the middle of the function now.
	Use xor rect extents instead of window extends if in
	wireframe mode.
	(meta_window_find_next_{vertical,horizontal}_edge: add
	new source_edge_position parameter to specify which edge
	on the active window to start from when looking for next
	edge on the screen. Return the coordinate of the edge
	found and not the coordinate of where the window should be
	moved to snap to where the edge was found.

	* src/window.c (update_move): all the user to specify
	an edge to resize with mouse in keyboard resize mode.
	window
This commit is contained in:
Ray Strode
2005-08-03 02:22:00 +00:00
committed by Ray Strode
parent 8e927fd300
commit 2972ab6df6
6 changed files with 554 additions and 335 deletions

View File

@ -6498,27 +6498,22 @@ update_move (MetaWindow *window,
if (window->maximized)
return;
if (mask & ShiftMask)
{
/* snap to edges */
if (dy != 0)
new_x = meta_window_find_nearest_vertical_edge (window, new_x);
if (dx != 0)
new_y = meta_window_find_nearest_horizontal_edge (window, new_y);
}
if (window->display->grab_wireframe_active)
{
/* FIXME Horribly broken, does not honor position
* constraints
*/
meta_window_update_wireframe (window, new_x, new_y,
window->display->grab_wireframe_rect.width,
window->display->grab_wireframe_rect.height);
}
meta_window_update_wireframe (window, new_x, new_y,
window->display->grab_wireframe_rect.width,
window->display->grab_wireframe_rect.height);
else
{
/* FIXME, edge snapping broken in wireframe mode */
if (mask & ShiftMask)
{
/* snap to edges */
new_x = meta_window_find_nearest_vertical_edge (window, new_x);
new_y = meta_window_find_nearest_horizontal_edge (window, new_y);
}
meta_window_move (window, TRUE, new_x, new_y);
}
meta_window_move (window, TRUE, new_x, new_y);
}
static void update_resize (MetaWindow *window,
@ -6562,6 +6557,50 @@ update_resize (MetaWindow *window,
/* 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;
if (window->display->grab_op == META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN)
{
if ((dx > 0) && (dy > 0))
{
window->display->grab_op = META_GRAB_OP_KEYBOARD_RESIZING_SE;
meta_window_update_keyboard_resize (window, TRUE);
}
else if ((dx < 0) && (dy > 0))
{
window->display->grab_op = META_GRAB_OP_KEYBOARD_RESIZING_SW;
meta_window_update_keyboard_resize (window, TRUE);
}
else if ((dx > 0) && (dy < 0))
{
window->display->grab_op = META_GRAB_OP_KEYBOARD_RESIZING_NE;
meta_window_update_keyboard_resize (window, TRUE);
}
else if ((dx < 0) && (dy < 0))
{
window->display->grab_op = META_GRAB_OP_KEYBOARD_RESIZING_NW;
meta_window_update_keyboard_resize (window, TRUE);
}
else if (dx < 0)
{
window->display->grab_op = META_GRAB_OP_KEYBOARD_RESIZING_W;
meta_window_update_keyboard_resize (window, TRUE);
}
else if (dx > 0)
{
window->display->grab_op = META_GRAB_OP_KEYBOARD_RESIZING_E;
meta_window_update_keyboard_resize (window, TRUE);
}
else if (dy > 0)
{
window->display->grab_op = META_GRAB_OP_KEYBOARD_RESIZING_S;
meta_window_update_keyboard_resize (window, TRUE);
}
else if (dy < 0)
{
window->display->grab_op = META_GRAB_OP_KEYBOARD_RESIZING_N;
meta_window_update_keyboard_resize (window, TRUE);
}
}
switch (window->display->grab_op)
{
@ -7270,11 +7309,13 @@ warp_grab_pointer (MetaWindow *window,
if (window == window->display->grab_window &&
window->display->grab_wireframe_active)
rect = window->display->grab_wireframe_rect;
{
meta_window_get_xor_rect (window, &window->display->grab_wireframe_rect,
&rect);
}
else
{
rect = window->rect;
meta_window_get_position (window, &rect.x, &rect.y);
meta_window_get_outer_rect (window, &rect);
}
switch (grab_op)