diff --git a/ChangeLog b/ChangeLog index d96f45b94..689d62531 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2002-12-08 Havoc Pennington + + * 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 * src/prefs.c (meta_prefs_get_application_based): make this always diff --git a/src/keybindings.c b/src/keybindings.c index dd162af78..2afe556b0 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 682b02c6e..9216b4879 100644 --- a/src/metacity.schemas.in +++ b/src/metacity.schemas.in @@ -71,8 +71,8 @@ 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, 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. @@ -426,7 +426,7 @@ you set string disabled - Toggle whether the window is on all workspaces + Toggle window on all workspaces The keybinding used to toggle whether the window is on all workspaces or just one. @@ -823,7 +823,7 @@ you set string - Raise window if obscured, lowers it otherwise + Raise obscured window, otherwise lower 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 + + /schemas/apps/metacity/window_keybindings/maximize_vertically + /apps/metacity/window_keybindings/maximize_vertically + metacity + string + + + Maximize window vertically + + This keybinding resizes a window to fill available vertical space. + + The format looks like "<Control>a" or + "<Shift><Alt>F1. + + The parser is fairly liberal and allows lower or upper case, + and also abbreviations such as "<Ctl>" and + "<Ctrl>". If you set the option to the special string + "disabled", then there will be no keybinding for this + action. + + + + + + /schemas/apps/metacity/window_keybindings/maximize_horizontally + /apps/metacity/window_keybindings/maximize_horizontally + metacity + string + + + Maximize window horizontally + + This keybinding resizes a window to fill available horizontal space. + + The format looks like "<Control>a" or + "<Shift><Alt>F1. + + The parser is fairly liberal and allows lower or upper case, + and also abbreviations such as "<Ctl>" and + "<Ctrl>". If you set the option to the special string + "disabled", then there will be no keybinding for this + action. + + + @@ -899,7 +944,7 @@ you set string <Alt>Tab - Move focus between windows using popup display + Move between windows with popup The keybinding used to move focus between windows, using a popup window. @@ -950,7 +995,7 @@ you set string <Control><Alt>Tab - Move focus between panels and the desktop using popup display + Move between panels and the desktop with popup The keybinding used to move focus between panels and the desktop, using a popup window. @@ -974,7 +1019,7 @@ you set string disabled - Move focus backwards between panels and the desktop using popup display + Move backwards between panels and the desktop with popup The keybinding used to move focus backwards between panels and the desktop, using a popup window. @@ -998,7 +1043,7 @@ you set string <Alt>Escape - Move focus between windows immediately + Move between windows immediately The keybinding used to move focus between windows without a popup window. @@ -1024,7 +1069,7 @@ you set string disabled - Move focus backwards between windows immediately + Move backwards between windows immediately The keybinding used to move focus backwards between windows without a popup window. Holding "shift" together with this @@ -1049,7 +1094,7 @@ you set string <Control><Alt>Escape - Move focus between panels and the desktop immediately + Move between panels and the desktop immediately The keybinding used to move focus between panels and the desktop, without a popup window. @@ -1073,7 +1118,7 @@ you set string <Control><Alt>Escape - Move focus backward between panels and the desktop immediately + Move backward between panels and the desktop immediately The keybinding used to move focus backwards between panels and the desktop, without a popup window. @@ -1461,7 +1506,7 @@ you set string <Control><Alt>Up - Switch to workspace above the current space + Switch to workspace above this one The keybinding that switches to the workspace above the current workspace. @@ -1486,7 +1531,7 @@ you set string <Control><Alt>Down - Switch to workspace below the current space + Switch to workspace below this one The keybinding that switches to the workspace below the current workspace. diff --git a/src/prefs.c b/src/prefs.c index 9ef8fbf28..380e8fb37 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 fe79edaf0..683bedba6 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 b4f80cf72..27e0d3c97 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 dbdfdf8da..21c71179b 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. */