Added code to prevent unnecessary width updates.
authorEric Mullins <emwine@earthlink.net>
Sun, 11 Oct 2009 01:30:23 +0000 (19:30 -0600)
committerEric Mullins <emwine@earthlink.net>
Sun, 11 Oct 2009 01:30:23 +0000 (19:30 -0600)
winboard/winboard.c

index af08df3..34c5cc3 100644 (file)
@@ -5462,6 +5462,7 @@ void UpdateICSWidth(HWND hText)
        TEXTMETRIC tm;\r
        RECT rc;\r
        HFONT hfont, hold_font;\r
+       LONG old_width, new_width;\r
        \r
        // get the text metrics\r
        hdc = GetDC(hText);\r
@@ -5476,7 +5477,13 @@ void UpdateICSWidth(HWND hText)
        SendMessage(hText, EM_GETRECT, 0, (LPARAM)&rc);\r
 \r
        // update the width\r
-       ics_update_width((rc.right-rc.left) / tm.tmAveCharWidth);\r
+       new_width = (rc.right-rc.left) / tm.tmAveCharWidth;\r
+       old_width = GetWindowLong(hText, GWL_USERDATA);\r
+       if (new_width != old_width)\r
+       {\r
+               ics_update_width(new_width);\r
+               SetWindowLong(hText, GWL_USERDATA, new_width);\r
+       }\r
 }\r
 \r
 VOID\r
@@ -8203,6 +8210,7 @@ ConsoleWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
    wMask = SendMessage(hText, EM_GETEVENTMASK, 0, 0L);\r
    SendMessage(hText, EM_SETEVENTMASK, 0, wMask | ENM_LINK);\r
    SendMessage(hText, EM_AUTOURLDETECT, TRUE, 0L);\r
+   SetWindowLong(hText, GWL_USERDATA, 79); // initialize the text window's width\r
 \r
     return FALSE;\r
 \r