From 13517837c7e51efcd802f0f4c76897bf95da2a64 Mon Sep 17 00:00:00 2001 From: Tom Beckmann Date: Wed, 18 Jul 2012 22:50:41 +0200 Subject: [PATCH] Improve focusing behavior --- src/Main.vala | 33 ++++++++++++++++++--------------- src/Widgets/WorkspaceView.vala | 4 ++-- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/Main.vala b/src/Main.vala index ed6dc421..4599532d 100644 --- a/src/Main.vala +++ b/src/Main.vala @@ -25,7 +25,7 @@ namespace Gala WindowSwitcher winswitcher; WorkspaceView workspace_view; - Window? moving; //place for the window that is being moved over + internal Window? moving; //place for the window that is being moved over int modal_count = 0; //count of modal modes overlaying each other @@ -149,17 +149,17 @@ namespace Gala var display = screen.get_display (); var active = screen.get_active_workspace (); - var idx = active.index () + (reverse ? -1 : 1); + var next = active.get_neighbor (reverse ? MotionDirection.LEFT : MotionDirection.RIGHT); - if (idx < 0 || idx >= screen.n_workspaces || - (active.n_windows == 1 && idx == screen.n_workspaces-1)) //dont allow empty workspaces to be created by moving + //dont allow empty workspaces to be created by moving + if (active.n_windows == 1 && next.index () == screen.n_workspaces - 1) return; if (!window.is_on_all_workspaces ()) - window.change_workspace_by_index (idx, true, display.get_current_time ()); + window.change_workspace (next); moving = window; - screen.get_workspace_by_index (idx).activate_with_focus (window, display.get_current_time ()); + next.activate_with_focus (window, display.get_current_time ()); } public new void begin_modal () @@ -647,16 +647,19 @@ namespace Gala switch_workspace_completed (); + var focus = display.get_focus_window (); + if (focus != null && focus.window_type == WindowType.DOCK) { + if (moving != null) + moving.activate (display.get_current_time ()); + else { + focus = Utils.get_next_window (screen.get_active_workspace ()); + if (focus != null) + focus.activate (display.get_current_time ()); + } + } else if (moving != null) + moving.activate (display.get_current_time ()); + moving = null; - - var focus = display.get_tab_current (Meta.TabList.NORMAL, screen, screen.get_active_workspace ()); - // Only switch focus to the next window if none has grabbed it already - if (focus == null) { - focus = Utils.get_next_window (screen.get_active_workspace ()); - if (focus != null) - focus.activate (display.get_current_time ()); - } - } public override void kill_switch_workspace () diff --git a/src/Widgets/WorkspaceView.vala b/src/Widgets/WorkspaceView.vala index 08f93052..3eb156a6 100644 --- a/src/Widgets/WorkspaceView.vala +++ b/src/Widgets/WorkspaceView.vala @@ -212,13 +212,13 @@ namespace Gala switch (event.keyval) { case Clutter.Key.Left: if ((event.modifier_state & Clutter.ModifierType.SHIFT_MASK) == 1) - plugin.move_window (screen.get_display ().get_focus_window (), true); + plugin.move_window ((plugin.moving == null)?screen.get_display ().get_focus_window ():plugin.moving, true); else switch_to_next_workspace (true); return false; case Clutter.Key.Right: if ((event.modifier_state & Clutter.ModifierType.SHIFT_MASK) == 1) - plugin.move_window (screen.get_display ().get_focus_window (), false); + plugin.move_window ((plugin.moving == null)?screen.get_display ().get_focus_window ():plugin.moving, false); else switch_to_next_workspace (false); return false;