Skip to content

Commit

Permalink
KDE Plasma Wayland: improve Wayland experience
Browse files Browse the repository at this point in the history
- Backport an upstream fix for focus-follows-mouse (focus-changing
  by moving the mouse slowwwwwly didn't work), thanks upstream.
- Simplify startplasma-wayland.sh script down to little more than
  documentation comments and ck-launch dbus-launch, thanks jbeich@
  • Loading branch information
Adriaan de Groot authored and Adriaan de Groot committed May 3, 2021
1 parent 7d49bd2 commit 2a92ce4
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 19 deletions.
2 changes: 1 addition & 1 deletion x11-wm/plasma5-kwin/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PORTNAME= kwin
DISTVERSION= ${KDE_PLASMA_VERSION}
PORTREVISION= 4
PORTREVISION= 5
CATEGORIES= x11-wm kde kde-plasma

MAINTAINER= kde@FreeBSD.org
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
commit 425170b7814c1ff27b165982b93d78422621bddb (origin/work/wayland-fix-focus-follows-mouse)
Author: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
Date: Mon May 3 11:24:22 2021 +0300

wayland: Fix focus follows mouse policy

We want to update the input focus only if the pointer is moved. Due to
that, AbstractClient::enterEvent() checks the last seen pointer position
to decide whether the window needs to be focused.

The issue is that when the pointer moves from a decoration to a surface,
the cached pointer position will be updated to the current pointer
position, and thus the check in AbstractClient::enterEvent() will fail.

We need to update the cached pointer position only if there is a focused
decoration.

diff --git src/input.cpp src/input.cpp
index 9377e9334..b1b961e39 100644
--- input.cpp
+++ input.cpp
@@ -2846,6 +2846,7 @@ void InputDeviceHandler::update()
setAt(toplevel);

if (focusUpdatesBlocked()) {
+ workspace()->updateFocusMousePosition(position().toPoint());
return;
}

@@ -2860,21 +2861,20 @@ void InputDeviceHandler::update()
// went onto or off from decoration, update focus
updateFocus();
}
- return;
- }
- updateInternalWindow(nullptr);
+ } else {
+ updateInternalWindow(nullptr);

- if (m_focus.focus != m_at.at) {
- // focus change
- updateDecoration();
- updateFocus();
- return;
- }
- // check if switched to/from decoration while staying on the same Toplevel
- if (updateDecoration()) {
- // went onto or off from decoration, update focus
- updateFocus();
+ if (m_focus.focus != m_at.at) {
+ // focus change
+ updateDecoration();
+ updateFocus();
+ } else if (updateDecoration()) {
+ // went onto or off from decoration, update focus
+ updateFocus();
+ }
}
+
+ workspace()->updateFocusMousePosition(position().toPoint());
}

Toplevel *InputDeviceHandler::at() const
diff --git src/pointer_input.cpp src/pointer_input.cpp
index bf59197d3..a93c2cf55 100644
--- pointer_input.cpp
+++ pointer_input.cpp
@@ -473,7 +473,6 @@ void PointerInputRedirection::cleanupDecoration(Decoration::DecoratedClientImpl
{
disconnect(m_decorationGeometryConnection);
m_decorationGeometryConnection = QMetaObject::Connection();
- workspace()->updateFocusMousePosition(position().toPoint());

if (old) {
// send leave event to old decoration
@@ -524,7 +523,6 @@ void PointerInputRedirection::focusUpdate(Toplevel *focusOld, Toplevel *focusNow

if (AbstractClient *ac = qobject_cast<AbstractClient*>(focusNow)) {
ac->enterEvent(m_pos.toPoint());
- workspace()->updateFocusMousePosition(m_pos.toPoint());
}

if (internalWindow()) {
2 changes: 1 addition & 1 deletion x11/plasma5-plasma-workspace/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PORTNAME= plasma-workspace
DISTVERSION= ${KDE_PLASMA_VERSION}
PORTREVISION= 2
PORTREVISION= 3
CATEGORIES= x11 kde kde-plasma

MAINTAINER= kde@FreeBSD.org
Expand Down
39 changes: 22 additions & 17 deletions x11/plasma5-plasma-workspace/files/startplasma-wayland.sh
Original file line number Diff line number Diff line change
@@ -1,44 +1,49 @@
#! /bin/sh
#
# Try to run a Plasma Wayland session; to be invoked from a text console
# Try to run a Plasma Wayland session; to be invoked from a text console.
# This script is far longer than it needs to be, because it documents
# all kinds of settings that you **might** want to set for specific
# use-cases or testing.

### TOOLKIT SETTINGS
#
# Tell toolkits to use wayland
export MOZ_ENABLE_WAYLAND=1
export GDK_BACKEND=wayland
export QT_QPA_PLATFORM=wayland-egl
export QT_WAYLAND_DISABLE_WINDOWDECORATION=1
# Force toolkits to use wayland.
# - MOZ is for Firefox
# - GDK is for GDK, will crash non-Wayland GDK-users like emacs
# - QPA is for Qt, forces EGL, causes graphics glitches
# export MOZ_ENABLE_WAYLAND=1
# export GDK_BACKEND=wayland
# export QT_QPA_PLATFORM=wayland-egl

# Possible settings for drivers
### DRIVER SETTINGS
#
# Some (older) Intel HD iGPU need this:
# export LIBVA_DRIVER_NAME=i965

### XDG SETTINGS
#
#
if test -z "$XDG_RUNTIME_DIR"; then
export XDG_RUNTIME_DIR=/tmp/`id -u`-runtime-dir
if ! test -d "$XDG_RUNTIME_DIR"; then
mkdir "$XDG_RUNTIME_DIR"
chmod 0700 "$XDG_RUNTIME_DIR"
fi
fi
export XDG_SESSION_TYPE=wayland
# export XDG_SESSION_TYPE=wayland

### KDE / Plasma / Qt settings
### KDE / Plasma / Qt SETTINGS
#
#
# To switch on software rendering:
# export KWIN_COMPOSE=Q
# Disable client-side-decorations:
# export QT_WAYLAND_DISABLE_WINDOWDECORATION=1
# To log debug things:
# export QT_LOGGING_RULES="kwin_core.debug=true;kwin_libinput.debug=true"
# To log to a specific file (recommended if you're using the logging rules
# and want to debug startup problems):
# LOGFILE=/tmp/plasma-wayland.log

# TODO: check if ck-launch-session is needed
### STARTUP SEQUENCE
#
# Plasma needs a DBus session-bus, and it needs to have access to
# the DRM GPU (e.g. to /dev/dri/card0) which we arrange through
# ConsoleKit2.
#
scaffolding="ck-launch-session"
if [ -z "$DBUS_SESSION_BUS_ADDRESS" ] ; then
scaffolding="$scaffolding dbus-run-session"
Expand Down

0 comments on commit 2a92ce4

Please sign in to comment.