public void SetWrapNeighbor (Wnck.MotionDirection direction, Desk newwrapneighbor) { Desk oldwrapneighbor = GetWrapNeighbor (direction); if (oldwrapneighbor != null && oldwrapneighbor != newwrapneighbor) { wrapneighbors.Remove (direction); if (oldwrapneighbor.GetWrapNeighbor (OppositeDirection (direction)) == this) oldwrapneighbor.SetWrapNeighbor (OppositeDirection (direction), null); } if (oldwrapneighbor != newwrapneighbor && newwrapneighbor != null) { wrapneighbors.Add (direction, newwrapneighbor); newwrapneighbor.SetWrapNeighbor (OppositeDirection (direction), this); } }
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); }
public Desk [,] GetDeskGridLayout () { Desk next, desk = GetUpperLeftDesk (); Gdk.Point gridsize = GetDeskGridSize (); Desk [,] grid = new Desk [gridsize.X, gridsize.Y]; grid [0, 0] = desk; int x = 0; for (int y = 0; y < gridsize.Y; y++) { x = 0; while ((next = desk.GetNeighbor (Wnck.MotionDirection.Right)) != null) { desk = next; x++; if (gridsize.X - 1 < x) break; grid [x, y] = desk; } if (gridsize.Y - 1 > y) { desk = (grid [0, y] != null ? grid [0, y].GetNeighbor (Wnck.MotionDirection.Down) : null); grid [0, y+1] = desk; } } return grid; }