From f4b62dcdc66f6b278439684a79170480f0c66efe Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Thu, 20 Sep 2012 15:29:42 +0200 Subject: [PATCH] Let windows stick to right display edge (WB) Auxiliary windows docked to the board window from below or to the right, which are pushed out of view when the board window resizes, will be trimmed to just touch the diplay edge (if sufficient width or height remains). When the board window shrinks, auxiliary windows touching the edge will be resized so they remain touching it. --- winboard/winboard.h | 1 + winboard/wlayout.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/winboard/winboard.h b/winboard/winboard.h index 6759f79..fe03547 100644 --- a/winboard/winboard.h +++ b/winboard/winboard.h @@ -215,3 +215,4 @@ extern HWND gameListDialog; VOID EditTagsProc(void); extern HWND editTagsDialog; +extern int screenWidth, screenHeight; diff --git a/winboard/wlayout.c b/winboard/wlayout.c index 2442466..08f461f 100644 --- a/winboard/wlayout.c +++ b/winboard/wlayout.c @@ -172,12 +172,20 @@ VOID ReattachAfterSize( LPRECT lprcOldPos, int new_w, int new_h, HWND hWndChild, int delta_y = new_h - (lprcOldPos->bottom - lprcOldPos->top); /* Adjust size & placement */ - if(pwpChild->x + pwpChild->width >= lprcOldPos->right ) + if(pwpChild->x + pwpChild->width >= lprcOldPos->right && + (pwpChild->x + pwpChild->width < screenWidth - 5 || delta_x > 0) ) // keep right edge glued to display edge if touching pwpChild->width += delta_x; - if(pwpChild->y + pwpChild->height >= lprcOldPos->bottom ) + if(pwpChild->x + pwpChild->width >= screenWidth ) // don't move right edge off screen + pwpChild->width = screenWidth - pwpChild->x; + if(pwpChild->y + pwpChild->height >= lprcOldPos->bottom && + (pwpChild->y + pwpChild->height < screenHeight - 35 || delta_y > 0) ) // keep bottom edge glued to display edge if touching pwpChild->height += delta_y; + if(pwpChild->y + pwpChild->height >= screenHeight - 30 ) // don't move bottom edge off screen + pwpChild->height = screenHeight - 30 - pwpChild->y; if(pwpChild->x >= lprcOldPos->right) pwpChild->width -= delta_x, pwpChild->x += delta_x; if(pwpChild->y >= lprcOldPos->bottom) pwpChild->height -= delta_y, pwpChild->y += delta_y; + if(pwpChild->width < 30) pwpChild->width = 30; // force minimum width + if(pwpChild->height < 50) pwpChild->height = 50; // force minimum height /* Move window */ if( hWndChild != NULL ) { SetWindowPos( hWndChild, HWND_TOP, -- 1.7.0.4