aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/viewer
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2017-03-08 15:36:30 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-08 21:11:50 +0000
commit4749b8c1b899f9f4e440f60c88c880a8765e6dee (patch)
tree06544a8faa7371dc572580212233df3b6ddcb8c3 /tools/viewer
parent3b65598bceb65736486db27ed49a56d787032747 (diff)
Maintain window position and size when re-created
Eliminates a UI oddity on Windows when cycling through backends. BUG=skia: Change-Id: I83f0325054def80bb9b6e5a9886461f8aad215ae Reviewed-on: https://skia-review.googlesource.com/9453 Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'tools/viewer')
-rw-r--r--tools/viewer/sk_app/win/Window_win.cpp19
-rw-r--r--tools/viewer/sk_app/win/Window_win.h2
2 files changed, 19 insertions, 2 deletions
diff --git a/tools/viewer/sk_app/win/Window_win.cpp b/tools/viewer/sk_app/win/Window_win.cpp
index d603a1439d..9614d71c21 100644
--- a/tools/viewer/sk_app/win/Window_win.cpp
+++ b/tools/viewer/sk_app/win/Window_win.cpp
@@ -19,6 +19,11 @@
namespace sk_app {
+static int gWindowX = CW_USEDEFAULT;
+static int gWindowY = 0;
+static int gWindowWidth = CW_USEDEFAULT;
+static int gWindowHeight = 0;
+
Window* Window::CreateNativeWindow(void* platformData) {
HINSTANCE hInstance = (HINSTANCE)platformData;
@@ -31,6 +36,17 @@ Window* Window::CreateNativeWindow(void* platformData) {
return window;
}
+Window_win::~Window_win() {
+ RECT r;
+ if (GetWindowRect(fHWnd, &r)) {
+ gWindowX = r.left;
+ gWindowY = r.top;
+ gWindowWidth = r.right - r.left;
+ gWindowHeight = r.bottom - r.top;
+ }
+ DestroyWindow(fHWnd);
+}
+
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
@@ -85,7 +101,8 @@ bool Window_win::init(HINSTANCE hInstance) {
// gIsFullscreen = fullscreen;
fHWnd = CreateWindow(gSZWindowClass, nullptr, WS_OVERLAPPEDWINDOW,
- CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, fHInstance, nullptr);
+ gWindowX, gWindowY, gWindowWidth, gWindowHeight,
+ nullptr, nullptr, fHInstance, nullptr);
if (!fHWnd)
{
return false;
diff --git a/tools/viewer/sk_app/win/Window_win.h b/tools/viewer/sk_app/win/Window_win.h
index 0c51304a81..6d2279393a 100644
--- a/tools/viewer/sk_app/win/Window_win.h
+++ b/tools/viewer/sk_app/win/Window_win.h
@@ -16,7 +16,7 @@ namespace sk_app {
class Window_win : public Window {
public:
Window_win() : Window() {}
- ~Window_win() override { DestroyWindow(fHWnd); }
+ ~Window_win() override;
bool init(HINSTANCE instance);