Skip to content

runloop should be more flexible #6

@tim-weis

Description

@tim-weis

This crate is awesome! I've tried virtually every native Windows windowing crate out there, and wasn't happy with any of them, for one reason or another. This one, though, is sweet: Well designed, documented in excruciating detail, concise, and embarrassingly tiny.

So tiny in fact, that I almost feel bad for proposing to make it larger. Anyway, here it goes:

As currently implemented, runloop's logic is fixed: It waits for a message to arrive, passes it on to an optional accelerator table, translates, and dispatches it. That works for a wide range of applications, but doesn't quite address a number common scenarios, namely the following three:

  1. A dialog-like window with automatic keyboard navigation.

    There's a hidden gem (?) in the Windows API, that gives you standard keyboard navigation for free: IsDialogMessageW. But it has to be called in your message loop (and it's a bit involved, too). That would be nice to have (if child window creation os on the road map).

  2. A UI thread that waits on messages and synchronization primitives.

    MsgWaitForMultipleObjects and MsgWaitForMultipleObjectsEx allow clients to fire off asynchronous operations and have them deliver status updates onto the UI thread. This is a common scenario, e.g. when using overlapped I/O. Again, this needs to be implemented in the message loop.

  3. A game-like loop with idle processing.

    The canonical message loop for games constantly polls for messages, and then moves on to do other calculations when the current batch of messages has been processed. In C this looks something like this:

    while (true) {
        while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) {
            TranslateMessage(&msg);
            DispatchMessageW(&msg);
        }
        // Perform other calculations
    }

    This scenario also isn't covered by runloop as currently implemented.

Though I don't have an immediate need for any of the above, I can see myself running into one of those limitations soon(-ish). Does this sound like something, that could be implemented in a future revision of this crate?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions