[aseprite] 166/308: Add scrollbars to Skia/Win SkiaDisplay to support trackpad scroll messages
Tobias Hansen
thansen at moszumanska.debian.org
Tue Mar 8 02:45:06 UTC 2016
This is an automated email from the git hooks/post-receive script.
thansen pushed a commit to branch master
in repository aseprite.
commit d496236d083982e79f16b9ae3237ce75f1e76b17
Author: David Capello <davidcapello at gmail.com>
Date: Mon Dec 28 16:54:50 2015 -0300
Add scrollbars to Skia/Win SkiaDisplay to support trackpad scroll messages
---
src/she/win/window.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 54 insertions(+), 1 deletion(-)
diff --git a/src/she/win/window.h b/src/she/win/window.h
index 0fc603c..a402dae 100644
--- a/src/she/win/window.h
+++ b/src/she/win/window.h
@@ -512,6 +512,46 @@ namespace she {
break;
}
+ case WM_NCCALCSIZE: {
+ if (wparam) {
+ // Scrollbars must be enabled and visible to get trackpad
+ // events of old drivers. So we cannot use ShowScrollBar() to
+ // hide them. This is a simple (maybe not so elegant)
+ // solution: Expand the client area to we overlap the
+ // scrollbars. In this way they are not visible, but we still
+ // get their messages.
+ NCCALCSIZE_PARAMS* cs = reinterpret_cast<NCCALCSIZE_PARAMS*>(lparam);
+ cs->rgrc[0].right += GetSystemMetrics(SM_CYVSCROLL);
+ cs->rgrc[0].bottom += GetSystemMetrics(SM_CYHSCROLL);
+ }
+ break;
+ }
+
+ case WM_NCHITTEST: {
+ LRESULT result = CallWindowProc(DefWindowProc, m_hwnd, msg, wparam, lparam);
+ gfx::Point pt(GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
+
+ RECT rc;
+ GetClientRect(m_hwnd, &rc);
+ MapWindowPoints(m_hwnd, NULL, (POINT*)&rc, 2);
+ gfx::Rect area(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top);
+
+ //LOG("NCHITTEST: %d %d - %d %d %d %d - %s\n", pt.x, pt.y, area.x, area.y, area.w, area.h, area.contains(pt) ? "true": "false");
+
+ // We ignore scrollbars so if the mouse is above them, we return
+ // as it's in the window client or resize area. (Remember that
+ // we have scroll bars are enabled and visible to receive
+ // trackpad messages only.)
+ if (result == HTHSCROLL) {
+ result = (area.contains(pt) ? HTCLIENT: HTBOTTOM);
+ }
+ else if (result == HTVSCROLL) {
+ result = (area.contains(pt) ? HTCLIENT: HTRIGHT);
+ }
+
+ return result;
+ }
+
}
return DefWindowProc(m_hwnd, msg, wparam, lparam);
@@ -546,7 +586,7 @@ namespace she {
WS_EX_APPWINDOW | WS_EX_ACCEPTFILES,
SHE_WND_CLASS_NAME,
L"",
- WS_OVERLAPPEDWINDOW,
+ WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL,
CW_USEDEFAULT, CW_USEDEFAULT,
width, height,
nullptr,
@@ -557,6 +597,19 @@ namespace she {
return nullptr;
SetWindowLongPtr(hwnd, GWLP_USERDATA, LONG_PTR(self));
+
+ // Set scroll info to receive WM_HSCROLL/VSCROLL events (events
+ // generated by some trackpad drivers).
+ SCROLLINFO si;
+ si.cbSize = sizeof(SCROLLINFO);
+ si.fMask = SIF_POS | SIF_RANGE | SIF_PAGE;
+ si.nMin = 0;
+ si.nPos = 50;
+ si.nMax = 100;
+ si.nPage = 10;
+ SetScrollInfo(hwnd, SB_HORZ, &si, FALSE);
+ SetScrollInfo(hwnd, SB_VERT, &si, FALSE);
+
return hwnd;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git
More information about the Pkg-games-commits
mailing list