diff options
author | Laszlo Agocs <[email protected]> | 2023-06-30 11:51:22 +0200 |
---|---|---|
committer | Laszlo Agocs <[email protected]> | 2023-07-05 09:14:20 +0200 |
commit | 73b80e1b42ea129b6b9bc31a593fd9e6e8b24241 (patch) | |
tree | 7ec5bde2b9e34f37b1f66552c255b744e441f6ce | |
parent | 1baa7fc3e7956773e6da6d062bc0f1c84a5ec3f3 (diff) |
Make key event forwarding functional with QQuickRenderControl
...in applications that only use the public API and so reimplement
the QQuickRenderControl::renderWindowFor() virtual.
For more complex cases one needs to reimplement a virtual in the
private class as well (QQuickRenderControlPrivate::isRenderWindow())
but simple apps do not need that (e.g. because they have a single
on-screen window and a single off-screen window).
However, right now isRenderWindow() is the only function that is
used when deciding if the "window" has focus. So apps that do not
reimplement the private virtual are in trouble.
By providing a simple default implementation that falls back on
renderWindowFor (the public virtual), we can keep most
applications working and avoid the regression we've been seeing in
the past few releases.
Whereas QQuickWidget is not affected since that reimplements both the
public and private virtuals. That is an example of a complex case where
(to support graphics view proxy widgets) one needs to provide a proper,
custom implementation of the private virtual (isRenderWindow).
Amends 8c0b1e06d9679676d12ff92db981198077eeda76
Pick-to: 6.6 6.5
Fixes: QTBUG-114961
Change-Id: I024f68da7f4260191b67be89b8957b47004e8339
Reviewed-by: Andy Nichols <[email protected]>
-rw-r--r-- | src/quick/items/qquickrendercontrol.cpp | 10 | ||||
-rw-r--r-- | src/quick/items/qquickrendercontrol_p.h | 2 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/quick/items/qquickrendercontrol.cpp b/src/quick/items/qquickrendercontrol.cpp index 49438c92db..34f63e3f7e 100644 --- a/src/quick/items/qquickrendercontrol.cpp +++ b/src/quick/items/qquickrendercontrol.cpp @@ -549,6 +549,16 @@ bool QQuickRenderControlPrivate::isRenderWindowFor(QQuickWindow *quickWin, const return false; } +bool QQuickRenderControlPrivate::isRenderWindow(const QWindow *w) +{ + Q_Q(QQuickRenderControl); + + if (window && w) + return q->renderWindowFor(window, nullptr) == w; + + return false; +} + /*! \return the QQuickWindow this QQuickRenderControl is associated with. diff --git a/src/quick/items/qquickrendercontrol_p.h b/src/quick/items/qquickrendercontrol_p.h index 29b83827d6..c27604b39c 100644 --- a/src/quick/items/qquickrendercontrol_p.h +++ b/src/quick/items/qquickrendercontrol_p.h @@ -44,7 +44,7 @@ public: } static bool isRenderWindowFor(QQuickWindow *quickWin, const QWindow *renderWin); - virtual bool isRenderWindow(const QWindow *w) { Q_UNUSED(w); return false; } + virtual bool isRenderWindow(const QWindow *w); static void cleanup(); |