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

Clarify functionality of QWindow::fromWinId() on the various platforms

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.4.0 Alpha
    • GUI: Window management
    • All

    Description

      People apparently have various expectations what QWindow::fromWinId() does. The original commit https://codereview.qt-project.org/#/c/42990/ added it as a means of handling XEmbed, that is, the resulting QWindow is just a wrapper around a foreign window on which QWindow's could be parented. For this use case, it is unexpected that for example QWindow::setGeometry(), setWindowFlags() have an impact on it.

      Other use cases from the related reports:

      • Wrap around a foreign window and access its properties using fex QWindow::geometry().etc. This does not work as the values are not synced at construction time (should they ? - using events?)
      • Should it be possible to wrap foreign child windows (see QTBUG-43252 ) and what should be the behavior wrt geometry, maptoGlobal - currently ForeignWindow = 0x00000020 | Window implies that it is toplevel only.
      • Fully control the window, retrieve events, etc.
      • Conceivably, it could also be used to fix/work around QTBUG-33079

      OS X notes:
      We want to support two use cases:

      • Embed a QWindow in a foreign NSView hierarchy. This should be done by retrieving the internal NSView pointer via QWindow::winId() and then reparenting that NSView. The foreign view then controls the geometry and visibility status of the Qt view. This corresponds to QMacNativeWidget in Qt 4/5
      • Embed a foreign NSView in a QWindow hierarchy. This should be done by using the QWindow::fromWinId() constructor and parenting that QWindow to some other Qt window. QWindow can then be used to control the geometry and visibility status of the foreign view. Retrieving arbitary events from the foreign view is not in scope. This corresponds to QMacCocoaViewContainer in Qt 4/5

      (Note that QMacNativeWidget currently uses private QPlatformNativeInterface API. This will be replaced with winId() and fromWinId())
      QMacCocoaViewContainer was refactored in https://codereview.qt-project.org/#/c/172969/

      Other work in clarifying the situation: https://gist.github.com/torarnv/c5dfe2d2bc0c089910ce

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-41186
          # Subject Branch Project Status CR V

          Activity

            People

              vestbo Tor Arne Vestbø
              kleint Friedemann Kleint
              Votes:
              8 Vote for this issue
              Watchers:
              14 Start watching this issue

              Dates

                Created:
                Updated: