wasm: make maximized and fullscreen windows not draggable

Also make fullscreen windows not have a titlebar

Task-number: QTBUG-69318
Change-Id: I017fc40fecb9f46d6540ffb72a71c9b62097a368
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
bb10
Lorn Potter 2018-07-10 05:34:54 +10:00
parent 353a58ceb9
commit 9c72ae61aa
4 changed files with 31 additions and 21 deletions

View File

@ -642,7 +642,7 @@ void QWasmCompositor::drawShadePanel(QWasmTitleBarOptions options, QPainter *pai
void QWasmCompositor::drawWindow(QOpenGLTextureBlitter *blitter, QWasmScreen *screen, QWasmWindow *window)
{
if (window->window()->type() != Qt::Popup)
if (window->window()->type() != Qt::Popup && !(window->m_windowState & Qt::WindowFullScreen))
drawWindowDecorations(blitter, screen, window);
drawWindowContent(blitter, screen, window);
}

View File

@ -362,13 +362,15 @@ void QWasmEventTranslator::processMouse(int eventType, const EmscriptenMouseEven
if (mouseEvent->button == 0) {
pressedWindow = window2;
buttonEventType = QEvent::MouseButtonPress;
if (htmlWindow && window2->flags().testFlag(Qt::WindowTitleHint) && htmlWindow->isPointOnTitle(point))
draggedWindow = window2;
else if (htmlWindow && htmlWindow->isPointOnResizeRegion(point)) {
draggedWindow = window2;
resizeMode = htmlWindow->resizeModeAtPoint(point);
resizePoint = point;
resizeStartRect = window2->geometry();
if (!(htmlWindow->m_windowState & Qt::WindowFullScreen) && !(htmlWindow->m_windowState & Qt::WindowMaximized)) {
if (htmlWindow && window2->flags().testFlag(Qt::WindowTitleHint) && htmlWindow->isPointOnTitle(point))
draggedWindow = window2;
else if (htmlWindow && htmlWindow->isPointOnResizeRegion(point)) {
draggedWindow = window2;
resizeMode = htmlWindow->resizeModeAtPoint(point);
resizePoint = point;
resizeStartRect = window2->geometry();
}
}
}
@ -399,14 +401,16 @@ void QWasmEventTranslator::processMouse(int eventType, const EmscriptenMouseEven
case 8://move //drag event
{
buttonEventType = QEvent::MouseMove;
if (resizeMode == QWasmWindow::ResizeNone && draggedWindow) {
draggedWindow->setX(draggedWindow->x() + mouseEvent->movementX);
draggedWindow->setY(draggedWindow->y() + mouseEvent->movementY);
}
if (!(htmlWindow->m_windowState & Qt::WindowFullScreen) && !(htmlWindow->m_windowState & Qt::WindowMaximized)) {
if (resizeMode == QWasmWindow::ResizeNone && draggedWindow) {
draggedWindow->setX(draggedWindow->x() + mouseEvent->movementX);
draggedWindow->setY(draggedWindow->y() + mouseEvent->movementY);
}
if (resizeMode != QWasmWindow::ResizeNone) {
QPoint delta = QPoint(mouseEvent->canvasX, mouseEvent->canvasY) - resizePoint;
resizeWindow(draggedWindow, resizeMode, resizeStartRect, delta);
if (resizeMode != QWasmWindow::ResizeNone && !(htmlWindow->m_windowState & Qt::WindowFullScreen)) {
QPoint delta = QPoint(mouseEvent->canvasX, mouseEvent->canvasY) - resizePoint;
resizeWindow(draggedWindow, resizeMode, resizeStartRect, delta);
}
}
break;
}

View File

@ -83,8 +83,6 @@ void QWasmWindow::initialize()
setWindowState(window()->windowStates());
setWindowFlags(window()->flags());
setWindowTitle(window()->title());
m_hasTitle = window()->flags().testFlag(Qt::WindowTitleHint) && m_needsCompositor;
if (window()->isTopLevel())
setWindowIcon(window()->icon());
m_normalGeometry = rect;
@ -135,8 +133,8 @@ void QWasmWindow::setVisible(bool visible)
QMargins QWasmWindow::frameMargins() const
{
int border = m_hasTitle ? 4. * (qreal(qt_defaultDpiX()) / 96.0) : 0;
int titleBarHeight = m_hasTitle ? titleHeight() : 0;
int border = hasTitleBar() ? 4. * (qreal(qt_defaultDpiX()) / 96.0) : 0;
int titleBarHeight = hasTitleBar() ? titleHeight() : 0;
QMargins margins;
margins.setLeft(border);
@ -177,7 +175,7 @@ void QWasmWindow::injectMousePressed(const QPoint &local, const QPoint &global,
Q_UNUSED(local);
Q_UNUSED(mods);
if (!m_hasTitle || button != Qt::LeftButton)
if (!hasTitleBar() || button != Qt::LeftButton)
return;
if (maxButtonRect().contains(global))
@ -198,7 +196,7 @@ void QWasmWindow::injectMouseReleased(const QPoint &local, const QPoint &global,
Q_UNUSED(local);
Q_UNUSED(mods);
if (!m_hasTitle || button != Qt::LeftButton)
if (!hasTitleBar() || button != Qt::LeftButton)
return;
if (closeButtonRect().contains(global) && m_activeControl == QWasmCompositor::SC_TitleBarCloseButton)
@ -395,4 +393,9 @@ void QWasmWindow::requestUpdate()
QPlatformWindow::requestUpdate();
}
bool QWasmWindow::hasTitleBar() const
{
return !(m_windowState & Qt::WindowFullScreen) && (window()->flags().testFlag(Qt::WindowTitleHint) && m_needsCompositor);
}
QT_END_NAMESPACE

View File

@ -105,6 +105,7 @@ public:
protected:
void invalidate();
bool hasTitleBar() const;
protected:
friend class QWasmScreen;
@ -119,6 +120,8 @@ protected:
WId m_winid = 0;
bool m_hasTitle = false;
bool m_needsCompositor = false;
friend class QWasmCompositor;
friend class QWasmEventTranslator;
};
QT_END_NAMESPACE
#endif // QWASMWINDOW_H