Rework InputDeviceHandler focus tracking

Authored by romangg on Sep 18 2018, 7:15 PM.



This patch aims at improving the Toplevel, internal window and decoration
focus tracking.

In detail the goals are:

  • Clean tracking of beneath and focus Toplevel as well as decoration and

internal windows. Splitting this up in well defined sub routines.

  • Minimal find Toplevel operations on window stack.
  • Reduce code duplication in pointer and touch child classes.
  • Reuse tracking in drag operations.
  • Allow direct usage of Wayland input interfaces for decoration and internal

windows in the future.

  • Update touch focus on external events like VD switches correctly.
Test Plan

Manually and existing autotests.

Diff Detail

R108 KWin
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
romangg requested review of this revision.Sep 18 2018, 7:15 PM
romangg created this revision.

Some more explanation:

InputDeviceHandler::at() always points to the Toplevel "below" the input device (according to stacking order). InputDeviceHandler::focus() on the other side points to the Toplevel, that has focus, i.e. receives input events from the device.

The core entry function to updating these parameters is InputDeviceHandler::update, which gets called on every relevant pointer / touch event once and resets at() and (if not blocked for example by an ongoing drag) focus() as well as decoration() and internalWindow().

If the device focuses the inside a foreign Toplevel only focus() returns a valid object. If the device has focus on the decoration of such a Toplevel, focus() and decoration() return objects. If the device focuses an internal window respectively focus() and internalWindow() return objects and if the device focus is on the decoration of such an internal window additionally decoration() returns a non-null object.

In the long run I want to abolish our custom QWindow input event injecting code in the event handlers for internal windows and decoration and tunnel it through our internal Wayland connection in order to leverage it with functionality in KWayland/Qt, for example for touch events.

zzag added a subscriber: zzag.Sep 18 2018, 9:02 PM
zzag added inline comments.

Really minor thing: can you please pick a different name? It's a method, thus it would be better to use imperative mood.


Minor nitpick: The name is confusing. It's not obvious that it uses the position() method. What about adding position parameter instead, e.g.

QWindow *internalWindowAtPosition(const QPointF &pos) const;
romangg set the repository for this revision to R108 KWin.Sep 19 2018, 12:38 AM
Restricted Application added a project: KWin. · View Herald TranscriptSep 19 2018, 12:38 AM
Restricted Application added a subscriber: kwin. · View Herald Transcript
romangg updated this revision to Diff 45163.EditedNov 9 2018, 10:45 AM
romangg marked 2 inline comments as done.
  • Rename methods
  • Use positional argument
  • Rebase on master
This revision was not accepted when it landed; it landed in state Needs Review.Dec 2 2018, 8:36 PM
This revision was automatically updated to reflect the committed changes.