mirror of https://github.com/BOINC/boinc.git
parent
eb705b3940
commit
9512909f57
42
client/app.C
42
client/app.C
|
@ -71,7 +71,6 @@
|
|||
#include "util.h"
|
||||
|
||||
#include "app.h"
|
||||
#include "boinc_api.h"
|
||||
|
||||
// Goes through an array of strings, and prints each string
|
||||
//
|
||||
|
@ -309,9 +308,9 @@ int ACTIVE_TASK::start(bool first_time) {
|
|||
//
|
||||
sprintf(buf, "%s%s", SHM_PREFIX, aid.comm_obj_name);
|
||||
shm_handle = create_shmem(buf, APP_CLIENT_SHMEM_SIZE,
|
||||
(void **)&app_client_shm->shm
|
||||
(void **)&app_client_shm.shm
|
||||
);
|
||||
app_client_shm->reset_msgs();
|
||||
app_client_shm.reset_msgs();
|
||||
|
||||
// NOTE: in Windows, stderr is redirected within boinc_init();
|
||||
|
||||
|
@ -607,23 +606,17 @@ bool ACTIVE_TASK::read_stderr_file() {
|
|||
return false;
|
||||
}
|
||||
|
||||
#if 0
|
||||
// Send a message to this active task requesting graphics mode change
|
||||
//
|
||||
int ACTIVE_TASK::gfx_mode(int mode) {
|
||||
if (mode < 0 || mode > 4) return -1;
|
||||
return app_client_shm.send_graphics_mode_msg(CORE_APP_GFX_SEG, mode);
|
||||
void ACTIVE_TASK::request_graphics_mode(int mode) {
|
||||
app_client_shm.send_graphics_mode_msg(CORE_APP_GFX_SEG, mode);
|
||||
graphics_requested_mode = mode;
|
||||
}
|
||||
|
||||
int ACTIVE_TASK_SET::start_screensaver(int use_blank_screen, int time_until_blank) {
|
||||
blank_screen = use_blank_screen;
|
||||
blank_time = time(0)+time_until_blank;
|
||||
|
||||
app_client_shm->send_msg(xml_graphics_modes[MODE_FULLSCREEN], CORE_APP_GFX_SEG);
|
||||
|
||||
return 0;
|
||||
void ACTIVE_TASK::check_graphics_mode_ack() {
|
||||
int mode;
|
||||
if (app_client_shm.get_graphics_mode_msg(APP_CORE_GFX_SEG, mode)) {
|
||||
this->graphics_acked_mode = mode;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Wait up to wait_time seconds for all processes in this set to exit
|
||||
//
|
||||
|
@ -991,11 +984,6 @@ int ACTIVE_TASK::parse(FILE* fin, CLIENT_STATE* cs) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
ACTIVE_TASK_SET::ACTIVE_TASK_SET() {
|
||||
app_client_shm = new APP_CLIENT_SHM;
|
||||
app_client_shm->shm = (char *)malloc(sizeof(char)*NUM_SEGS*SHM_SEG_SIZE);
|
||||
}
|
||||
|
||||
// Write XML information about this active task set
|
||||
//
|
||||
int ACTIVE_TASK_SET::write(FILE* fout) {
|
||||
|
@ -1105,3 +1093,13 @@ void ACTIVE_TASK_SET::restore_apps() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ACTIVE_TASK_SET::check_graphics_mode_ack() {
|
||||
unsigned int i;
|
||||
ACTIVE_TASK* atp;
|
||||
|
||||
for (i=0; i<active_tasks.size(); i++) {
|
||||
atp = active_tasks[i];
|
||||
atp->check_graphics_mode_ack();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,6 +90,8 @@ public:
|
|||
int graphics_request_time; // when we sent it
|
||||
int graphics_acked_mode; // most recent mode reported by app
|
||||
int graphics_mode_before_ss; // mode before last screensaver request
|
||||
void request_graphics_mode(int);
|
||||
void check_graphics_mode_ack();
|
||||
|
||||
ACTIVE_TASK();
|
||||
int init(RESULT*);
|
||||
|
@ -106,8 +108,6 @@ public:
|
|||
int abort();
|
||||
// kill, and flag as abort pending
|
||||
|
||||
int gfx_mode(int);
|
||||
|
||||
int suspend();
|
||||
int unsuspend();
|
||||
|
||||
|
@ -123,8 +123,6 @@ public:
|
|||
class ACTIVE_TASK_SET {
|
||||
public:
|
||||
vector<ACTIVE_TASK*> active_tasks;
|
||||
int blank_time, blank_screen;
|
||||
int start_screensaver(int,int);
|
||||
int insert(ACTIVE_TASK*);
|
||||
int remove(ACTIVE_TASK*);
|
||||
int wait_for_exit(double);
|
||||
|
@ -145,8 +143,7 @@ public:
|
|||
void save_app_modes();
|
||||
void hide_apps();
|
||||
void restore_apps();
|
||||
|
||||
ACTIVE_TASK_SET();
|
||||
void check_graphics_mode_ack();
|
||||
|
||||
int write(FILE*);
|
||||
int parse(FILE*, CLIENT_STATE*);
|
||||
|
|
|
@ -530,6 +530,7 @@ bool CLIENT_STATE::do_something() {
|
|||
|
||||
print_log("Polling; active layers:\n");
|
||||
net_stats.poll(*net_xfers);
|
||||
ss_logic.poll();
|
||||
if (activities_suspended) {
|
||||
print_log("None (suspended)\n");
|
||||
} else {
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "scheduler_op.h"
|
||||
#include "time_stats.h"
|
||||
#include "file_names.h"
|
||||
#include "ss_logic.h"
|
||||
|
||||
// CLIENT_STATE is the global variables of the core client
|
||||
// Most of the state is saved to and restored from "client_state.xml"
|
||||
|
@ -57,6 +58,7 @@ public:
|
|||
HOST_INFO host_info;
|
||||
GLOBAL_PREFS global_prefs;
|
||||
NET_STATS net_stats;
|
||||
SS_LOGIC ss_logic;
|
||||
|
||||
CLIENT_STATE();
|
||||
int init();
|
||||
|
|
|
@ -28,9 +28,7 @@ void SS_LOGIC::start_ss(time_t new_blank_time) {
|
|||
create_curtain();
|
||||
atp = gstate.active_tasks.get_graphics_capable_app();
|
||||
if (atp) {
|
||||
atp->app_client_shm.send_graphics_mode_msg(
|
||||
CORE_APP_GFX_SEG, MODE_FULLSCREEN
|
||||
);
|
||||
atp->request_graphics_mode(MODE_FULLSCREEN);
|
||||
ack_deadline = time(0) + 5;
|
||||
} else {
|
||||
do_boinc_logo_ss = true;
|
||||
|
@ -38,24 +36,26 @@ void SS_LOGIC::start_ss(time_t new_blank_time) {
|
|||
}
|
||||
|
||||
void SS_LOGIC::stop_ss() {
|
||||
if (!do_ss) return;
|
||||
do_ss = do_boinc_logo_ss = do_blank = false;
|
||||
delete_curtain();
|
||||
gstate.active_tasks.restore_apps();
|
||||
}
|
||||
|
||||
|
||||
// called every second
|
||||
//
|
||||
void SS_LOGIC::poll() {
|
||||
ACTIVE_TASK* atp;
|
||||
|
||||
gstate.active_tasks.check_graphics_mode_ack();
|
||||
|
||||
if (do_ss) {
|
||||
if (blank_time && (time(0) > blank_time)) {
|
||||
if (!do_blank) {
|
||||
atp = gstate.active_tasks.get_app_requested(MODE_FULLSCREEN);
|
||||
if (atp) {
|
||||
atp->app_client_shm.send_graphics_mode_msg(
|
||||
CORE_APP_GFX_SEG, MODE_HIDE_GRAPHICS
|
||||
);
|
||||
atp->request_graphics_mode(MODE_HIDE_GRAPHICS);
|
||||
}
|
||||
}
|
||||
do_boinc_logo_ss = false;
|
||||
|
@ -63,17 +63,17 @@ void SS_LOGIC::poll() {
|
|||
} else {
|
||||
atp = gstate.active_tasks.get_app_requested(MODE_FULLSCREEN);
|
||||
if (atp) {
|
||||
if (atp->graphics_acked_mode != MODE_FULLSCREEN
|
||||
&& (time(0)>ack_deadline)
|
||||
) {
|
||||
do_boinc_logo_ss = true;
|
||||
if (atp->graphics_acked_mode == MODE_FULLSCREEN) {
|
||||
do_boinc_logo_ss = false;
|
||||
} else {
|
||||
if (time(0)>ack_deadline) {
|
||||
do_boinc_logo_ss = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
atp = gstate.active_tasks.get_graphics_capable_app();
|
||||
if (atp) {
|
||||
atp->app_client_shm.send_graphics_mode_msg(
|
||||
CORE_APP_GFX_SEG, MODE_FULLSCREEN
|
||||
);
|
||||
atp->request_graphics_mode(MODE_FULLSCREEN);
|
||||
ack_deadline = time(0) + 5;
|
||||
} else {
|
||||
do_boinc_logo_ss = true;
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
// In either case, it close the curtain window and restores all apps
|
||||
// to their pre-screensaver state
|
||||
|
||||
#ifndef _SS_LOGIC_
|
||||
#define _SS_LOGIC_
|
||||
|
||||
#include <time.h>
|
||||
|
||||
class SS_LOGIC {
|
||||
|
@ -37,3 +40,5 @@ public:
|
|||
// at most one app has request_mode = FULLSCREEN
|
||||
// pre-ss mode of all apps is not FULLSCREEN
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -54,7 +54,7 @@ int CMyApp::ExitInstance()
|
|||
if (m_pMainWnd)
|
||||
m_pMainWnd->DestroyWindow();
|
||||
|
||||
gstate.free_mem();
|
||||
//gstate.free_mem();
|
||||
|
||||
return CWinApp::ExitInstance();
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ bool APP_CLIENT_SHM::send_msg(char *msg,int seg_num) {
|
|||
|
||||
// Check if there's already a message
|
||||
//
|
||||
if (shm[seg_num*SHM_SEG_SIZE]) return false;
|
||||
//if (shm[seg_num*SHM_SEG_SIZE]) return false;
|
||||
|
||||
// Copy the message into shared memory
|
||||
//
|
||||
|
|
|
@ -61,6 +61,8 @@ int parse_graphics_file(FILE* f, GRAPHICS_INFO* gi);
|
|||
#define MODE_WINDOW 2
|
||||
#define MODE_FULLSCREEN 3
|
||||
|
||||
#define END_SS_MSG "BOINC_SS_END"
|
||||
|
||||
extern char* xml_graphics_modes[5];
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue