Exemplo n.º 1
0
        public void SetNeighbor(Wnck.MotionDirection direction, Desk newneighbor)
        {
            Desk oldneighbor = GetNeighbor(direction);

            if (oldneighbor != null && oldneighbor != newneighbor)
            {
                neighbors.Remove(direction);
                if (oldneighbor.GetNeighbor(OppositeDirection(direction)) == this)
                {
                    oldneighbor.SetNeighbor(OppositeDirection(direction), null);
                }
            }
            if (oldneighbor != newneighbor && newneighbor != null)
            {
                neighbors.Add(direction, newneighbor);

                if (GetNeighbor(OppositeDirection(direction)) == null)
                {
                    Desk oldwrapneighbor = newneighbor.GetWrapNeighbor(OppositeDirection(direction));
                    if (oldwrapneighbor != null)
                    {
                        SetWrapNeighbor(OppositeDirection(direction), oldwrapneighbor);
                    }
                    else
                    {
                        SetWrapNeighbor(OppositeDirection(direction), newneighbor);
                    }
                }

                newneighbor.SetNeighbor(OppositeDirection(direction), this);
            }
        }
Exemplo n.º 2
0
        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);
            }
        }
		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);
		}
Exemplo n.º 4
0
		public void SetNeighbor (Wnck.MotionDirection direction, Desk newneighbor)
		{
			Desk oldneighbor = GetNeighbor (direction);
			if (oldneighbor != null && oldneighbor != newneighbor) {
				neighbors.Remove (direction);
				if (oldneighbor.GetNeighbor (OppositeDirection (direction)) == this)
					oldneighbor.SetNeighbor (OppositeDirection (direction), null);
			}
			if (oldneighbor != newneighbor && newneighbor != null) {
				neighbors.Add (direction, newneighbor);
				
				if (GetNeighbor (OppositeDirection (direction)) == null) {
					Desk oldwrapneighbor = newneighbor.GetWrapNeighbor (OppositeDirection (direction));
					if (oldwrapneighbor != null) {
						SetWrapNeighbor (OppositeDirection (direction), oldwrapneighbor);
					} else {
						SetWrapNeighbor (OppositeDirection (direction), newneighbor);
					}
				}
				
				newneighbor.SetNeighbor (OppositeDirection (direction), this);
			}
		}