Skip to content

Commit f4af360

Browse files
authored
Merge pull request #6688 from BOINC/mac_ss_tweaks
Mac ss tweaks
2 parents d02cee0 + a474d40 commit f4af360

File tree

2 files changed

+37
-31
lines changed

2 files changed

+37
-31
lines changed

client/gui_rpc_server_ops.cpp

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <libproc.h>
2525
#include "sandbox.h"
2626
#include "mac_branding.h"
27+
extern int compareOSVersionTo(int toMajor, int toMinor);
2728
#endif
2829

2930
#ifdef _WIN32
@@ -1501,34 +1502,36 @@ static void handle_run_graphics_app(GUI_RPC_CONN& grc) {
15011502
return;
15021503
}
15031504

1504-
// As of MacOS 14.0, the legacyScreenSaver sandbox prevents using
1505-
// bootstrap_look_up, so we launch a bridging utility to relay Mach
1506-
// communications between the graphics apps and the legacyScreenSaver.
1507-
if (gfx_ss_bridge_pid == 0) {
1508-
need_to_launch_gfx_ss_bridge = true;
1509-
} else if (waitpid(gfx_ss_bridge_pid, 0, WNOHANG)) {
1510-
gfx_ss_bridge_pid = 0;
1511-
need_to_launch_gfx_ss_bridge = true;
1512-
}
1513-
if (need_to_launch_gfx_ss_bridge) {
1514-
if (g_use_sandbox) {
1515-
1516-
snprintf(gfx_switcher_path, sizeof(gfx_switcher_path),
1517-
"/Library/Screen Savers/%s.saver/Contents/Resources/gfx_switcher",
1518-
saverName[iBrandID]
1519-
);
1505+
if (compareOSVersionTo(14, 0) >= 0) {
1506+
// As of MacOS 14.0, the legacyScreenSaver sandbox prevents using
1507+
// bootstrap_look_up, so we launch a bridging utility to relay Mach
1508+
// communications between the graphics apps and the legacyScreenSaver.
1509+
if (gfx_ss_bridge_pid == 0) {
1510+
need_to_launch_gfx_ss_bridge = true;
1511+
} else if (waitpid(gfx_ss_bridge_pid, 0, WNOHANG)) {
1512+
gfx_ss_bridge_pid = 0;
1513+
need_to_launch_gfx_ss_bridge = true;
15201514
}
1521-
argv[0] = const_cast<char*>("gfx_switcher");
1522-
argv[1] = "-run_bridge";
1523-
argv[2] = gfx_switcher_path;
1524-
argc = 3;
1525-
if (!theScreensaverLoginUser.empty()) {
1526-
argv[argc++] = "--ScreensaverLoginUser";
1527-
safe_strcpy(screensaverLoginUser, theScreensaverLoginUser.c_str());
1528-
argv[argc++] = screensaverLoginUser;
1515+
if (need_to_launch_gfx_ss_bridge) {
1516+
if (g_use_sandbox) {
1517+
1518+
snprintf(gfx_switcher_path, sizeof(gfx_switcher_path),
1519+
"/Library/Screen Savers/%s.saver/Contents/Resources/gfx_switcher",
1520+
saverName[iBrandID]
1521+
);
1522+
}
1523+
argv[0] = const_cast<char*>("gfx_switcher");
1524+
argv[1] = "-run_bridge";
1525+
argv[2] = gfx_switcher_path;
1526+
argc = 3;
1527+
if (!theScreensaverLoginUser.empty()) {
1528+
argv[argc++] = "--ScreensaverLoginUser";
1529+
safe_strcpy(screensaverLoginUser, theScreensaverLoginUser.c_str());
1530+
argv[argc++] = screensaverLoginUser;
1531+
}
1532+
argv[argc] = 0;
1533+
retval = run_program(current_dir, gfx_switcher_path, argc, argv, gfx_ss_bridge_pid);
15291534
}
1530-
argv[argc] = 0;
1531-
retval = run_program(current_dir, gfx_switcher_path, argc, argv, gfx_ss_bridge_pid);
15321535
}
15331536

15341537
if (slot == -1) {

lib/procinfo_mac.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,14 @@ int procinfo_setup(PROC_MAP& pm) {
137137
p.swap_size = (double)virtual_mem * 1024.;
138138
p.user_time += 60. * (float)hours;
139139
p.is_boinc_app = (p.id == pid || strcasestr(p.command, "boinc"));
140-
// Ideally, we should count ScreenSaverEngine.app as a BOINC process
141-
// only if BOINC is set as the screensaver. We could set a flag in
142-
// the client when the get_screensaver_tasks rpc is called, but that
143-
// would not be 100% reliable for several reasons.
144-
if (strcasestr(p.command, "screensaverengine")) p.is_boinc_app = true;
140+
// Ideally, we should count ScreenSaverEngine or legacyScreenSaver
141+
// as a BOINC process only if BOINC is set as the screensaver. We
142+
// could set a flag in the client when the get_screensaver_tasks
143+
// rpc is called, but that would not be 100% reliable for several
144+
// reasons.
145+
//
146+
// Check for either ScreenSaverEngine or legacyScreenSaver
147+
if (strcasestr(p.command, "screensaver")) p.is_boinc_app = true;
145148

146149
// We do not mark Mac processes as low priority because some processes
147150
// (e.g., Finder) change priority frequently, which would cause

0 commit comments

Comments
 (0)