void HandleWnckScreenDefaultActiveWorkspaceChanged(object o, ActiveWorkspaceChangedArgs args) { Desk activedesk = Desks.Find(desk => desk.IsActive); if (activedesk != null && activedesk.Parent != args.PreviousWorkspace) { DeskGrid = activedesk.GetDeskGridLayout(); } UpdateItem(); QueueRedraw(); }
void UpdateDesks() { lock (Desks) { DeskGrid = null; Desks.ForEach(desk => desk.Dispose()); Desks.Clear(); string DeskNameFormatString; if (Wnck.Screen.Default.WorkspaceCount > 1) { DeskNameFormatString = Catalog.GetString("Desk") + " {0}"; } else { DeskNameFormatString = Catalog.GetString("Virtual Desk") + " {0}"; } foreach (Wnck.Workspace workspace in Wnck.Screen.Default.Workspaces) { if (workspace.IsVirtual) { int deskWidth = workspace.Screen.Width; int deskHeight = workspace.Screen.Height; int rows = workspace.Height / deskHeight; int columns = workspace.Width / deskWidth; for (int row = 0; row < rows; row++) { for (int col = 0; col < columns; col++) { int desknumber = (int)(columns * row + col + 1); Gdk.Rectangle area = new Gdk.Rectangle(col * deskWidth, row * deskHeight, deskWidth, deskHeight); Desk desk = new Desk(string.Format(DeskNameFormatString, desknumber), desknumber, area, workspace); desk.SetNeighbor(Wnck.MotionDirection.Down, Desks.Find(d => d.Area.X == area.X && (d.Area.Y - deskHeight == area.Y))); desk.SetNeighbor(Wnck.MotionDirection.Up, Desks.Find(d => d.Area.X == area.X && (d.Area.Y + deskHeight == area.Y))); desk.SetNeighbor(Wnck.MotionDirection.Right, Desks.Find(d => (d.Area.X - deskWidth == area.X) && d.Area.Y == area.Y)); desk.SetNeighbor(Wnck.MotionDirection.Left, Desks.Find(d => (d.Area.X + deskWidth == area.X) && d.Area.Y == area.Y)); Desks.Add(desk); } } } else { Desk desk = new Desk(workspace); desk.SetNeighbor(Wnck.MotionDirection.Down, Desks.Find(d => d.Parent == workspace.GetNeighbor(Wnck.MotionDirection.Down))); desk.SetNeighbor(Wnck.MotionDirection.Up, Desks.Find(d => d.Parent == workspace.GetNeighbor(Wnck.MotionDirection.Up))); desk.SetNeighbor(Wnck.MotionDirection.Right, Desks.Find(d => d.Parent == workspace.GetNeighbor(Wnck.MotionDirection.Right))); desk.SetNeighbor(Wnck.MotionDirection.Left, Desks.Find(d => d.Parent == workspace.GetNeighbor(Wnck.MotionDirection.Left))); Desks.Add(desk); } } Desk activedesk = Desks.Find(d => d.IsActive); if (activedesk != null) { DeskGrid = activedesk.GetDeskGridLayout(); } } if (DesksChanged != null) { DesksChanged(new object(), EventArgs.Empty); } }