Skip to content

Draft: Contextual Behavior System

Eric Edlund requested to merge work/eric/unify-gestures into master

This MR is being split up to make review easier.

New System for Contextual Behavior

Any place the user can be (overview effect, desktop grid, etc) registers a Context object with the system. These contexts are centrally managed and will later have a KCM dedicated to them. In different contexts, different Gestures can be bound. This allows us to have to have swipe up open overview in the DEFAULT_CONTEXT but swipe down close it in the overview context.

There can be multiple ContextInstances for one Context, each with different bindings and behaviors.

Context objects have callbacks that tell them when to activate and drive their animation. By driving the animations centrally, we can force Contexts to animate synchronously, creating awesome transitions with uniform easing curves and speed. This also makes effect code simpler. The Context object also provides the animation direction so that theoretically effects could trigger differently depending on what gesture opens them.

This system also makes it possible for us to behave like Gnome does, where you can swipe down once to do something, then swipe down again and have an app drawer.

The new Action object is like a QAction that supports gestures. The VirtualDeskotpManager registers two Actions to switch desktops, one to switch respecting the 2d nature of the grid, and one to go next/previous. Those two actions can be bound in different contexts; we can switch respecting the grid in the DEFAULT_CONTEXT but also respect how Overview presents the desktops in the overview context. Later, we can create an Action to trigger the clear desktop effect. All this will be completely configurable once the KCM is finished.

Overview of changes:

  • In globalshortcuts.h/cpp all the Context stuff is handled.
  • Slide and desktop fade effect don't capture activeFullscreenEffect anymore.
  • In gesture.h/cpp and globalshortcuts.h/cpp I've merged a lot of enums/structs
  • Changes in gesture.h/cpp from taking a range of finger counts to a list of ints.
  • Adapt Overview, Desktopgrid and WindowView to this system. This included:
    • Making all animations driven by the EffectContext object
    • Closing/Opening the effect only in response to calls from the EffectContext object
    • Routing activation requests to the EffectContext object instead of acting on them directly
    • Using the state() in EffectContext instead of their own status variable
    • Removing touchscreen border activation code because touchscreen borders are now centrally handled
    • activeFullscreenEffect is only captured after an EffectContext is activated() and released immediately after being deactivated()
    • I've moved a lot of stuff into the common base kwinquickeffect.h/cpp from these effects

Specific concerns I have for code review:

  • My personal inadequacy in memory management
  • In reworking the effects to this new system, it's very possible I've broken something

Related to #59 BUG: 454246

Edited by Eric Edlund

Merge request reports