Skip to content

Commit

Permalink
Add a way for Win32 to move the GraphicsWindow
Browse files Browse the repository at this point in the history
only works in windowed (at least I forced it to be that way)
  • Loading branch information
poco0317 committed Feb 20, 2020
1 parent 2e78ca8 commit 4f84089
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/RageUtil/Graphics/RageDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#include <chrono>
#include <thread>

#ifdef _WIN32
#include "archutils/Win32/GraphicsWindow.h"
#endif

// Statistics stuff
auto g_LastCheckTimer = std::chrono::steady_clock::now();
int g_iNumVerts;
Expand Down Expand Up @@ -1364,6 +1368,17 @@ class LunaRageDisplay : public Luna<RageDisplay>
lua_pushboolean(L, p->SupportsFullscreenBorderlessWindow());
return 1;
}
static int MoveWindow(T* p, lua_State* L)
{
bool success = false;
#ifdef _WIN32
int x = IArg(1);
int y = IArg(2);
success = GraphicsWindow::PushWindow(x, y);
#endif
lua_pushboolean(L, success);
return 1;
}

LunaRageDisplay()
{
Expand All @@ -1376,6 +1391,7 @@ class LunaRageDisplay : public Luna<RageDisplay>
ADD_METHOD(GetDisplaySpecs);
ADD_METHOD(SupportsRenderToTexture);
ADD_METHOD(SupportsFullscreenBorderlessWindow);
ADD_METHOD(MoveWindow);
}
};

Expand Down
20 changes: 20 additions & 0 deletions src/archutils/Win32/GraphicsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,26 @@ GraphicsWindow::GetDisplaySpecs(DisplaySpecs& out)
}
}

BOOL
GraphicsWindow::PushWindow(int a, int b)
{
HWND g = GetHwnd();

if (!g_ActualParams.windowed)
return 0;

RECT r;
GetWindowRect(g, &r);
// The immediately below is for "Aero Glass"
// DwmGetWindowAttribute(g, DWMWA_EXTENDED_FRAME_BOUNDS, &r, sizeof(r));

int x = r.left + a;
int y = r.top + b;

return SetWindowPos(
g, nullptr, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
}

/*
* (c) 2004 Glenn Maynard
* All rights reserved.
Expand Down
3 changes: 3 additions & 0 deletions src/archutils/Win32/GraphicsWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ DestroyGraphicsWindow();
void
GetDisplaySpecs(DisplaySpecs& out);

BOOL
PushWindow(int a, int b);

ActualVideoModeParams*
GetParams();

Expand Down

0 comments on commit 4f84089

Please sign in to comment.