Merge commit '26c8cc348eacea01237cd64e1a68d0df8141e848'
This commit is contained in:
304
deps/glfw/src/window.c
vendored
304
deps/glfw/src/window.c
vendored
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 - www.glfw.org
|
||||
// GLFW 3.4 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
@ -25,8 +25,6 @@
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
// Please use C89 style variable declarations in this file because VS 2010
|
||||
//========================================================================
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
@ -44,6 +42,9 @@
|
||||
//
|
||||
void _glfwInputWindowFocus(_GLFWwindow* window, GLFWbool focused)
|
||||
{
|
||||
assert(window != NULL);
|
||||
assert(focused == GLFW_TRUE || focused == GLFW_FALSE);
|
||||
|
||||
if (window->callbacks.focus)
|
||||
window->callbacks.focus((GLFWwindow*) window, focused);
|
||||
|
||||
@ -55,7 +56,7 @@ void _glfwInputWindowFocus(_GLFWwindow* window, GLFWbool focused)
|
||||
{
|
||||
if (window->keys[key] == GLFW_PRESS)
|
||||
{
|
||||
const int scancode = _glfwPlatformGetKeyScancode(key);
|
||||
const int scancode = _glfw.platform.getKeyScancode(key);
|
||||
_glfwInputKey(window, key, scancode, GLFW_RELEASE, 0);
|
||||
}
|
||||
}
|
||||
@ -73,6 +74,8 @@ void _glfwInputWindowFocus(_GLFWwindow* window, GLFWbool focused)
|
||||
//
|
||||
void _glfwInputWindowPos(_GLFWwindow* window, int x, int y)
|
||||
{
|
||||
assert(window != NULL);
|
||||
|
||||
if (window->callbacks.pos)
|
||||
window->callbacks.pos((GLFWwindow*) window, x, y);
|
||||
}
|
||||
@ -82,6 +85,10 @@ void _glfwInputWindowPos(_GLFWwindow* window, int x, int y)
|
||||
//
|
||||
void _glfwInputWindowSize(_GLFWwindow* window, int width, int height)
|
||||
{
|
||||
assert(window != NULL);
|
||||
assert(width >= 0);
|
||||
assert(height >= 0);
|
||||
|
||||
if (window->callbacks.size)
|
||||
window->callbacks.size((GLFWwindow*) window, width, height);
|
||||
}
|
||||
@ -90,6 +97,9 @@ void _glfwInputWindowSize(_GLFWwindow* window, int width, int height)
|
||||
//
|
||||
void _glfwInputWindowIconify(_GLFWwindow* window, GLFWbool iconified)
|
||||
{
|
||||
assert(window != NULL);
|
||||
assert(iconified == GLFW_TRUE || iconified == GLFW_FALSE);
|
||||
|
||||
if (window->callbacks.iconify)
|
||||
window->callbacks.iconify((GLFWwindow*) window, iconified);
|
||||
}
|
||||
@ -98,6 +108,9 @@ void _glfwInputWindowIconify(_GLFWwindow* window, GLFWbool iconified)
|
||||
//
|
||||
void _glfwInputWindowMaximize(_GLFWwindow* window, GLFWbool maximized)
|
||||
{
|
||||
assert(window != NULL);
|
||||
assert(maximized == GLFW_TRUE || maximized == GLFW_FALSE);
|
||||
|
||||
if (window->callbacks.maximize)
|
||||
window->callbacks.maximize((GLFWwindow*) window, maximized);
|
||||
}
|
||||
@ -107,6 +120,10 @@ void _glfwInputWindowMaximize(_GLFWwindow* window, GLFWbool maximized)
|
||||
//
|
||||
void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height)
|
||||
{
|
||||
assert(window != NULL);
|
||||
assert(width >= 0);
|
||||
assert(height >= 0);
|
||||
|
||||
if (window->callbacks.fbsize)
|
||||
window->callbacks.fbsize((GLFWwindow*) window, width, height);
|
||||
}
|
||||
@ -116,6 +133,12 @@ void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height)
|
||||
//
|
||||
void _glfwInputWindowContentScale(_GLFWwindow* window, float xscale, float yscale)
|
||||
{
|
||||
assert(window != NULL);
|
||||
assert(xscale > 0.f);
|
||||
assert(xscale < FLT_MAX);
|
||||
assert(yscale > 0.f);
|
||||
assert(yscale < FLT_MAX);
|
||||
|
||||
if (window->callbacks.scale)
|
||||
window->callbacks.scale((GLFWwindow*) window, xscale, yscale);
|
||||
}
|
||||
@ -124,6 +147,8 @@ void _glfwInputWindowContentScale(_GLFWwindow* window, float xscale, float yscal
|
||||
//
|
||||
void _glfwInputWindowDamage(_GLFWwindow* window)
|
||||
{
|
||||
assert(window != NULL);
|
||||
|
||||
if (window->callbacks.refresh)
|
||||
window->callbacks.refresh((GLFWwindow*) window);
|
||||
}
|
||||
@ -132,6 +157,8 @@ void _glfwInputWindowDamage(_GLFWwindow* window)
|
||||
//
|
||||
void _glfwInputWindowCloseRequest(_GLFWwindow* window)
|
||||
{
|
||||
assert(window != NULL);
|
||||
|
||||
window->shouldClose = GLFW_TRUE;
|
||||
|
||||
if (window->callbacks.close)
|
||||
@ -142,6 +169,7 @@ void _glfwInputWindowCloseRequest(_GLFWwindow* window)
|
||||
//
|
||||
void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor)
|
||||
{
|
||||
assert(window != NULL);
|
||||
window->monitor = monitor;
|
||||
}
|
||||
|
||||
@ -186,7 +214,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
||||
if (!_glfwIsValidContextConfig(&ctxconfig))
|
||||
return NULL;
|
||||
|
||||
window = calloc(1, sizeof(_GLFWwindow));
|
||||
window = _glfw_calloc(1, sizeof(_GLFWwindow));
|
||||
window->next = _glfw.windowListHead;
|
||||
_glfw.windowListHead = window;
|
||||
|
||||
@ -197,13 +225,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->doublebuffer = fbconfig.doublebuffer;
|
||||
|
||||
@ -213,38 +242,14 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
||||
window->maxheight = GLFW_DONT_CARE;
|
||||
window->numer = GLFW_DONT_CARE;
|
||||
window->denom = GLFW_DONT_CARE;
|
||||
window->title = _glfw_strdup(title);
|
||||
|
||||
// Open the actual window and create its context
|
||||
if (!_glfwPlatformCreateWindow(window, &wndconfig, &ctxconfig, &fbconfig))
|
||||
if (!_glfw.platform.createWindow(window, &wndconfig, &ctxconfig, &fbconfig))
|
||||
{
|
||||
glfwDestroyWindow((GLFWwindow*) window);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (ctxconfig.client != GLFW_NO_API)
|
||||
{
|
||||
if (!_glfwRefreshContextAttribs(window, &ctxconfig))
|
||||
{
|
||||
glfwDestroyWindow((GLFWwindow*) window);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (window->monitor)
|
||||
{
|
||||
if (wndconfig.centerCursor)
|
||||
_glfwCenterCursorInContentArea(window);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (wndconfig.visible)
|
||||
{
|
||||
_glfwPlatformShowWindow(window);
|
||||
if (wndconfig.focused)
|
||||
_glfwPlatformFocusWindow(window);
|
||||
}
|
||||
}
|
||||
|
||||
return (GLFWwindow*) window;
|
||||
}
|
||||
|
||||
@ -268,6 +273,9 @@ void glfwDefaultWindowHints(void)
|
||||
_glfw.hints.window.autoIconify = GLFW_TRUE;
|
||||
_glfw.hints.window.centerCursor = GLFW_TRUE;
|
||||
_glfw.hints.window.focusOnShow = GLFW_TRUE;
|
||||
_glfw.hints.window.xpos = GLFW_ANY_POSITION;
|
||||
_glfw.hints.window.ypos = GLFW_ANY_POSITION;
|
||||
_glfw.hints.window.scaleFramebuffer = GLFW_TRUE;
|
||||
|
||||
// The default is 24 bits of color, 24 bits of depth and 8 bits of stencil,
|
||||
// double buffered
|
||||
@ -282,9 +290,6 @@ void glfwDefaultWindowHints(void)
|
||||
|
||||
// The default is to select the highest available refresh rate
|
||||
_glfw.hints.refreshRate = GLFW_DONT_CARE;
|
||||
|
||||
// The default is to use full Retina resolution framebuffers
|
||||
_glfw.hints.window.ns.retina = GLFW_TRUE;
|
||||
}
|
||||
|
||||
GLFWAPI void glfwWindowHint(int hint, int value)
|
||||
@ -362,8 +367,17 @@ GLFWAPI void glfwWindowHint(int hint, int value)
|
||||
case GLFW_VISIBLE:
|
||||
_glfw.hints.window.visible = value ? GLFW_TRUE : GLFW_FALSE;
|
||||
return;
|
||||
case GLFW_COCOA_RETINA_FRAMEBUFFER:
|
||||
_glfw.hints.window.ns.retina = value ? GLFW_TRUE : GLFW_FALSE;
|
||||
case GLFW_POSITION_X:
|
||||
_glfw.hints.window.xpos = value;
|
||||
return;
|
||||
case GLFW_POSITION_Y:
|
||||
_glfw.hints.window.ypos = value;
|
||||
return;
|
||||
case GLFW_WIN32_KEYBOARD_MENU:
|
||||
_glfw.hints.window.win32.keymenu = value ? GLFW_TRUE : GLFW_FALSE;
|
||||
return;
|
||||
case GLFW_WIN32_SHOWDEFAULT:
|
||||
_glfw.hints.window.win32.showDefault = value ? GLFW_TRUE : GLFW_FALSE;
|
||||
return;
|
||||
case GLFW_COCOA_GRAPHICS_SWITCHING:
|
||||
_glfw.hints.context.nsgl.offline = value ? GLFW_TRUE : GLFW_FALSE;
|
||||
@ -371,12 +385,19 @@ GLFWAPI void glfwWindowHint(int hint, int value)
|
||||
case GLFW_SCALE_TO_MONITOR:
|
||||
_glfw.hints.window.scaleToMonitor = value ? GLFW_TRUE : GLFW_FALSE;
|
||||
return;
|
||||
case GLFW_SCALE_FRAMEBUFFER:
|
||||
case GLFW_COCOA_RETINA_FRAMEBUFFER:
|
||||
_glfw.hints.window.scaleFramebuffer = value ? GLFW_TRUE : GLFW_FALSE;
|
||||
return;
|
||||
case GLFW_CENTER_CURSOR:
|
||||
_glfw.hints.window.centerCursor = value ? GLFW_TRUE : GLFW_FALSE;
|
||||
return;
|
||||
case GLFW_FOCUS_ON_SHOW:
|
||||
_glfw.hints.window.focusOnShow = value ? GLFW_TRUE : GLFW_FALSE;
|
||||
return;
|
||||
case GLFW_MOUSE_PASSTHROUGH:
|
||||
_glfw.hints.window.mousePassthrough = value ? GLFW_TRUE : GLFW_FALSE;
|
||||
return;
|
||||
case GLFW_CLIENT_API:
|
||||
_glfw.hints.context.client = value;
|
||||
return;
|
||||
@ -395,7 +416,7 @@ GLFWAPI void glfwWindowHint(int hint, int value)
|
||||
case GLFW_OPENGL_FORWARD_COMPAT:
|
||||
_glfw.hints.context.forward = value ? GLFW_TRUE : GLFW_FALSE;
|
||||
return;
|
||||
case GLFW_OPENGL_DEBUG_CONTEXT:
|
||||
case GLFW_CONTEXT_DEBUG:
|
||||
_glfw.hints.context.debug = value ? GLFW_TRUE : GLFW_FALSE;
|
||||
return;
|
||||
case GLFW_CONTEXT_NO_ERROR:
|
||||
@ -435,6 +456,10 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value)
|
||||
strncpy(_glfw.hints.window.x11.instanceName, value,
|
||||
sizeof(_glfw.hints.window.x11.instanceName) - 1);
|
||||
return;
|
||||
case GLFW_WAYLAND_APP_ID:
|
||||
strncpy(_glfw.hints.window.wl.appId, value,
|
||||
sizeof(_glfw.hints.window.wl.appId) - 1);
|
||||
return;
|
||||
}
|
||||
|
||||
_glfwInputError(GLFW_INVALID_ENUM, "Invalid window hint string 0x%08X", hint);
|
||||
@ -458,7 +483,7 @@ GLFWAPI void glfwDestroyWindow(GLFWwindow* handle)
|
||||
if (window == _glfwPlatformGetTls(&_glfw.contextSlot))
|
||||
glfwMakeContextCurrent(NULL);
|
||||
|
||||
_glfwPlatformDestroyWindow(window);
|
||||
_glfw.platform.destroyWindow(window);
|
||||
|
||||
// Unlink window from global linked list
|
||||
{
|
||||
@ -470,7 +495,8 @@ GLFWAPI void glfwDestroyWindow(GLFWwindow* handle)
|
||||
*prev = window->next;
|
||||
}
|
||||
|
||||
free(window);
|
||||
_glfw_free(window->title);
|
||||
_glfw_free(window);
|
||||
}
|
||||
|
||||
GLFWAPI int glfwWindowShouldClose(GLFWwindow* handle)
|
||||
@ -491,6 +517,16 @@ GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* handle, int value)
|
||||
window->shouldClose = value;
|
||||
}
|
||||
|
||||
GLFWAPI const char* glfwGetWindowTitle(GLFWwindow* handle)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
return window->title;
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
@ -498,19 +534,45 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title)
|
||||
assert(title != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfwPlatformSetWindowTitle(window, title);
|
||||
|
||||
char* prev = window->title;
|
||||
window->title = _glfw_strdup(title);
|
||||
|
||||
_glfw.platform.setWindowTitle(window, title);
|
||||
_glfw_free(prev);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetWindowIcon(GLFWwindow* handle,
|
||||
int count, const GLFWimage* images)
|
||||
{
|
||||
int i;
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
assert(window != NULL);
|
||||
assert(count >= 0);
|
||||
assert(count == 0 || images != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfwPlatformSetWindowIcon(window, count, images);
|
||||
|
||||
if (count < 0)
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_VALUE, "Invalid image count for window icon");
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
assert(images[i].pixels != NULL);
|
||||
|
||||
if (images[i].width <= 0 || images[i].height <= 0)
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_VALUE,
|
||||
"Invalid image dimensions for window icon");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_glfw.platform.setWindowIcon(window, count, images);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwGetWindowPos(GLFWwindow* handle, int* xpos, int* ypos)
|
||||
@ -524,7 +586,7 @@ GLFWAPI void glfwGetWindowPos(GLFWwindow* handle, int* xpos, int* ypos)
|
||||
*ypos = 0;
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfwPlatformGetWindowPos(window, xpos, ypos);
|
||||
_glfw.platform.getWindowPos(window, xpos, ypos);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos)
|
||||
@ -537,7 +599,7 @@ GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos)
|
||||
if (window->monitor)
|
||||
return;
|
||||
|
||||
_glfwPlatformSetWindowPos(window, xpos, ypos);
|
||||
_glfw.platform.setWindowPos(window, xpos, ypos);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwGetWindowSize(GLFWwindow* handle, int* width, int* height)
|
||||
@ -551,7 +613,7 @@ GLFWAPI void glfwGetWindowSize(GLFWwindow* handle, int* width, int* height)
|
||||
*height = 0;
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfwPlatformGetWindowSize(window, width, height);
|
||||
_glfw.platform.getWindowSize(window, width, height);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetWindowSize(GLFWwindow* handle, int width, int height)
|
||||
@ -566,7 +628,7 @@ GLFWAPI void glfwSetWindowSize(GLFWwindow* handle, int width, int height)
|
||||
window->videoMode.width = width;
|
||||
window->videoMode.height = height;
|
||||
|
||||
_glfwPlatformSetWindowSize(window, width, height);
|
||||
_glfw.platform.setWindowSize(window, width, height);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* handle,
|
||||
@ -609,9 +671,9 @@ GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* handle,
|
||||
if (window->monitor || !window->resizable)
|
||||
return;
|
||||
|
||||
_glfwPlatformSetWindowSizeLimits(window,
|
||||
minwidth, minheight,
|
||||
maxwidth, maxheight);
|
||||
_glfw.platform.setWindowSizeLimits(window,
|
||||
minwidth, minheight,
|
||||
maxwidth, maxheight);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* handle, int numer, int denom)
|
||||
@ -640,7 +702,7 @@ GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* handle, int numer, int denom)
|
||||
if (window->monitor || !window->resizable)
|
||||
return;
|
||||
|
||||
_glfwPlatformSetWindowAspectRatio(window, numer, denom);
|
||||
_glfw.platform.setWindowAspectRatio(window, numer, denom);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwGetFramebufferSize(GLFWwindow* handle, int* width, int* height)
|
||||
@ -654,7 +716,7 @@ GLFWAPI void glfwGetFramebufferSize(GLFWwindow* handle, int* width, int* height)
|
||||
*height = 0;
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfwPlatformGetFramebufferSize(window, width, height);
|
||||
_glfw.platform.getFramebufferSize(window, width, height);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* handle,
|
||||
@ -674,7 +736,7 @@ GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* handle,
|
||||
*bottom = 0;
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfwPlatformGetWindowFrameSize(window, left, top, right, bottom);
|
||||
_glfw.platform.getWindowFrameSize(window, left, top, right, bottom);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwGetWindowContentScale(GLFWwindow* handle,
|
||||
@ -689,7 +751,7 @@ GLFWAPI void glfwGetWindowContentScale(GLFWwindow* handle,
|
||||
*yscale = 0.f;
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfwPlatformGetWindowContentScale(window, xscale, yscale);
|
||||
_glfw.platform.getWindowContentScale(window, xscale, yscale);
|
||||
}
|
||||
|
||||
GLFWAPI float glfwGetWindowOpacity(GLFWwindow* handle)
|
||||
@ -697,8 +759,8 @@ GLFWAPI float glfwGetWindowOpacity(GLFWwindow* handle)
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(1.f);
|
||||
return _glfwPlatformGetWindowOpacity(window);
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(0.f);
|
||||
return _glfw.platform.getWindowOpacity(window);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetWindowOpacity(GLFWwindow* handle, float opacity)
|
||||
@ -717,7 +779,7 @@ GLFWAPI void glfwSetWindowOpacity(GLFWwindow* handle, float opacity)
|
||||
return;
|
||||
}
|
||||
|
||||
_glfwPlatformSetWindowOpacity(window, opacity);
|
||||
_glfw.platform.setWindowOpacity(window, opacity);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwIconifyWindow(GLFWwindow* handle)
|
||||
@ -726,7 +788,7 @@ GLFWAPI void glfwIconifyWindow(GLFWwindow* handle)
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfwPlatformIconifyWindow(window);
|
||||
_glfw.platform.iconifyWindow(window);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwRestoreWindow(GLFWwindow* handle)
|
||||
@ -735,7 +797,7 @@ GLFWAPI void glfwRestoreWindow(GLFWwindow* handle)
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfwPlatformRestoreWindow(window);
|
||||
_glfw.platform.restoreWindow(window);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwMaximizeWindow(GLFWwindow* handle)
|
||||
@ -748,7 +810,7 @@ GLFWAPI void glfwMaximizeWindow(GLFWwindow* handle)
|
||||
if (window->monitor)
|
||||
return;
|
||||
|
||||
_glfwPlatformMaximizeWindow(window);
|
||||
_glfw.platform.maximizeWindow(window);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwShowWindow(GLFWwindow* handle)
|
||||
@ -761,10 +823,10 @@ GLFWAPI void glfwShowWindow(GLFWwindow* handle)
|
||||
if (window->monitor)
|
||||
return;
|
||||
|
||||
_glfwPlatformShowWindow(window);
|
||||
_glfw.platform.showWindow(window);
|
||||
|
||||
if (window->focusOnShow)
|
||||
_glfwPlatformFocusWindow(window);
|
||||
_glfw.platform.focusWindow(window);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwRequestWindowAttention(GLFWwindow* handle)
|
||||
@ -774,7 +836,7 @@ GLFWAPI void glfwRequestWindowAttention(GLFWwindow* handle)
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
_glfwPlatformRequestWindowAttention(window);
|
||||
_glfw.platform.requestWindowAttention(window);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwHideWindow(GLFWwindow* handle)
|
||||
@ -787,7 +849,7 @@ GLFWAPI void glfwHideWindow(GLFWwindow* handle)
|
||||
if (window->monitor)
|
||||
return;
|
||||
|
||||
_glfwPlatformHideWindow(window);
|
||||
_glfw.platform.hideWindow(window);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwFocusWindow(GLFWwindow* handle)
|
||||
@ -797,7 +859,7 @@ GLFWAPI void glfwFocusWindow(GLFWwindow* handle)
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
_glfwPlatformFocusWindow(window);
|
||||
_glfw.platform.focusWindow(window);
|
||||
}
|
||||
|
||||
GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
|
||||
@ -810,19 +872,21 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
|
||||
switch (attrib)
|
||||
{
|
||||
case GLFW_FOCUSED:
|
||||
return _glfwPlatformWindowFocused(window);
|
||||
return _glfw.platform.windowFocused(window);
|
||||
case GLFW_ICONIFIED:
|
||||
return _glfwPlatformWindowIconified(window);
|
||||
return _glfw.platform.windowIconified(window);
|
||||
case GLFW_VISIBLE:
|
||||
return _glfwPlatformWindowVisible(window);
|
||||
return _glfw.platform.windowVisible(window);
|
||||
case GLFW_MAXIMIZED:
|
||||
return _glfwPlatformWindowMaximized(window);
|
||||
return _glfw.platform.windowMaximized(window);
|
||||
case GLFW_HOVERED:
|
||||
return _glfwPlatformWindowHovered(window);
|
||||
return _glfw.platform.windowHovered(window);
|
||||
case GLFW_FOCUS_ON_SHOW:
|
||||
return window->focusOnShow;
|
||||
case GLFW_MOUSE_PASSTHROUGH:
|
||||
return window->mousePassthrough;
|
||||
case GLFW_TRANSPARENT_FRAMEBUFFER:
|
||||
return _glfwPlatformFramebufferTransparent(window);
|
||||
return _glfw.platform.framebufferTransparent(window);
|
||||
case GLFW_RESIZABLE:
|
||||
return window->resizable;
|
||||
case GLFW_DECORATED:
|
||||
@ -831,6 +895,8 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
|
||||
return window->floating;
|
||||
case GLFW_AUTO_ICONIFY:
|
||||
return window->autoIconify;
|
||||
case GLFW_DOUBLEBUFFER:
|
||||
return window->doublebuffer;
|
||||
case GLFW_CLIENT_API:
|
||||
return window->context.client;
|
||||
case GLFW_CONTEXT_CREATION_API:
|
||||
@ -845,7 +911,7 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
|
||||
return window->context.robustness;
|
||||
case GLFW_OPENGL_FORWARD_COMPAT:
|
||||
return window->context.forward;
|
||||
case GLFW_OPENGL_DEBUG_CONTEXT:
|
||||
case GLFW_CONTEXT_DEBUG:
|
||||
return window->context.debug;
|
||||
case GLFW_OPENGL_PROFILE:
|
||||
return window->context.profile;
|
||||
@ -868,39 +934,41 @@ GLFWAPI void glfwSetWindowAttrib(GLFWwindow* handle, int attrib, int value)
|
||||
|
||||
value = value ? GLFW_TRUE : GLFW_FALSE;
|
||||
|
||||
if (attrib == GLFW_AUTO_ICONIFY)
|
||||
window->autoIconify = value;
|
||||
else if (attrib == GLFW_RESIZABLE)
|
||||
switch (attrib)
|
||||
{
|
||||
if (window->resizable == value)
|
||||
case GLFW_AUTO_ICONIFY:
|
||||
window->autoIconify = value;
|
||||
return;
|
||||
|
||||
window->resizable = value;
|
||||
if (!window->monitor)
|
||||
_glfwPlatformSetWindowResizable(window, value);
|
||||
}
|
||||
else if (attrib == GLFW_DECORATED)
|
||||
{
|
||||
if (window->decorated == value)
|
||||
case GLFW_RESIZABLE:
|
||||
window->resizable = value;
|
||||
if (!window->monitor)
|
||||
_glfw.platform.setWindowResizable(window, value);
|
||||
return;
|
||||
|
||||
window->decorated = value;
|
||||
if (!window->monitor)
|
||||
_glfwPlatformSetWindowDecorated(window, value);
|
||||
}
|
||||
else if (attrib == GLFW_FLOATING)
|
||||
{
|
||||
if (window->floating == value)
|
||||
case GLFW_DECORATED:
|
||||
window->decorated = value;
|
||||
if (!window->monitor)
|
||||
_glfw.platform.setWindowDecorated(window, value);
|
||||
return;
|
||||
|
||||
window->floating = value;
|
||||
if (!window->monitor)
|
||||
_glfwPlatformSetWindowFloating(window, value);
|
||||
case GLFW_FLOATING:
|
||||
window->floating = value;
|
||||
if (!window->monitor)
|
||||
_glfw.platform.setWindowFloating(window, value);
|
||||
return;
|
||||
|
||||
case GLFW_FOCUS_ON_SHOW:
|
||||
window->focusOnShow = value;
|
||||
return;
|
||||
|
||||
case GLFW_MOUSE_PASSTHROUGH:
|
||||
window->mousePassthrough = value;
|
||||
_glfw.platform.setWindowMousePassthrough(window, value);
|
||||
return;
|
||||
}
|
||||
else if (attrib == GLFW_FOCUS_ON_SHOW)
|
||||
window->focusOnShow = value;
|
||||
else
|
||||
_glfwInputError(GLFW_INVALID_ENUM, "Invalid window attribute 0x%08X", attrib);
|
||||
|
||||
_glfwInputError(GLFW_INVALID_ENUM, "Invalid window attribute 0x%08X", attrib);
|
||||
}
|
||||
|
||||
GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* handle)
|
||||
@ -946,9 +1014,9 @@ GLFWAPI void glfwSetWindowMonitor(GLFWwindow* wh,
|
||||
window->videoMode.height = height;
|
||||
window->videoMode.refreshRate = refreshRate;
|
||||
|
||||
_glfwPlatformSetWindowMonitor(window, monitor,
|
||||
xpos, ypos, width, height,
|
||||
refreshRate);
|
||||
_glfw.platform.setWindowMonitor(window, monitor,
|
||||
xpos, ypos, width, height,
|
||||
refreshRate);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* handle, void* pointer)
|
||||
@ -976,7 +1044,7 @@ GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* handle,
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP_POINTERS(window->callbacks.pos, cbfun);
|
||||
_GLFW_SWAP(GLFWwindowposfun, window->callbacks.pos, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
@ -987,7 +1055,7 @@ GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* handle,
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP_POINTERS(window->callbacks.size, cbfun);
|
||||
_GLFW_SWAP(GLFWwindowsizefun, window->callbacks.size, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
@ -998,7 +1066,7 @@ GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* handle,
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP_POINTERS(window->callbacks.close, cbfun);
|
||||
_GLFW_SWAP(GLFWwindowclosefun, window->callbacks.close, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
@ -1009,7 +1077,7 @@ GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* handle,
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP_POINTERS(window->callbacks.refresh, cbfun);
|
||||
_GLFW_SWAP(GLFWwindowrefreshfun, window->callbacks.refresh, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
@ -1020,7 +1088,7 @@ GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* handle,
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP_POINTERS(window->callbacks.focus, cbfun);
|
||||
_GLFW_SWAP(GLFWwindowfocusfun, window->callbacks.focus, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
@ -1031,7 +1099,7 @@ GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* handle,
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP_POINTERS(window->callbacks.iconify, cbfun);
|
||||
_GLFW_SWAP(GLFWwindowiconifyfun, window->callbacks.iconify, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
@ -1042,7 +1110,7 @@ GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* handle,
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP_POINTERS(window->callbacks.maximize, cbfun);
|
||||
_GLFW_SWAP(GLFWwindowmaximizefun, window->callbacks.maximize, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
@ -1053,7 +1121,7 @@ GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* handle
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP_POINTERS(window->callbacks.fbsize, cbfun);
|
||||
_GLFW_SWAP(GLFWframebuffersizefun, window->callbacks.fbsize, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
@ -1064,20 +1132,20 @@ GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow*
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP_POINTERS(window->callbacks.scale, cbfun);
|
||||
_GLFW_SWAP(GLFWwindowcontentscalefun, window->callbacks.scale, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
GLFWAPI void glfwPollEvents(void)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfwPlatformPollEvents();
|
||||
_glfw.platform.pollEvents();
|
||||
}
|
||||
|
||||
GLFWAPI void glfwWaitEvents(void)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfwPlatformWaitEvents();
|
||||
_glfw.platform.waitEvents();
|
||||
}
|
||||
|
||||
GLFWAPI void glfwWaitEventsTimeout(double timeout)
|
||||
@ -1093,12 +1161,12 @@ GLFWAPI void glfwWaitEventsTimeout(double timeout)
|
||||
return;
|
||||
}
|
||||
|
||||
_glfwPlatformWaitEventsTimeout(timeout);
|
||||
_glfw.platform.waitEventsTimeout(timeout);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwPostEmptyEvent(void)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfwPlatformPostEmptyEvent();
|
||||
_glfw.platform.postEmptyEvent();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user