Redirect resize from QSizeGrip to system resize in wasm compositor
Using two different resizing techniques (one in QSizeGrip, one in QWasmCompositor) leads to strange behavior while resizing wasm windows. Redirect the QSizeGrip's resize to wasm's compositor resize (which might be considered system resize) to avoid that. Change-Id: Idfc062643caac3ceee879bfb875d943aade28378 Reviewed-by: David Skoland <david.skoland@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
parent
4a338aa180
commit
de56047620
@ -168,6 +168,11 @@ void QWasmCompositor::setEnabled(bool enabled)
|
||||
m_isEnabled = enabled;
|
||||
}
|
||||
|
||||
void QWasmCompositor::startResize(Qt::Edges edges)
|
||||
{
|
||||
m_windowManipulation.startResize(edges);
|
||||
}
|
||||
|
||||
void QWasmCompositor::addWindow(QWasmWindow *window)
|
||||
{
|
||||
m_windowVisibility.insert(window, false);
|
||||
@ -788,6 +793,11 @@ void QWasmCompositor::WindowManipulation::onPointerDown(
|
||||
void QWasmCompositor::WindowManipulation::onPointerMove(
|
||||
const PointerEvent& event)
|
||||
{
|
||||
m_systemDragInitData = {
|
||||
.lastMouseMovePoint = m_screen->clipPoint(event.point),
|
||||
.lastMousePointerId = event.pointerId,
|
||||
};
|
||||
|
||||
if (operation() == Operation::None || event.pointerId != m_state->pointerId)
|
||||
return;
|
||||
|
||||
@ -822,6 +832,34 @@ void QWasmCompositor::WindowManipulation::onPointerUp(const PointerEvent& event)
|
||||
m_state.reset();
|
||||
}
|
||||
|
||||
void QWasmCompositor::WindowManipulation::startResize(Qt::Edges edges)
|
||||
{
|
||||
Q_ASSERT_X(operation() == Operation::None, Q_FUNC_INFO,
|
||||
"Resize must not start anew when one is in progress");
|
||||
|
||||
auto *window = m_screen->compositor()->windowAt(m_systemDragInitData.lastMouseMovePoint);
|
||||
if (Q_UNLIKELY(!window))
|
||||
return;
|
||||
|
||||
m_state.reset(new OperationState{
|
||||
.pointerId = m_systemDragInitData.lastMousePointerId,
|
||||
.window = window,
|
||||
.operationSpecific =
|
||||
ResizeState{
|
||||
.m_resizeEdges = edges,
|
||||
.m_originInScreenCoords = m_systemDragInitData.lastMouseMovePoint,
|
||||
.m_initialWindowBounds = window->geometry(),
|
||||
.m_minShrink =
|
||||
QPoint(window->minimumWidth() - window->geometry().width(),
|
||||
window->minimumHeight() - window->geometry().height()),
|
||||
.m_maxGrow =
|
||||
QPoint(window->maximumWidth() - window->geometry().width(),
|
||||
window->maximumHeight() - window->geometry().height()),
|
||||
},
|
||||
});
|
||||
m_screen->canvas().call<void>("setPointerCapture", m_systemDragInitData.lastMousePointerId);
|
||||
}
|
||||
|
||||
bool QWasmCompositor::processKeyboard(int eventType, const EmscriptenKeyboardEvent *emKeyEvent)
|
||||
{
|
||||
constexpr bool ProceedToNativeEvent = false;
|
||||
|
@ -57,6 +57,7 @@ public:
|
||||
};
|
||||
|
||||
void setEnabled(bool enabled);
|
||||
void startResize(Qt::Edges edges);
|
||||
|
||||
void addWindow(QWasmWindow *window);
|
||||
void removeWindow(QWasmWindow *window);
|
||||
@ -108,6 +109,7 @@ private:
|
||||
void onPointerDown(const PointerEvent& event, QWindow* windowAtPoint);
|
||||
void onPointerMove(const PointerEvent& event);
|
||||
void onPointerUp(const PointerEvent& event);
|
||||
void startResize(Qt::Edges edges);
|
||||
|
||||
Operation operation() const;
|
||||
|
||||
@ -128,11 +130,18 @@ private:
|
||||
QPointer<QWindow> window;
|
||||
std::variant<ResizeState, MoveState> operationSpecific;
|
||||
};
|
||||
struct SystemDragInitData
|
||||
{
|
||||
QPoint lastMouseMovePoint;
|
||||
int lastMousePointerId = -1;
|
||||
};
|
||||
|
||||
void resizeWindow(const QPoint& amount);
|
||||
ResizeState makeResizeState(Qt::Edges edges, const QPoint &startPoint, QWindow *window);
|
||||
|
||||
QWasmScreen *m_screen;
|
||||
|
||||
SystemDragInitData m_systemDragInitData;
|
||||
std::unique_ptr<OperationState> m_state;
|
||||
};
|
||||
|
||||
|
@ -212,6 +212,13 @@ void QWasmWindow::propagateSizeHints()
|
||||
}
|
||||
}
|
||||
|
||||
bool QWasmWindow::startSystemResize(Qt::Edges edges)
|
||||
{
|
||||
m_compositor->startResize(edges);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void QWasmWindow::injectMousePressed(const QPoint &local, const QPoint &global,
|
||||
Qt::MouseButton button, Qt::KeyboardModifiers mods)
|
||||
{
|
||||
|
@ -56,6 +56,7 @@ public:
|
||||
Qt::MouseButton button, Qt::KeyboardModifiers mods);
|
||||
void injectMouseReleased(const QPoint &local, const QPoint &global,
|
||||
Qt::MouseButton button, Qt::KeyboardModifiers mods);
|
||||
bool startSystemResize(Qt::Edges edges) final;
|
||||
|
||||
bool isPointOnTitle(QPoint point) const;
|
||||
bool isPointOnResizeRegion(QPoint point) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user