|
@@ -1261,7 +1261,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
|
if (_glfw.win32.disabledCursorWindow == window)
|
|
if (_glfw.win32.disabledCursorWindow == window)
|
|
_glfw.win32.disabledCursorWindow = NULL;
|
|
_glfw.win32.disabledCursorWindow = NULL;
|
|
|
|
|
|
- if (window->win32.handle)
|
|
|
|
|
|
+ if (window->win32.handle && !window->win32.external)
|
|
{
|
|
{
|
|
RemovePropW(window->win32.handle, L"GLFW");
|
|
RemovePropW(window->win32.handle, L"GLFW");
|
|
DestroyWindow(window->win32.handle);
|
|
DestroyWindow(window->win32.handle);
|
|
@@ -1998,3 +1998,102 @@ GLFWAPI HWND glfwGetWin32Window(GLFWwindow* handle)
|
|
return window->win32.handle;
|
|
return window->win32.handle;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+GLFWAPI GLFWwindow* glfwAttachWin32Window(HWND handle, GLFWwindow* share)
|
|
|
|
+{
|
|
|
|
+ _GLFWfbconfig fbconfig;
|
|
|
|
+ _GLFWctxconfig ctxconfig;
|
|
|
|
+ _GLFWwndconfig wndconfig;
|
|
|
|
+ _GLFWwindow* window;
|
|
|
|
+
|
|
|
|
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
|
|
|
+
|
|
|
|
+ fbconfig = _glfw.hints.framebuffer;
|
|
|
|
+ ctxconfig = _glfw.hints.context;
|
|
|
|
+ wndconfig = _glfw.hints.window;
|
|
|
|
+
|
|
|
|
+ ctxconfig.share = (_GLFWwindow*) share;
|
|
|
|
+ if (ctxconfig.share)
|
|
|
|
+ {
|
|
|
|
+ if (ctxconfig.client == GLFW_NO_API ||
|
|
|
|
+ ctxconfig.share->context.client == GLFW_NO_API)
|
|
|
|
+ {
|
|
|
|
+ _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
|
|
|
+ return NULL;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!_glfwIsValidContextConfig(&ctxconfig))
|
|
|
|
+ return NULL;
|
|
|
|
+
|
|
|
|
+ window = calloc(1, sizeof(_GLFWwindow));
|
|
|
|
+ window->next = _glfw.windowListHead;
|
|
|
|
+ _glfw.windowListHead = window;
|
|
|
|
+
|
|
|
|
+ window->autoIconify = wndconfig.autoIconify;
|
|
|
|
+ window->cursorMode = GLFW_CURSOR_NORMAL;
|
|
|
|
+
|
|
|
|
+ window->minwidth = GLFW_DONT_CARE;
|
|
|
|
+ window->minheight = GLFW_DONT_CARE;
|
|
|
|
+ window->maxwidth = GLFW_DONT_CARE;
|
|
|
|
+ window->maxheight = GLFW_DONT_CARE;
|
|
|
|
+ window->numer = GLFW_DONT_CARE;
|
|
|
|
+ window->denom = GLFW_DONT_CARE;
|
|
|
|
+
|
|
|
|
+ window->win32.handle = handle;
|
|
|
|
+ window->win32.external = GLFW_TRUE;
|
|
|
|
+
|
|
|
|
+ SetPropW(window->win32.handle, L"GLFW", window);
|
|
|
|
+ SetWindowLongPtrW(window->win32.handle, GWLP_WNDPROC, (LONG_PTR) windowProc);
|
|
|
|
+
|
|
|
|
+ {
|
|
|
|
+ const DWORD style = GetWindowLongW(window->win32.handle, GWL_STYLE);
|
|
|
|
+ const DWORD exStyle = GetWindowLongW(window->win32.handle, GWL_EXSTYLE);
|
|
|
|
+
|
|
|
|
+ if (style & WS_THICKFRAME)
|
|
|
|
+ window->resizable = GLFW_TRUE;
|
|
|
|
+ if (style & (WS_BORDER | WS_THICKFRAME))
|
|
|
|
+ window->decorated = GLFW_TRUE;
|
|
|
|
+ if (exStyle & WS_EX_TOPMOST)
|
|
|
|
+ window->floating = GLFW_TRUE;
|
|
|
|
+
|
|
|
|
+ window->win32.maximized = IsZoomed(window->win32.handle);
|
|
|
|
+ window->win32.iconified = IsIconic(window->win32.handle);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (ctxconfig.client != GLFW_NO_API)
|
|
|
|
+ {
|
|
|
|
+ if (ctxconfig.source == GLFW_NATIVE_CONTEXT_API)
|
|
|
|
+ {
|
|
|
|
+ if (!_glfwInitWGL())
|
|
|
|
+ return GLFW_FALSE;
|
|
|
|
+ if (!_glfwCreateContextWGL(window, &ctxconfig, &fbconfig))
|
|
|
|
+ return GLFW_FALSE;
|
|
|
|
+ }
|
|
|
|
+ else if (ctxconfig.source == GLFW_EGL_CONTEXT_API)
|
|
|
|
+ {
|
|
|
|
+ if (!_glfwInitEGL())
|
|
|
|
+ return GLFW_FALSE;
|
|
|
|
+ if (!_glfwCreateContextEGL(window, &ctxconfig, &fbconfig))
|
|
|
|
+ return GLFW_FALSE;
|
|
|
|
+ }
|
|
|
|
+ else if (ctxconfig.source == GLFW_OSMESA_CONTEXT_API)
|
|
|
|
+ {
|
|
|
|
+ if (!_glfwInitOSMesa())
|
|
|
|
+ return GLFW_FALSE;
|
|
|
|
+ if (!_glfwCreateContextOSMesa(window, &ctxconfig, &fbconfig))
|
|
|
|
+ return GLFW_FALSE;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (ctxconfig.client != GLFW_NO_API)
|
|
|
|
+ {
|
|
|
|
+ if (!_glfwRefreshContextAttribs(window, &ctxconfig))
|
|
|
|
+ {
|
|
|
|
+ glfwDestroyWindow((GLFWwindow*) window);
|
|
|
|
+ return NULL;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return (GLFWwindow*) window;
|
|
|
|
+}
|
|
|
|
+
|