From 50c2ab3847a59bdcc14096407b060a7fcff9cb23 Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Wed, 17 Oct 2007 00:53:15 +0000 Subject: [PATCH] Win V6 SCR compatibility: save, restore gfx window size & position. svn path=/trunk/boinc/; revision=13856 --- api/graphics2_win.C | 39 ++++++++++++++++++++++++++++++++++++++- checkin_notes | 10 ++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/api/graphics2_win.C b/api/graphics2_win.C index 791694b22d..15334020e3 100644 --- a/api/graphics2_win.C +++ b/api/graphics2_win.C @@ -21,6 +21,7 @@ #include "app_ipc.h" #include "util.h" #include "str_util.h" +#include "filesys.h" #include "graphics2.h" #define BOINC_WINDOW_CLASS_NAME "BOINC_app" @@ -106,6 +107,15 @@ static void make_window() { dwStyle=WS_POPUP; while(ShowCursor(false) >= 0); } else { + // Version 5 screensaver logic kills all MODE_WINDOW graphics before starting one + // in fullscreen mode, then restarts the ones it killed when screensaver stops. + // To be compatible with V5, we remember and restore the MODE_WINDOW dimensions. + FILE *f = boinc_fopen("gfx_info", "r"); + if (f) { + // ToDo: change this to XML parsing + fscanf(f, "%d %d %d %d\n", &rect.left, &rect.top, &rect.right, &rect.bottom); + fclose(f); + } WindowRect = rect; dwExStyle=WS_EX_APPWINDOW|WS_EX_WINDOWEDGE; dwStyle=WS_OVERLAPPEDWINDOW; @@ -304,13 +314,40 @@ BOOL unreg_win_class() { static VOID CALLBACK timer_handler(HWND, UINT, UINT, DWORD) { RECT rt; int width, height; + static int size_changed = 0; - GetClientRect(hWnd, &rt); + GetWindowRect(hWnd, &rt); width = rt.right-rt.left; height = rt.bottom-rt.top; if (throttled_app_render(width, height, dtime())) { SwapBuffers(hDC); + if (! fullscreen) { + // If user has changed window size, wait until it stops + // changing and then write the new dimensions to file + if ((rt.left != rect.left) || (rt.top != rect.top) || + (rt.right != rect.right) || (rt.bottom != rect.bottom) + ) { + if (IsZoomed(hWnd)) return; + if ((rt.left < 0) && (rt.right < 0)) return; + if ((rt.top < 0) && (rt.bottom < 0)) return; + size_changed = 1; + rect.left = rt.left; + rect.top = rt.top; + rect.right = rt.right; + rect.bottom = rt.bottom; + } else { + if (size_changed && (++size_changed > 10)) { + size_changed = 0; + FILE *f = boinc_fopen("gfx_info", "w"); + if (f) { + // ToDo: change this to XML + fprintf(f, "%d %d %d %d\n", rect.left, rect.top, rect.right, rect.bottom); + fclose(f); + } + } + } // End if (new size != previous size) else + } } } diff --git a/checkin_notes b/checkin_notes index b1a40f76c7..3bd4d15149 100644 --- a/checkin_notes +++ b/checkin_notes @@ -9587,3 +9587,13 @@ David 16 Oct 2007 bossa_get_job.php lib/ util.C + +Charlie 16 Oct 2007 + - Win V6 SCR compatibility: Version 5 screensaver logic kills all + MODE_WINDOW graphics before starting one in fullscreen mode, then + restarts the ones it killed when screensaver stops. So write + size and position to a file in slot directory and restore when + exiting fullscreen. + + api/ + graphics2_win.C