Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions daemon/MenuDaemon.vala
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace Gala {
private Granite.AccelLabel always_on_top_accellabel;
private Granite.AccelLabel close_accellabel;
private Granite.AccelLabel hide_accellabel;
private Granite.AccelLabel hide_others_accellabel;
private Granite.AccelLabel move_accellabel;
private Granite.AccelLabel move_left_accellabel;
private Granite.AccelLabel move_right_accellabel;
Expand All @@ -41,6 +42,7 @@ namespace Gala {
private Granite.AccelLabel screenshot_accellabel;
Gtk.Menu? window_menu = null;
Gtk.MenuItem hide;
Gtk.MenuItem hide_others;
Gtk.MenuItem maximize;
Gtk.MenuItem move;
Gtk.MenuItem resize;
Expand Down Expand Up @@ -120,6 +122,14 @@ namespace Gala {
perform_action (Gala.ActionType.HIDE_CURRENT);
});

hide_others_accellabel = new Granite.AccelLabel (_("Hide Others"));

hide_others = new Gtk.MenuItem ();
hide_others.add (hide_others_accellabel);
hide_others.activate.connect (() => {
perform_action (Gala.ActionType.HIDE_OTHERS);
});

maximize = new Gtk.MenuItem ();
maximize.activate.connect (() => {
perform_action (Gala.ActionType.MAXIMIZE_CURRENT);
Expand Down Expand Up @@ -202,6 +212,7 @@ namespace Gala {
window_menu.append (maximize);
window_menu.append (new Gtk.SeparatorMenuItem ());
window_menu.append (hide);
window_menu.append (hide_others);
window_menu.append (close);
window_menu.show_all ();
}
Expand Down Expand Up @@ -271,6 +282,8 @@ namespace Gala {

screenshot_accellabel.accel_string = gala_keybind_settings.get_strv ("window-screenshot")[0];

hide_others_accellabel.accel_string = gala_keybind_settings.get_strv ("hide-others")[0];

close.visible = Gala.WindowFlags.CAN_CLOSE in flags;
if (close.visible) {
close_accellabel.accel_string = keybind_settings.get_strv ("close")[0];
Expand Down
5 changes: 5 additions & 0 deletions data/gala.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@
<summary>The shortcut to enable picture-in-picture window</summary>
<description>The shortcut to show the selection area to choose a window.</description>
</key>
<key type="as" name="hide-others">
<default><![CDATA[['<Super><Shift>h']]]></default>
<summary>Shortcut to hide other windows</summary>
<description></description>
</key>
</schema>

<schema path="/org/pantheon/desktop/gala/appearance/" id="org.pantheon.desktop.gala.appearance">
Expand Down
1 change: 1 addition & 0 deletions lib/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace Gala {
SHOW_WORKSPACE_VIEW,
MAXIMIZE_CURRENT,
HIDE_CURRENT,
HIDE_OTHERS,
OPEN_LAUNCHER,
CUSTOM_COMMAND,
WINDOW_OVERVIEW,
Expand Down
19 changes: 19 additions & 0 deletions src/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ namespace Gala {
display.add_keybinding ("area-screenshot-clip", keybinding_settings, 0, (Meta.KeyHandlerFunc) handle_screenshot);
#endif

var gala_keybinding_settings = new GLib.Settings ("org.pantheon.desktop.gala.keybindings");
display.add_keybinding ("hide-others", gala_keybinding_settings, 0, (Meta.KeyHandlerFunc) handle_hide_others);

display.overlay_key.connect (() => {
launch_action ("overlay-action");
});
Expand Down Expand Up @@ -481,6 +484,12 @@ namespace Gala {
}
}

[CCode (instance_pos = -1)]
void handle_hide_others (Meta.Display display, Meta.Window? window,
Clutter.KeyEvent event, Meta.KeyBinding binding) {
perform_action (Gala.ActionType.HIDE_OTHERS);
}

private void on_gesture_detected (Gesture gesture) {
if (workspace_view.is_opened ()) {
return;
Expand Down Expand Up @@ -831,6 +840,16 @@ namespace Gala {
if (current != null && current.window_type == Meta.WindowType.NORMAL)
current.minimize ();
break;
case ActionType.HIDE_OTHERS:
unowned Meta.WorkspaceManager workspace_manager = display.get_workspace_manager ();
unowned Meta.Workspace workspace = workspace_manager.get_active_workspace ();
GLib.List<weak Meta.Window> windows = workspace.list_windows ();
windows.foreach ((window) => {
if (current != window && window.window_type == Meta.WindowType.NORMAL) {
window.minimize ();
}
});
break;
case ActionType.START_MOVE_CURRENT:
if (current != null && current.allows_move ())
current.begin_grab_op (Meta.GrabOp.KEYBOARD_MOVING, true, Gtk.get_current_event_time ());
Expand Down