Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-135843

QVulkanWindow does not receive key press events under Wayland

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.8.3, 6.9.0
    • QPA: Wayland
    • None
    • Debian 12.0
      KDE Plasma 5.27.5
      GPU: AMD Ryzen 7 PRO 4750U with Radeon Graphics (16)
    • Linux/Wayland

    Description

      This bug breaks the unmodified hellovulkancubes example under Wayland, preventing the user from moving around using Shift+WASD. The example handles key press events using QVulkanWindow::keyPressEvent to move around the scene:

       

      // Examples/Qt-6.9.0/vulkan/hellovulkancubes/vulkanwindow.cpp
      
      void VulkanWindow::keyPressEvent(QKeyEvent *e)
      {
          const float amount = e->modifiers().testFlag(Qt::ShiftModifier) ? 1.0f : 0.1f;
          switch (e->key()) {
          case Qt::Key_W:
              m_renderer->walk(amount);
              break;
          case Qt::Key_S:
              m_renderer->walk(-amount);
              break;
          case Qt::Key_A:
              m_renderer->strafe(-amount);
              break;
          case Qt::Key_D:
              m_renderer->strafe(amount);
              break;
          default:
              break;
          }
      } 

       

       

      This method never gets called under Wayland, meaning the user cannot move around. It does work as expected under X11, so this issue seems to be Wayland-specific. Mouse events work as expected under both X11 and Wayland.

      Exploration shows that under Wayland key events get delivered to the parent MainWindow instead of to VulkanWindow. This issue might be related to focus handling. It is possible to implement a workaround for the hellovulkancubes example by listening for key press events on MainWindow instead of on QVulkanWindow, although that would not fix the underlying issue.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.graphics.and.multimedia Qt Graphics Team
            jmuller Jeroen Muller
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes