modules/graphics/src/main/native-glass/win/GlassWindow.cpp

Print this page

        

@@ -57,10 +57,11 @@
 static jmethodID midNotifyMoveToAnotherScreen;
 
 unsigned int GlassWindow::sm_instanceCounter = 0;
 HHOOK GlassWindow::sm_hCBTFilter = NULL;
 HWND GlassWindow::sm_grabWindow = NULL;
+static HWND activeTouchWindow = NULL;
 
 GlassWindow::GlassWindow(jobject jrefThis, bool isTransparent, bool isDecorated, bool isUnified, bool isChild, HWND parentOrOwner)
     : BaseWnd(parentOrOwner),
     ViewContainer(),
     m_state(Normal),

@@ -573,11 +574,18 @@
             CheckUngrab(); // check if other owned windows hierarchy holds the grab
             // Pass the event to DefWindowProc()
             break;
         case WM_TOUCH:
             if (IsEnabled()) {
-                HandleViewTouchEvent(GetHWND(), msg, wParam, lParam);
+                if (activeTouchWindow == 0 || activeTouchWindow == GetHWND()) {
+                    if(HandleViewTouchEvent(GetHWND(), msg, wParam, lParam) > 0) {
+                        activeTouchWindow = GetHWND();
+                    } else {
+                        activeTouchWindow = 0;
+                    }
+                } 
+            fflush(stdout);
                 return 0;
             }
             break;
         case WM_TIMER:
             HandleViewTimerEvent(GetHWND(), wParam);

@@ -1276,10 +1284,14 @@
     (JNIEnv * env, jobject jThis, jlong ptr, jobject view)
 {
     ENTER_MAIN_THREAD()
     {
         GlassWindow *pWindow = GlassWindow::FromHandle(hWnd);
+
+        if (activeTouchWindow == hWnd) {
+            activeTouchWindow = 0;
+        }
         pWindow->ResetMouseTracking(hWnd);
         pWindow->SetGlassView(view);
         // The condition below may be restricted to WS_POPUP windows
         if (::IsWindowVisible(hWnd)) {
             pWindow->NotifyViewSize(hWnd);

@@ -1564,10 +1576,15 @@
             if (pWindow) {
                 pWindow->UngrabFocus();
             }
         }
         
+        if (!visible && activeTouchWindow == hWnd) {
+            pWindow->HandleViewTouchEvent(hWnd, 0, 0, 0);
+            activeTouchWindow = 0;
+        }
+        
         ::ShowWindow(hWnd, visible ? SW_SHOW : SW_HIDE);
         
         if (visible) {
             if (pWindow) {
                 if (pWindow->IsFocusable()) {