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

SDLMain.m: replace CPS* stuff with activateIgnoringOtherApps #775

Closed
SDLBugzilla opened this issue Feb 10, 2021 · 3 comments
Closed

SDLMain.m: replace CPS* stuff with activateIgnoringOtherApps #775

SDLBugzilla opened this issue Feb 10, 2021 · 3 comments
Labels
endoflife Bug might be valid, but SDL-1.2 is EOL.

Comments

@SDLBugzilla
Copy link
Collaborator

SDLBugzilla commented Feb 10, 2021

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: HG 1.2
Reported for operating system, platform: Mac OS X (All), All

Comments on the original bug report:

On 2018-03-24 21:16:46 +0000, Ozkan Sezer wrote:

Created attachment 3212
osx_main.patch

CPS stuff are deprecated and emit warnings at runtime, e.g.:

warning: CPSGetCurrentProcess(): This call is deprecated and should not be called anymore
warning: CPSSetForegroundOperationState() (as above)
warning: capture_display; Captured mirror master 0x350000c1 (unit 1) on behalf of slave 0x042716c0 (unit 0)

http://lists.libsdl.org/pipermail/sdl-libsdl.org/2006-April/055749.html
suggests doing something like:

 ProcessSerialNumber psn = { 0, kCurrentProcess};
 TransformProcessType (&psn, kProcessTransformToForegroundApplication);
 SetFrontProcess (&psn);

And SetFrontProcess is deprecated in 10.9. Processes.h suggests
[[NSApplication sharedApplication] activateIgnoringOtherApps: YES]
to make one's own application frontmost.

So, the attached patch is what I came up with: Please review, and
apply if it's OK.

On 2018-06-22 08:58:47 +0000, Ozkan Sezer wrote:

Any comments on this?

On 2018-06-22 17:43:31 +0000, Sam Lantinga wrote:

This seems reasonable. Does it work? If so, go ahead and commit it.

On 2018-06-22 17:49:40 +0000, Ozkan Sezer wrote:

I've been using it in uhexen2 (uhexen2.sf.net) for quite some time,
no ill effects reported so far. Will push shortly.

On 2018-06-22 18:04:46 +0000, Ozkan Sezer wrote:

Pushed: http://hg.libsdl.org/SDL/rev/67f391c74aee

On 2019-11-12 19:43:39 +0000, Dominik Reichardt wrote:

A bit late to the party, but this change is badly affecting DOSBox and possibly other programs.
With this changeset, starting the DOSBox binary from terminal opens DOSBox in the background and even worse, every keyboard input is sent to the terminal but not to DOSBox.

BUT if you put the binary in an app bundle and open the app, all is fine.

On 2019-11-12 20:05:37 +0000, Ozkan Sezer wrote:

(In reply to Dominik Reichardt from comment # 5)

A bit late to the party, but this change is badly affecting DOSBox and
possibly other programs.
With this changeset, starting the DOSBox binary from terminal opens DOSBox
in the background and even worse, every keyboard input is sent to the
terminal but not to DOSBox.

BUT if you put the binary in an app bundle and open the app, all is fine.

  • Do you have a patch?
  • Does reverting this patch make things work, despite the
    deprecation warnings, especially on new macOS versions?

On 2019-11-12 20:23:58 +0000, Dominik Reichardt wrote:

sorry, I have no patch. I have no clue what it does, only that it took me a while to hunt down where the culprit was.

Reverting the patch makes it work correctly again. Compiled and run on macOS 10.14 and also run successfully on macOS 10.15 (though just a late beta of 10.15 not the actual release).

[[NSApplication sharedApplication] activateIgnoringOtherApps: YES];
or
[NSApplication sharedApplication];
makes no difference. Only the other stuff taken out makes it not work (or work when put back in).

On 2019-11-12 20:34:49 +0000, Ozkan Sezer wrote:

Sam, Ryan: Do you have a better fix, or should I just revert this?

On 2019-11-13 04:35:18 +0000, Sam Lantinga wrote:

Go ahead and revert it.

On 2019-11-13 07:00:35 +0000, Ozkan Sezer wrote:

Reverted it in all projects.

Keeping the bug report open because the issue still needs fixing.

@icculus
Copy link
Collaborator

icculus commented Dec 11, 2021

I think this works in an app bundle and not from the command line because the magic happens in TransformProcessType (&psn, kProcessTransformToForegroundApplication); to turn the thing into a full-fledged GUI app with a Dock icon and menubar, more or less. This API was introduced in 10.3 (not Carbon) and is not deprecated.

So we probably need something a mix, like:

ProcessSerialNumber psn = { 0, kCurrentProcess};
TransformProcessType (&psn, kProcessTransformToForegroundApplication);
[[NSApplication sharedApplication] activateIgnoringOtherApps: YES]

Going to try this in an sdl12-compat branch, and I'll report back here later tonight if it works.

@icculus
Copy link
Collaborator

icculus commented Dec 14, 2021

Okay, this works. If someone (NOT ME) wants to merge this into classic SDL 1.2, these patches will probably apply directly:

libsdl-org/sdl12-compat#152

(in fact, you might just be able to copy the src/SDLmain/macosx directory from sdl12-compat right into SDL 1.2.)

I added this revert...

libsdl-org/sdl12-compat@ca53ab4

...because SDL2 handles it for us, but it might be good to add this code to SDL 1.2 (not 1.2's SDLmain).

@sezero
Copy link
Collaborator

sezero commented Dec 14, 2021

I added this revert...

libsdl-org/sdl12-compat@ca53ab4

...because SDL2 handles it for us, but it might be good to add this code to SDL 1.2 (not 1.2's SDLmain).

That's 10.6+ only, yes?

@slouken slouken added endoflife Bug might be valid, but SDL-1.2 is EOL. and removed bug labels May 15, 2022
@slouken slouken closed this as completed May 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
endoflife Bug might be valid, but SDL-1.2 is EOL.
Projects
None yet
Development

No branches or pull requests

4 participants