Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove usage of events for the core #99

Closed
Tracked by #100
dalyIsaac opened this issue Jun 28, 2022 · 0 comments · Fixed by #103
Closed
Tracked by #100

Remove usage of events for the core #99

dalyIsaac opened this issue Jun 28, 2022 · 0 comments · Fixed by #103
Labels
core Whim refactor The code can be simplified/moved/cleaned up

Comments

@dalyIsaac
Copy link
Owner

Relying on events for internal state changes leads to bad interleaving and out-of-order updates (#93).

Remove the following subscriptions:

src\Whim\Monitor\MonitorManager.cs:
61  	public void Initialize()
62  	{
63  		// Listen for changes in the monitors.
64: 		SystemEvents.DisplaySettingsChanging += SystemEvents_DisplaySettingsChanging;
65: 		_configContext.WindowManager.WindowFocused += WindowManager_WindowFocused;
66  	}
67
68  	private void WindowManager_WindowFocused(object? sender, WindowEventArgs e)

src\Whim\Monitor\Screen.cs:
164  						//sync the UserPreference.Desktop change event.  We'll keep count
165  						//of desktop changes so that the WorkingArea property on Screen
166  						//instances know when to invalidate their cache.
167: 						SystemEvents.UserPreferenceChanged += new UserPreferenceChangedEventHandler(OnUserPreferenceChanged);
168
169  						s_desktopChangedCount = 0;
170  					}

src\Whim\Workspace\Workspace.cs:
118  		}
119
120  		// Subscribe to window focus events
121: 		_configContext.WindowManager.WindowFocused += WindowManager_WindowFocused;
122  	}
123
124  	private void WindowManager_WindowFocused(object? sender, WindowEventArgs e)

src\Whim\Workspace\WorkspaceManager.cs:
76  		}
77
78  		// Subscribe to <see cref="IWindowManager"/> events.
79: 		_configContext.WindowManager.WindowRegistered += WindowManager_WindowRegistered;
80: 		_configContext.WindowManager.WindowUnregistered += WindowManager_WindowUnregistered;
81
82  		// Initialize each of the workspaces.
83  		foreach (IWorkspace workspace in _workspaces)

Keep events for plugins to subscribe to changes.

@dalyIsaac dalyIsaac added refactor The code can be simplified/moved/cleaned up core Whim labels Jun 28, 2022
@dalyIsaac dalyIsaac moved this to In Progress in Whim Jun 28, 2022
@dalyIsaac dalyIsaac mentioned this issue Jul 1, 2022
7 tasks
@dalyIsaac dalyIsaac linked a pull request Jul 3, 2022 that will close this issue
Repository owner moved this from In Progress to Done in Whim Jul 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Whim refactor The code can be simplified/moved/cleaned up
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant