예제 #1
0
 protected override ClickAnimation OnClicked(uint button, ModifierType mod, double xPercent, double yPercent)
 {
     if ((!ManagedWindows.Any() && button == 1) || button == 2 ||
         (button == 1 && (mod & ModifierType.ControlMask) == ModifierType.ControlMask))
     {
         Launch();
         return(ClickAnimation.Bounce);
     }
     return(base.OnClicked(button, mod, xPercent, yPercent));
 }
예제 #2
0
        void WnckScreenDefaultWindowClosed(object o, WindowClosedArgs args)
        {
            if (base_window == args.Window)
            {
                base_window = ManagedWindows
                              .Where(w => w != args.Window)
                              .DefaultIfEmpty(null)
                              .FirstOrDefault();
            }

            UpdateWindows(base_window);
            SetNameAndIcon();
        }
예제 #3
0
        protected override void OnScrolled(Gdk.ScrollDirection direction, Gdk.ModifierType mod)
        {
            int count = ManagedWindows.Count();

            if (count < 1 || (DateTime.UtcNow - last_scroll) < scroll_rate)
            {
                return;
            }

            last_scroll = DateTime.UtcNow;

            // This block will make sure that if we're scrolling on an app that is already active
            // that when we scroll we move on the next window instead of appearing to do nothing
            Wnck.Window focused = ManagedWindows.Where(w => w.IsActive).FirstOrDefault();
            if (focused != null)
            {
                for (; last_raised < count - 1; last_raised++)
                {
                    if (ManagedWindows.ElementAt(last_raised).Pid == focused.Pid)
                    {
                        break;
                    }
                }
            }

            switch (direction)
            {
            case ScrollDirection.Up:
            case ScrollDirection.Right:
                last_raised++;
                break;

            case ScrollDirection.Down:
            case ScrollDirection.Left:
                last_raised--;
                break;
            }

            if (last_raised < 0)
            {
                last_raised = count - 1;
            }
            else if (last_raised >= count)
            {
                last_raised = 0;
            }

            ManagedWindows.ElementAt(last_raised).CenterAndFocusWindow();
        }
예제 #4
0
        protected override MenuList OnGetMenuItems()
        {
            MenuList list = base.OnGetMenuItems();

            if (ManagedWindows.Any())
            {
                list[MenuListContainer.Actions].Insert(0, new MenuItem(Catalog.GetString("New _Window"), RunIcon, (o, a) => Launch()));
            }
            else
            {
                list[MenuListContainer.Actions].Insert(0, new MenuItem(Catalog.GetString("_Open"), RunIcon, (o, a) => Launch()));
            }

            return(list);
        }
예제 #5
0
        void SetState()
        {
            ItemState state = 0;

            if (Windows.Any(w => w == Wnck.Screen.Default.ActiveWindow))
            {
                state |= ItemState.Active;
            }
            if (ManagedWindows.Any(w => w.NeedsAttention()))
            {
                state |= ItemState.Urgent;
            }

            State = state;
        }
예제 #6
0
        protected override ClickAnimation OnClicked(uint button, ModifierType mod, double xPercent, double yPercent)
        {
            if (!ManagedWindows.Any() || button != 1)
            {
                return(ClickAnimation.None);
            }

            List <Wnck.Window>        stack   = new List <Wnck.Window> (Wnck.Screen.Default.WindowsStacked);
            IEnumerable <Wnck.Window> windows = ManagedWindows.OrderByDescending(w => stack.IndexOf(w));

            bool not_in_viewport = !windows.Any(w => !w.IsSkipTasklist && w.IsInViewport(w.Screen.ActiveWorkspace));
            bool urgent          = windows.Any(w => w.NeedsAttention());

            if (not_in_viewport || urgent)
            {
                foreach (Wnck.Window window in windows)
                {
                    if (urgent && !window.NeedsAttention())
                    {
                        continue;
                    }

                    if (!window.IsSkipTasklist)
                    {
                        WindowControl.IntelligentFocusOffViewportWindow(window, windows);
                        return(ClickAnimation.Darken);
                    }
                }
            }

            if (windows.Any(w => w.IsMinimized && w.IsInViewport(Wnck.Screen.Default.ActiveWorkspace)))
            {
                WindowControl.RestoreWindows(windows);
            }
            else if (windows.Any(w => w.IsActive && w.IsInViewport(Wnck.Screen.Default.ActiveWorkspace)) ||
                     Windows.Any(w => w == Wnck.Screen.Default.ActiveWindow))
            {
                WindowControl.MinimizeWindows(windows);
            }
            else
            {
                WindowControl.FocusWindows(windows);
            }

            return(ClickAnimation.Darken);
        }
