@@ -674,25 +674,33 @@ namespace Gala {
674674 * {@inheritDoc }
675675 */
676676 public void move_window (Meta .Window ? window , Meta .MotionDirection direction ) {
677- if (window == null )
677+ if (window == null ) {
678678 return ;
679+ }
679680
680681 unowned Meta . Display display = get_display ();
681682 unowned Meta . WorkspaceManager manager = display. get_workspace_manager ();
682683
683- var active = manager. get_active_workspace ();
684- var next = active. get_neighbor (direction);
684+ unowned var active = manager. get_active_workspace ();
685+ unowned var next = active. get_neighbor (direction);
685686
686- // dont allow empty workspaces to be created by moving, if we have dynamic workspaces
687+ // don't allow empty workspaces to be created by moving, if we have dynamic workspaces
687688 if (Meta . Prefs . get_dynamic_workspaces () && Utils . get_n_windows (active) == 1 && next. index () == manager. n_workspaces - 1 ) {
688689 Utils . bell (display);
689690 return ;
690691 }
691692
693+ // don't allow moving into non-existing workspaces
694+ if (active == next) {
695+ Utils . bell (display);
696+ return ;
697+ }
698+
692699 moving = window;
693700
694- if (! window. is_on_all_workspaces ())
701+ if (! window. is_on_all_workspaces ()) {
695702 window. change_workspace (next);
703+ }
696704
697705 next. activate_with_focus (window, display. get_current_time ());
698706 }
@@ -837,18 +845,10 @@ namespace Gala {
837845 current. stick ();
838846 break ;
839847 case ActionType . MOVE_CURRENT_WORKSPACE_LEFT:
840- if (current != null ) {
841- var wp = current. get_workspace (). get_neighbor (Meta . MotionDirection . LEFT );
842- if (wp != null )
843- current. change_workspace (wp);
844- }
848+ move_window (current, Meta . MotionDirection . LEFT );
845849 break ;
846850 case ActionType . MOVE_CURRENT_WORKSPACE_RIGHT:
847- if (current != null ) {
848- var wp = current. get_workspace (). get_neighbor (Meta . MotionDirection . RIGHT );
849- if (wp != null )
850- current. change_workspace (wp);
851- }
851+ move_window (current, Meta . MotionDirection . RIGHT );
852852 break ;
853853 case ActionType . CLOSE_CURRENT:
854854 if (current != null && current. can_close ())
0 commit comments