new functions to resize to fill screen

2002-12-08  Havoc Pennington  <hp@pobox.com>

	* src/window.c (meta_window_fill_vertical)
	(meta_window_fill_horizontal): new functions to resize to
	fill screen

	* src/keybindings.c: add vert, horiz maximize

	* src/prefs.c: had vert, horiz maximize

	* src/metacity.schemas.in: shorten some overlong short
	descriptions that make the keybindings capplet look ugly.
	Add maximize_vertically, maximize_horizontally keys.
This commit is contained in:
Havoc Pennington 2002-12-08 21:09:05 +00:00 committed by Havoc Pennington
parent 8d314aead8
commit e0c8b245ef
7 changed files with 203 additions and 13 deletions

View File

@ -1,3 +1,17 @@
2002-12-08 Havoc Pennington <hp@pobox.com>
* src/window.c (meta_window_fill_vertical)
(meta_window_fill_horizontal): new functions to resize to
fill screen
* src/keybindings.c: add vert, horiz maximize
* src/prefs.c: had vert, horiz maximize
* src/metacity.schemas.in: shorten some overlong short
descriptions that make the keybindings capplet look ugly.
Add maximize_vertically, maximize_horizontally keys.
2002-12-08 Havoc Pennington <hp@pobox.com>
* src/prefs.c (meta_prefs_get_application_based): make this always

View File

