Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editing the Kanban board doesn't work on wayland #617

Open
zjeffer opened this issue Jul 28, 2023 · 18 comments
Open

Editing the Kanban board doesn't work on wayland #617

zjeffer opened this issue Jul 28, 2023 · 18 comments

Comments

@zjeffer
Copy link
Collaborator

zjeffer commented Jul 28, 2023

But it does work with XWayland (running notes with --platform xcb)

@nuttyartist
Copy link
Owner

Why?

@zjeffer
Copy link
Collaborator Author

zjeffer commented Jul 29, 2023

No idea. Doubleclicking the text selects it but typing doesn't edit it. The checkboxes work fine.

@nuttyartist
Copy link
Owner

Any error? Just editing the text doesn't work or anything else? Everything shows up normally tho (could you share a screenshot)?

@zjeffer
Copy link
Collaborator Author

zjeffer commented Jul 29, 2023

No errors in the terminal. Here's a video:

2023-07-29.11-14-13.mp4

@nuttyartist
Copy link
Owner

nuttyartist commented Jul 29, 2023

That's odd! Do you think you can run a simeple QML test with just TextArea {} and TextField {} Qt Quick componenets to see if it's an upstream issue with Qt and Wayland?

@guihkx
Copy link
Collaborator

guihkx commented Feb 9, 2024

Revisiting this, and it's still reproducible with Qt 6.6.1 on Wayland (KDE Plasma 5.27).

Do you think you can run a simeple QML test with just TextArea {} and TextField {} Qt Quick componenets to see if it's an upstream issue with Qt and Wayland?

Is this a good example?

// test.qml
import QtQuick 2.12
import QtQuick.Controls 2.12

Rectangle {
    width: 300
    height: 100
    Text {
        id: taskTextNonEditable
        width: 300
        text: "Double click here to edit me!"
        font.pointSize: 15
        textFormat: TextEdit.MarkdownText
        wrapMode: Text.Wrap

        MouseArea {
            anchors.fill: parent

            onDoubleClicked: {
                taskTextNonEditable.visible = false;
                taskTextEdit.visible = true;
                taskTextEdit.cursorPosition = taskTextEdit.length;
                taskTextEdit.forceActiveFocus();
                taskTextEdit.focus = true;
            }
        }
    }
    TextArea {
        id: taskTextEdit
        width: 300
        text: taskTextNonEditable.text
        font.pointSize: 15
        textFormat: TextEdit.PlainText
        wrapMode: Text.Wrap
        visible: false
        background: Rectangle {
            radius: 5
            color: "#efefef"
        }
    }
}

If I run that with qml6 test.qml, I'm able to edit the text inside the textarea on Wayland:

qml-test-wayland.mp4

@nuttyartist
Copy link
Owner

Yes, that should do. Can you try importing this as well?

import QtQuick.Controls.Universal 2.12

@guihkx
Copy link
Collaborator

guihkx commented Feb 9, 2024

Same result: Editing the text works.

@nuttyartist
Copy link
Owner

What about: import QtQuick.Controls.Material 2.12?

@guihkx
Copy link
Collaborator

guihkx commented Feb 9, 2024

That one made things a bit more weird while editing the text, but it still works (in the video below I first edit without the import, and then after that I edit with the import):

qml-test-wayland-2.mp4

@nuttyartist
Copy link
Owner

nuttyartist commented Feb 9, 2024

Hmm. still works. Very odd! This is the code of CustomTextArea (https://github.com/nuttyartist/notes/blob/master/src/qml/CustomTextArea.qml) in one file for convenience. Can you try it:

EDIT: Changed import versions.

import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Controls.Universal 2.12

Window {
    id: rootWindow
    visible: true
    width: 640
    height: 480
    title: qsTr("Test")


    TextArea {
        id: root
        textFormat: TextEdit.PlainText
        wrapMode: Text.Wrap
        background: Rectangle {
            radius: 5
            color: root.themeData.theme === "Dark" ? "#313131" : "#efefef"
        }
        width: parent.width
        height: parent.height

        property var themeData
        property string accentColor
        property bool cursorAnimationRunning: true
        signal anyKeyPressed
        signal cursorHidden
        signal cursorShowed
        signal returnPressed
        property bool isHoldingShift: false

        Keys.onPressed: (event) => {
            if (event.key === Qt.Key_Shift) {
              isHoldingShift = true;
            }

            root.anyKeyPressed();
            root.cursorAnimationRunning = false;
        }

        Keys.onReleased: (event) => {
             if (event.key === Qt.Key_Shift) {
               isHoldingShift = false;
             }
            root.cursorAnimationRunning = true;
        }

        onPressed: {
            root.cursorShowed();
        }

        Keys.onReturnPressed: {
            returnPressed();
        }

        cursorDelegate: Rectangle {
            id: cursorDelegateObject
            visible: true
            color: root.accentColor
            width: 2

            Connections {
                target: root

                function onAnyKeyPressed () {
                    cursorDelegateObject.visible = true;
                }

                function onCursorHidden () {
                    cursorDelegateObject.visible = false;
                }

                function onCursorShowed () {
                    cursorDelegateObject.visible = true;
                }
            }

            SequentialAnimation {
                loops: Animation.Infinite
                running: root.cursorAnimationRunning

                PropertyAction {
                    target: cursorDelegateObject
                    property: 'visible'
                    value: true
                }

                PauseAnimation {
                    duration: 500
                }

                PropertyAction {
                    target: cursorDelegateObject
                    property: 'visible'
                    value: false
                }

                PauseAnimation {
                    duration: 500
                }
            }
        }
    }
}

@guihkx
Copy link
Collaborator

guihkx commented Feb 9, 2024

Typing still works:

qml-test-wayland-3.mp4

@nuttyartist
Copy link
Owner

Then, it's not immediately clear why on Wayland editing doesn't work in the Kanban. Needs deeper inspection.

@guihkx
Copy link
Collaborator

guihkx commented May 22, 2024

Revisiting as of Qt 6.7.1, and the issue is still present only on Wayland, unfortunately.

@nuttyartist
Copy link
Owner

nuttyartist commented May 22, 2024

That's very annoying. What distro has built-in Wayland that I can spin up to test this?

EDIT: Or can i just use my current PopOS machine? (Don't know much about Wayland)

@guihkx
Copy link
Collaborator

guihkx commented May 22, 2024

The latest version of Fedora is a probably a good choice, I think.

@nuttyartist Though you can probably use Wayland with Pop!_OS too: Logout from the current session and choose "GNOME" (and not "GNOME (Legacy)" or "GNOME (X11)" or whatever they call it) from the login manager screen.

@nuttyartist
Copy link
Owner

I believe this has something to do with the use of QWindowContainer (i.e. spawning a QML app inside a QWidget application). I just noticed that Daino Notes doesn't work in Wayland (unless used with the flag @zjeffer mentioned). But I checked a minimal example with a QML inside QWidget via QWindowContainer and a regular QML app and the regular worked without issues. I'll try to file a bug report.

@guihkx
Copy link
Collaborator

guihkx commented Oct 4, 2024

If you do, please share the link to the bug report with us too. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants