godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.07k stars 69 forks source link

Add support for "click-though" (mouse activity captured by an unfocused window) on macOS #8711

Open OKGougou opened 6 months ago

OKGougou commented 6 months ago

Describe the project you are working on

SpeakerView is the 3D view (made with Godot) of a concert hall's speaker configuration for SpatGRIS (a sound spatilization tool).

SpeakerView

Describe the problem or limitation you are having in your project

SpatGRIS and SpeakerView form an inseparable pair. Users often switch from one window to the other when working on a project. When the SpeakerView window is not in focus, the first mouse click in the window is an input event under Linux and Windows, but not under MacOS. The user must click in the window a second time to interact with SpeakerView.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Godot can be given click-though support on MacOS by adding the instance method [acceptsFirstMouse(for:)] (https://developer.apple.com/documentation/appkit/nsview/1483410-acceptsfirstmouse) to the source code and recompiling it and the export templates.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

In the file platform/macos/godot_content_view.mm, add the method:

- (BOOL)acceptsFirstMouse:(NSEvent *)event {
    return YES;
}

Not sure if it should go under the Focus or Mouse section...

If this enhancement will not be used often, can it be worked around with a few lines of script?

No, this is a core feature for input events on MacOS.

Is there a reason why this should be core and not an add-on in the asset library?

This change would allow desktop applications created with Godot to act in the same way on Linux, Windows and MacOS. I don't think an add-on would solve this problem.

Calinou commented 6 months ago

Should this be done by default? This would better match Windows/Linux behavior and lead to fewer surprises when exporting a project across platforms, but at the same time, I think most macOS apps have this disabled by default.

OKGougou commented 6 months ago

Indeed, this is not the default behavior of most MacOS applications. But it seems that a few components are chosen to respond to click-through, such as buttons, sliders or toggles. I know that JUCE implements it. Firefox and Qt under certain conditions. Maybe it would be better to have an option in the Godot project settings?