From 10f621441f29c1f4e8b612e57f3619debc2b6808 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sat, 18 Apr 2015 23:59:01 +0100 Subject: Fix bounding on windows frontend window scrolling --- windows/window.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'windows') diff --git a/windows/window.c b/windows/window.c index fae9247ef..ece8b341a 100644 --- a/windows/window.c +++ b/windows/window.c @@ -797,8 +797,27 @@ void win32_window_set_scroll(struct gui_window *w, int sx, int sy) return; } - w->requestscrollx = sx - w->scrollx; - w->requestscrolly = sy - w->scrolly; + /*LOG(("scroll sx,sy:%d,%d x,y:%d,%d w.h:%d,%d",sx,sy,w->scrollx,w->scrolly, width,height));*/ + + /* The resulting gui window scroll must remain withn the + * windows bounding box. + */ + if (sx < 0) { + w->requestscrollx = -w->scrollx; + } else if (sx > (width - w->width)) { + w->requestscrollx = (width - w->width) - w->scrollx; + } else { + w->requestscrollx = sx - w->scrollx; + } + if (sy < 0) { + w->requestscrolly = -w->scrolly; + } else if (sy > (height - w->height)) { + w->requestscrolly = (height - w->height) - w->scrolly; + } else { + w->requestscrolly = sy - w->scrolly; + } + + /*LOG(("requestscroll x,y:%d,%d", w->requestscrollx, w->requestscrolly));*/ /* set the vertical scroll offset */ si.cbSize = sizeof(si); @@ -809,7 +828,7 @@ void win32_window_set_scroll(struct gui_window *w, int sx, int sy) si.nPos = max(w->scrolly + w->requestscrolly, 0); si.nPos = min(si.nPos, height - w->height); SetScrollInfo(w->drawingarea, SB_VERT, &si, TRUE); - LOG(("SetScrollInfo VERT min:%d max:%d page:%d pos:%d", si.nMin, si.nMax, si.nPage, si.nPos)); + /*LOG(("SetScrollInfo VERT min:%d max:%d page:%d pos:%d", si.nMin, si.nMax, si.nPage, si.nPos));*/ /* set the horizontal scroll offset */ si.cbSize = sizeof(si); @@ -820,7 +839,7 @@ void win32_window_set_scroll(struct gui_window *w, int sx, int sy) si.nPos = max(w->scrollx + w->requestscrollx, 0); si.nPos = min(si.nPos, width - w->width); SetScrollInfo(w->drawingarea, SB_HORZ, &si, TRUE); - LOG(("SetScrollInfo HORZ min:%d max:%d page:%d pos:%d", si.nMin, si.nMax, si.nPage, si.nPos)); + /*LOG(("SetScrollInfo HORZ min:%d max:%d page:%d pos:%d", si.nMin, si.nMax, si.nPage, si.nPos));*/ /* Set caret position */ GetCaretPos(&p); @@ -834,6 +853,7 @@ void win32_window_set_scroll(struct gui_window *w, int sx, int sy) r.left = 0; r.right = w->width + 1; ScrollWindowEx(w->drawingarea, - w->requestscrollx, - w->requestscrolly, &r, NULL, NULL, &redraw, SW_INVALIDATE); + /*LOG(("ScrollWindowEx %d, %d", - w->requestscrollx, - w->requestscrolly));*/ w->scrolly += w->requestscrolly; w->scrollx += w->requestscrollx; w->requestscrollx = 0; -- cgit v1.2.3