summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHavoc Pennington <hp@pobox.com>2002-12-08 21:09:05 +0000
committerHavoc Pennington <hp@src.gnome.org>2002-12-08 21:09:05 +0000
commite0c8b245ef88813881d6e501887254acc4f88acb (patch)
tree7516e1eb4d559a093a2b7c3860db8148b15c4b37
parent8d314aead872d09198f887295c2e91e02ac525c6 (diff)
downloadmetacity-e0c8b245ef88813881d6e501887254acc4f88acb.tar.gz
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.
-rw-r--r--ChangeLog14
-rw-r--r--src/keybindings.c41
-rw-r--r--src/metacity.schemas.in71
-rw-r--r--src/prefs.c2
-rw-r--r--src/prefs.h2
-rw-r--r--src/window.c82
-rw-r--r--src/window.h4
7 files changed, 203 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index d96f45b9..689d6253 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
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
return FALSE for now, to avoid bug reports.
diff --git a/src/keybindings.c b/src/keybindings.c
index dd162af7..2afe556b 100644
--- a/src/keybindings.c
+++ b/src/keybindings.c
@@ -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,
diff --git a/src/metacity.schemas.in b/src/metacity.schemas.in
index 682b02c6..9216b487 100644
--- a/src/metacity.schemas.in
+++ b/src/metacity.schemas.in
@@ -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.
diff --git a/src/prefs.c b/src/prefs.c
index 9ef8fbf2..380e8fb3 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -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 }
};
diff --git a/src/prefs.h b/src/prefs.h
index fe79edaf..683bedba 100644
--- a/src/prefs.h
+++ b/src/prefs.h
@@ -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
{
diff --git a/src/window.c b/src/window.c
index b4f80cf7..27e0d3c9 100644
--- a/src/window.c
+++ b/src/window.c
@@ -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;
diff --git a/src/window.h b/src/window.h
index dbdfdf8d..21c71179 100644
--- a/src/window.h
+++ b/src/window.h
@@ -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.
*/