From 71255d3194a5fef96779a56ffc818313200191cb Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Sat, 29 Sep 2007 01:20:42 +0000 Subject: [PATCH] graphics API: Write changed window size only after it has stopped changing. svn path=/trunk/boinc/; revision=13713 --- api/graphics2_unix.C | 41 +++++++++++++++++++++++++---------------- checkin_notes | 8 +++++++- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/api/graphics2_unix.C b/api/graphics2_unix.C index 3b13c686cb..a751368cbc 100644 --- a/api/graphics2_unix.C +++ b/api/graphics2_unix.C @@ -81,30 +81,39 @@ void mouse_click_move(int x, int y){ static void maybe_render() { int new_xpos, new_ypos, new_width, new_height; + static int size_changed = 0; new_xpos = glutGet(GLUT_WINDOW_X); new_ypos = glutGet(GLUT_WINDOW_Y); new_width = glutGet(GLUT_WINDOW_WIDTH); new_height = glutGet(GLUT_WINDOW_HEIGHT); - if ((! fullscreen) && - ((new_xpos != xpos) || (new_ypos != ypos) || - (new_width != width) || (new_height != height)) - ) { - xpos = new_xpos; - ypos = new_ypos; - width = new_width; - height = new_height; - FILE *f = boinc_fopen("gfx_info", "w"); - if (f) { - // ToDo: change this to XML - fprintf(f, "%d %d %d %d\n", xpos, ypos, width, height); - fclose(f); - } - } - if (throttled_app_render(width, height, dtime())) { + if (throttled_app_render(new_width, new_height, dtime())) { glutSwapBuffers(); + if (! fullscreen) { + // If user has changed window size, wait until it stops + // changing and then write the new dimensions to file + if ((new_xpos != xpos) || (new_ypos != ypos) || + (new_width != width) || (new_height != height) + ) { + size_changed = 1; + xpos = new_xpos; + ypos = new_ypos; + width = new_width; + height = new_height; + } else { + if (++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", xpos, ypos, width, height); + fclose(f); + } + } + } // End if (new size != previous size) else + } // End if (! fullscreen) #ifdef __APPLE__ MacGLUTFix(fullscreen); if (need_show) { diff --git a/checkin_notes b/checkin_notes index 75abd42675..5e618045a6 100755 --- a/checkin_notes +++ b/checkin_notes @@ -8929,7 +8929,7 @@ Charlie 28 Sep 2007 api/ graphics2_unix.C - + David 28 Sept 2007 - scheduler: option wasn't working, because the reply.req structure was getting zeroed @@ -8938,3 +8938,9 @@ David 28 Sept 2007 sched/ handle_request.C sched_send.C + +Charlie 28 Sep 2007 + - graphics API: Write changed window size only after it has stopped changing. + + api/ + graphics2_unix.C