From a8c3d1614f91d02271c9dc9f03309ee27405bd0a Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Mon, 3 Mar 2008 01:58:54 +0000 Subject: [PATCH] Add ability to vertically and horizontally maximise using the mouse, by 2008-03-03 Cosimo Cecchi Add ability to vertically and horizontally maximise using the mouse, by clicking the titlebar in various ways. A very similar patch was received from Jason Ribero. Thanks also go to Tony Houghton and Carlo Wood, who both submitted patches which solved this differently. Closes #358674. * src/include/common.h (MetaActionTitlebar): new values for the new actions * src/core/core.c (meta_core_maximize_{vertic|horizont}ally): new functions. * src/ui/frames.c (meta_frame_titlebar_event): handle the new action values * src/core/window.h: new macros (for regularity, not really necessary) * src/core/prefs.c (symtab_titlebar_action): new string representations of the action values * src/metacity.schemas.in: documentation svn path=/trunk/; revision=3619 --- ChangeLog | 21 +++++++++++++++++++++ src/core/core.c | 34 +++++++++++++++++++++++++++++++++ src/core/prefs.c | 4 ++++ src/core/window.h | 2 ++ src/include/common.h | 2 ++ src/include/core.h | 4 ++++ src/metacity.schemas.in | 42 +++++++++++++++++++++++++++++------------ src/ui/frames.c | 26 +++++++++++++++++++++++++ 8 files changed, 123 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8eb37151b..3ffa4e27b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2008-03-03 Cosimo Cecchi + + Add ability to vertically and horizontally maximise + using the mouse, by clicking the titlebar in various + ways. A very similar patch was received from Jason Ribero. + Thanks also go to Tony Houghton and Carlo Wood, who + both submitted patches which solved this differently. + Closes #358674. + + * src/include/common.h (MetaActionTitlebar): new values + for the new actions + * src/core/core.c (meta_core_maximize_{vertic|horizont}ally): + new functions. + * src/ui/frames.c (meta_frame_titlebar_event): handle the + new action values + * src/core/window.h: new macros (for regularity, not really + necessary) + * src/core/prefs.c (symtab_titlebar_action): new string + representations of the action values + * src/metacity.schemas.in: documentation + 2008-02-29 Andrea Del Signore Add support for "spacer" as a button type which adds some diff --git a/src/core/core.c b/src/core/core.c index c9cd4e483..f8415f3d6 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -328,6 +328,40 @@ meta_core_maximize (Display *xdisplay, META_MAXIMIZE_HORIZONTAL | META_MAXIMIZE_VERTICAL); } +void +meta_core_toggle_maximize_vertically (Display *xdisplay, + Window frame_xwindow) +{ + MetaWindow *window = get_window (xdisplay, frame_xwindow); + + if (meta_prefs_get_raise_on_click ()) + meta_window_raise (window); + + if (META_WINDOW_MAXIMIZED_VERTICALLY (window)) + meta_window_unmaximize (window, + META_MAXIMIZE_VERTICAL); + else + meta_window_maximize (window, + META_MAXIMIZE_VERTICAL); +} + +void +meta_core_toggle_maximize_horizontally (Display *xdisplay, + Window frame_xwindow) +{ + MetaWindow *window = get_window (xdisplay, frame_xwindow); + + if (meta_prefs_get_raise_on_click ()) + meta_window_raise (window); + + if (META_WINDOW_MAXIMIZED_HORIZONTALLY (window)) + meta_window_unmaximize (window, + META_MAXIMIZE_HORIZONTAL); + else + meta_window_maximize (window, + META_MAXIMIZE_HORIZONTAL); +} + void meta_core_toggle_maximize (Display *xdisplay, Window frame_xwindow) diff --git a/src/core/prefs.c b/src/core/prefs.c index 5f5a3e4c8..eb7fcf591 100644 --- a/src/core/prefs.c +++ b/src/core/prefs.c @@ -200,6 +200,10 @@ static GConfEnumStringPair symtab_titlebar_action[] = { { META_ACTION_TITLEBAR_TOGGLE_SHADE, "toggle_shade" }, { META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE, "toggle_maximize" }, + { META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE_HORIZONTALLY, + "toggle_maximize_horizontally" }, + { META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE_VERTICALLY, + "toggle_maximize_vertically" }, { META_ACTION_TITLEBAR_MINIMIZE, "minimize" }, { META_ACTION_TITLEBAR_NONE, "none" }, { META_ACTION_TITLEBAR_LOWER, "lower" }, diff --git a/src/core/window.h b/src/core/window.h index 6706fe4c5..85f35c815 100644 --- a/src/core/window.h +++ b/src/core/window.h @@ -362,6 +362,8 @@ struct _MetaWindow */ #define META_WINDOW_MAXIMIZED(w) ((w)->maximized_horizontally && \ (w)->maximized_vertically) +#define META_WINDOW_MAXIMIZED_VERTICALLY(w) ((w)->maximized_vertically) +#define META_WINDOW_MAXIMIZED_HORIZONTALLY(w) ((w)->maximized_horizontally) #define META_WINDOW_ALLOWS_MOVE(w) ((w)->has_move_func && !(w)->fullscreen) #define META_WINDOW_ALLOWS_RESIZE_EXCEPT_HINTS(w) ((w)->has_resize_func && !META_WINDOW_MAXIMIZED (w) && !(w)->fullscreen && !(w)->shaded) #define META_WINDOW_ALLOWS_RESIZE(w) (META_WINDOW_ALLOWS_RESIZE_EXCEPT_HINTS (w) && \ diff --git a/src/include/common.h b/src/include/common.h index 41ec797f1..cdd814dbf 100644 --- a/src/include/common.h +++ b/src/include/common.h @@ -174,6 +174,8 @@ typedef enum { META_ACTION_TITLEBAR_TOGGLE_SHADE, META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE, + META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE_HORIZONTALLY, + META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE_VERTICALLY, META_ACTION_TITLEBAR_MINIMIZE, META_ACTION_TITLEBAR_NONE, META_ACTION_TITLEBAR_LOWER, diff --git a/src/include/core.h b/src/include/core.h index c374429f8..0c518e743 100644 --- a/src/include/core.h +++ b/src/include/core.h @@ -120,6 +120,10 @@ void meta_core_minimize (Display *xdisplay, Window frame_xwindow); void meta_core_toggle_maximize (Display *xdisplay, Window frame_xwindow); +void meta_core_toggle_maximize_horizontally (Display *xdisplay, + Window frame_xwindow); +void meta_core_toggle_maximize_vertically (Display *xdisplay, + Window frame_xwindow); void meta_core_unmaximize (Display *xdisplay, Window frame_xwindow); void meta_core_maximize (Display *xdisplay, diff --git a/src/metacity.schemas.in b/src/metacity.schemas.in index 4c2416d74..5e4f1dc38 100644 --- a/src/metacity.schemas.in +++ b/src/metacity.schemas.in @@ -114,10 +114,16 @@ Action on title bar double-click This option determines the effects of double-clicking on the - title bar. Current valid options are 'toggle_shade', which will - shade/unshade the window, 'toggle_maximize' which will - maximize/unmaximize the window, 'minimize' which will minimize - the window, and 'none' which will not do anything. + title bar. Current valid options are + 'toggle_shade', which will shade/unshade the window, + 'toggle_maximize' which will maximize/unmaximize the window, + 'toggle_maximize_horizontally' and 'toggle_maximize_vertically' + which will maximize/unmaximize the window in that direction only, + 'minimize' which will minimize the window, + 'shade' which will roll the window up, + 'menu' which will display the window menu, + 'lower' which will put the window behind all the others, + and 'none' which will not do anything. @@ -132,10 +138,16 @@ Action on title bar middle-click This option determines the effects of middle-clicking on the - title bar. Current valid options are 'toggle_shade', which will - shade/unshade the window, 'toggle_maximize' which will - maximize/unmaximize the window, 'minimize' which will minimize - the window, and 'none' which will not do anything. + title bar. Current valid options are + 'toggle_shade', which will shade/unshade the window, + 'toggle_maximize' which will maximize/unmaximize the window, + 'toggle_maximize_horizontally' and 'toggle_maximize_vertically' + which will maximize/unmaximize the window in that direction only, + 'minimize' which will minimize the window, + 'shade' which will roll the window up, + 'menu' which will display the window menu, + 'lower' which will put the window behind all the others, + and 'none' which will not do anything. @@ -150,10 +162,16 @@ Action on title bar right-click This option determines the effects of right-clicking on the - title bar. Current valid options are 'toggle_shade', which will - shade/unshade the window, 'toggle_maximize' which will - maximize/unmaximize the window, 'minimize' which will minimize - the window, and 'none' which will not do anything. + title bar. Current valid options are + 'toggle_shade', which will shade/unshade the window, + 'toggle_maximize' which will maximize/unmaximize the window, + 'toggle_maximize_horizontally' and 'toggle_maximize_vertically' + which will maximize/unmaximize the window in that direction only, + 'minimize' which will minimize the window, + 'shade' which will roll the window up, + 'menu' which will display the window menu, + 'lower' which will put the window behind all the others, + and 'none' which will not do anything. diff --git a/src/ui/frames.c b/src/ui/frames.c index ef7e0099a..093af9216 100644 --- a/src/ui/frames.c +++ b/src/ui/frames.c @@ -1249,6 +1249,32 @@ meta_frame_titlebar_event (MetaUIFrame *frame, } break; + case META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE_HORIZONTALLY: + { + meta_core_get (gdk_display, frame->xwindow, + META_CORE_GET_FRAME_FLAGS, &flags, + META_CORE_GET_END); + + if (flags & META_FRAME_ALLOWS_MAXIMIZE) + { + meta_core_toggle_maximize_horizontally (gdk_display, frame->xwindow); + } + } + break; + + case META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE_VERTICALLY: + { + meta_core_get (gdk_display, frame->xwindow, + META_CORE_GET_FRAME_FLAGS, &flags, + META_CORE_GET_END); + + if (flags & META_FRAME_ALLOWS_MAXIMIZE) + { + meta_core_toggle_maximize_vertically (gdk_display, frame->xwindow); + } + } + break; + case META_ACTION_TITLEBAR_MINIMIZE: { meta_core_get (gdk_display, frame->xwindow,