diff --git a/client/app.C b/client/app.C index 356b084aeb..62f9be074e 100644 --- a/client/app.C +++ b/client/app.C @@ -98,6 +98,7 @@ ACTIVE_TASK::ACTIVE_TASK() { graphics_request_time = time(0); graphics_acked_mode = MODE_UNSUPPORTED; graphics_mode_before_ss = MODE_HIDE_GRAPHICS; + last_status_msg_time = 0; } int ACTIVE_TASK::init(RESULT* rp) { @@ -802,7 +803,7 @@ int ACTIVE_TASK::get_cpu_time() { LONGLONG totTime; // Get the elapsed CPU time - if (GetProcessTimes( pid_handle, &creation_time, &exit_time, &kernel_time, &user_time )) { + if (GetProcessTimes(pid_handle, &creation_time, &exit_time, &kernel_time, &user_time)) { tKernel.LowPart = kernel_time.dwLowDateTime; tKernel.HighPart = kernel_time.dwHighDateTime; tUser.LowPart = user_time.dwLowDateTime; @@ -833,12 +834,16 @@ int ACTIVE_TASK::get_cpu_time() { bool ACTIVE_TASK::check_app_status() { char msg_buf[SHM_SEG_SIZE]; if (app_client_shm.get_msg(msg_buf, APP_CORE_WORKER_SEG)) { + last_status_msg_time = time(0); fraction_done = current_cpu_time = checkpoint_cpu_time = 0.0; parse_double(msg_buf, "", fraction_done); parse_double(msg_buf, "", current_cpu_time); parse_double(msg_buf, "", checkpoint_cpu_time); return true; } + if (last_status_msg_time+5 < time(0)) { + get_cpu_time(); + } return false; } diff --git a/client/app.h b/client/app.h index 5574a8f568..69acd6161e 100644 --- a/client/app.h +++ b/client/app.h @@ -84,6 +84,7 @@ public: double max_disk_usage; APP_CLIENT_SHM app_client_shm; // core/app shared mem + time_t last_status_msg_time; // info related to app's graphics mode (win, screensaver, etc.) int graphics_requested_mode; // our last request to this app diff --git a/client/ss_logic.C b/client/ss_logic.C index 3e19947c7f..135f6461db 100644 --- a/client/ss_logic.C +++ b/client/ss_logic.C @@ -22,6 +22,7 @@ void SS_LOGIC::start_ss(time_t new_blank_time) { if (do_ss) return; do_ss = true; do_blank = do_boinc_logo_ss = false; + sprintf(ss_msg, ""); blank_time = new_blank_time; gstate.active_tasks.save_app_modes(); gstate.active_tasks.hide_apps(); @@ -59,15 +60,18 @@ void SS_LOGIC::poll() { } } do_boinc_logo_ss = false; + sprintf(ss_msg, ""); do_blank = true; } else { atp = gstate.active_tasks.get_app_requested(MODE_FULLSCREEN); if (atp) { if (atp->graphics_acked_mode == MODE_FULLSCREEN) { do_boinc_logo_ss = false; + sprintf(ss_msg, ""); } else { if (time(0)>ack_deadline) { do_boinc_logo_ss = true; + sprintf(ss_msg, "App can't display graphics"); } } } else { @@ -77,6 +81,7 @@ void SS_LOGIC::poll() { ack_deadline = time(0) + 5; } else { do_boinc_logo_ss = true; + sprintf(ss_msg, "No work available"); } } } diff --git a/client/ss_logic.h b/client/ss_logic.h index 8b85f28b68..7345dd2f59 100644 --- a/client/ss_logic.h +++ b/client/ss_logic.h @@ -27,6 +27,8 @@ class SS_LOGIC { public: SS_LOGIC(); + char ss_msg[256]; // message to display on BOINC screensaver + void start_ss(time_t blank_time); void stop_ss(); void poll(); diff --git a/client/win/wingui_mainwindow.cpp b/client/win/wingui_mainwindow.cpp index 3b4a5fb360..82ff0a5a01 100755 --- a/client/win/wingui_mainwindow.cpp +++ b/client/win/wingui_mainwindow.cpp @@ -219,7 +219,10 @@ void CMainWindow::UpdateGUI(CLIENT_STATE* pcs) int cpuhour = (int)(cur_cpu / (60 * 60)); int cpumin = (int)(cur_cpu / 60) % 60; int cpusec = (int)(cur_cpu) % 60; - strBuf.Format("%0.2d:%0.2d:%0.2d", cpuhour, cpumin, cpusec); + if (cur_cpu == 0) + strBuf.Format("---"); + else + strBuf.Format("%0.2d:%0.2d:%0.2d", cpuhour, cpumin, cpusec); m_ResultListCtrl.SetItemText(i, 3, strBuf); // progress diff --git a/client/win/wingui_sswindow.cpp b/client/win/wingui_sswindow.cpp index 9d3dffbdd8..178412a687 100755 --- a/client/win/wingui_sswindow.cpp +++ b/client/win/wingui_sswindow.cpp @@ -45,7 +45,6 @@ CSSWindow::CSSWindow() ShowSSWindow(false); m_hBOINCIcon = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_ICON)); - m_bCleared = false; } // CMainWindow::SetMode @@ -65,8 +64,6 @@ void CSSWindow::ShowSSWindow(bool show_win) return; } - m_bCleared = false; - CString strWndClass = AfxRegisterWndClass(0); DWORD dwExStyle; DWORD dwStyle; @@ -144,6 +141,8 @@ int CSSWindow::OnCreate(LPCREATESTRUCT lpcs) // Initial position is (0,0) m_nPosX = m_nPosY = 0; + m_nTextPosX = -10000; + m_nTextPosY = 0; // Initial velocity is (1-5,1-5) m_nDX = (rand() % 5)+1; m_nDY = (rand() % 5)+1; @@ -170,17 +169,30 @@ void CSSWindow::OnPaint() { PAINTSTRUCT ps; CDC* pdc; - RECT winRect; + RECT winRect, textRect; // Fill the window with black pdc = BeginPaint(&ps); + pdc->SetBkColor(RGB(0,0,0)); GetClientRect(&winRect); pdc->FillSolidRect(&winRect, RGB(0,0,0)); - m_bCleared = true; // Draw the bouncing BOINC icon if we're not in blank screen mode if (gstate.ss_logic.do_boinc_logo_ss) { - pdc->DrawIcon(m_nPosX, m_nPosY, m_hBOINCIcon); + pdc->SetTextColor(RGB(255,255,255)); + // Draw status text + SetRect(&textRect, m_nTextPosX, m_nTextPosY, m_nTextPosX, m_nTextPosY); + pdc->DrawText(gstate.ss_logic.ss_msg, &textRect, DT_CALCRECT); + m_nTextPosX += 2; + if (m_nTextPosX + (textRect.right-textRect.left) < 0) + m_nTextPosX = textRect.left - textRect.right; + pdc->DrawText(gstate.ss_logic.ss_msg, &textRect, DT_LEFT); + if (m_nTextPosX > winRect.right) { + m_nTextPosX = -10000; + m_nTextPosY = rand() % (winRect.bottom-winRect.top); + } + + // Draw the bouncing icon m_nPosX += m_nDX; m_nPosY += m_nDY; if (m_nPosX <= winRect.left || (m_nPosX+32) >= winRect.right) m_nDX *= -1; @@ -189,6 +201,7 @@ void CSSWindow::OnPaint() if ((m_nPosX+32) > winRect.right) m_nPosX = winRect.right-32; if (m_nPosY < winRect.top) m_nPosY = winRect.top; if ((m_nPosY+32) > winRect.bottom) m_nPosY = winRect.bottom-32; + pdc->DrawIcon(m_nPosX, m_nPosY, m_hBOINCIcon); } EndPaint(&ps); @@ -202,10 +215,9 @@ void CSSWindow::OnPaint() void CSSWindow::OnTimer(UINT uEventID) { // Paint our own window - if(uEventID == m_uPaintTimerID) { - if(gstate.ss_logic.do_boinc_logo_ss || gstate.ss_logic.do_blank) { - Invalidate(); - OnPaint(); - } + if(uEventID == m_uPaintTimerID && + (gstate.ss_logic.do_boinc_logo_ss || gstate.ss_logic.do_blank)) { + Invalidate(); + OnPaint(); } } \ No newline at end of file diff --git a/client/win/wingui_sswindow.h b/client/win/wingui_sswindow.h index c989a064fb..3718e504ad 100755 --- a/client/win/wingui_sswindow.h +++ b/client/win/wingui_sswindow.h @@ -45,7 +45,6 @@ public: private: CPoint m_MousePos; - bool m_bCleared; UINT m_uPaintTimerID; // ID of current app timer @@ -54,6 +53,7 @@ private: HICON m_hBOINCIcon; int m_nPosX, m_nPosY; + int m_nTextPosX, m_nTextPosY; int m_nDX, m_nDY; LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);