From 55546db9b864a68c665261be4017723621501658 Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Fri, 28 Sep 2007 23:39:18 +0000 Subject: [PATCH] pull up r19867 from trunk r19867@cathode-dark-space: jaltman | 2007-08-24 10:51:46 -0400 ticket: new subject: NIM: Reposition New Credentials Dialog if necessary component: windows The new credentials dialog in Network Identity Manager does not check whether it is positioned outside of the display screen. It tries to position itself in the center of the primary display if the Network Identity Manager window is hidden and it tries to center itself over the main window if the main window is visible. If the main window is too close to the edge of the screen, this may result in the new credentials window being partially outside the display area. This is especially a problem when the new credentials dialog switches to the advanced view. The patch checks whether the window rectangle is visible before repositioning the new credentials dialog and adjusts the window rectangle so that it is. ticket: 5688 version_fixed: 1.6.3 git-svn-id: svn://anonsvn.mit.edu/krb5/branches/krb5-1-6@20002 dc483132-0cff-0310-8789-dd5450dbe970 --- src/windows/identity/ui/newcredwnd.c | 32 ++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/src/windows/identity/ui/newcredwnd.c b/src/windows/identity/ui/newcredwnd.c index 1d38e4c95..afc54fa23 100644 --- a/src/windows/identity/ui/newcredwnd.c +++ b/src/windows/identity/ui/newcredwnd.c @@ -1564,6 +1564,21 @@ nc_handle_wm_create(HWND hwnd, x = (r.right + r.left)/2 - width / 2; y = (r.top + r.bottom)/2 - height / 2; + /* we want to check if the entire rect is visible on the screen. + If the main window is visible and in basic mode, we might end + up with a rect that is partially outside the screen. */ + { + RECT r; + + SetRect(&r, x, y, x + width, y + height); + khm_adjust_window_dimensions_for_display(&r, 0); + + x = r.left; + y = r.top; + width = r.right - r.left; + height = r.bottom - r.top; + } + MoveWindow(hwnd, x, y, width, height, FALSE); ncd->dlg_bb = CreateDialogParam(khm_hInstance, @@ -2710,10 +2725,10 @@ static LRESULT nc_handle_wm_timer(HWND hwnd, #ifdef DEBUG { - long dx = (r_now.right - d->sz_ch_target.right) * + long dx = ((r_now.right - r_now.left) - d->sz_ch_target.right) * (d->sz_ch_source.right - d->sz_ch_target.right); - long dy = (r_now.bottom - d->sz_ch_target.bottom) * + long dy = ((r_now.bottom - r_now.top) - d->sz_ch_target.bottom) * (d->sz_ch_source.bottom - d->sz_ch_target.bottom); if (dx < 0 || dy < 0) { @@ -2728,11 +2743,20 @@ static LRESULT nc_handle_wm_timer(HWND hwnd, AdjustWindowRectEx(&r_now, NC_WINDOW_STYLES, FALSE, NC_WINDOW_EX_STYLES); + { + RECT r; + + GetWindowRect(hwnd, &r); + OffsetRect(&r_now, r.left - r_now.left, r.top - r_now.top); + } + + khm_adjust_window_dimensions_for_display(&r_now, 0); + SetWindowPos(hwnd, NULL, - 0, 0, + r_now.left, r_now.top, r_now.right - r_now.left, r_now.bottom - r_now.top, - SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | + SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER); /* and now we wait for the next timer message */ -- 2.26.2