@ -154,6 +154,16 @@ static void handle_run_command (MetaDisplay *display,
MetaWindow *window,
XEvent *event,
MetaKeyBinding *binding);
static void handle_maximize_vert (MetaDisplay *display,
MetaScreen *screen,
MetaWindow *window,
XEvent *event,
MetaKeyBinding *binding);
static void handle_maximize_horiz (MetaDisplay *display,
MetaScreen *screen,
MetaWindow *window,
XEvent *event,
MetaKeyBinding *binding);
/* debug */
static void handle_spew_mark (MetaDisplay *display,
@ -329,6 +339,8 @@ static const MetaKeyHandler window_handlers[] = {
{ META_KEYBINDING_RAISE_OR_LOWER, handle_raise_or_lower, NULL},
{ META_KEYBINDING_RAISE, handle_raise, NULL},
{ META_KEYBINDING_LOWER, handle_lower, NULL},
{ META_KEYBINDING_MAXIMIZE_VERTICALLY, handle_maximize_vert, NULL },
{ META_KEYBINDING_MAXIMIZE_HORIZONTALLY, handle_maximize_horiz, NULL },
{ NULL, NULL, NULL }
};
@ -2239,6 +2251,35 @@ handle_run_command (MetaDisplay *display,
}
}
static void
handle_maximize_vert (MetaDisplay *display,
MetaScreen *screen,
MetaWindow *window,
XEvent *event,
MetaKeyBinding *binding)
{
if (window)
{
if (window->has_resize_func)
meta_window_fill_vertical (window);
}
}
static void
handle_maximize_horiz (MetaDisplay *display,
MetaScreen *screen,
MetaWindow *window,
XEvent *event,
MetaKeyBinding *binding)
{
if (window)
{
if (window->has_resize_func)
meta_window_fill_horizontal (window);
}
}
static gboolean
process_workspace_switch_grab (MetaDisplay *display,
MetaScreen *screen,

View File

@ -71,8 +71,8 @@
<short>Action on title bar double-click</short>
<long>
This option determines the effects of double-clicking on the
title bar. Current valid options are 'toggle_shade', which will
shade/unshade the window, and 'toggle_maximize' which will
title bar. Current valid options are 'toggle_shaded', which will
shade/unshade the window, and 'toggle_maximized' which will
maximize/unmaximize the window.
</long>
</locale>
@ -426,7 +426,7 @@ you set
<type>string</type>
<default>disabled</default>
<locale name="C">
<short>Toggle whether the window is on all workspaces</short>
<short>Toggle window on all workspaces</short>
<long>
The keybinding used to toggle whether the window is on all
workspaces or just one.
@ -823,7 +823,7 @@ you set
<type>string</type>
<!-- no default for this one -->
<locale name="C">
<short>Raise window if obscured, lowers it otherwise</short>
<short>Raise obscured window, otherwise lower</short>
<long>
This keybinding changes whether a window is above or below
other windows. If the window is covered by another window, it raises
@ -888,6 +888,51 @@ you set
</locale>
</schema>
<schema>
<key>/schemas/apps/metacity/window_keybindings/maximize_vertically</key>
<applyto>/apps/metacity/window_keybindings/maximize_vertically</applyto>
<owner>metacity</owner>
<type>string</type>
<!-- no default for this one -->
<locale name="C">
<short>Maximize window vertically</short>
<long>
This keybinding resizes a window to fill available vertical space.
The format looks like "&lt;Control&gt;a" or
"&lt;Shift&gt;&lt;Alt&gt;F1.
The parser is fairly liberal and allows lower or upper case,
and also abbreviations such as "&lt;Ctl&gt;" and
"&lt;Ctrl&gt;". If you set the option to the special string
"disabled", then there will be no keybinding for this
action.
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/metacity/window_keybindings/maximize_horizontally</key>
<applyto>/apps/metacity/window_keybindings/maximize_horizontally</applyto>
<owner>metacity</owner>
<type>string</type>
<!-- no default for this one -->
<locale name="C">
<short>Maximize window horizontally</short>
<long>
This keybinding resizes a window to fill available horizontal space.
The format looks like "&lt;Control&gt;a" or
"&lt;Shift&gt;&lt;Alt&gt;F1.
The parser is fairly liberal and allows lower or upper case,
and also abbreviations such as "&lt;Ctl&gt;" and
"&lt;Ctrl&gt;". If you set the option to the special string
"disabled", then there will be no keybinding for this
action.
</long>
</locale>
</schema>
<!-- Global Keybindings -->
@ -899,7 +944,7 @@ you set
<type>string</type>
<default>&lt;Alt&gt;Tab</default>
<locale name="C">
<short>Move focus between windows using popup display</short>
<short>Move between windows with popup</short>
<long>
The keybinding used to move focus between windows, using
a popup window.
@ -950,7 +995,7 @@ you set
<type>string</type>
<default>&lt;Control&gt;&lt;Alt&gt;Tab</default>
<locale name="C">
<short>Move focus between panels and the desktop using popup display</short>
<short>Move between panels and the desktop with popup</short>
<long>
The keybinding used to move focus between panels and
the desktop, using a popup window.
@ -974,7 +1019,7 @@ you set
<type>string</type>
<default>disabled</default>
<locale name="C">
<short>Move focus backwards between panels and the desktop using popup display</short>
<short>Move backwards between panels and the desktop with popup</short>
<long>
The keybinding used to move focus backwards between panels
and the desktop, using a popup window.
@ -998,7 +1043,7 @@ you set
<type>string</type>
<default>&lt;Alt&gt;Escape</default>
<locale name="C">
<short>Move focus between windows immediately</short>
<short>Move between windows immediately</short>
<long>
The keybinding used to move focus between windows without
a popup window.
@ -1024,7 +1069,7 @@ you set
<type>string</type>
<default>disabled</default>
<locale name="C">
<short>Move focus backwards between windows immediately</short>
<short>Move backwards between windows immediately</short>
<long>
The keybinding used to move focus backwards between windows
without a popup window. Holding "shift" together with this
@ -1049,7 +1094,7 @@ you set
<type>string</type>
<default>&lt;Control&gt;&lt;Alt&gt;Escape</default>
<locale name="C">
<short>Move focus between panels and the desktop immediately</short>
<short>Move between panels and the desktop immediately</short>
<long>
The keybinding used to move focus between panels and
the desktop, without a popup window.
@ -1073,7 +1118,7 @@ you set
<type>string</type>
<default>&lt;Control&gt;&lt;Alt&gt;Escape</default>
<locale name="C">
<short>Move focus backward between panels and the desktop immediately</short>
<short>Move backward between panels and the desktop immediately</short>
<long>
The keybinding used to move focus backwards between panels and
the desktop, without a popup window.
@ -1461,7 +1506,7 @@ you set
<type>string</type>
<default>&lt;Control&gt;&lt;Alt&gt;Up</default>
<locale name="C">
<short>Switch to workspace above the current space</short>
<short>Switch to workspace above this one</short>
<long>
The keybinding that switches to the workspace above
the current workspace.
@ -1486,7 +1531,7 @@ you set
<type>string</type>
<default>&lt;Control&gt;&lt;Alt&gt;Down</default>
<locale name="C">
<short>Switch to workspace below the current space</short>
<short>Switch to workspace below this one</short>
<long>
The keybinding that switches to the workspace below
the current workspace.

View File

@ -1295,6 +1295,8 @@ static MetaKeyPref window_bindings[] = {
{ META_KEYBINDING_RAISE_OR_LOWER, 0, 0 },
{ META_KEYBINDING_RAISE, 0, 0 },
{ META_KEYBINDING_LOWER, 0, 0 },
{ META_KEYBINDING_MAXIMIZE_VERTICALLY, 0, 0 },
{ META_KEYBINDING_MAXIMIZE_HORIZONTALLY, 0, 0 },
{ NULL, 0, 0 }
};

View File

@ -150,6 +150,8 @@ void meta_prefs_change_workspace_name (int i,
#define META_KEYBINDING_RAISE_OR_LOWER "raise_or_lower"
#define META_KEYBINDING_RAISE "raise"
#define META_KEYBINDING_LOWER "lower"
#define META_KEYBINDING_MAXIMIZE_VERTICALLY "maximize_vertically"
#define META_KEYBINDING_MAXIMIZE_HORIZONTALLY "maximize_horizontally"
typedef enum _MetaKeyBindingAction
{

View File

@ -2621,6 +2621,88 @@ meta_window_move_resize_now (MetaWindow *window)
window->rect.height);
}
static void
check_maximize_to_xinerama (MetaWindow *window,
const MetaXineramaScreenInfo *xinerama)
{
/* If we now fill the screen, maximize.
* the point here is that fill horz + fill vert = maximized
*/
MetaRectangle rect;
if (!window->has_maximize_func)
return;
meta_window_get_outer_rect (window, &rect);
if ( rect.x >= xinerama->x_origin &&
rect.y >= xinerama->y_origin &&
(((xinerama->width - xinerama->x_origin) - rect.width) <
window->size_hints.width_inc) &&
(((xinerama->height - xinerama->y_origin) - rect.height) <
window->size_hints.height_inc) )
meta_window_maximize (window);
}
void
meta_window_fill_horizontal (MetaWindow *window)
{
const MetaXineramaScreenInfo *xinerama;
int x, y, w, h;
meta_window_get_user_position (window, &x, &y);
w = window->rect.width;
h = window->rect.height;
xinerama = meta_screen_get_xinerama_for_window (window->screen,
window);
x = xinerama->x_origin;
w = xinerama->width;
if (window->frame != NULL)
{
x += window->frame->child_x;
w -= (window->frame->child_x + window->frame->right_width);
}
meta_window_move_resize (window, TRUE,
x, y, w, h);
check_maximize_to_xinerama (window, xinerama);
}
void
meta_window_fill_vertical (MetaWindow *window)
{
const MetaXineramaScreenInfo *xinerama;
int x, y, w, h;
meta_window_get_user_position (window, &x, &y);
w = window->rect.width;
h = window->rect.height;
xinerama = meta_screen_get_xinerama_for_window (window->screen,
window);
y = xinerama->y_origin;
h = xinerama->height;
if (window->frame != NULL)
{
y += window->frame->child_y;
h -= (window->frame->child_y + window->frame->bottom_height);
}
meta_window_move_resize (window, TRUE,
x, y, w, h);
check_maximize_to_xinerama (window, xinerama);
}
static guint move_resize_idle = 0;
static GSList *move_resize_pending = NULL;

View File

@ -322,6 +322,10 @@ void meta_window_resize_with_gravity (MetaWindow *window,
int h,
int gravity);
void meta_window_fill_horizontal (MetaWindow *window);
void meta_window_fill_vertical (MetaWindow *window);
/* This recalcs the window/frame size, and recalcs the frame
* size/contents as well.
*/