init on screen center on first startup
This commit is contained in:
parent
2339e05b34
commit
caded3285c
|
@ -52,6 +52,9 @@ namespace Platform
|
||||||
int getWindowHeight();
|
int getWindowHeight();
|
||||||
bool isWindowMaximized();
|
bool isWindowMaximized();
|
||||||
|
|
||||||
|
int getDisplayHeight();
|
||||||
|
int getDisplayWidth();
|
||||||
|
|
||||||
/// Get GL extension function address
|
/// Get GL extension function address
|
||||||
void *getExtensionProcAddress(const char *ext);
|
void *getExtensionProcAddress(const char *ext);
|
||||||
/// Check if GL extension is supported
|
/// Check if GL extension is supported
|
||||||
|
|
|
@ -350,8 +350,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
RECT *rect = (RECT*)lParam;
|
RECT *rect = (RECT*)lParam;
|
||||||
win32.x = rect->left;
|
win32.x = rect->left;
|
||||||
win32.y = rect->top;
|
win32.y = rect->top;
|
||||||
win32.width = rect->right - rect->left;
|
|
||||||
win32.height = rect->bottom - rect->top;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
|
@ -366,6 +364,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
win32.width = LOWORD(lParam);
|
||||||
|
win32.height = HIWORD(lParam);
|
||||||
g_engine.onResize(LOWORD(lParam), HIWORD(lParam));
|
g_engine.onResize(LOWORD(lParam), HIWORD(lParam));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -772,6 +772,16 @@ int Platform::getWindowHeight()
|
||||||
return x11.height;
|
return x11.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Platform::getDisplayWidth()
|
||||||
|
{
|
||||||
|
return XDisplayWidth(x11.display, DefaultScreen(x11.display));
|
||||||
|
}
|
||||||
|
|
||||||
|
int Platform::getDisplayHeight()
|
||||||
|
{
|
||||||
|
return XDisplayHeight(x11.display, DefaultScreen(x11.display));
|
||||||
|
}
|
||||||
|
|
||||||
bool Platform::isWindowMaximized()
|
bool Platform::isWindowMaximized()
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
14
src/main.cpp
14
src/main.cpp
|
@ -48,10 +48,16 @@ void signal_handler(int sig)
|
||||||
/// Default configurations
|
/// Default configurations
|
||||||
void setDefaultConfigs()
|
void setDefaultConfigs()
|
||||||
{
|
{
|
||||||
g_config.setValue("window x", 0);
|
// default size
|
||||||
g_config.setValue("window y", 0);
|
int defWidth = 640;
|
||||||
g_config.setValue("window width", 640);
|
int defHeight = 480;
|
||||||
g_config.setValue("window height", 480);
|
|
||||||
|
// init on screen center
|
||||||
|
g_config.setValue("window x", (Platform::getDisplayWidth() - defWidth)/2);
|
||||||
|
g_config.setValue("window y", (Platform::getDisplayHeight() - defHeight)/2);
|
||||||
|
|
||||||
|
g_config.setValue("window width", defWidth);
|
||||||
|
g_config.setValue("window height", defHeight);
|
||||||
g_config.setValue("window maximized", false);
|
g_config.setValue("window maximized", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue