Move management of shared state to shared code

Platform code may not modify shared state.

Related to #1568.
This commit is contained in:
Camilla Löwy 2020-07-06 23:37:33 +02:00
parent 7da3e52c86
commit 6d2003d07a
5 changed files with 14 additions and 19 deletions

View File

@ -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];
}

View File

@ -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)

View File

@ -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);
}

View File

@ -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)

View File

@ -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)