Ejemplo n.º 1
0
        /// <summary>
        ///   Gets all newly created windows, not handled by the desktop manager yet.
        /// </summary>
        /// <returns>A list with all new windows.</returns>
        List <WindowSnapshot> GetNewWindows()
        {
            List <WindowInfo> newWindows = WindowManager.GetWindows().Except(
                Workspaces.SelectMany(d => d.WindowSnapshots).Concat(WindowClipboard)
                .Select(w => w.Info)
                .Concat(_invalidWindows)).ToList();

            var validWindows = new List <WindowSnapshot>();

            foreach (var w in newWindows)
            {
                var snapshot = new WindowSnapshot(CurrentWorkspace, w);
                if (IsValidWindow(snapshot))
                {
                    validWindows.Add(snapshot);
                }
                else
                {
                    lock ( _invalidWindows )
                    {
                        _invalidWindows.Add(w);
                    }
                }
            }
            return(validWindows);
        }
Ejemplo n.º 2
0
        protected bool Equals(WindowSnapshot other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }

            return(ReferenceEquals(this, other) || Info.Equals(other.Info));
        }
Ejemplo n.º 3
0
        /// <summary>
        ///   Find z-order of all passed windows.
        /// </summary>
        /// <returns>A new list containing all the passed windows, but ordered according to their z-order, most on top first.</returns>
        static List <WindowSnapshot> OrderWindowsByZOrder(List <WindowSnapshot> toOrder)
        {
            // TODO: Safeguard for infinite loop and possible destroyed windows.
            // http://stackoverflow.com/q/12992201/590790
            var        ordenedWindows = new List <WindowSnapshot>();
            WindowInfo window         = WindowManager.GetTopWindow();

            while (window != null)
            {
                WindowSnapshot match = toOrder.FirstOrDefault(w => w.Info.Equals(window));
                if (match != null)
                {
                    ordenedWindows.Add(match);
                }
                window = WindowManager.GetWindowBelow(window);
            }

            return(ordenedWindows);
        }
Ejemplo n.º 4
0
        /// <summary>
        ///   Show all windows associated with this virtual desktop.
        ///   Unresponsive window event is triggered when any unresponsive windows are detected during show operation.
        /// </summary>
        protected override void ShowInner()
        {
            // Early out when virtual desktop has not windows.
            if (_windows.Count == 0)
            {
                return;
            }

            var unresponsiveWindows = new List <WindowSnapshot>();

            // Reposition windows.
            // Topmost windows are repositioned separately in order to prevent non-topmost windows from becoming topmost when moving them above topmost windows in the z-order.
            var allWindows = _windows
                             .Where(w => !w.Ignore)
                             .GroupBy(w => w.Info.IsTopmost());

            allWindows.ForEach(group =>
            {
                var showWindows = group.Select(w => new RepositionWindowInfo(w.Info)
                {
                    Visible = w.Visible
                });
                unresponsiveWindows.AddRange(RepositionWindows(showWindows, true));
            });

            // Activate top window.
            // TODO: Is the topmost window always the previous active one? Possibly a better check is needed.
            // TODO: Which window to activate when desktops are merged?
            WindowSnapshot first = _windows.FirstOrDefault(w => w.Visible && !unresponsiveWindows.Contains(w));

            if (first != null)
            {
                first.Info.SetForegroundWindow();
            }

            TriggerIfUnresponsive(unresponsiveWindows);
        }
Ejemplo n.º 5
0
        protected bool Equals( WindowSnapshot other )
        {
            if ( ReferenceEquals( null, other ) )
            {
                return false;
            }

            return ReferenceEquals( this, other ) || Info.Equals( other.Info );
        }
Ejemplo n.º 6
0
 /// <summary>
 ///   Check whether the WindowInfo object represents a valid Window.
 /// </summary>
 /// <returns>True if valid, false if unvalid.</returns>
 bool IsValidWindow(WindowSnapshot window)
 {
     return(!window.Info.IsDestroyed() && _windowFilter(new Window(window.Info)));
 }