2003-06-11 23:36:48 +00:00
|
|
|
// The contents of this file are subject to the BOINC Public License
|
2003-05-15 17:10:26 +00:00
|
|
|
// Version 1.0 (the "License"); you may not use this file except in
|
|
|
|
// compliance with the License. You may obtain a copy of the License at
|
2003-06-11 23:36:48 +00:00
|
|
|
// http://boinc.berkeley.edu/license_1.0.txt
|
2003-05-15 17:10:26 +00:00
|
|
|
//
|
|
|
|
// Software distributed under the License is distributed on an "AS IS"
|
|
|
|
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
|
|
|
// License for the specific language governing rights and limitations
|
|
|
|
// under the License.
|
|
|
|
//
|
|
|
|
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
|
|
|
|
//
|
|
|
|
// The Initial Developer of the Original Code is the SETI@home project.
|
|
|
|
// Portions created by the SETI@home project are Copyright (C) 2002
|
|
|
|
// University of California at Berkeley. All Rights Reserved.
|
|
|
|
//
|
|
|
|
// Contributor(s):
|
|
|
|
//
|
|
|
|
|
2004-03-05 04:37:53 +00:00
|
|
|
#ifdef _WIN32
|
2004-06-16 23:16:08 +00:00
|
|
|
#include "boinc_win.h"
|
2004-03-05 04:37:53 +00:00
|
|
|
#endif
|
2003-05-08 18:11:05 +00:00
|
|
|
|
2004-03-05 04:37:53 +00:00
|
|
|
#include "client_state.h"
|
2004-07-18 04:41:27 +00:00
|
|
|
#include "client_msgs.h"
|
2003-05-08 18:11:05 +00:00
|
|
|
#include "ss_logic.h"
|
|
|
|
|
|
|
|
SS_LOGIC::SS_LOGIC() {
|
|
|
|
do_ss = false;
|
|
|
|
blank_time = 0;
|
|
|
|
ack_deadline = 0;
|
2004-11-17 10:25:39 +00:00
|
|
|
ss_status = 0;
|
2003-05-08 18:11:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// this is called when the core client receives a message
|
|
|
|
// from the screensaver module.
|
|
|
|
//
|
2004-11-17 19:19:26 +00:00
|
|
|
void SS_LOGIC::start_ss(GRAPHICS_MSG& m, double new_blank_time) {
|
2003-05-08 18:11:05 +00:00
|
|
|
ACTIVE_TASK* atp;
|
|
|
|
|
|
|
|
if (do_ss) return;
|
|
|
|
do_ss = true;
|
2004-11-18 01:52:07 +00:00
|
|
|
ss_status = SS_STATUS_ENABLED;
|
2004-11-16 08:04:57 +00:00
|
|
|
|
2003-05-08 18:11:05 +00:00
|
|
|
blank_time = new_blank_time;
|
|
|
|
gstate.active_tasks.save_app_modes();
|
|
|
|
gstate.active_tasks.hide_apps();
|
2004-11-16 08:04:57 +00:00
|
|
|
|
2004-11-17 19:19:26 +00:00
|
|
|
m.mode = MODE_FULLSCREEN;
|
2004-05-03 23:35:45 +00:00
|
|
|
if (!gstate.activities_suspended) {
|
2004-07-18 04:41:27 +00:00
|
|
|
atp = gstate.get_next_graphics_capable_app();
|
2004-05-03 23:35:45 +00:00
|
|
|
if (atp) {
|
2004-11-17 19:19:26 +00:00
|
|
|
atp->request_graphics_mode(m);
|
2004-09-13 05:27:28 +00:00
|
|
|
atp->is_ss_app = true;
|
2004-05-03 23:35:45 +00:00
|
|
|
ack_deadline = time(0) + 5;
|
|
|
|
}
|
2003-05-08 18:11:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SS_LOGIC::stop_ss() {
|
2003-05-09 20:33:57 +00:00
|
|
|
if (!do_ss) return;
|
2004-09-13 05:27:28 +00:00
|
|
|
reset();
|
2004-11-16 08:04:57 +00:00
|
|
|
do_ss = false;
|
2004-11-18 01:52:07 +00:00
|
|
|
ss_status = SS_STATUS_QUIT;
|
2003-05-08 18:11:05 +00:00
|
|
|
gstate.active_tasks.restore_apps();
|
|
|
|
}
|
|
|
|
|
2004-09-13 23:17:16 +00:00
|
|
|
// If an app is acting as screensaver, tell it to stop.
|
2004-07-19 20:37:45 +00:00
|
|
|
//
|
|
|
|
void SS_LOGIC::reset() {
|
2004-11-17 19:19:26 +00:00
|
|
|
GRAPHICS_MSG m;
|
|
|
|
|
|
|
|
m.mode = MODE_HIDE_GRAPHICS;
|
2004-09-13 23:17:16 +00:00
|
|
|
ACTIVE_TASK* atp = gstate.active_tasks.get_ss_app();
|
|
|
|
if (atp) {
|
2004-11-17 19:19:26 +00:00
|
|
|
atp->request_graphics_mode(m);
|
2004-09-13 23:17:16 +00:00
|
|
|
atp->is_ss_app = false;
|
2004-07-19 20:37:45 +00:00
|
|
|
}
|
|
|
|
}
|
2003-05-09 00:00:39 +00:00
|
|
|
|
2003-05-08 18:11:05 +00:00
|
|
|
// called every second
|
|
|
|
//
|
|
|
|
void SS_LOGIC::poll() {
|
|
|
|
ACTIVE_TASK* atp;
|
2004-11-17 19:19:26 +00:00
|
|
|
GRAPHICS_MSG m;
|
|
|
|
|
2003-05-08 18:11:05 +00:00
|
|
|
|
2004-07-18 05:30:26 +00:00
|
|
|
#if 0
|
2004-08-21 23:57:25 +00:00
|
|
|
// if you want to debug screensaver functionality...
|
2004-07-18 05:30:26 +00:00
|
|
|
static int foo=0;
|
|
|
|
foo++;
|
|
|
|
if (foo == 8) start_ss(time(0)+1000);
|
|
|
|
#endif
|
|
|
|
|
2004-08-21 23:57:25 +00:00
|
|
|
if (!do_ss) return;
|
|
|
|
|
|
|
|
if (gstate.activities_suspended) {
|
2004-09-13 23:17:16 +00:00
|
|
|
reset();
|
2004-11-16 08:04:57 +00:00
|
|
|
ss_status = SS_STATUS_BOINCSUSPENDED;
|
2004-08-21 23:57:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// check if it's time to go to black screen
|
|
|
|
//
|
|
|
|
if (blank_time && (time(0) > blank_time)) {
|
2004-11-16 08:04:57 +00:00
|
|
|
if (SS_STATUS_BLANKED != ss_status) {
|
2004-09-13 23:17:16 +00:00
|
|
|
reset();
|
2004-11-16 08:04:57 +00:00
|
|
|
ss_status = SS_STATUS_BLANKED;
|
2004-08-21 23:57:25 +00:00
|
|
|
}
|
|
|
|
} else {
|
2004-09-13 05:27:28 +00:00
|
|
|
atp = gstate.active_tasks.get_ss_app();
|
2004-08-21 23:57:25 +00:00
|
|
|
if (atp) {
|
2004-11-16 08:04:57 +00:00
|
|
|
if (atp->graphics_mode_acked != MODE_FULLSCREEN) {
|
2004-08-21 23:57:25 +00:00
|
|
|
if (time(0)>ack_deadline) {
|
2004-11-17 19:19:26 +00:00
|
|
|
m.mode = MODE_HIDE_GRAPHICS;
|
|
|
|
atp->request_graphics_mode(m);
|
2004-09-13 05:27:28 +00:00
|
|
|
atp->is_ss_app = false;
|
2004-11-17 10:25:39 +00:00
|
|
|
ss_status = SS_STATUS_NOTGRAPHICSCAPABLE;
|
2004-08-21 23:57:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
atp = gstate.get_next_graphics_capable_app();
|
|
|
|
if (atp) {
|
2004-11-17 20:06:44 +00:00
|
|
|
do_ss = false;
|
2004-11-16 08:04:57 +00:00
|
|
|
ss_status = SS_STATUS_RESTARTREQUEST;
|
2004-08-21 23:57:25 +00:00
|
|
|
} else {
|
|
|
|
if (gstate.active_tasks.active_tasks.size()==0) {
|
2004-11-16 08:04:57 +00:00
|
|
|
ss_status = SS_STATUS_NOAPPSEXECUTING;
|
2003-05-08 18:11:05 +00:00
|
|
|
} else {
|
2004-11-16 08:04:57 +00:00
|
|
|
ss_status = SS_STATUS_NOGRAPHICSAPPSEXECUTING;
|
2003-05-08 18:11:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-05-03 23:35:45 +00:00
|
|
|
}
|
2003-05-08 18:11:05 +00:00
|
|
|
}
|
2004-12-08 00:40:19 +00:00
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
static volatile const char __attribute__((unused)) *BOINCrcsid="$Id$";
|
|
|
|
#else
|
|
|
|
static volatile const char *BOINCrcsid="$Id$";
|
|
|
|
#endif
|