1. 15 Jan, 2018 1 commit
  2. 19 Sep, 2017 1 commit
    • Martin Flöser's avatar
      Support mapping QKeyEvent to xkb_keysym_t · a17c85a9
      Martin Flöser authored
      Summary:
      This is needed in virtual keyboard and also used KKeyServer so far. With
      this change it is moved to new API provided in Xkb. The new translation
      map is now also used for the direction from Qt::Key +
      Qt::KeyboardModifier to xkb_keysym_t.
      
      New implementation is supported by a new test case covering the same
      combinations as in the existing direction.
      
      Reviewers: #kwin, #plasma
      
      Subscribers: plasma-devel, kwin
      
      Tags: #kwin
      
      Differential Revision: https://phabricator.kde.org/D7356
      a17c85a9
  3. 16 Aug, 2017 3 commits
    • Martin Flöser's avatar
      Migrate Xkb::toQtKey away from KKeyServer · 5d101ce2
      Martin Flöser authored
      Summary:
      Turn Xkb into a QObject
      
      Reduced dependencies on other classes and allows to emit signal directly
      instead of emitting a signal on another class.
      
      Dependency inject KWayland::Server::SeatInterface into Xkb
      
      No need to depend on WaylandServer from within Xkb.
      
      [autotests] Add test case for Xkb::toQtKey
      
      Tests all key codes KKeyServer is able to map to Qt.
      
      Migrate Xkb::toQtKey away from KKeyServer
      
      The regression in kwindowsystem in
      32526718eae99ccb594360627586eebdf793372b showed once more that it's time
      to migrate the xkb keysym to Qt::Key mapping away from KKeyServer. The
      main problem with KKeyServer is that it's made for X11 and we don't have
      X11 here. This causes warnings printed at runtime and the code only
      works by accident at all because KKeyServer fails to initialise
      modifiers. That is normally KKeyServer would include the modifiers, but
      that is nothing we are interested in for mapping xkb keysyms to Qt::Key.
      
      So to address this, KWin now implements the mapping itself. It's based
      on the implementation in KKeyServer, but also improved by providing
      faster xkb to Qt conversion (which matters for KWin more than the other
      direction).
      
      Long term plan is to extend this so that also on X11 it can be used.
      Then it should be split out and be used in KKeyServer as a replacement
      for the current implementation which could support both X11 and Wayland.
      
      Test Plan:
      New test case added which covers all keysyms supported by
      existing KKeyserver mapping
      
      Reviewers: #kwin, #plasma
      
      Subscribers: plasma-devel, kwin
      
      Tags: #kwin
      
      Differential Revision: https://phabricator.kde.org/D7336
      5d101ce2
    • Martin Flöser's avatar
      Dependency inject KWayland::Server::SeatInterface into Xkb · dbb951b4
      Martin Flöser authored
      No need to depend on WaylandServer from within Xkb.
      dbb951b4
    • Martin Flöser's avatar
      Turn Xkb into a QObject · 08ae17e2
      Martin Flöser authored
      Reduced dependencies on other classes and allows to emit signal directly
      instead of emitting a signal on another class.
      08ae17e2
  4. 12 Aug, 2017 1 commit
    • Martin Flöser's avatar
      Remove Keyboard modifiers from Qt::Key created in Xkb::toQtKey · d56b75f6
      Martin Flöser authored
      The KWindowSystem change 32526718eae99ccb594360627586eebdf793372b caused
      a regression in KWin as Qt::Enter on keypad is no longer enter, but enter
      with modifier mask. For all other modifiers it was never a problem that
      the KKeyServer method also returned modifiers as it could not read the
      X modifiers anyway.
      
      As KWin has full knowledge about the modifiers through Xkb it does not
      need the modifier mapped into the Qt::Key.
      
      This fixes the failing TestWindowSelection autotest which started to fail
      due to the change in KWindowSystem.
      d56b75f6
  5. 18 Jun, 2017 1 commit
    • Martin Flöser's avatar
      Better handle cases when the xkb keymap fails to be created · 0df09a8c
      Martin Flöser authored
      Summary:
      If the keymap cannot be created a few pointers in Xkb are null.
      We should make sure to not call any xkbcommon functions on those
      null pointers and instead use proper fallbacks.
      
      This change introduces fixes for a few usages, but it's not unlikely
      that there are more cases.
      
      BUG: 381210
      FIXED-IN: 5.10.3
      
      Test Plan:
      Autotest added for the condition of the bug, which does
      not crash any more. Just starting the test found a few more crash
      cases.
      
      Reviewers: #kwin, #plasma
      
      Subscribers: plasma-devel, kwin
      
      Tags: #kwin
      
      Differential Revision: https://phabricator.kde.org/D6260
      0df09a8c
  6. 24 Apr, 2017 1 commit
    • Martin Flöser's avatar
      Handle modifier updates in the same sequence as Wayland does · a039c276
      Martin Flöser authored
      Summary:
      Consider the case that capslock gets pressed and released.
      In the case of Weston we have a sequence of:
       1. Key press event
       2. Modifier changed event
       3. Key release event
       4. Modifier changed event
      
      KWin however used to send the events in the following sequence:
       1. Modifier changed event (on key press)
       2. Key press event
       3. Modifier changed event (on key release)
       4. Key release event
      
      It looks like Xwayland is not able to properly process the sequence
      sent by KWin. And in fact KWin's sequence is wrong as it sends a state
      which does not match. We report that the caps lock is pressed in the
      modifiers prior to the application getting informed about the key press
      of caps lock.
      
      This change aligns KWin's implementation to the behavior of Weston. The
      main difference is that when modifiers change Xkb internally caches the
      serialized modifier states. And KeyboardInputRedirection just forwards
      the modifiers to KWayland::Server::SeatInterface once the processing has
      finished. SeatInterface ignores the forwarding if no states changes, so
      it is fine to do it that way.
      
      BUG: 377155
      
      Test Plan:
      Not yet tested with an affected Xwayland as I only have 1.18 and the
      problem started with 1.19. But verified the sequence of events with WAYLAND_DEBUG
      and caps lock stil working in QtWayland clients and Xwayland 1.18
      
      Reviewers: #kwin, #plasma
      
      Subscribers: plasma-devel, kwin
      
      Tags: #kwin
      
      Differential Revision: https://phabricator.kde.org/D5452
      a039c276
  7. 15 Feb, 2017 1 commit
  8. 14 Feb, 2017 1 commit
    • Martin Flöser's avatar
      Split modifier only handling into a dedicated InputEventSpy · 65ddd32d
      Martin Flöser authored
      Summary:
      The functionality regarding triggering modifier only shortcuts is moved
      out of Xkb - where it doesn't belong to - and is turned into an input
      event spy listening for the changes it is interested in. Previously
      the state got queried by asking e.g. for the pressed buttons, now it's
      tracked directly.
      
      The X11 side needs a larger change due to that as now pushing the events
      into Xkb does not trigger modifier only shortcuts any more. Instead the
      "normal" way through the platform API needs to be used which triggers the
      processing of filters and spies.
      
      The problem here is that our redirections only process events if they are
      inited and that only happens on Wayland. We cannot call init on them as
      that would create all the Wayland filters and spies and processing would
      probably break. As an intermediate solution the spies are now processed
      and there we know that it won't matter. A future solution would be to
      remove the init checks completely and just send through both filters and
      spies and ensure that on X11 only the supported ones are loaded.
      
      Closes T5220
      
      Test Plan: Tested on Wayland and X11
      
      Reviewers: #kwin, #plasma
      
      Subscribers: plasma-devel, kwin
      
      Tags: #kwin
      
      Maniphest Tasks: T5220
      
      Differential Revision: https://phabricator.kde.org/D4578
      65ddd32d
  9. 07 Feb, 2017 1 commit
  10. 30 Jan, 2017 1 commit
    • Martin Flöser's avatar
      Provide kxbk config through kwinApp · 8d9c4acf
      Martin Flöser authored
      Summary:
      So far KWin parsed the kxbkrc at multiple places (once in Xkb, once
      in KeyboardLayout). This is now replaced by one KSharedConfigPtr hold
      by kwinApp, just like the normal kwinrc. The KSharedConfigPtr is now
      passed to Xkb.
      
      As a nice side effect this makes it easier to test keyboard layout
      changes as we can now properly mock the keyboard configuration. Thus
      this change also comes with an autotest for loading keyboard layout
      configuration. This is becoming more and more a need as we start
      getting bug reports for layout specific issues like global shortcuts
      not working with Greek layout.
      
      Reviewers: #kwin, #plasma_on_wayland
      
      Subscribers: plasma-devel, kwin
      
      Tags: #plasma_on_wayland, #kwin
      
      Differential Revision: https://phabricator.kde.org/D4315
      8d9c4acf
  11. 27 Jan, 2017 1 commit
    • Martin Flöser's avatar
      Split Keyboard Repeat handling into a dedicated InputEventSpy · eb924772
      Martin Flöser authored
      Summary:
      So far the keyboard repeat handling was triggered directly from
      KeyboardInputRedirection::processKey. With the introduction of
      InputEventSpies it is no longer required to be done like that, we can
      split it out into a dedicated spy.
      
      This means that processKey only has to care about processing the key
      and allows us to better extend in future. So far keyboard repeat is
      only functional for libinput based platforms. But it should also be
      possible to use it in nested setups. By splitting it out we can
      prepare for that.
      
      Test Plan: Auto-test using repeat still passes
      
      Reviewers: #kwin, #plasma_on_wayland
      
      Subscribers: plasma-devel, kwin
      
      Tags: #plasma_on_wayland, #kwin
      
      Differential Revision: https://phabricator.kde.org/D4304
      eb924772
  12. 25 Jan, 2017 2 commits
    • Martin Flöser's avatar
      Add a basic SNI for keyboard layout · fe561c5c
      Martin Flöser authored
      Summary:
      On X11 the SNI for keyboard layout is provided by the keyboard kded.
      On Wayland that kded has no real access to the layouts and cannot
      properly implement switching. Given that it's better to integrate the
      SNI directly in KWin.
      
      The implementation of the SNI is largly based on the existing SNI from
      plasma-desktop/kcms/keyboard. The implementation so far supports:
       * Switching to next layout on toggle
       * Presenting all layouts in a context menu
       * Switching to a specific layout through the context menu
       * Opening the keyboard layout configuration module
       * scroll on SNI to switch layout
       * config option whether to show the SNI
      
      Not yet supported are:
       * flags and/or short text for the layouts
      
      The last point needs more explanation. On X11 the layout name is
      something like "de" or "us". This can be directly mapped to a flag and
      can be added as a short note.
      
      Xkbcommon does not provide this information directly. Instead it provides
      us the full name of the layout, e.g. "German" or "English (us)". There is
      no way in the API to go from "German" to "de".
      
      Instead we need to parse the evdev.xml file to gather all information
      about layouts. This is already done in the keyboard kcm to configure
      layouts. The implementation needs to be split out into a small helper
      library.
      
      Reviewers: #kwin, #plasma_on_wayland
      
      Subscribers: plasma-devel, kwin
      
      Tags: #plasma_on_wayland, #kwin
      
      Differential Revision: https://phabricator.kde.org/D4220
      fe561c5c
    • Martin Flöser's avatar
      Support modifier-only-shortcuts when capslock is on · 5a87fa3f
      Martin Flöser authored
      Summary:
      So far we didn't trigger modifier-only-shortcuts when capslock was
      enabled. In fact we even ensured that the shortcuts did not trigger.
      This seems not to be what our users expect. Meta should still trigger
      if capslock is on.
      
      This change modifies the logic to determine which modifier is currently
      pressed by using the modifiersRelevantForGlobalShortcuts. The difference
      to the "normal" modifiers is that this excludes capslock from modifiers
      and excludes consumed modifiers. The latter is not really relevant as
      modifier-only-shortcuts do not trigger if multiple keys are pressed,
      which is required to have a modifier consumed.
      
      BUG: 375355
      FIXED-IN: 5.8.6
      
      Test Plan: Only with adjusted autotest
      
      Reviewers: #kwin, #plasma
      
      Subscribers: plasma-devel, kwin
      
      Tags: #kwin
      
      Differential Revision: https://phabricator.kde.org/D4241
      5a87fa3f
  13. 22 Jan, 2017 1 commit
    • Martin Flöser's avatar
      Translate the layout name when passing to layout change OSD · a3be3e8e
      Martin Flöser authored
      Summary:
      Xkbcommon does not localize the layout names. We always get the US
      English variant. KWin so far passed the strings from xkbcommon directly
      to UI visible parts such as the Plasma OSD. This results in not
      translated elements in our UI.
      
      As I figured out today the translations exist in the domain
      xkeyboard-config. Passing the strings from xkbcommon through this domain
      gives us translated layouts.
      
      Unfortunately the xkeyboard-config is not installed by default on all
      distributions. E.g. on ubuntu/neon one needs to install xkb-data-i18n
      to have the translations available.
      
      Test Plan: Untested as I fail to start Plasma/5.8 KWin on my dev system
      
      Reviewers: #kwin, #plasma
      
      Subscribers: plasma-devel, kwin
      
      Tags: #kwin
      
      Differential Revision: https://phabricator.kde.org/D4243
      a3be3e8e
  14. 18 Jan, 2017 2 commits
    • Martin Flöser's avatar
      Split implementation of keyboard layout handling into a dedicated class · d6c0a541
      Martin Flöser authored
      Summary:
      So far the implementation of keyboard layout handling was split between
      KeyboardInputRedirection and Xkb. KeyboardInputRedirection registered
      the global shortcut and did the handling for layout switch and config
      changes. Xkb did the notification on layout change.
      
      Layout changes can nowadays be detected through an InputEventSpy. It
      can only happen after a key change or an explicit layout switch. Thus
      it does not need to be in Xkb anymore which allows to reduce Xkb to
      only care about the Xkb keymap and state tracking.
      
      This change introduces a new class KeyboardLayout which is an
      InputEventSpy and takes over the task of the layout change notification
      from Xkb and the layout management from KeyboardInputRedirection. Thus
      everything related to management of keyboard layout is together in one
      class.
      
      This allows in future to add unit test to it (requires further cleanup
      of Xkb to be able to use it and drop the InputRedirection dependency) and
      opens the possibility to also take over keyboard layout management on X11
      for the Plasma desktop.
      
      Test Plan: Manual testing
      
      Reviewers: #kwin, #plasma_on_wayland
      
      Subscribers: plasma-devel, kwin
      
      Tags: #plasma_on_wayland, #kwin
      
      Differential Revision: https://phabricator.kde.org/D4135
      d6c0a541
    • Martin Flöser's avatar
      Use an InputEventSpy to notify about key and modifier state changes · 437edb45
      Martin Flöser authored
      Summary:
      Instead of emitting the key state changed and modifier state changed
      signals from the right point before processing the events, let's use
      an InputEventSpy to do that. The spies were introduced to be called
      directly before the event processing. So the contract still holds.
      
      Reviewers: #kwin, #plasma_on_wayland
      
      Subscribers: plasma-devel, kwin
      
      Tags: #plasma_on_wayland, #kwin
      
      Differential Revision: https://phabricator.kde.org/D4128
      437edb45
  15. 30 Dec, 2016 1 commit
    • Martin Flöser's avatar
      Introduce an InputEventSpy for processing input events · 84e33081
      Martin Flöser authored
      Summary:
      So far KWin's input event processing is mostly based on
      InputEventFilters. A filter can - as the name suggest - filter out an
      input event from further processing. Our code shows that this is not
      sufficient for all input event processing.
      
      We have several areas inside KWin where we need to have access to all
      input events, where the processing needs to happen on all events and
      filtering is not allowed. This results in sub-optimal code which has
      classes which know too much and do too much.
      
      Examples:
       * key-repeat handling done in KeyboardInputRedirection
       * Layout change OSD in Xkb
       * modifier only shortcuts in Xkb
       * emitting signals for Cursor class in KeyboardInputRedirection
      
      Also there are misuses of the InputEventFilters and internal API
       * DebugConsole keyboard state (uses wrong information)
       * DebugConsole input events tab (uses Filter, should be a spy)
      
      This change introduces the API needed to fix these problems. It
      introduces an InputEventSpy which is modelled after the InputEventFilter
      with the difference that it has only void messages and uses the KWin
      introduced event classes.
      
      The spies are always processed prior to the filters, thus we know it can
      have all events.
      
      Reviewers: #kwin, #plasma
      
      Subscribers: plasma-devel, kwin
      
      Tags: #kwin
      
      Differential Revision: https://phabricator.kde.org/D3863
      84e33081
  16. 27 Dec, 2016 3 commits
    • Martin Flöser's avatar
      Add the modifiers relevant for global shortcuts into the input Events · 58361213
      Martin Flöser authored
      Summary:
      Prior to this change various event filters performed deep calls into
      Xkb class to figure out the modifiers relevant for global shortcuts (aka
      consumed modifiers). This shows that this is a general useful
      information which should be available to all input event filters
      directly.
      
      Thus it's now added to the input events and exposed directly in
      InputRedirection so that the calls into Xkb are no longer needed.
      
      Reviewers: #kwin, #plasma_on_wayland
      
      Subscribers: plasma-devel, kwin
      
      Tags: #plasma_on_wayland, #kwin
      
      Differential Revision: https://phabricator.kde.org/D3810
      58361213
    • Martin Flöser's avatar
      Use new xkbcommon API for consumed modifiers · d1fdb9a0
      Martin Flöser authored
      Summary:
      This change removes the workaround added with
      421824b6.
      
      Xkbcommon 0.7 introduces the needed API to make this work without a
      workaround.
      
      Test Plan: Test case still passes
      
      Reviewers: #kwin, #plasma_on_wayland
      
      Subscribers: plasma-devel, kwin
      
      Tags: #plasma_on_wayland, #kwin
      
      Differential Revision: https://phabricator.kde.org/D3809
      d1fdb9a0
    • Martin Flöser's avatar
      Reduce code duplication for processing input events · e3d79cdd
      Martin Flöser authored
      Summary:
      For every input event we have similar code. We go through all
      InputFilters, invoke a method with some arguments and check whether
      the filter returns true.
      
      Instead of duplicating that logic everywhere, there is now one method
      in InputRedirection which takes a std::function to call on the input
      filters. The std::function is supposed to be generated with a std::bind
      on the InputFilter::method with all the required arguments.
      
      Reviewers: #kwin, #plasma
      
      Subscribers: plasma-devel, kwin
      
      Tags: #kwin
      
      Differential Revision: https://phabricator.kde.org/D3806
      e3d79cdd
  17. 08 Dec, 2016 1 commit
    • Martin Flöser's avatar
      Implement support for pointer constraints · 0c5ca405
      Martin Flöser authored
      Summary:
      There are two types of constraints supported:
      1. Pointer confinement
      2. Pointer locking
      
      In the case of confinement the pointer is confined to a given region of
      the surface. This is comparable to general operation where the pointer
      is confined to the screen region.
      
      In the second case the pointer gets locked. That means it cannot move at
      all. No further position updates are provided, only relative motion
      events can go to the application. There is a hint about cursor position
      update on unlock which is not yet implemented in KWayland::Server, thus
      also not in this change.
      
      The implementation in KWin grants the requests for pointer constraints
      when the pointer enters the constrained region, either by pointer
      movement or by e.g. stacking order changes. There is no confirmation
      from user required to enter that mode. But we want to show an OSD when
      the pointer gets constrained, this is not yet implemented, though.
      
      Breaking an active constraint is relatively easy. E.g. changing the
      stacking order will break the constraint if another surface is under the
      cursor. Also (in case of confinement) moving the pointer to an
      overlapping window breaks the confinement. But as soon as one moves the
      pointer back to the window a constraint might get honoured again.
      
      To properly break there is a dedicated event filter. It listens for a
      long press of the Escape key. If hold for 3sec the pointer constraint is
      broken and not activated again till the pointer got moved out of the
      window. Afterward when moving in the pointer might activate again.
      
      The escape filter ensures that the key press is forwarded to the
      application if it's a short press or if another key gets pressed during
      the three seconds. If the three seconds way fires, the later escape
      release is not sent to the application.
      
      This basic interaction is also ensured through an added auto test.
      
      This change implements T4605.
      
      Test Plan: Added auto test and nested KWin Wayland with D3488
      
      Reviewers: #kwin, #plasma_on_wayland
      
      Subscribers: plasma-devel, kwin
      
      Tags: #plasma_on_wayland, #kwin
      
      Differential Revision: https://phabricator.kde.org/D3506
      0c5ca405
  18. 17 Nov, 2016 1 commit
    • Martin Flöser's avatar
      Implement interactive window selection for Wayland platforms · fd83366e
      Martin Flöser authored
      Summary:
      The interactive window selection is implemented in InputRedirection
      through a dedicated InputEventFilter. The InputEventFilter so far takes
      care of pointer input and keyboard input. In addition it ensures that
      keyboard and pointer focus is reset on start and on end.
      
      With this change KillWindow now also works on Wayland, but only for X11
      windows, as the Wayland variant is not yet implemented.
      
      Test Plan: Tested in nested setup, auto-tests still needed
      
      Reviewers: #kwin, #plasma_on_wayland
      
      Subscribers: plasma-devel, kwin
      
      Tags: #plasma_on_wayland, #kwin
      
      Differential Revision: https://phabricator.kde.org/D3365
      fd83366e
  19. 17 Oct, 2016 2 commits
    • Martin Flöser's avatar
      Fix shortcut triggering with shift+letter · 78a2732a
      Martin Flöser authored
      Summary:
      A shortcut with e.g. shift+w could not be triggered as shift is
      considered as consumed. It transforms the keysym to an uppercase variant
      thus it is consumed.
      
      This change checks for the condition that shift is pressed and is the
      only consumed modifier. If the current keysym is a letter the shift is
      removed from the consumed modifier again to still support the shortcut.
      
      BUG: 370341
      FIXED-IN: 5.8.2
      
      Reviewers: #kwin, #plasma_on_wayland
      
      Subscribers: plasma-devel, kwin
      
      Tags: #plasma_on_wayland, #kwin
      
      Differential Revision: https://phabricator.kde.org/D3015
      78a2732a
    • Martin Flöser's avatar
      Support LEDs in Xkb and libinput · 4c7752c9
      Martin Flöser authored
      Summary:
      The Xkb implementation starts to track the state of the LEDs in the
      keymap and emits a signal whenever the LEDs change. This signal is
      connected to a method in LibInput::Connection which updates the led
      state on all devices and uses it to init the state of the led when a new
      device gets connected.
      
      BUG: 369214
      FIXED-IN: 5.8.2
      
      Test Plan: Connected a keyboard with LEDs and enabled NumLock and ScrollLock.
      
      Reviewers: #kwin, #plasma_on_wayland
      
      Subscribers: plasma-devel, kwin
      
      Tags: #plasma_on_wayland, #kwin
      
      Differential Revision: https://phabricator.kde.org/D2943
      4c7752c9
  20. 06 Oct, 2016 3 commits
    • Martin Flöser's avatar
      Only trigger mod-only-shortcuts if global shortcuts are enabled · db2ff13d
      Martin Flöser authored
      Summary:
      KWin supports blocking global shortcuts when a window is active through
      window specific rules. This change ensures that the modifier only
      shortcuts also honor the blocking of global shortcuts. If global
      shortcuts are disabled, they won't trigger any more.
      
      BUG: 370146
      FIXED-IN: 5.8.1
      
      Reviewers: #kwin, #plasma
      
      Subscribers: plasma-devel, kwin
      
      Tags: #kwin
      
      Differential Revision: https://phabricator.kde.org/D2952
      db2ff13d
    • Martin Flöser's avatar
      Workaround xkbcommon behavior concerning consumed modifiers · 421824b6
      Martin Flöser authored
      Summary:
      If a key could be turned into a keysym with a modifier xkbcommon
      considers the modifier as consumed even if not pressed.
      E.g. Alt+F3 considers alt as consumed as there is a keysym gnerated with
      Ctrl+Alt+F3 (vt switching).
      
      This change tries to workaround the problem by ignoring the consumed
      modifiers if there are more modifiers consumed than active. It's
      possible that this will create regressions for other shortcuts - we need
      to test it in the wild. Although this might cause regressions I'm aiming
      for Plasma/5.8 branch with the change. It only affects Wayland and fixes
      quite important shortcuts from window manager perspective (desktop
      switching (ctrl+f1 to ctrl+f4), desktop grid (ctrl+f8), present windows
      (ctrl+f9, ctrl+10), cube (ctrl+f11), user actions (alt+f3), close window
      (alt+f4)). If it causes regressions they need to be fixed as well in the
      Plasma/5.8 branch.
      
      A new API entry point for xkbcommon was proposed, but is not yet merged
      and there is no release with it yet. Once that is available the
      workaround should get removed and replaced by the new API call.
      
      BUG: 368989
      FIXED-IN: 5.8.1
      
      Test Plan: Going to restart session now with the change
      
      Reviewers: #kwin, #plasma_on_wayland
      
      Subscribers: plasma-devel, kwin
      
      Tags: #plasma_on_wayland, #kwin
      
      Differential Revision: https://phabricator.kde.org/D2945
      421824b6
    • Martin Flöser's avatar
      Only repeat one key · 3bc60893
      Martin Flöser authored
      Summary:
      So far KWin tried to repeat all pressed keys which should repeat. But
      this is not how X11 and e.g. QtWayland handle it. There only one key -
      the last one which got pressed - repeats. And this makes sense as the
      key is used to generate a keysym and that one KWin caches. Thus the
      logic so far resulted in incorrect keysyms to be generated during the
      repeat. E.g. pressing a, pressing b, releasing b would repeat b instead
      of the hold a as b was the last generated keysym.
      
      This change addresses this problem and let's only one key repeat at a
      time. When the currently repeating key gets released the repeat timer is
      stopped and other hold keys won't repeat any more. This also matches the
      behavior of X11 and QtWayland.
      
      BUG: 369091
      FIXED-IN: 5.8.1
      
      Reviewers: #kwin, #plasma_on_wayland
      
      Subscribers: plasma-devel, kwin
      
      Tags: #plasma_on_wayland, #kwin
      
      Differential Revision: https://phabricator.kde.org/D2941
      3bc60893
  21. 14 Sep, 2016 1 commit
    • Martin Flöser's avatar
      Remove not-wanted modifiers prior to evaluating global shortcuts · 42358716
      Martin Flöser authored
      Summary:
      When triggering global shortcuts we are more interested in the hold
      keys than the currently active modifiers. E.g. capslock should not
      be seen as "shift is hold". Similar we need to remove consumed
      modifiers. Shift+5 is % and not Shift+% - the shift modifier is
      consumed and needs to be removed from shortcut evaluation.
      
      To support this we need to have the actual state directly from
      xkbcommon. Thus a new method is added which exposes the modifiers
      relevant for global shortcut matching. In addition on every key press
      all consumed modifiers are calculated and kept so that they can be
      used for shortcut matching.
      
      In addition a workaround is added for Backtab. Similar workaround
      exists in kglobalaccel for X11. The problem is that our shortcuts are
      stored incorrectly: Shift+Tab instead of Backtab. Thus a mapping back
      is required. To make everything worse KWin registers the wrong key
      sequence "Alt+Shift+Backtab" which doesn't make any sense and is
      broken on X11 at least.
      
      The workaround supports both special cases. The one for Backtab should
      be turned into Shift+Tab and also KWin's special case of adding shift
      to backtab.
      
      CCBUG: 368581
      
      Reviewers: #kwin, #plasma_on_wayland, bshah
      
      Subscribers: plasma-devel, kwin
      
      Tags: #plasma_on_wayland, #kwin
      
      Differential Revision: https://phabricator.kde.org/D2768
      42358716
  22. 30 Aug, 2016 1 commit
    • Martin Flöser's avatar
      Support compose key in xkbcommon integration · a98a1b13
      Martin Flöser authored
      Summary:
      The Xkb class now creates a compose key table and a state object and
      feeds all key presses through the compose state machine.
      
      Xkb now tracks the latest keysym which is provided through new method
      currentKeysym. This is now used when creating a QKeyEvent instead of
      passing the key code to the xkb state. With that the keysym can also
      be updated through the compose state system.
      
      This only affects KWin internal usage where text is composed, e.g. the
      present windows effect filter. Wayland clients do not gain compose key
      support, though.
      
      Minimum xkbcommon version raised to 0.5 as compose key support is new
      in that version.
      
      Test Plan: Enabled compose key support in keymap and verified through DebugConsole
      
      Reviewers: #kwin, #plasma_on_wayland
      
      Subscribers: plasma-devel, kwin
      
      Tags: #plasma_on_wayland, #kwin
      
      Differential Revision: https://phabricator.kde.org/D2622
      a98a1b13
  23. 29 Aug, 2016 1 commit
  24. 21 Aug, 2016 1 commit
    • Martin Flöser's avatar
      Only trigger keyboard layout OSD if KWin manages input · 7d7bbcc5
      Martin Flöser authored
      Summary:
      On platforms where KWin does not manage input, that is does not
      use libinput, KWin gets the keyboard layout from another place, e.g.
      the X server. In that case KWin should of course not trigger the
      layout changed OSD if KWin thinks (for whatever reason) that the
      layout changed.
      
      BUG: 367637
      
      Reviewers: #kwin, #plasma_on_wayland
      
      Subscribers: plasma-devel, kwin
      
      Tags: #plasma_on_wayland, #kwin
      
      Differential Revision: https://phabricator.kde.org/D2521
      7d7bbcc5
  25. 19 Aug, 2016 1 commit
    • Martin Flöser's avatar
      Ensure modifier locks and latches don't trigger the mod only shortcut · ec98f498
      Martin Flöser authored
      Summary:
      If caps lock is on the shift key should not trigger. Similar pressing
      caps lock should neither on activation press nor on deactivation press
      trigger the shortcut. Related to that are latched modifiers aka sticky
      modifiers: if the modifier is still on after releasing the key the
      shortcut should not trigger. We must assume the user wanted to use the
      modifier to activate the modifier, not to activate the shortcut.
      
      This change ensures that we don't track for modifier only shortcuts if
      a modifier is active before press or after release.
      
      The added test case demonstrates for caps lock, latched modifiers is
      currently still untested. (Needs a way to mock it).
      
      Test Plan: See test case for caps lock.
      
      Reviewers: #kwin, #plasma
      
      Subscribers: kwin
      
      Tags: #kwin
      
      Differential Revision: https://phabricator.kde.org/D2467
      ec98f498
  26. 18 Aug, 2016 1 commit
    • Martin Flöser's avatar
      Introduce env variable KWIN_XKB_DEFAULT_KEYMAP to force default layout creation · ea22b8f1
      Martin Flöser authored
      Summary:
      The Xkb class loads keyboard layouts from the users configuration. This
      makes tests fail locally if the user has a layout which behaves
      differently to the one the test expects. E.g. on a German layout the
      right alt key is different to the one of US layout.
      
      In order to have a more stable test base the env variable
      KWIN_XKB_DEFAULT_KEYMAP forces the loading of the default keymap, thus
      tests have a common layout set.
      
      Reviewers: #kwin, #plasma_on_wayland
      
      Subscribers: plasma-devel, kwin
      
      Tags: #plasma_on_wayland, #kwin
      
      Differential Revision: https://phabricator.kde.org/D2466
      ea22b8f1
  27. 16 Aug, 2016 2 commits
    • Martin Flöser's avatar
      Support modifier only shortcuts on X11 · 2c333417
      Martin Flöser authored
      Summary:
      With this change KWin/X11 reuses Wayland's modifier only shortcut
      architecture. The XInput2 event filter also listens for
       * XI_RawKeyPress
       * XI_RawKeyRelease
      
      Those events are also reported if another X11 client grabs keyboard
      input. Thus KWin gets all key events, just like on Wayland.
      
      All key events are then sent through the Xkb class which performs the
      mapping from key codes to key syms and is able to detect whether the
      modifier got pressed/released without another key being pressed.
      
      This change will require a few follow up changes, which are required
      also for Wayland:
       * ignore if another input device got interacted (e.g. mouse press,
         touch screen, scroll, etc)
       * use the layout from XServer instead of using our own (needed on
         Wayland in nested setup)
      
      The biggest disadvantage of the change is that it triggers a wake
      up of KWin on every key event. But as KWin already listens to all
      pointer events that's not a big difference and normally a key event
      will wake up the compositor any way.
      
      Reviewers: #plasma
      
      Subscribers: kwin
      
      Tags: #kwin
      
      Differential Revision: https://phabricator.kde.org/D2425
      2c333417
    • Martin Flöser's avatar
      Block modifier only shortcuts when screen is/gets locked · 06d562a5
      Martin Flöser authored
      If the screen is locked the modifier only shortcuts should not trigger.
      Also if the screen gets locked while a modifier is hold the shortcuts
      should not trigger.
      
      Reviewed-By: bshah
      06d562a5
  28. 15 Aug, 2016 1 commit
  29. 16 Jul, 2016 1 commit
  30. 29 Jun, 2016 1 commit
    • Martin Flöser's avatar
      Support for syncing the clipboard from X11 to Wayland and vice versa · 3493e976
      Martin Flöser authored
      Summary:
      The clipboard sync is done by a dedicated helper binary launched by
      KWin. This helper binary is forced to xcb platform to piggy-back on
      Qt's implementation of the X11 clipboard. In addition it implements
      the Wayland clipboard - which is much simpler. Reading the Wayland
      clipboard is based on the implementation in QtWayland.
      
      KWin internally knows the DataDeviceInterface belonging to the helper
      application. Whenever an xwayland client is focussed, this DataDevice
      is allowed to set the selection and KWin manually updates the current
      selection in the SeatInterface. By that the sync from X11 to Wayland
      is implemented. When afterwards a Wayland client is selected, it's sent
      the current selection which references the X clipboard and a data
      transfer can be initiated in the normal Wayland way.
      
      For the other direction KWin sends the current selection to the helper's
      DataDevice whenever an xwayland window is focused. The helper application
      reads the Wayland clipboard and sets it on the X11 clipboard. Thus the
      Wayland clipboard is synced to X11.
      
      The approach used here will also be useful for implementing a clipboard
      manager (aka klipper).
      
      Currently the implementation is not yet fully completed. We need to
      make sure that the helper application gets restarted in case of a crash.
      
      Test Plan: See added test case
      
      Reviewers: #plasma_on_wayland, #kwin
      
      Subscribers: plasma-devel, kwin
      
      Tags: #plasma_on_wayland, #kwin
      
      Differential Revision: https://phabricator.kde.org/D1973
      3493e976