[aseprite] 168/308: Improve default window size on Skia/Win port (fix #693)
Tobias Hansen
thansen at moszumanska.debian.org
Tue Mar 8 02:45:07 UTC 2016
This is an automated email from the git hooks/post-receive script.
thansen pushed a commit to branch master
in repository aseprite.
commit a6544d92afda30ab679d1cc42a26a222672ce87c
Author: David Capello <davidcapello at gmail.com>
Date: Mon Dec 28 18:02:07 2015 -0300
Improve default window size on Skia/Win port (fix #693)
---
src/app/modules/gui.cpp | 6 ++++--
src/she/alleg4/she.cpp | 4 ++++
src/she/skia/skia_system.h | 13 +++++++++++++
src/she/system.h | 1 +
src/she/win/window.h | 13 +++++++++++++
5 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/src/app/modules/gui.cpp b/src/app/modules/gui.cpp
index 0003ad5..ff0250b 100644
--- a/src/app/modules/gui.cpp
+++ b/src/app/modules/gui.cpp
@@ -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", "");
}
diff --git a/src/she/alleg4/she.cpp b/src/she/alleg4/she.cpp
index 2313b42..1f9738f 100644
--- a/src/she/alleg4/she.cpp
+++ b/src/she/alleg4/she.cpp
@@ -163,6 +163,10 @@ public:
// Do nothing
}
+ gfx::Size defaultNewDisplaySize() override {
+ return gfx::Size(0, 0);
+ }
+
Display* defaultDisplay() override {
return unique_display;
}
diff --git a/src/she/skia/skia_system.h b/src/she/skia/skia_system.h
index f5e5213..c5dfea2 100644
--- a/src/she/skia/skia_system.h
+++ b/src/she/skia/skia_system.h
@@ -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;
}
diff --git a/src/she/system.h b/src/she/system.h
index f73f949..14a198f 100644
--- a/src/she/system.h
+++ b/src/she/system.h
@@ -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;
diff --git a/src/she/win/window.h b/src/she/win/window.h
index a402dae..d447bac 100644
--- a/src/she/win/window.h
+++ b/src/she/win/window.h
@@ -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;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git
More information about the Pkg-games-commits
mailing list