Example #1
0
        public void MoveFocusedWindowToMonitor(int index)
        {
            Logger.Debug("MoveFocusedWindowToMonitor({0})", index);
            if (index >= _context.MonitorContainer.NumMonitors)
            {
                return;
            }

            var window          = FocusedWorkspace.FocusedWindow;
            var targetMonitor   = _context.MonitorContainer.GetMonitorAtIndex(index);
            var targetWorkspace = _context.WorkspaceContainer.GetWorkspaceForMonitor(targetMonitor);

            if (window != null && targetWorkspace != null)
            {
                var windows = FocusedWorkspace.ManagedWindows;
                // get next window
                var nextWindow = windows.SkipWhile(x => x != window).Skip(1).FirstOrDefault();
                if (nextWindow == null)
                {
                    // get previous window
                    nextWindow = windows.TakeWhile(x => x != window).LastOrDefault();
                }

                FocusedWorkspace.RemoveWindow(window);
                targetWorkspace.AddWindow(window);

                _windowsToWorkspaces[window] = targetWorkspace;
                WindowMoved?.Invoke(window, FocusedWorkspace, targetWorkspace);

                nextWindow?.Focus();
            }
        }
Example #2
0
        public void MoveFocusedWindowToWorkspace(int index)
        {
            Logger.Debug("MoveFocusedWindowToWorkspace({0})", index);
            var window          = FocusedWorkspace.FocusedWindow;
            var targetWorkspace = _context.WorkspaceContainer.GetWorkspaceAtIndex(FocusedWorkspace, index);

            if (window != null && targetWorkspace != null)
            {
                var windows = FocusedWorkspace.Windows.Where(w => w.CanLayout);
                // get next window
                var nextWindow = windows.SkipWhile(x => x != window).Skip(1).FirstOrDefault();
                if (nextWindow == null)
                {
                    // get previous window
                    nextWindow = windows.TakeWhile(x => x != window).LastOrDefault();
                }

                FocusedWorkspace.RemoveWindow(window);
                targetWorkspace.AddWindow(window);

                _windowsToWorkspaces[window] = targetWorkspace;
                WindowMoved?.Invoke(window, FocusedWorkspace, targetWorkspace);

                nextWindow?.Focus();
            }
        }
Example #3
0
 void fireWindowMovedEvent(WindowEvent e)
 {
     if (WindowMoved != null)
     {
         try
         {
             WindowMoved.Invoke(this, new WindowEventForwarder(e));
         }
         catch { }
     }
 }
        private void OnWindowMoved()
        {
            var relativeRect = RelativeToWindow.GetBounds();
            var myRect       = Window.GetBounds();

            myRect.X -= relativeRect.X;
            myRect.Y -= relativeRect.Y;

            WindowMoved?.Invoke(this, new WindowLocationUpdatedEventArgs(Window.GetIsVisible(), myRect));

            //WindowMoved?.Invoke(this, new WindowLocationUpdatedEventArgs(Window.GetIsVisible(), Window.TransformTo(RelativeToWindow, Window.GetBounds())));
        }
Example #5
0
        public void MoveFocusedWindowToPreviousMonitor()
        {
            Logger.Debug("MoveFocusedWindowToPreviousMonitor");
            var window          = FocusedWorkspace.FocusedWindow;
            var focusedMonitor  = _context.MonitorContainer.FocusedMonitor;
            var targetMonitor   = _context.MonitorContainer.GetPreviousMonitor();
            var targetWorkspace = _context.WorkspaceContainer.GetWorkspaceForMonitor(targetMonitor);

            if (window != null && targetWorkspace != null)
            {
                FocusedWorkspace.RemoveWindow(window);
                targetWorkspace.AddWindow(window);

                _windowsToWorkspaces[window] = targetWorkspace;
                WindowMoved?.Invoke(window, FocusedWorkspace, targetWorkspace);
                if (focusedMonitor != targetMonitor)
                {
                    _context.MonitorContainer.FocusedMonitor = targetMonitor;
                    window.Focus();
                    FocusedMonitorUpdated?.Invoke();
                }
            }
        }