Skip to content

Commit c2bf1e1

Browse files
connorjclarkSiegeLord
authored andcommitted
add [compatability] osx_tell_dock_outside_bundle
1 parent db64a60 commit c2bf1e1

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

allegro5.cfg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,8 @@ max_page_size = 0
238238
# automatically, but may break old code that handled this eventuality.
239239
# Set this to false for such code.
240240
automatic_menu_display_resize = true
241+
242+
# On OSX outside an app bundle, on system init allegro manually promotes the process
243+
# to a graphical application. This may be undesirable for console applications. Set
244+
# this to false to disable this behavior.
245+
osx_tell_dock_outside_bundle = true

include/allegro5/platform/aintosx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ typedef struct HID_DEVICE_COLLECTION HID_DEVICE_COLLECTION;
117117
#endif
118118

119119
int _al_osx_bootstrap_ok(void);
120+
void _al_osx_tell_dock(void);
120121

121122
void _al_osx_keyboard_handler(int pressed, NSEvent *event, ALLEGRO_DISPLAY*);
122123
void _al_osx_keyboard_modifiers(unsigned int new_mods, ALLEGRO_DISPLAY*);

src/macosx/osxgl.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,6 +1301,8 @@ static void init_new_vsync(ALLEGRO_DISPLAY_OSX_WIN *dpy)
13011301
osx_run_fullscreen_display(dpy);
13021302
});
13031303
[pool drain];
1304+
1305+
_al_osx_tell_dock();
13041306
return &dpy->parent;
13051307
}
13061308
#if 0
@@ -1696,6 +1698,7 @@ static void init_new_vsync(ALLEGRO_DISPLAY_OSX_WIN *dpy)
16961698

16971699
[pool drain];
16981700

1701+
_al_osx_tell_dock();
16991702
return display;
17001703
}
17011704

src/macosx/system.m

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,17 @@
5353
static _AL_VECTOR osx_display_modes;
5454
static ALLEGRO_SYSTEM osx_system;
5555

56-
/* osx_tell_dock:
56+
/* _al_osx_tell_dock:
5757
* Tell the dock about us; promote us from a console app to a graphical app
5858
* with dock icon and menu
5959
*/
60-
static void osx_tell_dock(void)
60+
void _al_osx_tell_dock(void)
6161
{
62+
if (_al_osx_bundle != NULL) {
63+
/* If in a bundle, the dock will recognise us automatically */
64+
return;
65+
}
66+
6267
ProcessSerialNumber psn = { 0, kCurrentProcess };
6368
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
6469
[[NSApplication sharedApplication] performSelectorOnMainThread: @selector(activateIgnoringOtherApps:)
@@ -112,9 +117,16 @@ int _al_osx_bootstrap_ok(void)
112117
osx_system.vt = _al_system_osx_driver();
113118
_al_vector_init(&osx_system.displays, sizeof(ALLEGRO_DISPLAY*));
114119

115-
if (_al_osx_bundle == NULL) {
120+
// `_al_osx_tell_dock` is better done after creating a display. Support old behavior for compatability.
121+
bool do_osx_tell_dock = true;
122+
const char* osx_tell_dock_outside_bundle_value =
123+
al_get_config_value(al_get_system_config(), "compatibility", "osx_tell_dock_outside_bundle");
124+
if (osx_tell_dock_outside_bundle_value && strcmp(osx_tell_dock_outside_bundle_value, "false") == 0)
125+
do_osx_tell_dock = false;
126+
127+
if (do_osx_tell_dock) {
116128
/* If in a bundle, the dock will recognise us automatically */
117-
osx_tell_dock();
129+
_al_osx_tell_dock();
118130
}
119131

120132
/* Mark the beginning of time. */

0 commit comments

Comments
 (0)