Bug 286592 - x11/sddm: Plasma Wayland, pressing Alt+Fn switches VT
Summary: x11/sddm: Plasma Wayland, pressing Alt+Fn switches VT
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Some People
Assignee: freebsd-kde (group)
URL:
Keywords:
: 291368 (view as bug list)
Depends on:
Blocks:
 
Reported: 2025-05-05 05:26 UTC by Haowu Ge
Modified: 2026-11-09 18:36 UTC (History)
16 users (show)

See Also:
jhale: maintainer-feedback+


Attachments
Log after CRT+C (2.73 KB, text/plain)
2025-05-05 05:26 UTC, Haowu Ge
no flags Details
add raw kbd mode ioctl (1.00 KB, patch)
2025-10-12 18:44 UTC, Jesper Schmitz Mouridsen
no flags Details | Diff
Try to mimic seatd. (1.04 KB, text/plain)
2025-10-19 09:03 UTC, Jesper Schmitz Mouridsen
no flags Details
same but in git format (1.32 KB, patch)
2025-10-19 09:19 UTC, Jesper Schmitz Mouridsen
jsm: maintainer-approval? (kde)
Details | Diff
v3 (1.39 KB, patch)
2025-10-22 05:57 UTC, Jason E. Hale
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Haowu Ge 2025-05-05 05:26:20 UTC
Created attachment 260162 [details]
Log after CRT+C

My laptop is a ThinkPad X13 with an i5-10210U processor and I'm using the drm-61-kmod-6.1.128.1402000_2 driver. When I log in using Wayland mode, pressing "Ctrl+C" causes the system to automatically return to the SDDM interface. I'm not sure how to provide further debugging information.
Comment 1 Max Brazhnikov freebsd_committer freebsd_triage 2025-05-16 18:47:10 UTC
Upstream bug report: https://bugs.kde.org/479679
Comment 2 Max Brazhnikov freebsd_committer freebsd_triage 2025-05-21 08:22:58 UTC
(In reply to Max Brazhnikov from comment #1)
seems it is unrelated issue. Could you run Plasma from console, rather than from SDDM, and check for ctrl+c?
Comment 3 Cullum Smith 2025-05-21 18:56:22 UTC
The Ctrl+C issue appears to only manifest when starting Plasma from SDDM.

When I start it from the console using the following incantation, Ctrl+C works fine:

ck-launch-session /usr/local/lib/libexec/plasma-dbus-run-session-if-needed startplasma-wayland

But obviously not a very user-friendly solution :-)

I suspect this may have something to do with the fact that SDDM runs X11 at the same time Plasma runs Wayland. Perhaps there is some kind of conflict.

