Fix gs_frame spawning on monitor other than the one the main window is on (#4029)

* Fix gs_frame spawning on a screen other than the one the RPCS3 window is on for multi-monitor setups

* Cleaned up code & refactored it into a utility function for reuse

* Qt: take gs_frame's framemargins into account by using showEvent
This commit is contained in:
TGEnigma 2018-02-03 20:50:48 +01:00 committed by Ani
parent cd9bfba790
commit f6b0b31e8b
10 changed files with 112 additions and 21 deletions

View file

@ -23,7 +23,7 @@
constexpr auto qstr = QString::fromStdString;
gs_frame::gs_frame(const QString& title, int w, int h, QIcon appIcon, bool disableMouse)
gs_frame::gs_frame(const QString& title, const QRect& geometry, QIcon appIcon, bool disableMouse)
: QWindow(), m_windowTitle(title), m_disable_mouse(disableMouse)
{
//Get version by substringing VersionNumber-buildnumber-commithash to get just the part before the dash
@ -55,8 +55,7 @@ gs_frame::gs_frame(const QString& title, int w, int h, QIcon appIcon, bool disab
m_show_fps = static_cast<bool>(g_cfg.misc.show_fps_in_title);
resize(w, h);
setGeometry(geometry);
setTitle(m_windowTitle);
setVisibility(Hidden);
create();
@ -70,6 +69,18 @@ void gs_frame::paintEvent(QPaintEvent *event)
Q_UNUSED(event);
}
void gs_frame::showEvent(QShowEvent *event)
{
// we have to calculate new window positions, since the frame is only known once the window was created
// the left and right margins are too big on my setup for some reason yet unknown, so we'll have to ignore them
int x = geometry().left(); //std::max(geometry().left(), frameMargins().left());
int y = std::max(geometry().top(), frameMargins().top());
setPosition(x, y);
QWindow::showEvent(event);
}
void gs_frame::keyPressEvent(QKeyEvent *keyEvent)
{
auto l_handleKeyEvent = [this ,keyEvent]()