Browse Source

Move management of shared state to shared code

Platform code may not modify shared state.

Related to #1568.
Camilla Löwy 5 years ago
parent
commit
6d2003d07a
5 changed files with 14 additions and 19 deletions
  1. 0 1
      src/cocoa_window.m
  2. 0 2
      src/win32_window.c
  3. 14 7
      src/window.c
  4. 0 4
      src/wl_window.c
  5. 0 5
      src/x11_window.c

+ 0 - 1
src/cocoa_window.m

@@ -1373,7 +1373,6 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
 
 void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled)
 {
-    window->mousePassthrough = enabled;
     @autoreleasepool {
     [window->ns.object setIgnoresMouseEvents:enabled];
     }

+ 0 - 2
src/win32_window.c

@@ -1887,8 +1887,6 @@ void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enable
 
     if (enabled)
         SetLayeredWindowAttributes(window->win32.handle, key, alpha, flags);
-
-    window->mousePassthrough = enabled;
 }
 
 float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)

+ 14 - 7
src/window.c

@@ -197,13 +197,14 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
     window->videoMode.blueBits    = fbconfig.blueBits;
     window->videoMode.refreshRate = _glfw.hints.refreshRate;
 
-    window->monitor     = (_GLFWmonitor*) monitor;
-    window->resizable   = wndconfig.resizable;
-    window->decorated   = wndconfig.decorated;
-    window->autoIconify = wndconfig.autoIconify;
-    window->floating    = wndconfig.floating;
-    window->focusOnShow = wndconfig.focusOnShow;
-    window->cursorMode  = GLFW_CURSOR_NORMAL;
+    window->monitor          = (_GLFWmonitor*) monitor;
+    window->resizable        = wndconfig.resizable;
+    window->decorated        = wndconfig.decorated;
+    window->autoIconify      = wndconfig.autoIconify;
+    window->floating         = wndconfig.floating;
+    window->focusOnShow      = wndconfig.focusOnShow;
+    window->mousePassthrough = wndconfig.mousePassthrough;
+    window->cursorMode       = GLFW_CURSOR_NORMAL;
 
     window->minwidth    = GLFW_DONT_CARE;
     window->minheight   = GLFW_DONT_CARE;
@@ -908,7 +909,13 @@ GLFWAPI void glfwSetWindowAttrib(GLFWwindow* handle, int attrib, int value)
     else if (attrib == GLFW_FOCUS_ON_SHOW)
         window->focusOnShow = value;
     else if (attrib == GLFW_MOUSE_PASSTHROUGH)
+    {
+        if (window->mousePassthrough == value)
+            return;
+
+        window->mousePassthrough = value;
         _glfwPlatformSetWindowMousePassthrough(window, value);
+    }
     else
         _glfwInputError(GLFW_INVALID_ENUM, "Invalid window attribute 0x%08X", attrib);
 }

+ 0 - 4
src/wl_window.c

@@ -1129,9 +1129,6 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
 
 void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled)
 {
-    if (enabled == window->mousePassthrough)
-        return;
-
     if (enabled)
     {
         struct wl_region* region = wl_compositor_create_region(_glfw.wl.compositor);
@@ -1141,7 +1138,6 @@ void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enable
     else
         wl_surface_set_input_region(window->wl.surface, 0);
     wl_surface_commit(window->wl.surface);
-    window->mousePassthrough = enabled;
 }
 
 float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)

+ 0 - 5
src/x11_window.c

@@ -2707,9 +2707,6 @@ void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enable
     if (!_glfw.x11.xshape.available)
         return;
 
-    if (enabled == window->mousePassthrough)
-        return;
-
     if (enabled)
     {
         Region region = XCreateRegion();
@@ -2722,8 +2719,6 @@ void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enable
         XShapeCombineMask(_glfw.x11.display, window->x11.handle,
                           ShapeInput, 0, 0, None, ShapeSet);
     }
-
-    window->mousePassthrough = enabled;
 }
 
 float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)