I was unable to get SDDM itself to run using Wayland (I last tried a few months ago).
Comment 4 Max Brazhnikov freebsd_committer freebsd_triage 2025-05-22 19:49:08 UTC
It is definitely some king of interplay between SDDM and Plasma Wayland.
For example, Wayfire is not affected by this. Moreover, the issue is not always reproducible with Plasma: after pressing some random keys Ctrl-C does not trigger session termination.
Comment 5 Haowu Ge 2025-05-23 00:45:55 UTC
(In reply to Cullum Smith from comment #3)

Thank you. 
After using ck-launch-session, Ctrl+C no longer exits.  
there is still an issue: right-clicking on the desktop causes the desktop process to exit (the screen displays black).
Do I need to submit a new bug ticket?
Comment 6 Haowu Ge 2025-05-23 00:51:36 UTC
(In reply to Haowu Ge from comment #5)

plasma_session
Comment 7 bas 2025-06-30 12:37:36 UTC
Just commenting as a kind of "me too". There's a difference between the right-click, which was helped by doing what the upstream bugreport's comments suggest and adding:

CXXFLAGS+= -D_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION=2

..to my /etc/make.conf or the Poudriere equivalent, and then rebuilding graphics/qt6-wayland with this set.

The Ctrl-C issue remains when starting a Wayland session from SDDM, but it's not present when starting from the console the way Cullum Smith's comment here shows.
Comment 8 Max Brazhnikov freebsd_committer freebsd_triage 2025-07-15 10:27:36 UTC
Upstream report: https://bugs.kde.org/505552
Comment 9 devnull freebsd_committer freebsd_triage 2025-08-28 04:39:49 UTC
Closed upstream; and see Peter Wemm's response to <https://mastodon.bsd.cafe/@grahamperrin/114888161580474815>.
Comment 10 Vladlen Popolitov 2025-09-06 11:11:55 UTC
I did all steps from the FreeBSD Handbook from Install up to X11 install and Desktop Environment configuration.
After KDE Plasma install (with SDDM) https://docs.freebsd.org/en/books/handbook/desktop/#kde-start I got the described problem - Ctrl-C exits environment to login screen of SDDM.
I suppose this bug affects all who install FreeBSD and DE according to the Handbook.

If I remove sddm and install lightdm with KDE, this bug does not appear.
I think, it is connected to sddm in same way.

FreeBSD 14.3, amd64, graphics processor Intel.
Comment 11 Paavo-Einari Kaipila 2025-10-10 08:05:58 UTC
(In reply to Vladlen Popolitov from comment #10)

bug #288627
Comment 12 Jesper Schmitz Mouridsen freebsd_committer freebsd_triage 2025-10-12 12:55:54 UTC
It could be related to the VT still taking keyboard inputs e.g ctrl+C even after ioctl(ttyfd,KDSETMODE,KD_GRAPHICS). That does not seem to happen on Linux.
Possible reproducers: I am in console mode tty2/ttyv2 on linux/freebsd.
cat linuxttytest.c 
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <linux/kd.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
int main() {
int fd = open("/dev/tty2",O_RDONLY | O_NOCTTY);
ioctl(fd,KDSETMODE,KD_GRAPHICS);
sleep(10);
ioctl(fd,KDSETMODE,KD_TEXT);
}
cat freebsdttytest.c 
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <sys/consio.h>
#include <fcntl.h>
#include <errno.h>
int main() {
int fd = open("/dev/ttyv2",O_RDONLY | O_NOCTTY);
ioctl(fd,KDSETMODE,KD_GRAPHICS);
sleep(10);
ioctl(fd,KDSETMODE,KD_TEXT);
}
Note that on FreeBSD you can use ctrl+c during the sleep...
Comment 13 Jesper Schmitz Mouridsen freebsd_committer freebsd_triage 2025-10-12 18:44:58 UTC
Created attachment 264502 [details]
add raw kbd mode ioctl

Looking at what Xorg does, this raw kbd mode makes it not impossible to invoke ctrl+c in the tty...
Comment 14 Fabio Comolli 2025-10-12 23:44:30 UTC
(In reply to Jesper Schmitz Mouridsen from comment #13)

Seems to work for me. CTRL+C now does what it's supposed to do and CTRL+Z does not freeze the entire session. Will test more in the next few days.
Comment 15 Dan Kotowski 2025-10-13 17:23:48 UTC
(In reply to Jesper Schmitz Mouridsen from comment #13)

This resolves the issue for me as well
Comment 16 Fabio Comolli 2025-10-15 14:41:26 UTC
(In reply to Fabio Comolli from comment #14)

I just discovered that just typing in a Librewolf page the character " (SHIFT+2 on the Italian keyboard) logs out immediately from a sddm+Wayland session, so I guess this issue is not completely fixed.
Comment 17 Jesper Schmitz Mouridsen freebsd_committer freebsd_triage 2025-10-15 17:25:32 UTC
(In reply to Fabio Comolli from comment #16)
Yeah, I looked again and the key mapping just happens to change so that SHIFT + " gets interpreted as CTRL-C
Comment 18 Wes Frazier 2025-10-18 10:48:22 UTC
As a temporary workaround I have had some success adding "stty intr undef" near the top of the script located at: /usr/local/share/sddm/scripts/wayland-session
Comment 19 Fabio Comolli 2025-10-18 10:55:56 UTC
(In reply to Wes Frazier from comment #18)
Using the standard sddm package or the patched one?
Comment 20 Wes Frazier 2025-10-18 10:57:50 UTC
(In reply to Fabio Comolli from comment #19)
With the standard sddm package.
Comment 21 Fabio Comolli 2025-10-18 11:04:42 UTC
(In reply to Wes Frazier from comment #20)
Ok, this seems to get take care of the CTRL-C issue but CTRL-Z still hangs the whole session with the standard package.
Comment 22 Wes Frazier 2025-10-18 11:27:32 UTC
You are correct. Adding a number of stty lines makes it more robust.

Im now adding:

stty intr undef
stty susp undef                                                                                                                             
stty dsusp undef             
stty quit undef
stty stop undef
stty kill undef

To intercept more control characters. This should cover crtl+z and a few others.
Comment 23 Fabio Comolli 2025-10-18 11:47:14 UTC
(In reply to Wes Frazier from comment #22)
Works for me. I don't know if it's acceptable, though.
Comment 24 Wes Frazier 2025-10-18 11:48:41 UTC
(In reply to Fabio Comolli from comment #23)
Yeah, it's a temporary workaround at best. It's not a propper or elegant solution.
Comment 25 Dan Kotowski 2025-10-19 06:37:20 UTC
(In reply to Wes Frazier from comment #22)

Right, because this is just undefining all the various key-combo interrupts in the root tty; it doesn't actually fix that this tty is still capturing signals that it shouldn't.
Comment 26 Jesper Schmitz Mouridsen freebsd_committer freebsd_triage 2025-10-19 09:03:32 UTC
Created attachment 264712 [details]
Try to mimic seatd.

This is setting the underlying tty in raw mode as per here https://github.com/freebsd/freebsd-src/blob/7d6221ff14478ce70fab24c58e0326ff5c4baf52/lib/libc/gen/termios.c#L159-L160C1. So the key combos would not reach the vt IIUC. Works for me (fingers crossed)

Inspired by the seatd terminal_set_keyboard function
Comment 27 Jesper Schmitz Mouridsen freebsd_committer freebsd_triage 2025-10-19 09:19:48 UTC
Created attachment 264713 [details]
same but in git format
Comment 28 Fabio Comolli 2025-10-19 09:22:37 UTC
(In reply to Jesper Schmitz Mouridsen from comment #27)

Unfortunately since I went back to 14.3 I'm unable to compile sddm from ports (not relatred to the patch); as such, I'm unable to test this fix.
Comment 29 Wes Frazier 2025-10-20 11:36:44 UTC
Patch seems to have done the trick for me. I dropped it into /usr/ports/x11/sddm/files and rebuilt sddm via ports and is working flawlessly for me now. I tested Crtl+C, Crtl+Z, and SHIFT+". (And I did make sure my changes to /usr/local/share/sddm/scripts/wayland-session had reverted. )
Comment 30 Fabio Comolli 2025-10-20 12:59:01 UTC
Works for me too. (In case anyone may be interested, to compile from ports when using pkgbase you need not only FreeBSD-clang but also FreeBSD-clang-dev).
Comment 31 Dan Kotowski 2025-10-21 07:34:59 UTC
Unfortunately I'm still seeing the same behavior, but with different key combos. Ctrl-C no longer breaks things, but now other things do, like Shift-@.
Comment 32 Fabio Comolli 2025-10-21 08:20:41 UTC
(In reply to Dan Kotowski from comment #31)
Cannot reproduce it with Italian keyboard - @ and shift-@ (which translates to ΒΈ) work just fine as you can see from this comment.
Comment 33 Wes Frazier 2025-10-21 12:14:27 UTC
(In reply to Dan Kotowski from comment #31)
Cannot reproduce the Shift+@ behavior with this last patch.

Keyboard locale information from my system:

lang_default = en
dialect = C.UTF-8
lang_abk = C.UTF-8
Currently supported languages: da de el en es fr he hy no pl pt ru sv tr uk
Comment 34 Dan Kotowski 2025-10-21 12:30:52 UTC
$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_ALL=

Keyboard is set to Generic 104
Comment 35 Fabio Comolli 2025-10-21 13:43:13 UTC
(In reply to Dan Kotowski from comment #34)
Cannot reproduce it, sorry. Keyboard is now set to English-US - Generic 104 and I can reliably hit @, which by the way is now SHIFT-2.

[15:40][fmc000@tu45b-freebsd ~]$ env|grep LC
LC_ALL=
LC_MESSAGES=en_US.UTF-8
LC_MONETARY=en_US.UTF-8
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8
LC_COLLATE=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
[15:42][fmc000@tu45b-freebsd ~]$
Comment 36 Dan Kotowski 2025-10-21 20:58:51 UTC
After some poking and prodding with jsm, we found the last issue on my end was user error, as I needed to run an explicit `pkg upgrade -f sddm` after rebuilding.

The latest patch does sufficiently fix Ctrl-C, -Z, and Shift-2.
Comment 37 Jason E. Hale freebsd_committer freebsd_triage 2025-10-22 05:57:39 UTC
Created attachment 264776 [details]
v3

Iteration upon https://bugs.freebsd.org/bugzilla/attachment.cgi?id=264713&action=edit.

Align whitespace, block for FreeBSD, and make more robust (fail on non-zero returns, use qFatal() before attempting next block.
Comment 38 Fabio Comolli 2025-10-22 16:49:05 UTC
(In reply to Jason E. Hale from comment #37)

FWIW, v3 works fine here. Tested with both Italian and English (US) layout: CTRL-C, CTRL-Z, " and @.
Comment 39 commit-hook freebsd_committer freebsd_triage 2025-10-24 11:47:08 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=b7d53d8438e66f84768f28cbccc92a04d5df76b8

commit b7d53d8438e66f84768f28cbccc92a04d5df76b8
Author:     Max Brazhnikov <makc@FreeBSD.org>
AuthorDate: 2025-10-24 11:45:43 +0000
Commit:     Max Brazhnikov <makc@FreeBSD.org>
CommitDate: 2025-10-24 11:45:57 +0000

    x11/sddm: add workaround for Wayland sessions.

    Mimic seatd and put the underlying tty in raw mode
    to prevent killing Wayland sessions on CTRL+C.

    Upstream reports:
    KDE:            https://bugs.kde.org/505552
    SDDM:           https://github.com/sddm/sddm/issues/1986

    PR:             286592
    Submitted by:   jsm, jhale

 x11/sddm/Makefile                                  |  2 +-
 .../patch-src_common_VirtualTerminal.cpp (new)     | 30 ++++++++++++++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)
Comment 40 commit-hook freebsd_committer freebsd_triage 2025-10-24 11:48:14 UTC
A commit in branch 2025Q4 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=538fd5a82f20a383e9220eb0c2b798f4d50e1cef

commit 538fd5a82f20a383e9220eb0c2b798f4d50e1cef
Author:     Max Brazhnikov <makc@FreeBSD.org>
AuthorDate: 2025-10-24 11:45:43 +0000
Commit:     Max Brazhnikov <makc@FreeBSD.org>
CommitDate: 2025-10-24 11:47:02 +0000

    x11/sddm: add workaround for Wayland sessions.

    Mimic seatd and put the underlying tty in raw mode
    to prevent killing Wayland sessions on CTRL+C.

    Upstream reports:
    KDE:            https://bugs.kde.org/505552
    SDDM:           https://github.com/sddm/sddm/issues/1986

    PR:             286592
    Submitted by:   jsm, jhale

    (cherry picked from commit b7d53d8438e66f84768f28cbccc92a04d5df76b8)

 x11/sddm/Makefile                                  |  2 +-
 .../patch-src_common_VirtualTerminal.cpp (new)     | 30 ++++++++++++++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)
Comment 41 Max Brazhnikov freebsd_committer freebsd_triage 2025-10-24 11:54:30 UTC
Thanks all for testing. jsm@, jhale@ thank you for the patches!
Comment 42 Max Brazhnikov freebsd_committer freebsd_triage 2025-11-16 14:29:45 UTC
Reopen, there's still a problem. When Plasma Wayland is launched via patched sddm, pressing alt+Fx, for example alt+F2, switches to the corresponding VT instead of opening Krunner.

Moreover, the screen is actually not repainted after the first alt+Fx and you do not see text terminal, but "frozen" Plasma instead. You have to switch to another vt to get visible prompt. Pressing alt+F10 brings you to the Plasma, and you also see  that Plasma has caught you first "alt+F2" and opened Krunner for you.

When Plasma is started from the terminal, it works as expected: ctlr+alt+Fx switches from Plasma to vt without any problem.
Comment 43 Dan Kotowski 2025-11-17 12:33:32 UTC
(In reply to Max Brazhnikov from comment #42)

I DO NOT experience the Alt-Fx vt-switch bug as described in 1st.

I DO experience the the Alt-Fx redraw bug as described in 2nd.
Comment 44 Max Brazhnikov freebsd_committer freebsd_triage 2025-11-17 18:12:19 UTC
(In reply to Dan Kotowski from comment #43)

> I DO NOT experience the Alt-Fx vt-switch bug as described in 1st.

How do you start Plasma? From display manager or from VT?
Comment 45 Dan Kotowski 2025-11-17 18:18:01 UTC
(In reply to Max Brazhnikov from comment #44)

From SDDM login screen
Comment 46 devnull freebsd_committer freebsd_triage 2025-12-03 22:04:01 UTC
(In reply to Max Brazhnikov from comment #42)

Bug 291368
Comment 47 Max Brazhnikov freebsd_committer freebsd_triage 2025-12-11 19:00:41 UTC
*** Bug 291368 has been marked as a duplicate of this bug. ***
Comment 48 Gleb Popov freebsd_committer freebsd_triage 2026-03-19 08:21:14 UTC
Haven't this been fixed already?
Comment 49 Max Brazhnikov freebsd_committer freebsd_triage 2026-03-19 10:20:08 UTC
(In reply to Gleb Popov from comment #48)
Haven't this been fixed already?
> Haven't this been fixed already?
The Ctrl+C bug is fixed (you have fixed it :), the other bug is still there, see my comment https://bugs.freebsd.org/286592#c42
Comment 50 Jesper Schmitz Mouridsen freebsd_committer freebsd_triage 2026-08-02 21:28:54 UTC
(In reply to Max Brazhnikov from comment #49)
Combining the seatd mimic which is solving the ctrl+c issue with my original non fix with KDSKBMODE K_RAW seems to fix this

like this 
(also add #include <sys/kbio.h> to  src/common/VirtualTerminal.cpp
#ifdef __FreeBSD__
                struct termios tios;

                if (tcgetattr(fd, &tios) != 0) {
                    qFatal("Failed to get term attrs for VT %d: %s", vt, strerror(errno));
                } else {
                cfmakeraw(&tios);
                    if (tcsetattr(fd, TCSAFLUSH, &tios) != 0) {
                        qWarning("Failed to set term attrs for VT %d: %s", vt, strerror(errno));
                    }
                }
                        ioctl(fd,KDSKBMODE,K_RAW); 
#endif


lso
Comment 51 commit-hook freebsd_committer freebsd_triage 2026-08-03 16:44:56 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=c8a6d8ae8a39e609c4a919a6fff36da660b6a66b

commit c8a6d8ae8a39e609c4a919a6fff36da660b6a66b
Author:     Gleb Popov <arrowd@FreeBSD.org>
AuthorDate: 2026-08-03 16:41:25 +0000
Commit:     Gleb Popov <arrowd@FreeBSD.org>
CommitDate: 2026-08-03 16:43:26 +0000

    x11/sddm: Wayland session fixes

    PR:             286592, 296052

 x11/sddm/Makefile                                  |  2 +-
 .../files/patch-src_common_VirtualTerminal.cpp     | 20 ------
 .../files/patch-src_helper_UserSession.cpp (new)   | 84 ++++++++++++++++++++++
 3 files changed, 85 insertions(+), 21 deletions(-)
Comment 52 Cullum Smith 2026-08-25 13:28:00 UTC
I was excited to try this new fix, and it does work for me. However, the KDE screenlocker now appears broken under SDDM Wayland. "Screen locker has broken and unlocking is not possible anymore."

Aug 25 09:21:11 desktop1 kernel: pid 89644 (kscreenlocker_greet), jid 0, uid 10000: exited on signal 11 (no core dump - denied by kern.coredump)

Works fine with Wayland + Ly
Comment 53 Gleb Popov freebsd_committer freebsd_triage 2026-08-25 13:41:11 UTC
(In reply to Cullum Smith from comment #52)
How do I reproduce it? Is Meta+L enough to trigger this?
Comment 54 Cullum Smith 2026-08-25 13:42:38 UTC
It is for me. The screen locks, but as soon as press a button or move my mouse, kscreenlocker_greet segfaults
Comment 55 Cullum Smith 2026-08-25 13:55:32 UTC
Sorry, please disregard. kscreenlocker is also crashing under ly as well.

Must be due to a recent ports update...I just happened to upgrade at the same time I installed sddm.
Comment 56 Gleb Popov freebsd_committer freebsd_triage 2026-10-06 19:29:45 UTC
I guess I managed to reproduce the crash and obtained the backtrace:

#0  0x00000008004949ab in LayerShellQt::QWaylandLayerSurface::requestActivate() () at /usr/local/lib/libLayerShellQtInterface.so.6
#1  0x000000080378ac12 in QObject::event(QEvent*) () at /usr/local/lib/qt6/libQt6Core.so.6
#2  0x0000000802d45778 in QGuiApplication::event(QEvent*) () at /usr/local/lib/qt6/libQt6Gui.so.6
#3  0x00000008037376e8 in QCoreApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/local/lib/qt6/libQt6Core.so.6
#4  0x0000000803738612 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () at /usr/local/lib/qt6/libQt6Core.so.6
#5  0x00000008039fcffc in ??? () at /usr/local/lib/qt6/libQt6Core.so.6
#6  0x00000008052f3f85 in ??? () at /usr/local/lib/libglib-2.0.so.0
#7  0x00000008052f4416 in ??? () at /usr/local/lib/libglib-2.0.so.0
#8  0x00000008052f44b6 in g_main_context_iteration () at /usr/local/lib/libglib-2.0.so.0
#9  0x00000008039fca15 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/local/lib/qt6/libQt6Core.so.6
#10 0x0000000803741c06 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/local/lib/qt6/libQt6Core.so.6
#11 0x000000080373799f in QCoreApplication::exec() () at /usr/local/lib/qt6/libQt6Core.so.6
#12 0x000000000022608c in ??? ()
#13 0x0000000803bf51ff in __libc_start1 (argc=1, argv=0x7fffffffe260, env=0x7fffffffe270, cleanup=<optimized out>, mainX=0x225040) at /usr/src/lib/libc/csu/libc_start1.c:180
#14 0x0000000000216534 in ??? ()

I will debug this issue a bit later, unless someone beats me to it.
Comment 57 Gleb Popov freebsd_committer freebsd_triage 2026-11-09 18:36:26 UTC
It stopped crashing for me. Probably this was due layer-shell-qt not bumped after the Qt update or something like that.