From d826e620a9719527c535aa6c5e5d11ebeaa0afd5 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Wed, 3 Jul 2002 02:32:40 +0000 Subject: [PATCH] use new macros to get whether we allow move/resize correct 2002-07-02 Havoc Pennington * src/window.c (meta_window_show_menu): use new macros to get whether we allow move/resize correct * src/frame.c (meta_frame_get_flags): use new macros to get whether we can move/resize correct, considering maximized/fullscreen for the move case. * src/window.h (META_WINDOW_ALLOWS_RESIZE, META_WINDOW_ALLOWS_MOVE): new macros * src/keybindings.c (process_keyboard_resize_grab): finish the right/left resize, patch from Jayaraj #78179. Has the same old move/resize bug, if it hits a constraint it starts to break because we move without resizing. --- ChangeLog | 18 +++++++++++ src/frame.c | 19 ++++-------- src/keybindings.c | 77 +++++++++++++++++++++++++++++++++++++++++++++-- src/window.c | 4 +-- src/window.h | 8 +++++ 5 files changed, 109 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index b19561d1e..3cf804f57 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2002-07-02 Havoc Pennington + + * src/window.c (meta_window_show_menu): use new macros to get + whether we allow move/resize correct + + * src/frame.c (meta_frame_get_flags): use new macros to get + whether we can move/resize correct, considering + maximized/fullscreen for the move case. + + * src/window.h (META_WINDOW_ALLOWS_RESIZE, + META_WINDOW_ALLOWS_MOVE): new macros + + * src/keybindings.c (process_keyboard_resize_grab): finish the + right/left resize, patch from Jayaraj #78179. + + Has the same old move/resize bug, if it hits a constraint it + starts to break because we move without resizing. + 2002-07-02 Mark McLoughlin * src/keybindings.c: diff --git a/src/frame.c b/src/frame.c index 92628805f..06e14f1fb 100644 --- a/src/frame.c +++ b/src/frame.c @@ -229,21 +229,14 @@ meta_frame_get_flags (MetaFrame *frame) flags |= META_FRAME_ALLOWS_SHADE; } - if (frame->window->has_move_func) + if (META_WINDOW_ALLOWS_MOVE (frame->window)) flags |= META_FRAME_ALLOWS_MOVE; - - if (frame->window->has_resize_func && - !frame->window->maximized && - !frame->window->shaded) - { - if (frame->window->size_hints.min_width < - frame->window->size_hints.max_width) - flags |= META_FRAME_ALLOWS_HORIZONTAL_RESIZE; - if (frame->window->size_hints.min_height < - frame->window->size_hints.max_height) - flags |= META_FRAME_ALLOWS_VERTICAL_RESIZE; - } + if (META_WINDOW_ALLOWS_HORIZONTAL_RESIZE (frame->window)) + flags |= META_FRAME_ALLOWS_HORIZONTAL_RESIZE; + + if (META_WINDOW_ALLOWS_VERTICAL_RESIZE (frame->window)) + flags |= META_FRAME_ALLOWS_VERTICAL_RESIZE; if (frame->window->has_focus) flags |= META_FRAME_HAS_FOCUS; diff --git a/src/keybindings.c b/src/keybindings.c index 957e34caa..b343b4543 100644 --- a/src/keybindings.c +++ b/src/keybindings.c @@ -1597,11 +1597,84 @@ process_keyboard_resize_grab (MetaDisplay *display, case XK_Left: case XK_KP_Left: - /* FIXME */ + switch (gravity) + { + case EastGravity: + case SouthEastGravity: + case NorthEastGravity: + /* Move left edge left */ + edge = meta_window_find_next_vertical_edge (window, TRUE); + x -= width_inc; + + if (smart_snap || ((edge > x) && ABS (edge - x) < width_inc)) + x = edge; + + width += (orig_x - x); + break; + + case WestGravity: + case SouthWestGravity: + case NorthWestGravity: + /* Move right edge left */ + edge = meta_window_find_next_vertical_edge (window, FALSE); + width -= width_inc; + + if (smart_snap || ((edge > (x+width)) && + ABS (edge - (x+width)) < width_inc)) + width = edge - x; + + handled = TRUE; + break; + + case NorthGravity: + case SouthGravity: + case CenterGravity: + g_assert_not_reached (); + break; + } + + handled = TRUE; break; + case XK_Right: case XK_KP_Right: - /* FIXME */ + switch (gravity) + { + case EastGravity: + case SouthEastGravity: + case NorthEastGravity: + /* Move left edge right */ + edge = meta_window_find_next_vertical_edge (window, FALSE); + x += width_inc; + + if (smart_snap || ((edge < x) && ABS (edge - x) < width_inc)) + x = edge; + + width -= (x - orig_x); + break; + + case WestGravity: + case SouthWestGravity: + case NorthWestGravity: + /* Move right edge right */ + edge = meta_window_find_next_vertical_edge (window, TRUE); + width += width_inc; + + if (smart_snap || ((edge > (x+width)) && + ABS (edge - (x+width)) < width_inc)) + width = edge - x; + + handled = TRUE; + break; + + case NorthGravity: + case SouthGravity: + case CenterGravity: + g_assert_not_reached (); + break; + } + + handled = TRUE; break; default: diff --git a/src/window.c b/src/window.c index 1d8998ff9..9eccea192 100644 --- a/src/window.c +++ b/src/window.c @@ -5499,10 +5499,10 @@ meta_window_show_menu (MetaWindow *window, if (!window->has_shade_func) insensitive |= META_MENU_OP_SHADE | META_MENU_OP_UNSHADE; - if (!window->has_move_func) + if (!META_WINDOW_ALLOWS_MOVE (window)) insensitive |= META_MENU_OP_MOVE; - if (!window->has_resize_func) + if (!META_WINDOW_ALLOWS_RESIZE (window)) insensitive |= META_MENU_OP_RESIZE; if (window->always_sticky) diff --git a/src/window.h b/src/window.h index 479467794..a3e8df52d 100644 --- a/src/window.h +++ b/src/window.h @@ -252,6 +252,14 @@ struct _MetaWindow int dialog_pipe; }; +#define META_WINDOW_ALLOWS_MOVE(w) ((w)->has_move_func && !(w)->maximized && !(w)->fullscreen) +#define META_WINDOW_ALLOWS_RESIZE_EXCEPT_HINTS(w) ((w)->has_resize_func && !(w)->maximized && !(w)->fullscreen && !(w)->shaded) +#define META_WINDOW_ALLOWS_RESIZE(w) (META_WINDOW_ALLOWS_RESIZE_EXCEPT_HINTS (w) && \ + (((w)->size_hints.min_width < (w)->size_hints.max_width) || \ + ((w)->size_hints.min_height < (w)->size_hints.max_height))) +#define META_WINDOW_ALLOWS_HORIZONTAL_RESIZE(w) (META_WINDOW_ALLOWS_RESIZE_EXCEPT_HINTS (w) && (w)->size_hints.min_width < (w)->size_hints.max_width) +#define META_WINDOW_ALLOWS_VERTICAL_RESIZE(w) (META_WINDOW_ALLOWS_RESIZE_EXCEPT_HINTS (w) && (w)->size_hints.min_height < (w)->size_hints.max_height) + MetaWindow* meta_window_new (MetaDisplay *display, Window xwindow, gboolean must_be_viewable);