We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2858 - [Patch] Mac: update some internal code to use modern codepaths rather than deprecated functionality, when available
Summary: [Patch] Mac: update some internal code to use modern codepaths rather than de...
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.0
Hardware: x86_64 Mac OS X (All)
: P2 minor
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords: triage-2.0.4
Depends on:
Blocks:
 
Reported: 2015-01-27 18:56 UTC by Alex Szpakowski
Modified: 2015-02-20 01:06 UTC (History)
1 user (show)

See Also:


Attachments
Patch to use some modern Mac APIs rather than deprecated ones, when available (4.38 KB, patch)
2015-01-27 18:56 UTC, Alex Szpakowski
Details | Diff
Patch to use some modern Mac APIs rather than deprecated ones, when available (4.28 KB, patch)
2015-01-27 20:44 UTC, Alex Szpakowski
Details | Diff
Patch to prefer some modern Mac APIs over deprecated ones (v3) (4.80 KB, patch)
2015-02-02 07:45 UTC, Alex Szpakowski
Details | Diff
Patch to prefer some modern Mac APIs over deprecated ones (v4) (4.99 KB, patch)
2015-02-02 09:20 UTC, Alex Szpakowski
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Szpakowski 2015-01-27 18:56:11 UTC
Created attachment 2007 [details]
Patch to use some modern Mac APIs rather than deprecated ones, when available

SDL's Mac code for preventing the screensaver from activating and for making the app show up in the Dock is using long-deprecated APIs. I have attached a patch to use more modern APIs when available.
Comment 1 Alex Szpakowski 2015-01-27 20:44:17 UTC
Created attachment 2008 [details]
Patch to use some modern Mac APIs rather than deprecated ones, when available
Comment 2 Ryan C. Gordon 2015-02-02 07:04:02 UTC
(In reply to Alex Szpakowski from comment #1)
> Created attachment 2008 [details]
> Patch to use some modern Mac APIs rather than deprecated ones, when available

Notes:

- Cocoa_ShouldUseIdleIOPMAssertion() should just be checked once at init time and stored as a BOOL somewhere under _this. Not that it's a real expensive function or anything, of course.

- Put a FIXME or something on this: CFSTR("SDL-based app running") ... eventually I'd like to add a simple app metadata API that lets an app describe some basic things about itself, since there are a few places on various platforms where we end up saying "SDL application" instead of "Super Mario Bros."

- Does the legacy path not need to call SetFrontProcess()? That got removed in the patch.

--ryan.
Comment 3 Alex Szpakowski 2015-02-02 07:33:32 UTC
(In reply to Ryan C. Gordon from comment #2)
> - Put a FIXME or something on this: CFSTR("SDL-based app running") ...
> eventually I'd like to add a simple app metadata API that lets an app
> describe some basic things about itself, since there are a few places on
> various platforms where we end up saying "SDL application" instead of "Super
> Mario Bros."

Should I just make it use the actual application name? SDL_cocoaevents.m already has a function to determine it, since it creates the menubar items programmatically.

(In reply to Ryan C. Gordon from comment #2)
> - Does the legacy path not need to call SetFrontProcess()? That got removed
> in the patch.
> 
> --ryan.

The patch replaces the SetFrontProcess call with [NSApp activateIgnoringOtherApps:YES] (the Cocoa version of that Carbon function.)
Comment 4 Alex Szpakowski 2015-02-02 07:37:34 UTC
(In reply to Alex Szpakowski from comment #3)
> Should I just make it use the actual application name? SDL_cocoaevents.m
> already has a function to determine it, since it creates the menubar items
> programmatically.

Actually the Apple documentation says this, so I guess the app name isn't quite appropriate:
> specify a CFString like "Checking mail" or "Compiling" that describes the task that this assertion protects.
Comment 5 Alex Szpakowski 2015-02-02 07:45:36 UTC
Created attachment 2013 [details]
Patch to prefer some modern Mac APIs over deprecated ones (v3)
Comment 6 Alex Szpakowski 2015-02-02 09:20:23 UTC
Created attachment 2014 [details]
Patch to prefer some modern Mac APIs over deprecated ones (v4)

I updated the name used in IOPMAssertionCreate to include the application name, and added a comment about it.
Comment 7 Ryan C. Gordon 2015-02-19 05:22:19 UTC
Marking a large number of bugs with the "triage-2.0.4" keyword at once. Sorry if you got a lot of email from this. This is to help me sort through some bugs in regards to a 2.0.4 release. We may or may not fix this bug for 2.0.4, though!
Comment 8 Ryan C. Gordon 2015-02-20 01:06:43 UTC
This looks good to me; it's now https://hg.libsdl.org/SDL/rev/ad9d35983de5, thanks!

--ryan.