Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Handling key events in Wayland compositor (IviApplication)
Forum Updated to NodeBB v4.3 + New Features

Handling key events in Wayland compositor (IviApplication)

Scheduled Pinned Locked Moved Solved QML and Qt Quick
iviapplication
2 Posts 1 Posters 98 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • HoratioH Offline
    HoratioH Offline
    Horatio
    wrote last edited by
    #1

    I am working on this IviApplication example on Ubuntu 22.04 desktop. I am using Qt5.15.2.
    https://doc.qt.io/qt-6.5/qtwaylandcompositor-ivi-compositor-example.html
    Example source code:
    https://code.qt.io/cgit/qt/qtwayland.git/tree/examples/wayland/ivi-compositor?h=5.15

    I successfully run it. I can see two programs running on the left and right area.

    By adding onFocusChanged and Keys.onReleased signal handlers to the ShellSurfaceItem, I can see the program getting focus when I mouse-click on its area and the program getting key events when I press keyboard.

    My question is how to move focus from one program to another by using keyboard? It is essential on a device without touch screen.
    I tried the WaylandSeat but always got error no matter where I put it. The QML engine cannot create it.

    Thank you for your help.

    1 Reply Last reply
    0
    • HoratioH Offline
      HoratioH Offline
      Horatio
      wrote last edited by Horatio
      #2

      Answering my own question...

      1. Pass WaylandCompositor's property - defaultSeat into C++ as QWaylandSeat*.
        https://doc.qt.io/archives/qt-5.15/qml-qtwayland-compositor-waylandcompositor.html#defaultSeat-prop
      WaylandCompositor
      {
          id: iCompositor
          Component.onCompleted:
          {
              CppHelper.setDefaultWaylandSeat( iCompositor.defaultSeat );
          }
      }
      
      1. Use QWaylandSeat's setKeyboardFocus(), which takes QWaylandSurface*.
        https://doc.qt.io/archives/qt-5.15/qwaylandseat.html#setKeyboardFocus

      2. QWaylandSurface* can be found in the onIviSurfaceCreated() as iviSurface. You can pass it into C++.

      IviApplication 
      {
          onIviSurfaceCreated:
          {
              var surfaceArea = iviSurface.iviId === 1337 ? leftArea : rightArea;
              var item = chromeComponent.createObject(surfaceArea, { "shellSurface": iviSurface } );
              item.handleResized();
              // Pass QWaylandSurface* into C++.
              CppHelper.registerIviSurface( iviSurface );
          }
      }
      
      1. The signal keyboardFocusChanged can be used to observe the change.
        https://doc.qt.io/archives/qt-5.15/qwaylandseat.html#keyboardFocusChanged

      However, setKeyboardFocus() doesn't work very well. I do get the signal keyboard focus changed, but the focus jump back to the original window if I actually press a keyboard key.

      1 Reply Last reply
      0
      • HoratioH Horatio has marked this topic as solved

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved