Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Mouse focus when cursor leaves window #423

Merged
merged 4 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions include/QCefView.h
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,6 @@ class QCEFVIEW_EXPORT QCefView : public QWidget
/// <returns>True to allow the close, false to cancel the close</returns>
virtual bool onRequestCloseFromWeb();

virtual void leaveEvent(QEvent* event) override;

#pragma region QWidget
public slots:
/// <summary>
Expand Down Expand Up @@ -547,6 +545,11 @@ public slots:
/// </summary>
void wheelEvent(QWheelEvent* event) override;

/// <summary>
/// Please refer to QWidget::leaveEvent
/// </summary>
void leaveEvent(QEvent* event) override;

/// <summary>
/// Please refer to QWidget::contextMenuEvent
/// </summary>
Expand Down
14 changes: 7 additions & 7 deletions src/QCefView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,15 +330,15 @@ QCefView::onRequestCloseFromWeb()
void
EdnY1 marked this conversation as resolved.
Show resolved Hide resolved
QCefView::leaveEvent(QEvent* event)
{
QWidget::leaveEvent(event);
Q_D(QCefView);

if (d_ptr->isOSRModeEnabled()) {
QPoint localPos{ -1, -1 };
QPoint globalPos = mapToGlobal(localPos);
QPoint localPos = QCursor::pos();
QPoint globalPos = mapToGlobal(localPos);
EdnY1 marked this conversation as resolved.
Show resolved Hide resolved

QMouseEvent moveEvent(QEvent::MouseMove, localPos, globalPos, Qt::NoButton, Qt::NoButton, Qt::NoModifier);
mouseMoveEvent(&moveEvent);
}
QMouseEvent moveEvent(QEvent::MouseMove, localPos, globalPos, Qt::NoButton, Qt::NoButton, Qt::NoModifier);
d->onViewMouseEvent(&moveEvent);

QWidget::leaveEvent(event);
}

QVariant
Expand Down
Loading