summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann <sandmann@redhat.com>2005-01-21 16:30:10 +0000
committerSøren Sandmann Pedersen <ssp@src.gnome.org>2005-01-21 16:30:10 +0000
commit98442a04674f5512340019e7b969a6a8d0615a33 (patch)
tree615f789381c2f6a15dd6ea98b7d4c019dae5c14e
parentccc1b7194458db1cdefb303899215f54945271f1 (diff)
downloadmetacity-98442a04674f5512340019e7b969a6a8d0615a33.tar.gz
Some cleanups Make frame windows override redirect so clients can resize
Fri Jan 21 11:26:27 2005 Søren Sandmann <sandmann@redhat.com> * src/window.c: Some cleanups * src/ui.c: Make frame windows override redirect so clients can resize them.
-rw-r--r--src/display.c44
-rw-r--r--src/display.h4
-rw-r--r--src/ui.c4
-rw-r--r--src/window.c257
4 files changed, 143 insertions, 166 deletions
diff --git a/src/display.c b/src/display.c
index a6711050..430267d7 100644
--- a/src/display.c
+++ b/src/display.c
@@ -1085,6 +1085,50 @@ meta_grab_op_is_resizing (MetaGrabOp op)
}
gboolean
+meta_grab_op_is_resizing_east (MetaGrabOp op)
+{
+ return (op == META_GRAB_OP_RESIZING_SE ||
+ op == META_GRAB_OP_RESIZING_NE ||
+ op == META_GRAB_OP_RESIZING_E ||
+ op == META_GRAB_OP_KEYBOARD_RESIZING_SE ||
+ op == META_GRAB_OP_KEYBOARD_RESIZING_NE ||
+ op == META_GRAB_OP_KEYBOARD_RESIZING_E);
+}
+
+gboolean
+meta_grab_op_is_resizing_west (MetaGrabOp op)
+{
+ return (op == META_GRAB_OP_RESIZING_NW ||
+ op == META_GRAB_OP_RESIZING_SW ||
+ op == META_GRAB_OP_RESIZING_W ||
+ op == META_GRAB_OP_KEYBOARD_RESIZING_NW ||
+ op == META_GRAB_OP_KEYBOARD_RESIZING_SW ||
+ op == META_GRAB_OP_KEYBOARD_RESIZING_W);
+}
+
+gboolean
+meta_grab_op_is_resizing_south (MetaGrabOp op)
+{
+ return (op == META_GRAB_OP_RESIZING_SW ||
+ op == META_GRAB_OP_RESIZING_SE ||
+ op == META_GRAB_OP_RESIZING_S ||
+ op == META_GRAB_OP_KEYBOARD_RESIZING_SW ||
+ op == META_GRAB_OP_KEYBOARD_RESIZING_SE ||
+ op == META_GRAB_OP_KEYBOARD_RESIZING_S);
+}
+
+gboolean
+meta_grab_op_is_resizing_north (MetaGrabOp op)
+{
+ return (op == META_GRAB_OP_RESIZING_NW ||
+ op == META_GRAB_OP_RESIZING_NE ||
+ op == META_GRAB_OP_RESIZING_N ||
+ op == META_GRAB_OP_KEYBOARD_RESIZING_NW ||
+ op == META_GRAB_OP_KEYBOARD_RESIZING_NE ||
+ op == META_GRAB_OP_KEYBOARD_RESIZING_N);
+}
+
+gboolean
meta_grab_op_is_moving (MetaGrabOp op)
{
switch (op)
diff --git a/src/display.h b/src/display.h
index a122c35a..506e7caa 100644
--- a/src/display.h
+++ b/src/display.h
@@ -487,6 +487,10 @@ int meta_resize_gravity_from_grab_op (MetaGrabOp op);
gboolean meta_grab_op_is_moving (MetaGrabOp op);
gboolean meta_grab_op_is_resizing (MetaGrabOp op);
+gboolean meta_grab_op_is_resizing_east (MetaGrabOp op);
+gboolean meta_grab_op_is_resizing_west (MetaGrabOp op);
+gboolean meta_grab_op_is_resizing_north (MetaGrabOp op);
+gboolean meta_grab_op_is_resizing_south(MetaGrabOp op);
gboolean meta_rectangle_intersect (MetaRectangle *src1,
MetaRectangle *src2,
diff --git a/src/ui.c b/src/ui.c
index 9a5a74c7..be95bdf9 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -217,12 +217,12 @@ meta_ui_create_frame_window (MetaUI *ui,
attrs.cursor = NULL;
attrs.wmclass_name = NULL;
attrs.wmclass_class = NULL;
- attrs.override_redirect = FALSE;
+ attrs.override_redirect = TRUE; /* to allow clients to resize the frame window */
attrs.width = width;
attrs.height = height;
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
+ attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP | GDK_WA_NOREDIR;
window =
gdk_window_new (gdk_screen_get_root_window(screen),
diff --git a/src/window.c b/src/window.c
index 75bdeaaa..03d844a7 100644
--- a/src/window.c
+++ b/src/window.c
@@ -6205,56 +6205,27 @@ 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;
-
- switch (window->display->grab_op)
+
+ if (meta_grab_op_is_resizing_east (window->display->grab_op))
{
- case META_GRAB_OP_RESIZING_SE:
- case META_GRAB_OP_RESIZING_NE:
- case META_GRAB_OP_RESIZING_E:
- case META_GRAB_OP_KEYBOARD_RESIZING_SE:
- case META_GRAB_OP_KEYBOARD_RESIZING_NE:
- case META_GRAB_OP_KEYBOARD_RESIZING_E:
new_w += dx;
- break;
-
- case META_GRAB_OP_RESIZING_NW:
- case META_GRAB_OP_RESIZING_SW:
- case META_GRAB_OP_RESIZING_W:
- case META_GRAB_OP_KEYBOARD_RESIZING_NW:
- case META_GRAB_OP_KEYBOARD_RESIZING_SW:
- case META_GRAB_OP_KEYBOARD_RESIZING_W:
+ }
+ else if (meta_grab_op_is_resizing_west (window->display->grab_op))
+ {
new_w -= dx;
new_x += dx;
- break;
-
- default:
- break;
}
-
- switch (window->display->grab_op)
+
+ if (meta_grab_op_is_resizing_south (window->display->grab_op))
{
- case META_GRAB_OP_RESIZING_SE:
- case META_GRAB_OP_RESIZING_S:
- case META_GRAB_OP_RESIZING_SW:
- case META_GRAB_OP_KEYBOARD_RESIZING_SE:
- case META_GRAB_OP_KEYBOARD_RESIZING_S:
- case META_GRAB_OP_KEYBOARD_RESIZING_SW:
new_h += dy;
- break;
-
- case META_GRAB_OP_RESIZING_N:
- case META_GRAB_OP_RESIZING_NE:
- case META_GRAB_OP_RESIZING_NW:
- case META_GRAB_OP_KEYBOARD_RESIZING_N:
- case META_GRAB_OP_KEYBOARD_RESIZING_NE:
- case META_GRAB_OP_KEYBOARD_RESIZING_NW:
+ }
+ else if (meta_grab_op_is_resizing_north (window->display->grab_op))
+ {
new_h -= dy;
- new_y += dy;
- break;
- default:
- break;
+ new_h += dy;
}
-
+
if (!check_moveresize_frequency (window, &remaining) && !force)
{
/* we are ignoring an event here, so we schedule a
@@ -6406,6 +6377,69 @@ check_use_this_motion_notify (MetaWindow *window,
}
}
+static void
+handle_moving_event (MetaWindow *window, XEvent *event)
+{
+ if (event->type == ButtonRelease &&
+ event->xbutton.root == window->screen->xroot)
+ {
+ update_move (window, event->xbutton.state,
+ event->xbutton.x_root, event->xbutton.y_root);
+
+ meta_display_end_grab_op (window->display, event->xbutton.time);
+ }
+ else if (event->type == MotionNotify &&
+ event->xmotion.root == window->screen->xroot &&
+ check_use_this_motion_notify (window, event))
+ {
+ update_move (window,
+ event->xmotion.state,
+ event->xmotion.x_root,
+ event->xmotion.y_root);
+ }
+ else if ((event->type == EnterNotify || event->type == LeaveNotify) &&
+ event->xcrossing.root == window->screen->xroot)
+ {
+ update_move (window,
+ event->xcrossing.state,
+ event->xcrossing.x_root,
+ event->xcrossing.y_root);
+ }
+}
+
+
+static void
+handle_resizing_event (MetaWindow *window, XEvent *event)
+{
+ if (event->type == ButtonRelease &&
+ event->xbutton.root == window->screen->xroot)
+ {
+ update_resize (window,
+ event->xbutton.x_root,
+ event->xbutton.y_root,
+ TRUE);
+
+ meta_display_end_grab_op (window->display, event->xbutton.time);
+ }
+ else if (event->type == MotionNotify &&
+ event->xmotion.root == window->screen->xroot &&
+ check_use_this_motion_notify (window, event))
+ {
+ update_resize (window,
+ event->xmotion.x_root,
+ event->xmotion.y_root,
+ FALSE);
+ }
+ else if ((event->type == EnterNotify || event->type == LeaveNotify) &&
+ event->xcrossing.root == window->screen->xroot)
+ {
+ update_resize (window,
+ event->xcrossing.x_root,
+ event->xcrossing.y_root,
+ FALSE);
+ }
+}
+
void
meta_window_handle_mouse_grab_op_event (MetaWindow *window,
XEvent *event)
@@ -6427,106 +6461,24 @@ meta_window_handle_mouse_grab_op_event (MetaWindow *window,
window->sync_request_time.tv_usec = 0;
/* This means we are ready for another configure. */
- switch (window->display->grab_op)
- {
- case META_GRAB_OP_RESIZING_E:
- case META_GRAB_OP_RESIZING_W:
- case META_GRAB_OP_RESIZING_S:
- case META_GRAB_OP_RESIZING_N:
- case META_GRAB_OP_RESIZING_SE:
- case META_GRAB_OP_RESIZING_SW:
- case META_GRAB_OP_RESIZING_NE:
- case META_GRAB_OP_RESIZING_NW:
- case META_GRAB_OP_KEYBOARD_RESIZING_S:
- case META_GRAB_OP_KEYBOARD_RESIZING_N:
- case META_GRAB_OP_KEYBOARD_RESIZING_W:
- case META_GRAB_OP_KEYBOARD_RESIZING_E:
- case META_GRAB_OP_KEYBOARD_RESIZING_SE:
- case META_GRAB_OP_KEYBOARD_RESIZING_NE:
- case META_GRAB_OP_KEYBOARD_RESIZING_SW:
- case META_GRAB_OP_KEYBOARD_RESIZING_NW:
+ if (meta_grab_op_is_resizing (window->display->grab_op))
+ {
/* no pointer round trip here, to keep in sync */
update_resize (window,
window->display->grab_latest_motion_x,
window->display->grab_latest_motion_y,
TRUE);
- break;
-
- default:
- break;
- }
+ }
}
#endif /* HAVE_XSYNC */
-
- switch (event->type)
- {
- case ButtonRelease:
- if (meta_grab_op_is_moving (window->display->grab_op))
- {
- if (event->xbutton.root == window->screen->xroot)
- update_move (window, event->xbutton.state,
- event->xbutton.x_root, event->xbutton.y_root);
- }
- else if (meta_grab_op_is_resizing (window->display->grab_op))
- {
- if (event->xbutton.root == window->screen->xroot)
- update_resize (window,
- event->xbutton.x_root,
- event->xbutton.y_root,
- TRUE);
- }
-
- meta_display_end_grab_op (window->display, event->xbutton.time);
- break;
- case MotionNotify:
- if (meta_grab_op_is_moving (window->display->grab_op))
- {
- if (event->xmotion.root == window->screen->xroot)
- {
- if (check_use_this_motion_notify (window,
- event))
- update_move (window,
- event->xmotion.state,
- event->xmotion.x_root,
- event->xmotion.y_root);
- }
- }
- else if (meta_grab_op_is_resizing (window->display->grab_op))
- {
- if (event->xmotion.root == window->screen->xroot)
- {
- if (check_use_this_motion_notify (window,
- event))
- update_resize (window,
- event->xmotion.x_root,
- event->xmotion.y_root,
- FALSE);
- }
- }
- break;
-
- case EnterNotify:
- case LeaveNotify:
- if (meta_grab_op_is_moving (window->display->grab_op))
- {
- if (event->xcrossing.root == window->screen->xroot)
- update_move (window,
- event->xcrossing.state,
- event->xcrossing.x_root,
- event->xcrossing.y_root);
- }
- else if (meta_grab_op_is_resizing (window->display->grab_op))
- {
- if (event->xcrossing.root == window->screen->xroot)
- update_resize (window,
- event->xcrossing.x_root,
- event->xcrossing.y_root,
- FALSE);
- }
- break;
- default:
- break;
+ if (meta_grab_op_is_moving (window->display->grab_op))
+ {
+ handle_moving_event (window, event);
+ }
+ else if (meta_grab_op_is_resizing (window->display->grab_op))
+ {
+ handle_resizing_event (window, event);
}
}
@@ -6713,40 +6665,17 @@ meta_window_refresh_resize_popup (MetaWindow *window)
*/
if (window->display->grab_wireframe_active)
return;
-
- switch (window->display->grab_op)
- {
- case META_GRAB_OP_RESIZING_SE:
- case META_GRAB_OP_RESIZING_S:
- case META_GRAB_OP_RESIZING_SW:
- case META_GRAB_OP_RESIZING_N:
- case META_GRAB_OP_RESIZING_NE:
- case META_GRAB_OP_RESIZING_NW:
- case META_GRAB_OP_RESIZING_W:
- case META_GRAB_OP_RESIZING_E:
- case META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN:
- case META_GRAB_OP_KEYBOARD_RESIZING_S:
- case META_GRAB_OP_KEYBOARD_RESIZING_N:
- case META_GRAB_OP_KEYBOARD_RESIZING_W:
- case META_GRAB_OP_KEYBOARD_RESIZING_E:
- case META_GRAB_OP_KEYBOARD_RESIZING_SE:
- case META_GRAB_OP_KEYBOARD_RESIZING_NE:
- case META_GRAB_OP_KEYBOARD_RESIZING_SW:
- case META_GRAB_OP_KEYBOARD_RESIZING_NW:
- break;
- default:
- /* Not resizing */
- return;
- }
+ if (!meta_grab_op_is_resizing (window->display->grab_op))
+ return;
- if (window->display->grab_resize_popup == NULL)
+ if (window->display->grab_resize_popup == NULL &&
+ (window->size_hints.width_inc > 1 ||
+ window->size_hints.height_inc > 1))
{
- if (window->size_hints.width_inc > 1 ||
- window->size_hints.height_inc > 1)
- window->display->grab_resize_popup =
- meta_ui_resize_popup_new (window->display->xdisplay,
- window->screen->number);
+ window->display->grab_resize_popup =
+ meta_ui_resize_popup_new (window->display->xdisplay,
+ window->screen->number);
}
if (window->display->grab_resize_popup != NULL)