]> git.tdb.fi Git - libs/gui.git/blobdiff - source/graphics/windows/window.cpp
Track window positions
[libs/gui.git] / source / graphics / windows / window.cpp
index e9989501565b303c16ae3fe9eaad4dce9d8b1ee2..b148915d9bc94b6581037a682c3982c0bf78212f 100644 (file)
@@ -1,3 +1,4 @@
+#define _WIN32_WINNT 0x0601
 #include <windowsx.h>
 #include <msp/core/application.h>
 #include <msp/core/systemerror.h>
@@ -22,6 +23,7 @@ LRESULT CALLBACK wndproc_(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
                ev.msg = msg;
                ev.wparam = wparam;
                ev.lparam = lparam;
+               ev.extra = GetMessageExtraInfo();
                if(wnd && wnd->event(ev))
                        return 0;
        }
@@ -129,6 +131,21 @@ void Window::warp_pointer(int, int)
 {
 }
 
+void Window::platform_set_touch_input()
+{
+       WORD winver = LOWORD(GetVersion);
+       if(winver<_WIN32_WINNT)
+       {
+               touch_input = false;
+               throw runtime_error("no touch support");
+       }
+
+       if(touch_input)
+               RegisterTouchWindow(priv->window, 3);  // TWF_FINETOUCH|TWF_WANTPALM
+       else
+               UnregisterTouchWindow(priv->window);
+}
+
 void Window::platform_show()
 {
        ShowWindow(priv->window, SW_SHOWNORMAL);
@@ -145,6 +162,7 @@ bool Window::event(const Event &evnt)
        {
        case WM_KEYDOWN:
        case WM_KEYUP:
+       case WM_CHAR:
        case WM_LBUTTONDOWN:
        case WM_LBUTTONUP:
        case WM_MBUTTONDOWN:
@@ -153,6 +171,7 @@ bool Window::event(const Event &evnt)
        case WM_RBUTTONUP:
        case WM_MOUSEWHEEL:
        case WM_MOUSEMOVE:
+       case WM_TOUCHMOVE:
                signal_input_event.emit(evnt);
                break;
        case WM_SIZE:
@@ -161,9 +180,23 @@ bool Window::event(const Event &evnt)
                resizing = false;
                signal_resize.emit(options.width, options.height);
                break;
+       case WM_MOVE:
+               options.x = static_cast<short>(LOWORD(evnt.lparam));
+               options.y = static_cast<short>(HIWORD(evnt.lparam));
+               signal_move.emit(options.x, options.y);
+               break;
        case WM_CLOSE:
                signal_close.emit();
                break;
+       case WM_PAINT:
+               {
+                       RECT update_rect;
+                       GetUpdateRect(priv->window, &update_rect, false);
+                       unsigned width = update_rect.right-update_rect.left;
+                       unsigned height = update_rect.bottom-update_rect.top;
+                       signal_expose.emit(update_rect.left, update_rect.top, width, height, evnt);
+               }
+               break;
        default:
                return false;
        }