public void ScanForWindowUpdates() { Win32Window[] windows = GetDesktopWindowHandlesAndTitles(); foreach (Win32Window window in windows) { Win32Window existing = _windows.FirstOrDefault(w => w.Handle == window.Handle); if (existing == null) { _windows.Add(window); WindowAdded?.Invoke(this, new NativeWindowEventArgs(window)); } else if (!existing.Equals(window)) { existing.UpdateFrom(window); WindowUpdated?.Invoke(this, new NativeWindowEventArgs(window)); } } List <Win32Window> toRemove = new List <Win32Window>(); foreach (Win32Window window in _windows) { if (!windows.Any(w => w.Handle == window.Handle)) { toRemove.Add(window); } } foreach (Win32Window window in toRemove) { _windows.Remove(window); WindowRemoved?.Invoke(this, new NativeWindowEventArgs(window)); } }
public void UpdateWindow(IWindow window, WindowUpdateType type) { if (_windowsToWorkspaces.ContainsKey(window)) { Logger.Trace("UpdateWindow({0})", window); var workspace = _windowsToWorkspaces[window]; if (window.IsFocused) { var monitor = _context.WorkspaceContainer.GetCurrentMonitorForWorkspace(workspace); if (monitor != null) { _context.MonitorContainer.FocusedMonitor = monitor; } else { if (type == WindowUpdateType.Foreground) { // TODO: show flash for workspace (in bar?) Logger.Trace("workspace.IsIndicating = true for workspace {0}", workspace); workspace.IsIndicating = true; WorkspaceUpdated?.Invoke(); } } if (type == WindowUpdateType.Move) { TrySwapWindowToMouse(window); } _windowsToWorkspaces[window].UpdateWindow(window, type); WindowUpdated?.Invoke(window, workspace); } } }
private void UpdateWindow(IntPtr handle, WindowUpdateType type) { if (type == WindowUpdateType.Show && _windows.ContainsKey(handle)) { var window = _windows[handle]; WindowUpdated?.Invoke(window, type); } else if (type == WindowUpdateType.Show) { RegisterWindow(handle); } else if (type == WindowUpdateType.Hide && _windows.ContainsKey(handle)) { var window = _windows[handle]; if (!window.DidManualHide) { UnregisterWindow(handle); } else { WindowUpdated?.Invoke(window, type); } } else if (_windows.ContainsKey(handle)) { var window = _windows[handle]; WindowUpdated?.Invoke(window, type); } }
private void WindowMove(IntPtr handle) { if (_mouseMoveWindow != null && _windows.ContainsKey(handle)) { var window = _windows[handle]; if (_mouseMoveWindow == window) { WindowUpdated?.Invoke(window, WindowUpdateType.Move); } } }
private void EndWindowMove(IntPtr handle) { if (_windows.ContainsKey(handle)) { var window = _windows[handle]; Logger.Debug("EndWindowMove[{0}]", window); HandleWindowMoveEnd(); WindowUpdated?.Invoke(window, WindowUpdateType.MoveEnd); } }