<table><tr><td style="">graesslin created this revision.<br />graesslin added reviewers: KWin, Plasma on Wayland.<br />Restricted Application added subscribers: kwin, plasma-devel.<br />Restricted Application added projects: Plasma on Wayland, KWin.
</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/D3506" rel="noreferrer">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>There are two types of constraints supported:</p>
<ol class="remarkup-list">
<li class="remarkup-list-item">Pointer confinement</li>
<li class="remarkup-list-item">Pointer locking</li>
</ol>
<p>In the case of confinement the pointer is confined to a given region of<br />
the surface. This is comparable to general operation where the pointer<br />
is confined to the screen region.</p>
<p>In the second case the pointer gets locked. That means it cannot move at<br />
all. No further position updates are provided, only relative motion<br />
events can go to the application. There is a hint about cursor position<br />
update on unlock which is not yet implemented in KWayland::Server, thus<br />
also not in this change.</p>
<p>The implementation in KWin grants the requests for pointer constraints<br />
when the pointer enters the constrained region, either by pointer<br />
movement or by e.g. stacking order changes. There is no confirmation<br />
from user required to enter that mode. But we want to show an OSD when<br />
the pointer gets constrained, this is not yet implemented, though.</p>
<p>Breaking an active constraint is relatively easy. E.g. changing the<br />
stacking order will break the constraint if another surface is under the<br />
cursor. Also (in case of confinement) moving the pointer to an<br />
overlapping window breaks the confinement. But as soon as one moves the<br />
pointer back to the window a constraint might get honoured again.</p>
<p>To properly break there is a dedicated event filter. It listens for a<br />
long press of the Escape key. If hold for 3sec the pointer constraint is<br />
broken and not activated again till the pointer got moved out of the<br />
window. Afterward when moving in the pointer might activate again.</p>
<p>The escape filter ensures that the key press is forwarded to the<br />
application if it's a short press or if another key gets pressed during<br />
the three seconds. If the three seconds way fires, the later escape<br />
release is not sent to the application.</p>
<p>This basic interaction is also ensured through an added auto test.</p>
<p>This change implements <a href="https://phabricator.kde.org/T4605" style="background-color: #e7e7e7;
border-color: #e7e7e7;
border-radius: 3px;
padding: 0 4px;
font-weight: bold;
color: black;text-decoration: none;" rel="noreferrer">T4605</a>.</p></div></div><br /><div><strong>TEST PLAN</strong><div><p>Added auto test and nested KWin Wayland with <a href="https://phabricator.kde.org/D3488" style="background-color: #e7e7e7;
border-color: #e7e7e7;
border-radius: 3px;
padding: 0 4px;
font-weight: bold;
color: black;text-decoration: none;" rel="noreferrer">D3488</a></p></div></div><br /><div><strong>REPOSITORY</strong><div><div>rKWIN KWin</div></div></div><br /><div><strong>BRANCH</strong><div><div>pointer-constraints</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D3506" rel="noreferrer">https://phabricator.kde.org/D3506</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>autotests/integration/CMakeLists.txt<br />
autotests/integration/kwin_wayland_test.h<br />
autotests/integration/pointer_constraints_test.cpp<br />
autotests/integration/test_helpers.cpp<br />
input.cpp<br />
input.h<br />
keyboard_input.cpp<br />
pointer_input.cpp<br />
pointer_input.h<br />
wayland_server.cpp</div></div></div><br /><div><strong>EMAIL PREFERENCES</strong><div><a href="https://phabricator.kde.org/settings/panel/emailpreferences/" rel="noreferrer">https://phabricator.kde.org/settings/panel/emailpreferences/</a></div></div><br /><div><strong>To: </strong>graesslin, KWin, Plasma on Wayland<br /><strong>Cc: </strong>plasma-devel, kwin, lesliezhai, ali-mohamed, hardening, jensreuterberg, abetts, eliasp, sebas<br /></div>