1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-27 04:28:52 -05:00

Removed caching of Win32 window styles.

This commit is contained in:
Camilla Berglund 2015-06-02 21:12:37 +02:00
parent acaddf9cd9
commit a257e7a3ee
2 changed files with 39 additions and 28 deletions

View File

@ -150,8 +150,6 @@ typedef HRESULT (WINAPI * DWMFLUSH_T)(VOID);
typedef struct _GLFWwindowWin32 typedef struct _GLFWwindowWin32
{ {
HWND handle; HWND handle;
DWORD dwStyle;
DWORD dwExStyle;
GLboolean cursorInside; GLboolean cursorInside;
GLboolean iconified; GLboolean iconified;

View File

@ -38,6 +38,37 @@
#define _GLFW_WNDCLASSNAME L"GLFW30" #define _GLFW_WNDCLASSNAME L"GLFW30"
// Returns the window style for the specified window
//
static getWindowStyle(const _GLFWwindow* window)
{
DWORD style = WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
if (window->decorated && !window->monitor)
{
style |= WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
if (window->resizable)
style |= WS_MAXIMIZEBOX | WS_SIZEBOX;
}
else
style |= WS_POPUP;
return style;
}
// Returns the extended window style for the specified window
//
static getWindowExStyle(const _GLFWwindow* window)
{
DWORD style = WS_EX_APPWINDOW;
if (window->decorated && !window->monitor)
style |= WS_EX_WINDOWEDGE;
return style;
}
// Updates the cursor clip rect // Updates the cursor clip rect
// //
static void updateClipRect(_GLFWwindow* window) static void updateClipRect(_GLFWwindow* window)
@ -608,8 +639,8 @@ static void getFullWindowSize(_GLFWwindow* window,
int* fullWidth, int* fullHeight) int* fullWidth, int* fullHeight)
{ {
RECT rect = { 0, 0, clientWidth, clientHeight }; RECT rect = { 0, 0, clientWidth, clientHeight };
AdjustWindowRectEx(&rect, window->win32.dwStyle, AdjustWindowRectEx(&rect, getWindowStyle(window),
FALSE, window->win32.dwExStyle); FALSE, getWindowExStyle(window));
*fullWidth = rect.right - rect.left; *fullWidth = rect.right - rect.left;
*fullHeight = rect.bottom - rect.top; *fullHeight = rect.bottom - rect.top;
} }
@ -624,13 +655,8 @@ static int createWindow(_GLFWwindow* window,
int xpos, ypos, fullWidth, fullHeight; int xpos, ypos, fullWidth, fullHeight;
WCHAR* wideTitle; WCHAR* wideTitle;
window->win32.dwStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
window->win32.dwExStyle = WS_EX_APPWINDOW;
if (window->monitor) if (window->monitor)
{ {
window->win32.dwStyle |= WS_POPUP;
// NOTE: This window placement is temporary and approximate, as the // NOTE: This window placement is temporary and approximate, as the
// correct position and size cannot be known until the monitor // correct position and size cannot be known until the monitor
// video mode has been set // video mode has been set
@ -640,19 +666,6 @@ static int createWindow(_GLFWwindow* window,
} }
else else
{ {
if (wndconfig->decorated)
{
window->win32.dwStyle |= WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
if (wndconfig->resizable)
{
window->win32.dwStyle |= WS_MAXIMIZEBOX | WS_SIZEBOX;
window->win32.dwExStyle |= WS_EX_WINDOWEDGE;
}
}
else
window->win32.dwStyle |= WS_POPUP;
xpos = CW_USEDEFAULT; xpos = CW_USEDEFAULT;
ypos = CW_USEDEFAULT; ypos = CW_USEDEFAULT;
@ -669,10 +682,10 @@ static int createWindow(_GLFWwindow* window,
return GL_FALSE; return GL_FALSE;
} }
window->win32.handle = CreateWindowExW(window->win32.dwExStyle, window->win32.handle = CreateWindowExW(getWindowExStyle(window),
_GLFW_WNDCLASSNAME, _GLFW_WNDCLASSNAME,
wideTitle, wideTitle,
window->win32.dwStyle, getWindowStyle(window),
xpos, ypos, xpos, ypos,
fullWidth, fullHeight, fullWidth, fullHeight,
NULL, // No parent window NULL, // No parent window
@ -870,8 +883,8 @@ void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos) void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
{ {
RECT rect = { xpos, ypos, xpos, ypos }; RECT rect = { xpos, ypos, xpos, ypos };
AdjustWindowRectEx(&rect, window->win32.dwStyle, AdjustWindowRectEx(&rect, getWindowStyle(window),
FALSE, window->win32.dwExStyle); FALSE, getWindowExStyle(window));
SetWindowPos(window->win32.handle, NULL, rect.left, rect.top, 0, 0, SetWindowPos(window->win32.handle, NULL, rect.left, rect.top, 0, 0,
SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE); SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE);
} }
@ -916,8 +929,8 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
_glfwPlatformGetWindowSize(window, &width, &height); _glfwPlatformGetWindowSize(window, &width, &height);
SetRect(&rect, 0, 0, width, height); SetRect(&rect, 0, 0, width, height);
AdjustWindowRectEx(&rect, window->win32.dwStyle, AdjustWindowRectEx(&rect, getWindowStyle(window),
FALSE, window->win32.dwExStyle); FALSE, getWindowExStyle(window));
if (left) if (left)
*left = -rect.left; *left = -rect.left;