Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

Commit

Permalink
snap layout: try improve the maximize button handling
Browse files Browse the repository at this point in the history
  • Loading branch information
wangwenx190 committed Aug 19, 2023
1 parent 54e3f62 commit 58afa6a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/core/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -731,18 +731,18 @@ void Utils::emulateQtMouseEvent(const QObject *target, const QWindow *window, co
if (!obj) {
return;
}
static constexpr const auto fakePos = QPoint{ -999, -999 };
const QPoint tweakedLocalPos = (fake ? fakePos : localPos);
const QPoint tweakedScenePos = (fake ? fakePos : scenePos);
const QPoint tweakedGlobalPos = (fake ? fakePos : globalPos);
QMouseEvent event(QEvent::MouseButtonRelease, tweakedLocalPos, tweakedScenePos, tweakedGlobalPos, button, buttons, modifiers);
QMouseEvent event(QEvent::MouseButtonRelease, localPos, scenePos, globalPos, button, buttons, modifiers);
QCoreApplication::sendEvent(obj, &event);
};
switch (buttonState) {
case ButtonState::Normal: {
targetObj->setProperty(kEnteredFlag, {});
// Send an extra mouse release event to let the control dismiss it's hover state.
sendMouseReleaseEvent(targetObj, true);
// But only when the mouse is not still hovering above the control, otherwise Qt will
// generate a mouse click event, which is not what the user would expect.
if (!underMouse) {
sendMouseReleaseEvent(targetObj);
}
if (isWidget) {
sendLeaveEvent(targetObj);
} else {
Expand Down

0 comments on commit 58afa6a

Please sign in to comment.