From 9512909f57b72154e1e62e55e5b5b4927fbce9d4 Mon Sep 17 00:00:00 2001 From: Dan Werthimer Date: Fri, 9 May 2003 00:00:39 +0000 Subject: [PATCH] no message svn path=/trunk/boinc/; revision=1170 --- client/app.C | 42 +++++++++++++++----------------- client/app.h | 9 +++---- client/client_state.C | 1 + client/client_state.h | 2 ++ client/ss_logic.C | 26 ++++++++++---------- client/ss_logic.h | 5 ++++ client/win/wingui_mainwindow.cpp | 2 +- lib/app_ipc.C | 2 +- lib/app_ipc.h | 2 ++ 9 files changed, 48 insertions(+), 43 deletions(-) diff --git a/client/app.C b/client/app.C index e45082fd93..0447a01a66 100644 --- a/client/app.C +++ b/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; icheck_graphics_mode_ack(); + } +} diff --git a/client/app.h b/client/app.h index 031f8f4220..1c373108be 100644 --- a/client/app.h +++ b/client/app.h @@ -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_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*); diff --git a/client/client_state.C b/client/client_state.C index b8af4a7ac7..bd6627a36a 100644 --- a/client/client_state.C +++ b/client/client_state.C @@ -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 { diff --git a/client/client_state.h b/client/client_state.h index 3ef6aa8823..9ea68c0254 100644 --- a/client/client_state.h +++ b/client/client_state.h @@ -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(); diff --git a/client/ss_logic.C b/client/ss_logic.C index ae1985cd8a..0452b69fa8 100644 --- a/client/ss_logic.C +++ b/client/ss_logic.C @@ -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; diff --git a/client/ss_logic.h b/client/ss_logic.h index f0e3596b17..8b85f28b68 100644 --- a/client/ss_logic.h +++ b/client/ss_logic.h @@ -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 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 diff --git a/client/win/wingui_mainwindow.cpp b/client/win/wingui_mainwindow.cpp index e2a70bd95d..20c8d7880b 100755 --- a/client/win/wingui_mainwindow.cpp +++ b/client/win/wingui_mainwindow.cpp @@ -54,7 +54,7 @@ int CMyApp::ExitInstance() if (m_pMainWnd) m_pMainWnd->DestroyWindow(); - gstate.free_mem(); + //gstate.free_mem(); return CWinApp::ExitInstance(); } diff --git a/lib/app_ipc.C b/lib/app_ipc.C index 7c2d522937..e4c08fce78 100755 --- a/lib/app_ipc.C +++ b/lib/app_ipc.C @@ -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 // diff --git a/lib/app_ipc.h b/lib/app_ipc.h index 3c0a9abc53..c9c6c2c57b 100755 --- a/lib/app_ipc.h +++ b/lib/app_ipc.h @@ -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