Skip to content

all: nuke WindowGroup, overhaul Application, WindowBase, top-level an…#59

Merged
dblohm7 merged 1 commit intomainfrom
aaron/nuke_windowgroup
Apr 11, 2024
Merged

all: nuke WindowGroup, overhaul Application, WindowBase, top-level an…#59
dblohm7 merged 1 commit intomainfrom
aaron/nuke_windowgroup

Conversation

@dblohm7
Copy link
Member

@dblohm7 dblohm7 commented Apr 3, 2024

…d modal message loops

WindowGroup was a bad abstraction that supported creating windows across multiple threads in the same application. This is completely opposite to the Win32 application model and should never have been supported. This PR completely removes WindowGroup, moving any of its code that was actually useful over to more appropriate locations.

Instead, we add a top-level message pump via Application. I also did not particularly like the way that modal message pumps were attached to Forms, so I reimplemented the modal message loop as part of Application and then modified Form and Dialog to use the new stuff. This also allows us to fix issue 42: we don't need events to track how many of themselves are on the call stack; we guarantee that there are no events pending by virtual of the modal loop calling OnPostDispatch.

To make all of this stuff happen, I rewrote a bunch of things in Application. I removed lazy initialization of Application; this is too fragile when we have important things that should ideally be initialized before we start creating windows and such. Programs must now explicitly call walk.InitApp() to initialize the framework, and call walk.App().Run() to execute the top-level message pump. We also add an allocator for WM_APP messages and perform setup of a rudimentary handler of (de)cloaking events.

This PR also changes a bunch of things in WindowBase. Window initialization is broken down into smaller pieces such that they can be integrated into WM_NCCREATE and WM_CREATE handlers. We also move most of the implementation of WindowBase.Dispose into the WM_DESTROY handler. We add an allocator for WM_USER messages.

We also remove Max and Min in favour of the Go's new built-in implementations. Some additional minor cleanup is done here and there. It's not directly related to the issues at hand, but since this PR already requires so many changes to example code (and eventually our own app), I felt that it was easier to do these things all at once.

All sample programs in this repo have been updated accordingly. A follow-up PR is ready for our GUI but will not be merged until after the next release.

Fixes #33
Fixes #42
Fixes #53
Fixes #58

@dblohm7 dblohm7 requested a review from nickkhyl April 3, 2024 17:23
Copy link
Member

@nickkhyl nickkhyl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with the following changes!

…d modal message loops

WindowGroup was a bad abstraction that supported creating windows across
multiple threads in the same application. This is completely opposite to
the Win32 application model and should never have been supported. This PR
completely removes WindowGroup, moving any of its code that was actually
useful over to more appropriate locations.

Instead, we add a top-level message pump via Application. I also did not
particularly like the way that modal message pumps were attached to Forms,
so I reimplemented the modal message loop as part of Application and then
modified Form and Dialog to use the new stuff. This also allows us to fix
issue 42: we don't need events to track how many of themselves are on the
call stack; we guarantee that there are no events pending by virtual of
the modal loop calling OnPostDispatch.

To make all of this stuff happen, I rewrote a bunch of things in Application.
I removed lazy initialization of Application; this is too fragile when we
have important things that should ideally be initialized before we start
creating windows and such. Programs must now explicitly call walk.InitApp()
to initialize the framework, and call walk.App().Run() to execute the
top-level message pump. We also add an allocator for WM_APP messages and
perform setup of a rudimentary handler of (de)cloaking events.

This PR also changes a bunch of things in WindowBase. Window initialization
is broken down into smaller pieces such that they can be integrated into
WM_NCCREATE and WM_CREATE handlers. We also move most of the implementation
of WindowBase.Dispose into the WM_DESTROY handler. We add an allocator for
WM_USER messages.

We also remove Max and Min in favour of the Go's new built-in implementations.
Some additional minor cleanup is done here and there. It's not directly
related to the issues at hand, but since this PR already requires so many
changes to example code (and eventually our own app), I felt that it was
easier to do these things all at once.

All sample programs in this repo have been updated accordingly.
A follow-up PR is ready for our GUI but will not be merged until after the
next release.

Fixes #33
Fixes #42
Fixes #53
Fixes #58

Signed-off-by: Aaron Klotz <aaron@tailscale.com>
@dblohm7 dblohm7 force-pushed the aaron/nuke_windowgroup branch from 6a81deb to 14f5a03 Compare April 11, 2024 19:15
@dblohm7 dblohm7 merged commit 325926d into main Apr 11, 2024
@dblohm7 dblohm7 deleted the aaron/nuke_windowgroup branch April 11, 2024 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants