https://bugs.kde.org/show_bug.cgi?id=523649

            Bug ID: 523649
           Summary: When a key is held down and an interactive window move
                    or resize operation is started, releasing the key
                    before finishing the move/resize causes keyboard
                    auto-repeat to continue indefinitely.  The repeat
                    stops immediately after pressing and releasing any
    Classification: Plasma
           Product: kwin
      Version First 6.7.3
       Reported In:
          Platform: EndeavourOS
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

## title
Keyboard auto-repeat does not stop after releasing a key during interactive
window move/resize

## Summary
When a key is held down and an interactive window move or resize operation is
started, releasing the key before finishing the move/resize causes keyboard
auto-repeat to continue indefinitely.

The repeat stops immediately after pressing and releasing any key once.

The issue is reproducible in both Qt and GLFW applications, suggesting it is
not toolkit-specific.


## Steps to Reproduce
1. Run the attached minimal Qt application.
2. Focus the application window.
3. Press and hold the A key.
4. While still holding the key, start moving (or resizing) the window using the
mouse.
5. Release the A key before finishing the move/resize operation.
6. Finish the move/resize.

## Actual Result
Keyboard auto-repeat continues indefinitely even though the key has already
been released.
The application keeps receiving repeated key events forever until another
keyboard key is pressed and released

## Expected Result
Auto-repeat should stop immediately after the physical key is released.

Running the Qt application with
```shell
QT_QPA_PLATFORM=xcb python test.py
```
still reproduces the issue.

The issue is reproducible with:
- PyQt application
- Native GLFW/OpenGL application

The issue happens with:
- Wayland session
- XWayland (QT_QPA_PLATFORM=xcb)

The issue is triggered by:
- Interactive window move
- Interactive window resize

## Event Observation

Using Qt event logging:
```python
def keyPressEvent(self, event):
    print(
        "PRESS",
        event.key(),
        event.text(),
        event.isAutoRepeat(),
        event.nativeScanCode(),
        event.nativeVirtualKey()
    )

def keyReleaseEvent(self, event):
    print(
        "RELEASE",
        event.key(),
        event.text(),
        event.isAutoRepeat(),
        event.nativeScanCode(),
        event.nativeVirtualKey()
    )
```
After the physical key has already been released, the application continues to
receive events such as:
```
PRESS 65 a True
RELEASE 65 a True
PRESS 65 a True
RELEASE 65 a True
PRESS 65 a True
RELEASE 65 a True
...
```
This continues indefinitely.

Pressing and releasing any key once immediately stops the repeated events.

## Additional Reproducer (GLFW/OpenGL)

The issue is also reproducible in a minimal GLFW/OpenGL application.
The application continuously checks the keyboard state using glfwGetKey():
```c
#include <GLFW/glfw3.h>
#include <stdio.h>

void process_input(GLFWwindow *window)
{
    int pressed = glfwGetKey(window, GLFW_KEY_R) == GLFW_PRESS;

    printf("GLFW KEY R = %d\n", pressed);
}

int main(void)
{
    if (!glfwInit())
        return -1;

    GLFWwindow *window = glfwCreateWindow(
        800,
        600,
        "GLFW Keyboard Test",
        NULL,
        NULL
    );

    if (!window)
    {
        glfwTerminate();
        return -1;
    }

    glfwMakeContextCurrent(window);

    while (!glfwWindowShouldClose(window))
    {
        glfwPollEvents();

        process_input(window);

        glfwSwapBuffers(window);
    }

    glfwTerminate();

    return 0;
}
```

1. Run the GLFW application.
2. Hold the R key.
3. Start interactive move or resize of the window.
4. Release the R key while the move/resize operation is still active.
5. Finish the move/resize.

Expected:
```
GLFW KEY R = 0
```
after releasing the key.

Actual:
```
GLFW KEY R = 1
```
continues indefinitely until another keyboard event occurs.

## Additional Information
XDG_SESSION_TYPE = wayland
$XDG_CURRENT_DESKTOP = KDE
$WAYLAND_DISPLAY = wayland-0
qt6-base 6.11.1-1
qt6-wayland 6.11.1-1
plasmashell 6.7.3
kwin 6.7.3

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to