diff options
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | src/display.c | 19 | ||||
-rw-r--r-- | src/display.h | 5 | ||||
-rw-r--r-- | src/effects.c | 86 | ||||
-rw-r--r-- | src/keybindings.c | 83 | ||||
-rw-r--r-- | src/screen.c | 2 | ||||
-rw-r--r-- | src/screen.h | 2 | ||||
-rw-r--r-- | src/window.c | 180 | ||||
-rw-r--r-- | src/window.h | 8 |
9 files changed, 273 insertions, 126 deletions
@@ -1,3 +1,17 @@ +2003-07-20 Havoc Pennington <hp@pobox.com> + + Still broken in various ways, specifically EnterNotify that + occurred prior to XGrabPointer is processed as if it occurred + after. + + * src/window.c (meta_window_update_keyboard_move): add this + instead of meta_window_warp_pointer() crack + + * src/effects.c (meta_effects_update_wireframe): draw a kind of + grid for the wireframe, instead of just a rectangle, like twm + + * src/screen.c (meta_screen_new): line width of 3 for the XOR gc + 2003-07-18 Havoc Pennington <hp@redhat.com> "Reduced resources" mode based on wireframe patch from diff --git a/src/display.c b/src/display.c index a2cefb46..d6b0655f 100644 --- a/src/display.c +++ b/src/display.c @@ -1216,7 +1216,8 @@ event_callback (XEvent *event, * goes to the frame. */ frame_was_receiver = TRUE; - meta_topic (META_DEBUG_EVENTS, "Frame was receiver of event\n"); + meta_topic (META_DEBUG_EVENTS, "Frame was receiver of event for %s\n", + window->desc); } #ifdef HAVE_XSYNC @@ -2780,8 +2781,9 @@ meta_display_begin_grab_op (MetaDisplay *display, Window grab_xwindow; meta_topic (META_DEBUG_WINDOW_OPS, - "Doing grab op %d on window %s button %d pointer already grabbed: %d\n", - op, window ? window->desc : "none", button, pointer_already_grabbed); + "Doing grab op %d on window %s button %d pointer already grabbed: %d pointer pos %d,%d\n", + op, window ? window->desc : "none", button, pointer_already_grabbed, + root_x, root_y); if (display->grab_op != META_GRAB_OP_NONE) { @@ -2841,8 +2843,8 @@ meta_display_begin_grab_op (MetaDisplay *display, display->grab_xwindow = grab_xwindow; display->grab_button = button; display->grab_mask = modmask; - display->grab_initial_root_x = root_x; - display->grab_initial_root_y = root_y; + display->grab_anchor_root_x = root_x; + display->grab_anchor_root_y = root_y; display->grab_latest_motion_x = root_x; display->grab_latest_motion_y = root_y; display->grab_last_moveresize_time.tv_sec = 0; @@ -2858,11 +2860,16 @@ meta_display_begin_grab_op (MetaDisplay *display, meta_window_get_position (display->grab_window, &display->grab_initial_window_pos.x, &display->grab_initial_window_pos.y); + display->grab_anchor_window_pos = display->grab_initial_window_pos; +#if 0 display->grab_wireframe_active = meta_grab_op_is_resizing (display->grab_op) || meta_grab_op_is_moving (display->grab_op); - +#else + display->grab_wireframe_active = FALSE; +#endif + if (display->grab_wireframe_active) { /* FIXME we should really display the outer frame rect, diff --git a/src/display.h b/src/display.h index 16a11646..b2b2280f 100644 --- a/src/display.h +++ b/src/display.h @@ -231,8 +231,9 @@ struct _MetaDisplay MetaWindow *grab_window; Window grab_xwindow; int grab_button; - int grab_initial_root_x; - int grab_initial_root_y; + int grab_anchor_root_x; + int grab_anchor_root_y; + MetaRectangle grab_anchor_window_pos; int grab_latest_motion_x; int grab_latest_motion_y; gulong grab_mask; diff --git a/src/effects.c b/src/effects.c index 0ed4fae7..dee15296 100644 --- a/src/effects.c +++ b/src/effects.c @@ -420,25 +420,87 @@ meta_effects_begin_wireframe (MetaScreen *screen, meta_effects_update_wireframe (screen, NULL, rect); } +static void +draw_xor_rect (MetaScreen *screen, + const MetaRectangle *rect) +{ + /* The lines in the center can't overlap the rectangle or each + * other, or the XOR gets reversed. So we have to draw things + * a bit oddly. + */ + XSegment segments[8]; + int i; + +#define LINE_WIDTH META_WIREFRAME_XOR_LINE_WIDTH + + XDrawRectangle (screen->display->xdisplay, + screen->xroot, + screen->root_xor_gc, + rect->x, rect->y, + rect->width, rect->height); + + /* Don't put lines inside small rectangles where they won't fit */ + if (rect->width < (LINE_WIDTH * 4) || + rect->height < (LINE_WIDTH * 4)) + return; + + /* Two vertical lines at 1/3 and 2/3 */ + segments[0].x1 = rect->x + rect->width / 3; + segments[0].y1 = rect->y + LINE_WIDTH / 2 + LINE_WIDTH % 2; + segments[0].x2 = segments[0].x1; + segments[0].y2 = rect->y + rect->height - LINE_WIDTH / 2; + + segments[1] = segments[0]; + segments[1].x1 = rect->x + (rect->width / 3) * 2; + segments[1].x2 = segments[1].x1; + + /* Now make two horizontal lines at 1/3 and 2/3, but not + * overlapping the verticals + */ + + segments[2].x1 = rect->x + LINE_WIDTH / 2 + LINE_WIDTH % 2; + segments[2].x2 = segments[0].x1 - LINE_WIDTH / 2; + segments[2].y1 = rect->y + rect->height / 3; + segments[2].y2 = segments[2].y1; + + segments[3] = segments[2]; + segments[3].x1 = segments[2].x2 + LINE_WIDTH; + segments[3].x2 = segments[1].x1 - LINE_WIDTH / 2; + + segments[4] = segments[3]; + segments[4].x1 = segments[3].x2 + LINE_WIDTH; + segments[4].x2 = rect->x + rect->width - LINE_WIDTH / 2; + + /* Second horizontal line is just like the first, but + * shifted down + */ + i = 5; + while (i < 8) + { + segments[i] = segments[i - 3]; + segments[i].y1 = rect->y + (rect->height / 3) * 2; + segments[i].y2 = segments[i].y1; + ++i; + } + + XDrawSegments (screen->display->xdisplay, + screen->xroot, + screen->root_xor_gc, + segments, + G_N_ELEMENTS (segments)); +} + void meta_effects_update_wireframe (MetaScreen *screen, const MetaRectangle *old_rect, const MetaRectangle *new_rect) { if (old_rect) - XDrawRectangle (screen->display->xdisplay, - screen->xroot, - screen->root_xor_gc, - old_rect->x, old_rect->y, - old_rect->width, old_rect->height); - + draw_xor_rect (screen, old_rect); + if (new_rect) - XDrawRectangle (screen->display->xdisplay, - screen->xroot, - screen->root_xor_gc, - new_rect->x, new_rect->y, - new_rect->width, new_rect->height); - + draw_xor_rect (screen, new_rect); + XFlush (screen->display->xdisplay); } diff --git a/src/keybindings.c b/src/keybindings.c index 43f07141..b59d9878 100644 --- a/src/keybindings.c +++ b/src/keybindings.c @@ -1703,11 +1703,13 @@ process_keyboard_move_grab (MetaDisplay *display, } /* FIXME in wireframe mode the edge snapping is all fucked up - * since the edge-find routines use window->rect - */ - + * since the edge-find routines use window->rect. Window + * constraints are also broken with wireframe. + */ smart_snap = (event->xkey.state & ShiftMask) != 0; - + if (display->grab_wireframe_active) + smart_snap = FALSE; + #define SMALL_INCREMENT 1 #define NORMAL_INCREMENT 10 @@ -1740,11 +1742,14 @@ process_keyboard_move_grab (MetaDisplay *display, case XK_KP_Prior: case XK_Up: case XK_KP_Up: - edge = meta_window_find_next_horizontal_edge (window, FALSE); y -= incr; - - if (smart_snap || ((edge > y) && ABS (edge - y) < incr)) - y = edge; + + if (!display->grab_wireframe_active) + { + edge = meta_window_find_next_horizontal_edge (window, FALSE); + if (smart_snap || ((edge > y) && ABS (edge - y) < incr)) + y = edge; + } handled = TRUE; break; @@ -1752,11 +1757,14 @@ process_keyboard_move_grab (MetaDisplay *display, case XK_KP_Next: case XK_Down: case XK_KP_Down: - edge = meta_window_find_next_horizontal_edge (window, TRUE); y += incr; - if (smart_snap || ((edge < y) && ABS (edge - y) < incr)) - y = edge; + if (!display->grab_wireframe_active) + { + edge = meta_window_find_next_horizontal_edge (window, TRUE); + if (smart_snap || ((edge < y) && ABS (edge - y) < incr)) + y = edge; + } handled = TRUE; break; @@ -1768,11 +1776,14 @@ process_keyboard_move_grab (MetaDisplay *display, case XK_KP_End: case XK_Left: case XK_KP_Left: - edge = meta_window_find_next_vertical_edge (window, FALSE); x -= incr; - - if (smart_snap || ((edge > x) && ABS (edge - x) < incr)) - x = edge; + + if (!display->grab_wireframe_active) + { + edge = meta_window_find_next_vertical_edge (window, FALSE); + if (smart_snap || ((edge > x) && ABS (edge - x) < incr)) + x = edge; + } handled = TRUE; break; @@ -1780,35 +1791,43 @@ process_keyboard_move_grab (MetaDisplay *display, case XK_KP_Next: case XK_Right: case XK_KP_Right: - edge = meta_window_find_next_vertical_edge (window, TRUE); x += incr; - if (smart_snap || ((edge < x) && ABS (edge - x) < incr)) - x = edge; + + if (!display->grab_wireframe_active) + { + edge = meta_window_find_next_vertical_edge (window, TRUE); + if (smart_snap || ((edge < x) && ABS (edge - x) < incr)) + x = edge; + } + handled = TRUE; break; } if (handled) { + meta_topic (META_DEBUG_KEYBINDINGS, + "Computed new window location %d,%d due to keypress\n", + x, y); if (display->grab_wireframe_active) { MetaRectangle new_xor; - new_xor = window->display->grab_wireframe_rect; + new_xor = display->grab_wireframe_rect; new_xor.x = x; new_xor.y = y; - + meta_effects_update_wireframe (window->screen, - &window->display->grab_wireframe_rect, + &display->grab_wireframe_rect, &new_xor); - window->display->grab_wireframe_rect = new_xor; + display->grab_wireframe_rect = new_xor; } else { meta_window_move (window, TRUE, x, y); } - meta_window_warp_pointer (window, display->grab_op); + meta_window_update_keyboard_move (window); } return handled; @@ -1959,7 +1978,7 @@ process_keyboard_resize_grab (MetaDisplay *display, if (handled) { - meta_window_update_resize_grab_op (window, TRUE); + meta_window_update_keyboard_resize (window, TRUE); return TRUE; } @@ -1982,11 +2001,13 @@ process_keyboard_resize_grab (MetaDisplay *display, gravity = meta_resize_gravity_from_grab_op (display->grab_op); /* FIXME in wireframe mode the edge snapping is all fucked up - * since the edge-find routines use window->rect - */ - + * since the edge-find routines use window->rect. Window + * constraints are also broken with wireframe. + */ smart_snap = (event->xkey.state & ShiftMask) != 0; - + if (display->grab_wireframe_active) + smart_snap = FALSE; + #define SMALL_INCREMENT 1 #define NORMAL_INCREMENT 10 @@ -2204,6 +2225,10 @@ process_keyboard_resize_grab (MetaDisplay *display, if (handled) { + meta_topic (META_DEBUG_KEYBINDINGS, + "Computed new window location %d,%d %dx%d due to keypress\n", + x, y, width, height); + if (display->grab_wireframe_active) { MetaRectangle new_xor; @@ -2225,7 +2250,7 @@ process_keyboard_resize_grab (MetaDisplay *display, { meta_window_move_resize (window, TRUE, x, y, width, height); } - meta_window_update_resize_grab_op (window, FALSE); + meta_window_update_keyboard_resize (window, FALSE); } return handled; diff --git a/src/screen.c b/src/screen.c index 45b0e249..4773ec10 100644 --- a/src/screen.c +++ b/src/screen.c @@ -545,7 +545,7 @@ meta_screen_new (MetaDisplay *display, gc_values.subwindow_mode = IncludeInferiors; gc_values.function = GXinvert; - gc_values.line_width = 2; + gc_values.line_width = META_WIREFRAME_XOR_LINE_WIDTH; screen->root_xor_gc = XCreateGC (screen->display->xdisplay, screen->xroot, diff --git a/src/screen.h b/src/screen.h index 042df8b3..32e110b3 100644 --- a/src/screen.h +++ b/src/screen.h @@ -56,6 +56,8 @@ typedef enum META_SCREEN_RIGHT } MetaScreenDirection; +#define META_WIREFRAME_XOR_LINE_WIDTH 5 + struct _MetaScreen { MetaDisplay *display; diff --git a/src/window.c b/src/window.c index 900f0b81..5b537491 100644 --- a/src/window.c +++ b/src/window.c @@ -1871,7 +1871,7 @@ meta_window_unmaximize (MetaWindow *window) if (meta_grab_op_is_moving (window->display->grab_op) && window->display->grab_window == window) { - window->display->grab_initial_window_pos = window->saved_rect; + window->display->grab_anchor_window_pos = window->saved_rect; } meta_window_move_resize (window, @@ -5615,12 +5615,20 @@ update_move (MetaWindow *window, window->display->grab_latest_motion_x = x; window->display->grab_latest_motion_y = y; - dx = x - window->display->grab_initial_root_x; - dy = y - window->display->grab_initial_root_y; + dx = x - window->display->grab_anchor_root_x; + dy = y - window->display->grab_anchor_root_y; - new_x = window->display->grab_initial_window_pos.x + dx; - new_y = window->display->grab_initial_window_pos.y + dy; + new_x = window->display->grab_anchor_window_pos.x + dx; + new_y = window->display->grab_anchor_window_pos.y + dy; + meta_verbose ("x,y = %d,%d anchor ptr %d,%d anchor pos %d,%d dx,dy %d,%d\n", + x, y, + window->display->grab_anchor_root_x, + window->display->grab_anchor_root_y, + window->display->grab_anchor_window_pos.x, + window->display->grab_anchor_window_pos.y, + dx, dy); + /* shake loose (unmaximize) maximized window if dragged beyond the threshold * in the Y direction. You can't pull a window loose via X motion. */ @@ -5700,13 +5708,6 @@ update_move (MetaWindow *window, if (window->maximized) return; - 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); - } - if (window->display->grab_wireframe_active) { /* FIXME Horribly broken, does not honor position @@ -5724,6 +5725,14 @@ update_move (MetaWindow *window, } 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); } } @@ -5741,15 +5750,15 @@ update_resize (MetaWindow *window, window->display->grab_latest_motion_x = x; window->display->grab_latest_motion_y = y; - dx = x - window->display->grab_initial_root_x; - dy = y - window->display->grab_initial_root_y; + dx = x - window->display->grab_anchor_root_x; + dy = y - window->display->grab_anchor_root_y; - new_w = window->display->grab_initial_window_pos.width; - new_h = window->display->grab_initial_window_pos.height; + new_w = window->display->grab_anchor_window_pos.width; + new_h = window->display->grab_anchor_window_pos.height; /* FIXME this is only used in wireframe mode */ - new_x = window->display->grab_initial_window_pos.x; - new_y = window->display->grab_initial_window_pos.y; + new_x = window->display->grab_anchor_window_pos.x; + new_y = window->display->grab_anchor_window_pos.y; switch (window->display->grab_op) { @@ -6446,53 +6455,70 @@ meta_window_is_ancestor_of_transient (MetaWindow *window, return d.found; } +/* Warp pointer to location appropriate for grab, + * return root coordinates where pointer ended up. + */ static gboolean -warp_pointer (MetaWindow *window, - MetaGrabOp grab_op, - int *x, - int *y) +warp_grab_pointer (MetaWindow *window, + MetaGrabOp grab_op, + int *x, + int *y) { + MetaRectangle rect; + + /* We may not have done begin_grab_op yet, i.e. may not be in a grab + */ + + if (window == window->display->grab_window && + window->display->grab_wireframe_active) + rect = window->display->grab_wireframe_rect; + else + { + rect = window->rect; + meta_window_get_position (window, &rect.x, &rect.y); + } + switch (grab_op) { case META_GRAB_OP_KEYBOARD_MOVING: case META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN: - *x = window->rect.width / 2; - *y = window->rect.height / 2; + *x = rect.width / 2; + *y = rect.height / 2; break; case META_GRAB_OP_KEYBOARD_RESIZING_S: - *x = window->rect.width / 2; - *y = window->rect.height; + *x = rect.width / 2; + *y = rect.height; break; case META_GRAB_OP_KEYBOARD_RESIZING_N: - *x = window->rect.width / 2; + *x = rect.width / 2; *y = 0; break; case META_GRAB_OP_KEYBOARD_RESIZING_W: *x = 0; - *y = window->rect.height / 2; + *y = rect.height / 2; break; case META_GRAB_OP_KEYBOARD_RESIZING_E: - *x = window->rect.width; - *y = window->rect.height / 2; + *x = rect.width; + *y = rect.height / 2; break; case META_GRAB_OP_KEYBOARD_RESIZING_SE: - *x = window->rect.width; - *y = window->rect.height; + *x = rect.width; + *y = rect.height; break; case META_GRAB_OP_KEYBOARD_RESIZING_NE: - *x = window->rect.width; + *x = rect.width; *y = 0; break; case META_GRAB_OP_KEYBOARD_RESIZING_SW: *x = 0; - *y = window->rect.height; + *y = rect.height; break; case META_GRAB_OP_KEYBOARD_RESIZING_NW: @@ -6504,45 +6530,42 @@ warp_pointer (MetaWindow *window, return FALSE; } + *x += rect.x; + *y += rect.y; + meta_error_trap_push_with_return (window->display); + + meta_topic (META_DEBUG_WINDOW_OPS, + "Warping pointer to %d,%d with window at %d,%d\n", + *x, *y, rect.x, rect.y); XWarpPointer (window->display->xdisplay, None, - window->xwindow, + window->screen->xroot, 0, 0, 0, 0, - *x, - *y); + *x, *y); if (meta_error_trap_pop_with_return (window->display, FALSE) != Success) { - meta_verbose ("Failed to warp pointer for window %s\n", window->desc); + meta_verbose ("Failed to warp pointer for window %s\n", + window->desc); return FALSE; } - + return TRUE; } -gboolean -meta_window_warp_pointer (MetaWindow *window, - MetaGrabOp grab_op) -{ - int x, y; - - return warp_pointer (window, grab_op, &x, &y); -} - void meta_window_begin_grab_op (MetaWindow *window, MetaGrabOp op, Time timestamp) { - int x, y, x_offset, y_offset; - - meta_window_get_position (window, &x, &y); + int x, y; meta_window_raise (window); - warp_pointer (window, op, &x_offset, &y_offset); + warp_grab_pointer (window, + op, &x, &y); meta_display_begin_grab_op (window->display, window->screen, @@ -6550,31 +6573,36 @@ meta_window_begin_grab_op (MetaWindow *window, op, FALSE, 0, 0, timestamp, - x + x_offset, - y + y_offset); + x, y); } void -meta_window_update_resize_grab_op (MetaWindow *window, - gboolean update_cursor) +meta_window_update_keyboard_resize (MetaWindow *window, + gboolean update_cursor) { - int x, y, x_offset, y_offset; - - meta_window_get_position (window, &x, &y); + int x, y; - warp_pointer (window, window->display->grab_op, &x_offset, &y_offset); + warp_grab_pointer (window, + window->display->grab_op, + &x, &y); - /* As we warped the pointer, we have to reset the apparent - * initial window state, since if the mouse moves we want - * to use those events to do the right thing. - */ - if (window->display->grab_window == window) - { - window->display->grab_initial_root_x = x + x_offset; - window->display->grab_initial_root_y = y + y_offset; - - window->display->grab_initial_window_pos = window->rect; - } + { + /* As we warped the pointer, we have to reset the anchor state, + * since if the mouse moves we want to use those events to do the + * right thing. + */ + int dx, dy; + + dx = x - window->display->grab_anchor_root_x; + dy = y - window->display->grab_anchor_root_y; + + window->display->grab_anchor_root_x += dx; + window->display->grab_anchor_root_y += dy; + 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 (update_cursor) { @@ -6588,6 +6616,16 @@ meta_window_update_resize_grab_op (MetaWindow *window, } void +meta_window_update_keyboard_move (MetaWindow *window) +{ + int x, y; + + warp_grab_pointer (window, + window->display->grab_op, + &x, &y); +} + +void meta_window_update_layer (MetaWindow *window) { MetaGroup *group; diff --git a/src/window.h b/src/window.h index 3b36872e..91f3711c 100644 --- a/src/window.h +++ b/src/window.h @@ -469,15 +469,13 @@ void meta_window_foreach_ancestor (MetaWindow *window, MetaWindowForeachFunc func, void *data); -gboolean meta_window_warp_pointer (MetaWindow *window, - MetaGrabOp grab_op); - void meta_window_begin_grab_op (MetaWindow *window, MetaGrabOp op, Time timestamp); -void meta_window_update_resize_grab_op (MetaWindow *window, - gboolean update_cursor); +void meta_window_update_keyboard_resize (MetaWindow *window, + gboolean update_cursor); +void meta_window_update_keyboard_move (MetaWindow *window); void meta_window_update_layer (MetaWindow *window); |