Improve default window size on Skia/Win port (fix #693)

This commit is contained in:
David Capello 2015-12-28 18:02:07 -03:00
parent 2fc447edd6
commit a6544d92af
5 changed files with 35 additions and 2 deletions

View File

@ -212,8 +212,10 @@ void exit_module_gui()
static void load_gui_config(int& w, int& h, bool& maximized,
std::string& windowLayout)
{
w = get_config_int("GfxMode", "Width", 0);
h = get_config_int("GfxMode", "Height", 0);
gfx::Size defSize = she::instance()->defaultNewDisplaySize();
w = get_config_int("GfxMode", "Width", defSize.w);
h = get_config_int("GfxMode", "Height", defSize.h);
maximized = get_config_bool("GfxMode", "Maximized", false);
windowLayout = get_config_string("GfxMode", "WindowLayout", "");
}

View File

@ -163,6 +163,10 @@ public:
// Do nothing
}
gfx::Size defaultNewDisplaySize() override {
return gfx::Size(0, 0);
}
Display* defaultDisplay() override {
return unique_display;
}

View File

@ -67,6 +67,19 @@ public:
m_gpuAcceleration = state;
}
gfx::Size defaultNewDisplaySize() override {
gfx::Size sz;
#ifdef _WIN32
sz.w = GetSystemMetrics(SM_CXMAXIMIZED);
sz.h = GetSystemMetrics(SM_CYMAXIMIZED);
sz.w -= GetSystemMetrics(SM_CXSIZEFRAME)*4;
sz.h -= GetSystemMetrics(SM_CYSIZEFRAME)*4;
sz.w = MAX(0, sz.w);
sz.h = MAX(0, sz.h);
#endif
return sz;
}
Display* defaultDisplay() override {
return m_defaultDisplay;
}

View File

@ -38,6 +38,7 @@ namespace she {
virtual EventQueue* eventQueue() = 0;
virtual bool gpuAcceleration() const = 0;
virtual void setGpuAcceleration(bool state) = 0;
virtual gfx::Size defaultNewDisplaySize() = 0;
virtual Display* defaultDisplay() = 0;
virtual Display* createDisplay(int width, int height, int scale) = 0;
virtual Surface* createSurface(int width, int height) = 0;

View File

@ -598,6 +598,19 @@ namespace she {
SetWindowLongPtr(hwnd, GWLP_USERDATA, LONG_PTR(self));
// Center the window
RECT workarea;
if (SystemParametersInfo(SPI_GETWORKAREA, 0, (PVOID)&workarea, 0)) {
SetWindowPos(hwnd, nullptr,
(workarea.right-workarea.left)/2-width/2,
(workarea.bottom-workarea.top)/2-height/2, 0, 0,
SWP_NOSIZE |
SWP_NOSENDCHANGING |
SWP_NOOWNERZORDER |
SWP_NOZORDER |
SWP_NOREDRAW);
}
// Set scroll info to receive WM_HSCROLL/VSCROLL events (events
// generated by some trackpad drivers).
SCROLLINFO si;