예제 #7
0
        void SetIndicator()
        {
            int count = ManagedWindows.Count();

            if (count > 1)
            {
                Indicator = ActivityIndicator.SinglePlus;
            }
            else if (count == 1)
            {
                Indicator = ActivityIndicator.Single;
            }
            else
            {
                Indicator = ActivityIndicator.None;
            }
        }
예제 #8
0
        public void DoLayout()
        {
            var windows = ManagedWindows.ToList();

            if (_context.Enabled)
            {
                var monitor = _context.WorkspaceContainer.GetCurrentMonitorForWorkspace(this);
                if (monitor != null)
                {
                    windows.ForEach(w => w.ShowInCurrentState());

                    var locations = GetLayoutEngine().CalcLayout(windows, monitor.Width, monitor.Height)
                                    .ToArray();

                    using (var handle = _context.Windows.DeferWindowsPos(windows.Count))
                    {
                        for (var i = 0; i < locations.Length; i++)
                        {
                            var window = windows[i];
                            var loc    = locations[i];

                            var adjustedLoc = new WindowLocation(loc.X + monitor.X, loc.Y + monitor.Y,
                                                                 loc.Width, loc.Height, loc.State);

                            if (!window.IsMouseMoving)
                            {
                                handle.DeferWindowPos(window, adjustedLoc);
                            }
                        }
                    }
                }
                else
                {
                    windows.ForEach(w => w.Hide());
                }
            }
            else
            {
                windows.ForEach(w => w.ShowInCurrentState());
            }
        }
예제 #9
0
        void SetNameAndIcon()
        {
            if (!ManagedWindows.Any())
            {
                return;
            }

            if (ShowHovers)
            {
                if (ManagedWindows.Count() > 1 && Windows.First().ClassGroup != null)
                {
                    HoverText = ManagedWindows.First().ClassGroup.Name;
                }
                else
                {
                    HoverText = ManagedWindows.First().Name;
                }
            }

            SetIconFromPixbuf(base_window.Icon);
        }
예제 #10
0
        protected override MenuList OnGetMenuItems()
        {
            MenuList list = base.OnGetMenuItems();

            if (ManagedWindows.Any())
            {
                if (ManagedWindows.Any(w => w.IsMaximized))
                {
                    list[MenuListContainer.Actions].Add(new MenuItem(Catalog.GetString("Unma_ximize"), MaximizeIcon,
                                                                     (o, a) => WindowControl.UnmaximizeWindows(ManagedWindows)));
                }
                else
                {
                    list[MenuListContainer.Actions].Add(new MenuItem(Catalog.GetString("Ma_ximize"), MaximizeIcon,
                                                                     (o, a) => WindowControl.MaximizeWindows(ManagedWindows)));
                }

                if (ManagedWindows.Any(w => w.IsMinimized))
                {
                    list[MenuListContainer.Actions].Add(new MenuItem(Catalog.GetString("_Restore"), MinimizeIcon,
                                                                     (o, a) => WindowControl.RestoreWindows(ManagedWindows)));
                }
                else
                {
                    list[MenuListContainer.Actions].Add(new MenuItem(Catalog.GetString("Mi_nimize"), MinimizeIcon,
                                                                     (o, a) => WindowControl.MinimizeWindows(ManagedWindows)));
                }

                list[MenuListContainer.Actions].Add(new MenuItem(Catalog.GetString("_Close All"), CloseIcon,
                                                                 (o, a) => WindowControl.CloseWindows(ManagedWindows)));

                foreach (Wnck.Window window in ManagedWindows)
                {
                    list[MenuListContainer.Windows].Add(new WindowMenuItem(window, window.Icon));
                }
            }

            return(list);
        }
예제 #11
0
        public void FocusPrimaryWindow()
        {
            var window = ManagedWindows.FirstOrDefault();

            window?.Focus();
        }
예제 #12
0
        public void CloseFocusedWindow()
        {
            var window = ManagedWindows.FirstOrDefault(w => w.IsFocused);

            window?.Close();
        }
예제 #13
0
 public void RemoveWindow(KOSManagedWindow w)
 {
     ManagedWindows.Remove(w);
 }
예제 #14
0
 public void AddWindow(KOSManagedWindow w)
 {
     ManagedWindows.Add(w);
 }