Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QGuiApplication::focusWindow() always return null in wayland platform
Forum Updated to NodeBB v4.3 + New Features

QGuiApplication::focusWindow() always return null in wayland platform

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 826 Views 2 Watching
  • 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.
  • T Offline
    T Offline
    Trung Nguyen Hoang
    wrote on last edited by Trung Nguyen Hoang
    #1

    Hi everyone,

    I'm executing the Qt auto test (v 5.15.2) on a Linux platform that uses Wayland, Weston compositor, and Weston ivi-shell.
    And when executing any test suite that active a windows, they are all failed.
    Example for qt5/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem2 test suite,
    when I run: ./tst_qquickitem2 -platform wayland, I receive the log as below:

    Loc: [tst_qquickitem.cpp(483)]
    QWARN  : tst_QQuickItem::activeFocusOnTab3() qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
    QWARN  : tst_QQuickItem::activeFocusOnTab3() qWaitForWindowActive was called on a platform that doesn't support window activation. This means there is an error in the test and it should either check for the WindowActivation platform capability before calling qWaitForWindowActivate, use qWaitForWindowExposed instead, or skip the test. Falling back to qWaitForWindowExposed.
    FAIL!  : tst_QQuickItem::activeFocusOnTab3() Compared pointers are not the same
      Loc: [tst_qquickitem.cpp(523)
    

    More information:
    I checked the test suite source code and added some debug there, then I recognized that the function QGuiApplication::focusWindow() always returns null, which leads to the test case failing.
    I also tried to build with xcb and execute the test suite in the X11 environment, then everything is OK.

    I also tried to google but cannot find any useful information to solve it.
    Can anyone give me some hints?

    Thanks,

    1 Reply Last reply
    1
    • T Offline
      T Offline
      Trung Nguyen Hoang
      wrote on last edited by
      #2

      I found something, just want to post it here so that it can help someone.

      The warnings in my post are not the root cause of the issue.

      I got the error "Compared pointers are not the same" due to the "input focus" is not set in the surfaces created by the test suite.
      If I modify the test case to wail for a few seconds and then use LayerManagerControl to set the input focus, I see the test cases are passed.
      Command: "LayerManagerControl set surfaces [surfaced] input focus all"

      1 Reply Last reply
      1
      • G Offline
        G Offline
        Ggwp1234
        wrote on last edited by
        #3

        I have the same problem with Qt QApplication::focusWindow() and QApplication::focusWindowChanged signal. Regardless of the platform (Linux X11, Wayland) QApplication::focusWindow() is always nullptr because of this I should use X11 and Wayland native libraries. I didnt find any solve for this problem.
        That is my simple code, may be it support find and solve the bug/problem.Screenshot from 2023-08-23 21-16-30.png Screenshot from 2023-08-23 21-17-07.png Screenshot from 2023-08-23 21-17-42.png Screenshot from 2023-08-23 21-18-12.png

        M 1 Reply Last reply
        0
        • G Ggwp1234

          I have the same problem with Qt QApplication::focusWindow() and QApplication::focusWindowChanged signal. Regardless of the platform (Linux X11, Wayland) QApplication::focusWindow() is always nullptr because of this I should use X11 and Wayland native libraries. I didnt find any solve for this problem.
          That is my simple code, may be it support find and solve the bug/problem.Screenshot from 2023-08-23 21-16-30.png Screenshot from 2023-08-23 21-17-07.png Screenshot from 2023-08-23 21-17-42.png Screenshot from 2023-08-23 21-18-12.png

          M Offline
          M Offline
          mpergand
          wrote on last edited by mpergand
          #4

          @Ggwp1234
          I think you should show a window in the first place,
          or maybe you mean to use applicationStateChanged signal ?

          1 Reply Last reply
          0

          • Login

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