Skip to content

User code cannot distinguish live-resize expose events from regular ones #13243

Closed
@slime73

Description

@slime73

I have live resize implemented in my 'traditional' style / while-loop-and-polling app, via an SDL event watcher that listens for SDL_EVENT_WINDOW_EXPOSED and redraws.

This sort of works but introduces issues including stuttering during resizes, because the app ends up redrawing from inside the SDL_EVENT_WINDOW_EXPOSED event in situations where the event didn't originate from a live-resize OS notification, and those situations can be pretty frequent even during a resize.

I'm testing a local change to SDL_OnWindowLiveResizeUpdate which just sends 1 instead of 0 for the event.window.data1 event field. When my code detects that and only redraws if it is 1, the issues I've been having go away.

If that change is desired, I could make a pull request for it - I think it shouldn't introduce any backwards incompatibilities since the data1 field wasn't being used for anything meaningful in the expose event before. Or if people have better ideas I'm interested in those too. :)

The code in SDL is here:

SDL/src/video/SDL_video.c

Lines 4136 to 4145 in 7d9fd48

void SDL_OnWindowLiveResizeUpdate(SDL_Window *window)
{
if (SDL_HasMainCallbacks()) {
SDL_IterateMainCallbacks(false);
} else {
// Send an expose event so the application can redraw
SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_EXPOSED, 0, 0);
}
SDL_PumpEventMaintenance();

I haven't looked much at how it all works with a callback-style app instead of a traditional one, so I'm not sure if a similar idea would be useful there or not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions