From ab98339572a9a945bbaeebbe26e31e241f82a850 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Sun, 19 Dec 2004 04:27:02 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=4900 --- api/windows_opengl.C | 35 +++++++++++++--------- checkin_notes | 9 ++++++ client/win/win_screensaver.cpp | 55 +++++++++++++++++++++++++--------- 3 files changed, 71 insertions(+), 28 deletions(-) diff --git a/api/windows_opengl.C b/api/windows_opengl.C index bd919cf2ca..bb7cd76455 100755 --- a/api/windows_opengl.C +++ b/api/windows_opengl.C @@ -21,22 +21,25 @@ #define BOINC_WINDOW_CLASS_NAME "BOINC_app" -static HDC hDC = NULL; -static HGLRC hRC = NULL; -static HWND hWnd = NULL; // Holds Our Window Handle -static HINSTANCE hInstance; // Holds The Instance Of The Application -static RECT rect = {50, 50, 50+640, 50+480}; -static int current_graphics_mode = MODE_HIDE_GRAPHICS; -static int acked_graphics_mode = -1; -static POINT mousePos; -static HDC myhDC; -BOOL win_loop_done; +const UINT WM_BOINCSFW = RegisterWindowMessage(TEXT("BOINCSetForegroundWindow")); + + +static HDC hDC = NULL; +static HGLRC hRC = NULL; +static HWND hWnd = NULL; // Holds Our Window Handle +static HINSTANCE hInstance; // Holds The Instance Of The Application +static RECT rect = {50, 50, 50+640, 50+480}; +static int current_graphics_mode = MODE_HIDE_GRAPHICS; +static int acked_graphics_mode = -1; +static POINT mousePos; +static HDC myhDC; +BOOL win_loop_done; static GRAPHICS_MSG graphics_msg; -static HWINSTA hOriginalWindowStation = NULL; -static HDESK hOriginalDesktop = NULL; -static HWINSTA hInteractiveWindowStation = NULL; -static HDESK hInteractiveDesktop = NULL; +static HWINSTA hOriginalWindowStation = NULL; +static HDESK hOriginalDesktop = NULL; +static HWINSTA hInteractiveWindowStation = NULL; +static HDESK hInteractiveDesktop = NULL; static bool visible = true; @@ -309,6 +312,10 @@ LRESULT CALLBACK WndProc( } app_graphics_resize(LOWORD(lParam), HIWORD(lParam)); return 0; + default: + if ( WM_BOINCSFW == uMsg ) { + SetForegroundWindow(hWnd); + } } // Pass All Unhandled Messages To DefWindowProc diff --git a/checkin_notes b/checkin_notes index c64cb05c3b..3e5681e3f2 100755 --- a/checkin_notes +++ b/checkin_notes @@ -21588,3 +21588,12 @@ Rom 18 Dec 2004 lib/ hostinfo.h +Rom 18 Dec 2004 + - Add another layer of checks for Windows 2000 or better machines to get + try and get graphics to appear. + + api/ + windows_opengl.C + client/win/ + win_screensaver.cpp + diff --git a/client/win/win_screensaver.cpp b/client/win/win_screensaver.cpp index 0b278305e9..82b7a16dda 100755 --- a/client/win/win_screensaver.cpp +++ b/client/win/win_screensaver.cpp @@ -47,6 +47,17 @@ #include "win_util.h" +// +// Define the stuff needed to actually do a set foreground window on +// Windows 2000 or later machines. +// +#ifndef BSF_ALLOWSFW +#define BSF_ALLOWSFW 0x00000080 +#endif + +const UINT WM_BOINCSFW = RegisterWindowMessage(TEXT("BOINCSetForegroundWindow")); + + static CScreensaver* gs_pScreensaver = NULL; @@ -60,19 +71,18 @@ INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine #ifdef _DEBUG // Initialize Diagnostics when compiled for debug - try { - boinc_init_diagnostics ( - BOINC_DIAG_DUMPCALLSTACKENABLED | - BOINC_DIAG_HEAPCHECKENABLED | - BOINC_DIAG_MEMORYLEAKCHECKENABLED | - BOINC_DIAG_ARCHIVESTDERR | - BOINC_DIAG_REDIRECTSTDERROVERWRITE | - BOINC_DIAG_TRACETOSTDERR - ); - } - catch (boinc_runtime_base_exception e) + retval = boinc_init_diagnostics ( + BOINC_DIAG_DUMPCALLSTACKENABLED | + BOINC_DIAG_HEAPCHECKENABLED | + BOINC_DIAG_MEMORYLEAKCHECKENABLED | + BOINC_DIAG_ARCHIVESTDERR | + BOINC_DIAG_REDIRECTSTDERROVERWRITE | + BOINC_DIAG_TRACETOSTDERR + ); + if (retval) { - MessageBox(NULL, e.what(), "BOINC SCreensaver Diagnostic Error", MB_OK); + BOINCTRACE("WinMain - BOINC Screensaver Diagnostic Error '%d'", retval); + MessageBox(NULL, NULL, "BOINC Screensaver Diagnostic Error", MB_OK); } #endif @@ -573,7 +583,7 @@ HRESULT CScreensaver::CreateSaverWindow() m_Monitors[0].hWnd = m_hWnd; GetClientRect( m_hWnd, &m_rcRenderTotal ); GetClientRect( m_hWnd, &m_rcRenderCurDevice ); - SetTimer(m_hWnd, 2, 1000, NULL); + SetTimer(m_hWnd, 2, 10000, NULL); break; case sm_full: @@ -606,7 +616,7 @@ HRESULT CScreensaver::CreateSaverWindow() if( m_hWnd == NULL ) m_hWnd = pMonitorInfo->hWnd; - SetTimer(pMonitorInfo->hWnd, 2, 1000, NULL); + SetTimer(pMonitorInfo->hWnd, 2, 10000, NULL); } } } @@ -867,6 +877,20 @@ LRESULT CScreensaver::PrimarySaverProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPA { BOINCTRACE(_T("CScreensaver::PrimarySaverProc - Graphics Window Detected but NOT the foreground window, bringing window to foreground.\n")); SetForegroundWindow(hwndBOINCGraphicsWindow); + + hwndForegroundWindow = GetForegroundWindow(); + if ( hwndForegroundWindow != hwndBOINCGraphicsWindow ) + { + // This may be needed on Windows 2000 or better machines + DWORD dwComponents = BSM_APPLICATIONS; + BroadcastSystemMessage( + BSF_ALLOWSFW, + &dwComponents, + WM_BOINCSFW, + NULL, + NULL + ); + } } } break; @@ -1794,8 +1818,11 @@ BOOL CScreensaver::IsConfigStartupBOINC() BOINCTRACE(_T("IsConfigStartupBOINC: Returning '%d'\n"), bRetVal); return bRetVal; } + + #ifdef __GNUC__ static volatile const char __attribute__((unused)) *BOINCrcsid="$Id$"; #else static volatile const char *BOINCrcsid="$Id$"; #endif +