win32 visible, focused, size fix

master
Henrique Santiago 13 years ago
parent 5254b8d230
commit 8a13517714

@ -40,7 +40,7 @@ struct Win32PlatformPrivate {
int x, y; int x, y;
int width, height; int width, height;
int minWidth, minHeight; int minWidth, minHeight;
bool maximized; bool focused, visible, maximized;
} win32; } win32;
void Platform::init(const char *appName) void Platform::init(const char *appName)
@ -299,6 +299,16 @@ void Platform::swapBuffers()
SwapBuffers(win32.hdc); SwapBuffers(win32.hdc);
} }
bool Platform::isWindowFocused()
{
return win32.focused;
}
bool Platform::isWindowVisible()
{
return win32.visible;
}
int Platform::getWindowX() int Platform::getWindowX()
{ {
return win32.x; return win32.x;
@ -345,8 +355,15 @@ const char *Platform::getAppUserDir()
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
static int lastX, lastY;
switch(uMsg) switch(uMsg)
{ {
case WM_ACTIVATE:
{
win32.focused = !(wParam == WA_INACTIVE);
break;
}
case WM_CLOSE: case WM_CLOSE:
{ {
g_engine.onClose(); g_engine.onClose();
@ -361,6 +378,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
} }
case WM_MOVE: case WM_MOVE:
{ {
lastX = win32.x;
lastY = win32.y;
win32.x = LOWORD(lParam); win32.x = LOWORD(lParam);
win32.y = HIWORD(lParam); win32.y = HIWORD(lParam);
break; break;
@ -370,6 +389,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
switch(wParam) switch(wParam)
{ {
case SIZE_MAXIMIZED: case SIZE_MAXIMIZED:
win32.x = lastX;
win32.y = lastY;
win32.maximized = true; win32.maximized = true;
break; break;
case SIZE_RESTORED: case SIZE_RESTORED:
@ -377,14 +398,19 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
break; break;
} }
win32.width = LOWORD(lParam); win32.visible = !(wParam == SIZE_MINIMIZED);
win32.height = HIWORD(lParam);
if(!win32.maximized) {
win32.width = LOWORD(lParam);
win32.height = HIWORD(lParam);
}
g_engine.onResize(LOWORD(lParam), HIWORD(lParam)); g_engine.onResize(LOWORD(lParam), HIWORD(lParam));
break; break;
} }
default: default:
{ {
return DefWindowProc(hWnd,uMsg,wParam,lParam); return DefWindowProc(hWnd, uMsg, wParam, lParam);
} }
} }
return 0; return 0;

Loading…
Cancel
Save