Skip to content

[SDL3] Window used in plugin as child of host will lose mouse events on macOS #12745

Description

@kunitoki

I have a small framework built on top of SDL2 which can target audio plugins editor windows.

I tried porting the framework to SDL3 but plugin windows (standalone windows work fine) but on Cocoa (macOS Sequoia), when i open the plugin window from the host and click the slider inside the window and drag it (without making the cursor to leave the window), an immediate SDL_SetMouseFocus(NULL) is generated because SDL is detecting we are outside of the window (which we are not!) and then any mouse interaction with the window is failing badly.

Image

Seems like this is not doing the right detection:

void Cocoa_HandleMouseEvent(SDL_VideoDevice *_this, NSEvent *event)
{
    // ...

    // All events except NSEventTypeMouseExited can only happen if the window
    // has mouse focus, so we'll always set the focus even if we happen to miss
    // NSEventTypeMouseEntered, which apparently happens if the window is
    // created under the mouse on macOS 12.7
    NSEventType event_type = [event type];
    if (event_type == NSEventTypeMouseExited) {
        Cocoa_MouseFocus = NULL;
    } else {
        Cocoa_MouseFocus = [event window];
    }

The exact same plugin works fine in SDL2 (but i don't receive the mouse enter and leave events).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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