<table><tr><td style="">davidedmundson created this revision.<br />Restricted Application added projects: Plasma, Frameworks.<br />Restricted Application added subscribers: Frameworks, plasma-devel.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D5515" rel="noreferrer">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>There was an unidentified bug where when opening a context menu in<br />
response to a mousePress event led to the next click events not being<br />
registered. The mouse got grabbed by the item in the mousePressEvent,<br />
but when we open a menu it didn't get released. The next click goes to<br />
the currently grabbed item.</p>

<p>A workaround was added back in 2015 (and copied into various other parts<br />
of Plasma) to ungrab the mouse after launching the context menu inside<br />
our rightClickEvent. This doesn't work because qquickwindow code is<br />
shuffled. It now sends the event and then grabs the mouse.</p>

<p>qquickwindow.cpp:653 on Qt5.8.0</p>

<p>Which means we're now trying to do the ungrab, before QWindow has set<br />
our item as the grabber. That obviously doesn't work.</p>

<p>This real bug needs fixing in Qt, (I now know the root cause!)<br />
but we have a workaround here already, we may as well make it work.</p>

<p>Note: This also needs doing in a bajillion (6) places in p-w/p-d.</p>

<p>FWIW, the root cause of all of these bugs is:</p>

<ul class="remarkup-list">
<li class="remarkup-list-item">QtQuick internally keeps track of which item has "grabbed" the mouse</li>
<li class="remarkup-list-item">It's weirdly a singleton between windows, but that should be fine</li>
<li class="remarkup-list-item">It relies on the fact that when we get an X mouse press event we</li>
</ul>

<p>should always get a mouse release event. X is surprisingly smart and<br />
will send this even if you change window focus.</p>

<ul class="remarkup-list">
<li class="remarkup-list-item">However - context menus are evil bastards. They do a low level grab</li>
</ul>

<p>(completely different type of grab than the one above) and grab all<br />
mouse events at the X level</p>

<ul class="remarkup-list">
<li class="remarkup-list-item">Our original QtQuickItem which was handling the right click event no</li>
</ul>

<p>longer gets our release event</p>

<ul class="remarkup-list">
<li class="remarkup-list-item">The reason it's only somtimes is we have a "race" between being</li>
</ul>

<p>created and the grab going through X, and the user actually releasing<br />
the mouse.</p></div></div><br /><div><strong>TEST PLAN</strong><div><p>Had 1 reproducible case<br />
Added this. No longer could reproduce</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R242 Plasma Framework (Library)</div></div></div><br /><div><strong>BRANCH</strong><div><div>origin-master (branched from master)</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D5515" rel="noreferrer">https://phabricator.kde.org/D5515</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>src/scriptengines/qml/plasmoid/containmentinterface.cpp</div></div></div><br /><div><strong>To: </strong>davidedmundson, Plasma<br /><strong>Cc: </strong>plasma-devel, Frameworks, spstarr, progwolff, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol<br /></div>