Commit c56169f7 authored by Alexandru Croitor's avatar Alexandru Croitor
Browse files

Close popups when parent window is moved


When an HTML select box was clicked inside of a QWebEngineView and
the parent QWebEngineView window was moved using the mouse
(via window decoration toolbar for example) the popup window
would stay around instead of being closed.

This happened because of the usage of the Qt:Tool window flag for the
popup window, which implies a tool that floats near its parent window.

The fix is threefold:
1) Use Qt::Popup instead, similarly to how QMenu does it.
   Whenever the parent window is moved, the popup will now get a
   CloseEvent.
2) Handle the CloseEvent by telling Chromium to close and destroy
   the popup.
3) On Windows the OS might send mouse move events to the popup RWHVQD
   instance after its parent QWebEngineView, RWHVQD,
   QWebEnginePagePrivate (client adapter) is destroyed. We need to
   guard the mouse forwarding code not to access the client adapter
   if it has already been destroyed.

The second point is done by telling Chromium that its popup lost focus
which it interprets as a sign to hide it, and automatically destroy
it. This will destroy the underlying RWHVQtDelegateWidget and
RWHVQt instances.

Task-number: QTBUG-59891
Change-Id: I47f94a93c495a6caa5de92a6022eaca154994eda
Reviewed-by: default avatarMichael Brüning <michael.bruning@qt.io>
parent d603b705
No related merge requests found
Showing with 30 additions and 10 deletions
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment