2008-08-06 18:36:30 +00:00
|
|
|
// This file is part of BOINC.
|
2005-01-20 23:22:22 +00:00
|
|
|
// http://boinc.berkeley.edu
|
2008-08-06 18:36:30 +00:00
|
|
|
// Copyright (C) 2008 University of California
|
2004-08-11 11:30:25 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
2005-01-20 23:22:22 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
2005-01-20 23:22:22 +00:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2004-08-11 11:30:25 +00:00
|
|
|
|
2007-09-25 16:04:45 +00:00
|
|
|
// Graphics-related interaction with running apps.
|
|
|
|
//
|
|
|
|
// NOTE: This code is deprecated.
|
|
|
|
// We're keeping it in so that "Show Graphics" will work
|
|
|
|
// when pre-V6 apps run on a V6 client.
|
|
|
|
// At some point (when all projects have V6 apps,
|
|
|
|
// and all old CPDN jobs are finished) we can remove this.
|
2004-08-11 11:30:25 +00:00
|
|
|
|
|
|
|
#include "cpp.h"
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#include "boinc_win.h"
|
2005-11-21 18:34:44 +00:00
|
|
|
#else
|
|
|
|
#include "config.h"
|
2004-08-11 11:30:25 +00:00
|
|
|
#endif
|
|
|
|
|
2004-11-18 04:09:10 +00:00
|
|
|
#include "diagnostics.h"
|
2004-08-11 11:30:25 +00:00
|
|
|
#include "client_state.h"
|
2004-09-13 05:27:28 +00:00
|
|
|
#include "client_msgs.h"
|
2004-08-11 11:30:25 +00:00
|
|
|
|
|
|
|
#include "app.h"
|
2004-11-17 09:27:06 +00:00
|
|
|
#include "util.h"
|
|
|
|
|
2005-04-08 21:40:32 +00:00
|
|
|
|
2004-11-17 19:19:26 +00:00
|
|
|
void ACTIVE_TASK::request_graphics_mode(GRAPHICS_MSG& m) {
|
|
|
|
char buf[MSG_CHANNEL_SIZE], buf2[256];
|
2004-08-11 11:30:25 +00:00
|
|
|
|
2004-09-13 05:27:28 +00:00
|
|
|
if (!app_client_shm.shm) return;
|
2004-11-17 09:27:06 +00:00
|
|
|
|
2007-10-11 11:02:48 +00:00
|
|
|
if (m.mode == MODE_FULLSCREEN) {
|
|
|
|
// Remember mode before screensaver
|
|
|
|
graphics_mode_before_ss = graphics_mode_acked;
|
|
|
|
} else if (graphics_mode_acked != MODE_FULLSCREEN) {
|
|
|
|
graphics_mode_before_ss = MODE_HIDE_GRAPHICS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( (m.mode == MODE_HIDE_GRAPHICS) && (graphics_mode_acked == MODE_FULLSCREEN) ) {
|
|
|
|
// Restore mode from before screensaver
|
|
|
|
m.mode = graphics_mode_before_ss;
|
|
|
|
}
|
2023-05-05 18:05:20 +00:00
|
|
|
|
2005-02-15 07:30:44 +00:00
|
|
|
graphics_msg = m; // save graphics_station, desktop, display
|
2004-11-17 19:19:26 +00:00
|
|
|
|
2013-06-04 03:24:48 +00:00
|
|
|
safe_strcpy(buf, xml_graphics_modes[m.mode]);
|
2004-11-17 19:19:26 +00:00
|
|
|
if (strlen(m.window_station)) {
|
2022-08-03 09:21:59 +00:00
|
|
|
snprintf(buf2, sizeof(buf2), "<window_station>%s</window_station>", m.window_station);
|
2004-11-17 19:19:26 +00:00
|
|
|
strcat(buf, buf2);
|
|
|
|
}
|
|
|
|
if (strlen(m.desktop)) {
|
2022-08-03 09:21:59 +00:00
|
|
|
snprintf(buf2, sizeof(buf2), "<desktop>%s</desktop>", m.desktop);
|
2004-11-17 19:19:26 +00:00
|
|
|
strcat(buf, buf2);
|
|
|
|
}
|
2005-03-10 00:43:22 +00:00
|
|
|
if (strlen(m.display)) {
|
2022-08-03 09:21:59 +00:00
|
|
|
snprintf(buf2, sizeof(buf2), "<display>%s</display>", m.display);
|
2005-02-15 07:30:44 +00:00
|
|
|
strcat(buf, buf2);
|
|
|
|
}
|
2004-11-17 09:27:06 +00:00
|
|
|
|
2006-06-22 19:40:30 +00:00
|
|
|
if (log_flags.scrsave_debug) {
|
2009-02-23 04:54:04 +00:00
|
|
|
msg_printf(wup->project, MSG_INFO,
|
2010-04-29 20:32:51 +00:00
|
|
|
"[scrsave] ACTIVE_TASK::request_graphics_mode(): requesting graphics mode %s for %s",
|
2006-06-22 19:40:30 +00:00
|
|
|
xml_graphics_modes[m.mode], result->name
|
|
|
|
);
|
|
|
|
}
|
2004-09-13 05:27:28 +00:00
|
|
|
graphics_request_queue.msg_queue_send(
|
2004-11-17 09:27:06 +00:00
|
|
|
buf,
|
2004-09-13 05:27:28 +00:00
|
|
|
app_client_shm.shm->graphics_request
|
2004-08-11 11:30:25 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2004-09-13 05:27:28 +00:00
|
|
|
|
2006-12-06 20:59:29 +00:00
|
|
|
// handle messages on the "graphics_reply" channel
|
|
|
|
//
|
2004-08-11 11:30:25 +00:00
|
|
|
void ACTIVE_TASK::check_graphics_mode_ack() {
|
2004-11-17 19:19:26 +00:00
|
|
|
GRAPHICS_MSG gm;
|
2004-08-11 11:30:25 +00:00
|
|
|
char buf[MSG_CHANNEL_SIZE];
|
2007-10-24 00:44:42 +00:00
|
|
|
#if (defined (__APPLE__) && (defined(__i386__) || defined(__x86_64__)))
|
2006-02-06 23:44:05 +00:00
|
|
|
// PowerPC apps emulated on i386 Macs crash if running graphics
|
|
|
|
if (powerpc_emulated_on_i386) {
|
|
|
|
graphics_mode_acked = MODE_UNSUPPORTED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
2004-08-24 21:44:54 +00:00
|
|
|
|
|
|
|
if (!app_client_shm.shm) return;
|
2004-08-11 11:30:25 +00:00
|
|
|
if (app_client_shm.shm->graphics_reply.get_msg(buf)) {
|
2004-11-18 01:30:37 +00:00
|
|
|
app_client_shm.decode_graphics_msg(buf, gm);
|
2006-06-22 19:40:30 +00:00
|
|
|
if (log_flags.scrsave_debug) {
|
2009-02-23 04:54:04 +00:00
|
|
|
msg_printf(wup->project, MSG_INFO,
|
2010-04-29 20:32:51 +00:00
|
|
|
"[scrsave] ACTIVE_TASK::check_graphics_mode_ack(): got graphics ack %s for %s, previous mode %s",
|
2006-06-22 19:40:30 +00:00
|
|
|
buf, result->name, xml_graphics_modes[graphics_mode_acked]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2005-05-18 06:46:29 +00:00
|
|
|
if (gm.mode != MODE_REREAD_PREFS) {
|
|
|
|
graphics_mode_acked = gm.mode;
|
|
|
|
}
|
2004-08-11 11:30:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ACTIVE_TASK_SET::graphics_poll() {
|
|
|
|
unsigned int i;
|
|
|
|
ACTIVE_TASK* atp;
|
|
|
|
|
|
|
|
for (i=0; i<active_tasks.size(); i++) {
|
|
|
|
atp = active_tasks[i];
|
2004-08-23 22:44:53 +00:00
|
|
|
if (!atp->process_exists()) continue;
|
2004-09-13 05:27:28 +00:00
|
|
|
atp->graphics_request_queue.msg_queue_poll(
|
|
|
|
atp->app_client_shm.shm->graphics_request
|
|
|
|
);
|
2004-08-11 11:30:25 +00:00
|
|
|
atp->check_graphics_mode_ack();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ACTIVE_TASK::supports_graphics() {
|
2007-10-24 00:44:42 +00:00
|
|
|
#if (defined (__APPLE__) && (defined(__i386__) || defined(__x86_64__)))
|
2006-02-06 23:44:05 +00:00
|
|
|
// PowerPC apps emulated on i386 Macs crash if running graphics
|
|
|
|
if (powerpc_emulated_on_i386)
|
|
|
|
return false;
|
|
|
|
#endif
|
2006-06-30 23:32:26 +00:00
|
|
|
if (graphics_mode_acked == MODE_UNSUPPORTED) return false;
|
2006-08-07 00:58:12 +00:00
|
|
|
if (scheduler_state != CPU_SCHED_SCHEDULED) return false;
|
2006-06-30 23:32:26 +00:00
|
|
|
return true;
|
2004-08-11 11:30:25 +00:00
|
|
|
}
|
|
|
|
|