Skip to content

SDL3: Bug: SDL_PenProximityEvent never supplies a no-zero windowID #12356

@Elbagast

Description

@Elbagast

Present in SDL 3.2.4 and affects all platforms.

Documentation for SDL_PenProximityEvent states:

SDL_WindowID windowID; /**< The window with pen focus, if any */

However these events will never have a non-zero windowID because the functions which dispatch them do not set it and cannot ever supply one, because they do not accept an argument for a relevant window.

Solution:

  • Modify function SDL_AddPenDevice to add an argument SDL_Window * window and use that as a source of the event member windowID if the window is a valid pointer.
  • Modify function SDL_RemovePenDevice to add an argument SDL_Window *window and use that as a source of the event member windowID if the window is a valid pointer.
  • Update all calls to these functions to supply a window if available, otherwise nullptr.

Function signatures would look something like this, though since these are API internal you may have other ideas about argument order:

SDL_PenID SDL_AddPenDevice(Uint64 timestamp, const char *name, const SDL_PenInfo *info, void *handle, SDL_Window *window);

SDL_PenID SDL_RemovePenDevice(Uint64 timestamp, SDL_PenID instance_id, SDL_Window *window);

The check for window validity can be the same as in other pen functions, such that you would only need to add this line to the event configuration for both functions:

event.pproximity.windowID = window ? window->id : 0;

The Windows platform code that calls these for WM_POINTER messages look like they would have no issue supplying a window in the same way as other pen events. I don't know about other platforms or pen backends because I haven't been looking into them.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions