Add ability to vertically and horizontally maximise using the mouse, by

2008-03-03  Cosimo Cecchi  <anarki@lilik.it>

	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
This commit is contained in:
Cosimo Cecchi 2008-03-03 01:58:54 +00:00 committed by Thomas James Alexander Thurman
parent ac10c309ea
commit a8c3d1614f
8 changed files with 123 additions and 12 deletions

View File

@ -1,3 +1,24 @@
2008-03-03 Cosimo Cecchi <anarki@lilik.it>
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 <sejerpz@tin.it> 2008-02-29 Andrea Del Signore <sejerpz@tin.it>
Add support for "spacer" as a button type which adds some Add support for "spacer" as a button type which adds some

View File

@ -328,6 +328,40 @@ meta_core_maximize (Display *xdisplay,
META_MAXIMIZE_HORIZONTAL | META_MAXIMIZE_VERTICAL); 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 void
meta_core_toggle_maximize (Display *xdisplay, meta_core_toggle_maximize (Display *xdisplay,
Window frame_xwindow) Window frame_xwindow)

View File

@ -200,6 +200,10 @@ static GConfEnumStringPair symtab_titlebar_action[] =
{ {
{ META_ACTION_TITLEBAR_TOGGLE_SHADE, "toggle_shade" }, { META_ACTION_TITLEBAR_TOGGLE_SHADE, "toggle_shade" },
{ META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE, "toggle_maximize" }, { 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_MINIMIZE, "minimize" },
{ META_ACTION_TITLEBAR_NONE, "none" }, { META_ACTION_TITLEBAR_NONE, "none" },
{ META_ACTION_TITLEBAR_LOWER, "lower" }, { META_ACTION_TITLEBAR_LOWER, "lower" },

View File

@ -362,6 +362,8 @@ struct _MetaWindow
*/ */
#define META_WINDOW_MAXIMIZED(w) ((w)->maximized_horizontally && \ #define META_WINDOW_MAXIMIZED(w) ((w)->maximized_horizontally && \
(w)->maximized_vertically) (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_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_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) && \ #define META_WINDOW_ALLOWS_RESIZE(w) (META_WINDOW_ALLOWS_RESIZE_EXCEPT_HINTS (w) && \

View File

@ -174,6 +174,8 @@ typedef enum
{ {
META_ACTION_TITLEBAR_TOGGLE_SHADE, META_ACTION_TITLEBAR_TOGGLE_SHADE,
META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE, META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE,
META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE_HORIZONTALLY,
META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE_VERTICALLY,
META_ACTION_TITLEBAR_MINIMIZE, META_ACTION_TITLEBAR_MINIMIZE,
META_ACTION_TITLEBAR_NONE, META_ACTION_TITLEBAR_NONE,
META_ACTION_TITLEBAR_LOWER, META_ACTION_TITLEBAR_LOWER,

View File

@ -120,6 +120,10 @@ void meta_core_minimize (Display *xdisplay,
Window frame_xwindow); Window frame_xwindow);
void meta_core_toggle_maximize (Display *xdisplay, void meta_core_toggle_maximize (Display *xdisplay,
Window frame_xwindow); 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, void meta_core_unmaximize (Display *xdisplay,
Window frame_xwindow); Window frame_xwindow);
void meta_core_maximize (Display *xdisplay, void meta_core_maximize (Display *xdisplay,

View File

@ -114,10 +114,16 @@
<short>Action on title bar double-click</short> <short>Action on title bar double-click</short>
<long> <long>
This option determines the effects of double-clicking on the This option determines the effects of double-clicking on the
title bar. Current valid options are 'toggle_shade', which will title bar. Current valid options are
shade/unshade the window, 'toggle_maximize' which will 'toggle_shade', which will shade/unshade the window,
maximize/unmaximize the window, 'minimize' which will minimize 'toggle_maximize' which will maximize/unmaximize the window,
the window, and 'none' which will not do anything. '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.
</long> </long>
</locale> </locale>
</schema> </schema>
@ -132,10 +138,16 @@
<short>Action on title bar middle-click</short> <short>Action on title bar middle-click</short>
<long> <long>
This option determines the effects of middle-clicking on the This option determines the effects of middle-clicking on the
title bar. Current valid options are 'toggle_shade', which will title bar. Current valid options are
shade/unshade the window, 'toggle_maximize' which will 'toggle_shade', which will shade/unshade the window,
maximize/unmaximize the window, 'minimize' which will minimize 'toggle_maximize' which will maximize/unmaximize the window,
the window, and 'none' which will not do anything. '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.
</long> </long>
</locale> </locale>
</schema> </schema>
@ -150,10 +162,16 @@
<short>Action on title bar right-click</short> <short>Action on title bar right-click</short>
<long> <long>
This option determines the effects of right-clicking on the This option determines the effects of right-clicking on the
title bar. Current valid options are 'toggle_shade', which will title bar. Current valid options are
shade/unshade the window, 'toggle_maximize' which will 'toggle_shade', which will shade/unshade the window,
maximize/unmaximize the window, 'minimize' which will minimize 'toggle_maximize' which will maximize/unmaximize the window,
the window, and 'none' which will not do anything. '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.
</long> </long>
</locale> </locale>
</schema> </schema>

View File

@ -1249,6 +1249,32 @@ meta_frame_titlebar_event (MetaUIFrame *frame,
} }
break; 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: case META_ACTION_TITLEBAR_MINIMIZE:
{ {
meta_core_get (gdk_display, frame->xwindow, meta_core_get (gdk_display, frame->xwindow,