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

QApplication::topLevelAt() and ::widgetAt() do not honor multi-screen setups

    XMLWordPrintable

Details

    Description

      QApplication::topLevelAt() and ::widgetAt() do not take the screen into consideration. Instead, they always return widgets from the screen with the current mouse cursor. This breaks on setups with multiple touch screens.

      There's also no way to query a widget at coordinates for any given screen without manually moving the mouse cursor into that screen.

      I created the following quick hack for the customer, but it would be nice if this could be fixed in Qt properly, e.g. by adding another parameter: QApplication::topLevelAt(const QPoint&, int screen).

      diff --git a/src/gui/kernel/qapplication_x11.cpp
      b/src/gui/kernel/qapplication_x11.cpp
      index 3664743..bea83d5 100644
      — a/src/gui/kernel/qapplication_x11.cpp
      +++ b/src/gui/kernel/qapplication_x11.cpp
      @@ -2872,13 +2872,8 @@ Window QX11Data::findClientWindow(Window win, Atom
      property, bool leaf)
      return target;
      }

      -QWidget *QApplication::topLevelAt(const QPoint &p)
      +Q_GUI_EXPORT QWidget *x11TopLevelAtScreen(const QPoint &p, int screen)

      { -#ifdef QT_NO_CURSOR - Q_UNUSED(p); - return 0; -#else - int screen = QCursor::x11Screen(); int unused; int x = p.x(); @@ -2931,6 +2926,16 @@ QWidget *QApplication::topLevelAt(const QPoint &p) }

      }
      return w ? w->window() : 0;
      +}
      +
      +QWidget *QApplication::topLevelAt(const QPoint &p)
      +

      { +#ifdef QT_NO_CURSOR + Q_UNUSED(p); + return 0; +#else + int screen = QCursor::x11Screen(); + return x11TopLevelAtScreen(p, screen); #endif }

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            fernenge Harald Fernengel
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes