[krbdev.mit.edu #5613] NIM GUI: views jump around on the screen

Kevin Koch via RT rt at krbdev.mit.edu
Wed Aug 8 08:56:59 EDT 2007


> Ideally, killing the timer and saving the window position should be
> performed in khm_set_main_window_mode().  This allows the rest of the
> code to call this function without having to worry about saving the
> window position, which is good because it's already being called from
> multiple places.
> 
> Note that khm_set_main_window_mode() is called once before the main
> window is actually created.  Also, main_wnd_save_sizepos() relies on
> khm_main_wnd_mode.  So, killing the timer and saving the position
> should
> happen before khm_main_wnd_mode is modified if khm_hwnd_main is non-
> NULL.

Point taken.  

Patch:

Index: mainwnd.c
===================================================================
--- mainwnd.c	(revision 19745)
+++ mainwnd.c	(working copy)
@@ -205,6 +205,47 @@
     }
 }
 
+void main_wnd_save_sizepos() {
+    RECT r;
+    khm_handle csp_cw;
+    khm_handle csp_mw;
+    const wchar_t * wconfig;
+
+    if (!khm_hwnd_main) return;
+    KillTimer(khm_hwnd_main, MW_RESIZE_TIMER);
+
+    if (khm_main_wnd_mode == KHM_MAIN_WND_MINI)
+        wconfig = L"Windows\\MainMini";
+    else
+        wconfig = L"Windows\\Main";
+
+    GetWindowRect(khm_hwnd_main, &r);
+
+    if (KHM_SUCCEEDED(khc_open_space(NULL,
+                                     L"CredWindow",
+                                     KHM_PERM_WRITE,
+                                     &csp_cw))) {
+        if (KHM_SUCCEEDED(khc_open_space(csp_cw,
+                                        wconfig,
+                                        KHM_PERM_WRITE,
+                                        &csp_mw))) {
+            khm_int32 t;
+
+            khc_write_int32(csp_mw, L"XPos", r.left);
+            khc_write_int32(csp_mw, L"YPos", r.top);
+            khc_write_int32(csp_mw, L"Width", r.right - r.left);
+            khc_write_int32(csp_mw, L"Height", r.bottom - r.top);
+
+            if (KHM_SUCCEEDED(khc_read_int32(csp_mw, L"Dock", &t)) && 
t != KHM_DOCK_NONE) {
+                khc_write_int32(csp_mw, L"Dock", KHM_DOCK_AUTO);
+            }
+
+            khc_close_space(csp_mw);
+        }
+        khc_close_space(csp_cw);
+    }
+}
+
 LRESULT CALLBACK 
 khm_main_wnd_proc(HWND hwnd,
                   UINT uMsg,
@@ -567,54 +611,11 @@
 
     case WM_TIMER:
         if (wParam == MW_RESIZE_TIMER) {
-            RECT r;
-            khm_handle csp_cw;
-            khm_handle csp_mw;
-            const wchar_t * wconfig;
-
-            if (khm_main_wnd_mode == KHM_MAIN_WND_MINI)
-                wconfig = L"Windows\\MainMini";
-            else
-                wconfig = L"Windows\\Main";
-
-            KillTimer(hwnd, wParam);
-
-            GetWindowRect(hwnd, &r);
-
-            if (KHM_SUCCEEDED(khc_open_space(NULL,
-                                             L"CredWindow",
-                                             KHM_PERM_WRITE,
-                                             &csp_cw))) {
-                if (KHM_SUCCEEDED(khc_open_space(csp_cw,
-                                                 wconfig,
-                                                 KHM_PERM_WRITE,
-                                                 &csp_mw))) {
-                    khm_int32 t;
-
-                    khc_write_int32(csp_mw, L"XPos", r.left);
-                    khc_write_int32(csp_mw, L"YPos", r.top);
-                    khc_write_int32(csp_mw, L"Width",
-                                    r.right - r.left);
-                    khc_write_int32(csp_mw, L"Height",
-                                    r.bottom - r.top);
-
-                    if (KHM_SUCCEEDED(khc_read_int32(csp_mw, L"Dock", 
&t)) &&
-                        t != KHM_DOCK_NONE) {
-                        khc_write_int32(csp_mw, L"Dock", 
KHM_DOCK_AUTO);
-                    }
-
-                    khc_close_space(csp_mw);
-                }
-                khc_close_space(csp_cw);
-            }
-
+            main_wnd_save_sizepos();
             return 0;
-
         } else if (wParam == MW_REFRESH_TIMER) {
             kmq_post_message(KMSG_CRED, KMSG_CRED_REFRESH, 0, 0);
-
             return 0;
-
         }
         break;
 
@@ -1114,6 +1116,8 @@
 
     khui_refresh_actions();
 
+    main_wnd_save_sizepos();
+
     khm_main_wnd_mode = mode;
     if (khm_hwnd_main) {
         khm_get_main_window_rect(&r);



More information about the krb5-bugs mailing list