diff options
author | Vincent Sanders <vince@kyllikki.org> | 2015-04-18 23:59:01 +0100 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2015-04-18 23:59:01 +0100 |
commit | 10f621441f29c1f4e8b612e57f3619debc2b6808 (patch) | |
tree | 6448aa430c75d8acafc959daf8ac466867b8986e | |
parent | 2465fc4e6b8476fff1e081536e6145e4ce811ee5 (diff) | |
download | netsurf-10f621441f29c1f4e8b612e57f3619debc2b6808.tar.gz netsurf-10f621441f29c1f4e8b612e57f3619debc2b6808.tar.bz2 |
Fix bounding on windows frontend window scrolling
-rw-r--r-- | windows/window.c | 28 |
1 files changed, 24 insertions, 4 deletions
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; |