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)); }
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(); }
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(); }
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); }
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; }
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); }
void SetIndicator() { int count = ManagedWindows.Count(); if (count > 1) { Indicator = ActivityIndicator.SinglePlus; } else if (count == 1) { Indicator = ActivityIndicator.Single; } else { Indicator = ActivityIndicator.None; } }
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()); } }
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); }
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); }
public void FocusPrimaryWindow() { var window = ManagedWindows.FirstOrDefault(); window?.Focus(); }
public void CloseFocusedWindow() { var window = ManagedWindows.FirstOrDefault(w => w.IsFocused); window?.Close(); }
public void RemoveWindow(KOSManagedWindow w) { ManagedWindows.Remove(w); }
public void AddWindow(KOSManagedWindow w) { ManagedWindows.Add(w); }