Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac exports on steam require double click to use left mouse button #68745

Closed
Miziziziz opened this issue Nov 16, 2022 · 11 comments · Fixed by #68777
Closed

Mac exports on steam require double click to use left mouse button #68745

Miziziziz opened this issue Nov 16, 2022 · 11 comments · Fixed by #68777

Comments

@Miziziziz
Copy link

Godot version

3.5.1

System information

macOS 13.0 Ventura

Issue description

Not sure if this is a steam issue or a godot issue, but it happens on two of my games on steam that I've tested. Can provide copies to testers if they need.

Basically if you open the game left click is unresponsive unless you click twice. The fix is to not move the mouse at all until the game menu fully loads. Notably the same bug is found in CSGO here: https://steamcommunity.com/discussions/forum/2/1752358461539279191/

Steps to reproduce

Open a godot-made game in steam from a macbook.
I can provide a key for one if needed

Minimal reproduction project

No response

@bruvzg
Copy link
Member

bruvzg commented Nov 16, 2022

Is it an issue if you run the .app bundle directly from Finder instead of running it from Steam? It's possible that macOS Ventura broke the window activation hack again (and if Steam is running executable directly, instead of a bundle).

@bruvzg bruvzg self-assigned this Nov 16, 2022
@bruvzg bruvzg added this to the 4.0 milestone Nov 16, 2022
@bruvzg
Copy link
Member

bruvzg commented Nov 16, 2022

Also, are "semaphore" buttons in the window title bar grayed out when it's happening?

@Miziziziz
Copy link
Author

Miziziziz commented Nov 16, 2022

Is it an issue if you run the .app bundle directly from Finder instead of running it from Steam? It's possible that macOS Ventura broke the window activation hack again (and if Steam is running executable directly, instead of a bundle).

Yeah it works fine running it from the finder

Also, are "semaphore" buttons in the window title bar grayed out when it's happening?

Sorry what do you mean by semaphore buttons?

@bruvzg
Copy link
Member

bruvzg commented Nov 16, 2022

Screenshot 2022-11-16 at 22 03 12

@Miziziziz
Copy link
Author

yes they are grayed out, and if I move the cursor outside and click the bar it fixes the problem

@bruvzg
Copy link
Member

bruvzg commented Nov 16, 2022

OK, it seems to be the same issue, but now it's manifesting when you run the executable directly even if it's bundled (on previous OS versions it was doing in only for unbundled apps and when running from terminal).

Firstly, Steam config for the game should specify the path to the bundle instead of the executable, e.g., Game.app not Game.app/Contents/MacOS/Game. This should fix the issue.

This is working with non-Steam shortcuts added to Steam.

Also, try the following patch (I have briefly tested it, and it seems to work, but I do not what API Steam is using, so it might need more testing).

diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index cc9b9287ed..61b6a73bec 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -195,7 +195,9 @@ static NSCursor *cursorFromSelector(SEL selector, SEL fallback = nil) {
 
 - (void)applicationDidFinishLaunching:(NSNotification *)notice {
 	NSString *nsappname = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
-	if (nsappname == nil || isatty(STDOUT_FILENO) || isatty(STDIN_FILENO) || isatty(STDERR_FILENO)) {
+	NSString *nsbundleid_env = [NSString stringWithUTF8String:getenv("__CFBundleIdentifier")]; 
+	NSString *nsbundleid = [[NSBundle mainBundle]bundleIdentifier];
+	if (nsappname == nil || isatty(STDOUT_FILENO) || isatty(STDIN_FILENO) || isatty(STDERR_FILENO) || ![nsbundleid isEqualToString:nsbundleid_env]) {
 		// If the executable is started from terminal or is not bundled, macOS WindowServer won't register and activate app window correctly (menu and title bar are grayed out and input ignored).
 		[self performSelector:@selector(forceUnbundledWindowActivationHackStep1) withObject:nil afterDelay:0.02];
 	}

@akien-mga
Copy link
Member

akien-mga commented Nov 17, 2022

Bad config - steamdb.info/app/404790/config (yep, Godot itself is affected).

Thanks, I just edited it to point to Godot.app directly. It still passes --path $HOME -p as arguments, will that work?

@bruvzg
Copy link
Member

bruvzg commented Nov 17, 2022

It still passes --path $PATH -p as arguments, will that work?

It should work, at least with non-Steam bundle arguments are passed correctly.

@bruvzg
Copy link
Member

bruvzg commented Nov 17, 2022

I just edited it to point to Godot.app directly.

Steam version activation issue seems to be fixed. Arguments are passed, but I'm not sure what it supposed to do. Is it for self-contained mode? It's not working on macOS in 3.x anyway, and I think we decided not to fix it last time it was discussed (fixed in 4.0 - #56762).

@akien-mga
Copy link
Member

Steam version activation issue seems to be fixed. Arguments are passed, but I'm not sure what it supposed to do.

The --path $HOME (previous $PATH mention was a typo) I think is to set the working path to $HOME, so that when you create a new project it shows you your home and not the Steam installation folder.

And -p is to force running the project manager in case you put a project.godot file in your $HOME by mistake.

@Miziziziz
Copy link
Author

Firstly, Steam config for the game should specify the path to the bundle instead of the executable, e.g., Game.app not Game.app/Contents/MacOS/Game. This should fix the issue.

Oh yeah this fixed it, thanks!

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

Successfully merging a pull request may close this issue.

4 participants