[aseprite] 97/308: Remember exact window position (e.g. in which monitor it was closed)
Tobias Hansen
thansen at moszumanska.debian.org
Tue Mar 8 02:44:56 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 a088bf46a25ee80549601820fbf717f9958fccc2
Author: David Capello <davidcapello at gmail.com>
Date: Fri Dec 11 19:40:18 2015 -0300
Remember exact window position (e.g. in which monitor it was closed)
It's working on alleg4 port on Windows only.
---
src/app/modules/gui.cpp | 17 ++++++++++--
src/she/alleg4/alleg_display.cpp | 60 ++++++++++++++++++++++++++++++++++++++--
src/she/alleg4/alleg_display.h | 2 ++
src/she/display.h | 5 ++++
4 files changed, 79 insertions(+), 5 deletions(-)
diff --git a/src/app/modules/gui.cpp b/src/app/modules/gui.cpp
index 692001b..32ebe1f 100644
--- a/src/app/modules/gui.cpp
+++ b/src/app/modules/gui.cpp
@@ -90,7 +90,8 @@ static ui::Timer* defered_invalid_timer = nullptr;
static gfx::Region defered_invalid_region;
// Load & save graphics configuration
-static void load_gui_config(int& w, int& h, bool& maximized);
+static void load_gui_config(int& w, int& h, bool& maximized,
+ std::string& windowLayout);
static void save_gui_config();
static int get_screen_scale()
@@ -106,7 +107,8 @@ static bool create_main_display(bool gpuAccel,
{
int w, h;
int scale = get_screen_scale();
- load_gui_config(w, h, maximized);
+ std::string windowLayout;
+ load_gui_config(w, h, maximized, windowLayout);
she::instance()->setGpuAcceleration(gpuAccel);
@@ -136,6 +138,9 @@ static bool create_main_display(bool gpuAccel,
}
}
+ if (main_display && !windowLayout.empty())
+ main_display->setLayout(windowLayout);
+
return (main_display != nullptr);
}
@@ -201,11 +206,13 @@ void exit_module_gui()
main_display->dispose();
}
-static void load_gui_config(int& w, int& h, bool& maximized)
+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);
maximized = get_config_bool("GfxMode", "Maximized", false);
+ windowLayout = get_config_string("GfxMode", "WindowLayout", "");
}
static void save_gui_config()
@@ -215,6 +222,10 @@ static void save_gui_config()
set_config_bool("GfxMode", "Maximized", display->isMaximized());
set_config_int("GfxMode", "Width", display->originalWidth());
set_config_int("GfxMode", "Height", display->originalHeight());
+
+ std::string windowLayout = display->getLayout();
+ if (!windowLayout.empty())
+ set_config_string("GfxMode", "WindowLayout", windowLayout.c_str());
}
}
diff --git a/src/she/alleg4/alleg_display.cpp b/src/she/alleg4/alleg_display.cpp
index d798baf..a42b935 100644
--- a/src/she/alleg4/alleg_display.cpp
+++ b/src/she/alleg4/alleg_display.cpp
@@ -24,9 +24,7 @@
#ifdef _WIN32
#include <winalleg.h>
-
#include <windowsx.h>
-
#include <commctrl.h>
#if defined STRICT || defined __GNUC__
@@ -53,6 +51,7 @@
#include <cassert>
#include <list>
+#include <sstream>
#include <vector>
#include "she/alleg4/clock.h"
@@ -594,6 +593,63 @@ void Alleg4Display::releaseMouse()
#endif
}
+std::string Alleg4Display::getLayout()
+{
+#ifdef _WIN32
+ WINDOWPLACEMENT wp;
+ wp.length = sizeof(WINDOWPLACEMENT);
+ if (GetWindowPlacement((HWND)nativeHandle(), &wp)) {
+ std::ostringstream s;
+ s << 1 << ' '
+ << wp.flags << ' '
+ << wp.showCmd << ' '
+ << wp.ptMinPosition.x << ' '
+ << wp.ptMinPosition.y << ' '
+ << wp.ptMaxPosition.x << ' '
+ << wp.ptMaxPosition.y << ' '
+ << wp.rcNormalPosition.left << ' '
+ << wp.rcNormalPosition.top << ' '
+ << wp.rcNormalPosition.right << ' '
+ << wp.rcNormalPosition.bottom;
+ return s.str();
+ }
+#endif
+ return "";
+}
+
+void Alleg4Display::setLayout(const std::string& layout)
+{
+#ifdef _WIN32
+
+ WINDOWPLACEMENT wp;
+ wp.length = sizeof(WINDOWPLACEMENT);
+
+ std::istringstream s(layout);
+ int ver;
+ s >> ver;
+ if (ver == 1) {
+ s >> wp.flags
+ >> wp.showCmd
+ >> wp.ptMinPosition.x
+ >> wp.ptMinPosition.y
+ >> wp.ptMaxPosition.x
+ >> wp.ptMaxPosition.y
+ >> wp.rcNormalPosition.left
+ >> wp.rcNormalPosition.top
+ >> wp.rcNormalPosition.right
+ >> wp.rcNormalPosition.bottom;
+ }
+ else
+ return;
+
+ if (SetWindowPlacement((HWND)nativeHandle(), &wp)) {
+ // TODO use the return value
+ }
+#else
+ // Do nothing
+#endif
+}
+
void* Alleg4Display::nativeHandle()
{
#ifdef _WIN32
diff --git a/src/she/alleg4/alleg_display.h b/src/she/alleg4/alleg_display.h
index 9b5a748..51c2845 100644
--- a/src/she/alleg4/alleg_display.h
+++ b/src/she/alleg4/alleg_display.h
@@ -37,6 +37,8 @@ namespace she {
void setMousePosition(const gfx::Point& position) override;
void captureMouse() override;
void releaseMouse() override;
+ std::string getLayout() override;
+ void setLayout(const std::string& layout) override;
void* nativeHandle() override;
private:
diff --git a/src/she/display.h b/src/she/display.h
index bc2dec6..ae2e3b1 100644
--- a/src/she/display.h
+++ b/src/she/display.h
@@ -62,6 +62,11 @@ namespace she {
virtual void captureMouse() = 0;
virtual void releaseMouse() = 0;
+ // Set/get the specific information to restore the exact same
+ // window position (e.g. in the same monitor).
+ virtual std::string getLayout() = 0;
+ virtual void setLayout(const std::string& layout) = 0;
+
// Returns the HWND on Windows.
virtual DisplayHandle nativeHandle() = 0;
};
--
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