mirror of https://github.com/mgba-emu/mgba.git
Qt: Cap window size to monitor size
This commit is contained in:
parent
a32cb5cc5e
commit
6af4ddefdd
1
CHANGES
1
CHANGES
|
@ -41,6 +41,7 @@ Misc:
|
|||
- Qt: Support switching webcams
|
||||
- Core: Add keysRead callback
|
||||
- Vita: Improved frame drawing speed
|
||||
- Qt: Cap window size on start to monitor size
|
||||
|
||||
0.7.1: (2019-02-24)
|
||||
Bugfixes:
|
||||
|
|
|
@ -5,14 +5,15 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#include "Window.h"
|
||||
|
||||
#include <QDesktopWidget>
|
||||
#include <QKeyEvent>
|
||||
#include <QKeySequence>
|
||||
#include <QMenuBar>
|
||||
#include <QMessageBox>
|
||||
#include <QMimeData>
|
||||
#include <QPainter>
|
||||
#include <QScreen>
|
||||
#include <QStackedLayout>
|
||||
#include <QWindow>
|
||||
|
||||
#ifdef USE_SQLITE3
|
||||
#include "ArchiveInspector.h"
|
||||
|
@ -200,6 +201,15 @@ void Window::argumentsPassed(mArguments* args) {
|
|||
|
||||
void Window::resizeFrame(const QSize& size) {
|
||||
QSize newSize(size);
|
||||
if (windowHandle()) {
|
||||
QRect geom = windowHandle()->screen()->availableGeometry();
|
||||
if (newSize.width() > geom.width()) {
|
||||
newSize.setWidth(geom.width());
|
||||
}
|
||||
if (newSize.height() > geom.height()) {
|
||||
newSize.setHeight(geom.height());
|
||||
}
|
||||
}
|
||||
m_screenWidget->setSizeHint(newSize);
|
||||
newSize -= m_screenWidget->size();
|
||||
newSize += this->size();
|
||||
|
@ -595,7 +605,7 @@ void Window::showEvent(QShowEvent* event) {
|
|||
m_wasOpened = true;
|
||||
resizeFrame(m_screenWidget->sizeHint());
|
||||
QVariant windowPos = m_config->getQtOption("windowPos");
|
||||
QRect geom = QApplication::desktop()->availableGeometry(this);
|
||||
QRect geom = windowHandle()->screen()->availableGeometry();
|
||||
if (!windowPos.isNull() && geom.contains(windowPos.toPoint())) {
|
||||
move(windowPos.toPoint());
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue