Rename QWSI::handleWindowActivated to QWSI::handleFocusWindowChanged
A single QWindow is QGuiApplication::focusWindow() at a time, and this window is typically also QWindow::isActive(), but other windows may also be QWindow::isActive(). For example, we treat any sibling or ancestor of the focusWindow as being QWindow::isActive() as well. In addition, in the case of non-QWindow child windows, we may have to query the platform for the activation state, which means we also need a way for the platform to reflect changes in this state through QWSI. The current API for this, QWSI::handleWindowActivated, is in practice a focus window change API, so as a first step let's rename it to better reflect what it's doing. Task-number: QTBUG-119287 Change-Id: I381baf8505dd13a4a829c961095a8d2ed120092b Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
parent
5ab2b8b951
commit
8723daf696
@ -2087,8 +2087,8 @@ void Q_TRACE_INSTRUMENT(qtgui) QGuiApplicationPrivate::processWindowSystemEvent(
|
||||
case QWindowSystemInterfacePrivate::Leave:
|
||||
QGuiApplicationPrivate::processLeaveEvent(static_cast<QWindowSystemInterfacePrivate::LeaveEvent *>(e));
|
||||
break;
|
||||
case QWindowSystemInterfacePrivate::ActivatedWindow:
|
||||
QGuiApplicationPrivate::processActivatedEvent(static_cast<QWindowSystemInterfacePrivate::ActivatedWindowEvent *>(e));
|
||||
case QWindowSystemInterfacePrivate::FocusWindow:
|
||||
QGuiApplicationPrivate::processFocusWindowEvent(static_cast<QWindowSystemInterfacePrivate::FocusWindowEvent *>(e));
|
||||
break;
|
||||
case QWindowSystemInterfacePrivate::WindowStateChanged:
|
||||
QGuiApplicationPrivate::processWindowStateChangedEvent(static_cast<QWindowSystemInterfacePrivate::WindowStateChangedEvent *>(e));
|
||||
@ -2511,10 +2511,10 @@ void QGuiApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::Le
|
||||
QCoreApplication::sendSpontaneousEvent(e->leave.data(), &event);
|
||||
}
|
||||
|
||||
void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e)
|
||||
void QGuiApplicationPrivate::processFocusWindowEvent(QWindowSystemInterfacePrivate::FocusWindowEvent *e)
|
||||
{
|
||||
QWindow *previous = QGuiApplicationPrivate::focus_window;
|
||||
QWindow *newFocus = e->activated.data();
|
||||
QWindow *newFocus = e->focused.data();
|
||||
|
||||
if (previous == newFocus)
|
||||
return;
|
||||
|
@ -115,7 +115,8 @@ public:
|
||||
static void processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e);
|
||||
static void processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e);
|
||||
|
||||
static void processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e);
|
||||
static void processFocusWindowEvent(QWindowSystemInterfacePrivate::FocusWindowEvent *e);
|
||||
|
||||
static void processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *e);
|
||||
static void processWindowScreenChangedEvent(QWindowSystemInterfacePrivate::WindowScreenChangedEvent *e);
|
||||
static void processWindowDevicePixelRatioChangedEvent(QWindowSystemInterfacePrivate::WindowDevicePixelRatioChangedEvent *e);
|
||||
|
@ -370,18 +370,18 @@ void QPlatformWindow::setMask(const QRegion ®ion)
|
||||
Reimplement to let Qt be able to request activation/focus for a window
|
||||
|
||||
Some window systems will probably not have callbacks for this functionality,
|
||||
and then calling QWindowSystemInterface::handleWindowActivated(QWindow *w)
|
||||
and then calling QWindowSystemInterface::handleFocusWindowChanged(QWindow *w)
|
||||
would be sufficient.
|
||||
|
||||
If the window system has some event handling/callbacks then call
|
||||
QWindowSystemInterface::handleWindowActivated(QWindow *w) when the window system
|
||||
QWindowSystemInterface::handleFocusWindowChanged(QWindow *w) when the window system
|
||||
gives the notification.
|
||||
|
||||
Default implementation calls QWindowSystem::handleWindowActivated(QWindow *w)
|
||||
Default implementation calls QWindowSystem::handleFocusWindowChanged(QWindow *w)
|
||||
*/
|
||||
void QPlatformWindow::requestActivateWindow()
|
||||
{
|
||||
QWindowSystemInterface::handleWindowActivated(window());
|
||||
QWindowSystemInterface::handleFocusWindowChanged(window());
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -240,9 +240,9 @@ void QWindowSystemInterface::handleEnterLeaveEvent(QWindow *enter, QWindow *leav
|
||||
handleEnterEvent(enter, local, global);
|
||||
}
|
||||
|
||||
QT_DEFINE_QPA_EVENT_HANDLER(void, handleWindowActivated, QWindow *window, Qt::FocusReason r)
|
||||
QT_DEFINE_QPA_EVENT_HANDLER(void, handleFocusWindowChanged, QWindow *window, Qt::FocusReason r)
|
||||
{
|
||||
handleWindowSystemEvent<QWindowSystemInterfacePrivate::ActivatedWindowEvent, Delivery>(window, r);
|
||||
handleWindowSystemEvent<QWindowSystemInterfacePrivate::FocusWindowEvent, Delivery>(window, r);
|
||||
}
|
||||
|
||||
QT_DEFINE_QPA_EVENT_HANDLER(void, handleWindowStateChanged, QWindow *window, Qt::WindowStates newState, int oldState)
|
||||
|
@ -157,8 +157,9 @@ public:
|
||||
template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
|
||||
static void handleLeaveEvent(QWindow *window);
|
||||
static void handleEnterLeaveEvent(QWindow *enter, QWindow *leave, const QPointF &local = QPointF(), const QPointF& global = QPointF());
|
||||
|
||||
template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
|
||||
static void handleWindowActivated(QWindow *window, Qt::FocusReason r = Qt::OtherFocusReason);
|
||||
static void handleFocusWindowChanged(QWindow *window, Qt::FocusReason r = Qt::OtherFocusReason);
|
||||
|
||||
template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
|
||||
static void handleWindowStateChanged(QWindow *window, Qt::WindowStates newState, int oldState = -1);
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
GeometryChange = 0x02,
|
||||
Enter = UserInputEvent | 0x03,
|
||||
Leave = UserInputEvent | 0x04,
|
||||
ActivatedWindow = 0x05,
|
||||
FocusWindow = 0x05,
|
||||
WindowStateChanged = 0x06,
|
||||
Mouse = UserInputEvent | 0x07,
|
||||
Wheel = UserInputEvent | 0x09,
|
||||
@ -125,12 +125,12 @@ public:
|
||||
QPointer<QWindow> leave;
|
||||
};
|
||||
|
||||
class ActivatedWindowEvent : public WindowSystemEvent {
|
||||
class FocusWindowEvent : public WindowSystemEvent {
|
||||
public:
|
||||
explicit ActivatedWindowEvent(QWindow *activatedWindow, Qt::FocusReason r)
|
||||
: WindowSystemEvent(ActivatedWindow), activated(activatedWindow), reason(r)
|
||||
explicit FocusWindowEvent(QWindow *focusedWindow, Qt::FocusReason r)
|
||||
: WindowSystemEvent(FocusWindow), focused(focusedWindow), reason(r)
|
||||
{ }
|
||||
QPointer<QWindow> activated;
|
||||
QPointer<QWindow> focused;
|
||||
Qt::FocusReason reason;
|
||||
};
|
||||
|
||||
|
@ -63,7 +63,7 @@ void QFbScreen::addWindow(QFbWindow *window)
|
||||
}
|
||||
setDirty(window->geometry());
|
||||
QWindow *w = topWindow();
|
||||
QWindowSystemInterface::handleWindowActivated(w);
|
||||
QWindowSystemInterface::handleFocusWindowChanged(w);
|
||||
topWindowChanged(w);
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ void QFbScreen::removeWindow(QFbWindow *window)
|
||||
mWindowStack.removeOne(window);
|
||||
setDirty(window->geometry());
|
||||
QWindow *w = topWindow();
|
||||
QWindowSystemInterface::handleWindowActivated(w);
|
||||
QWindowSystemInterface::handleFocusWindowChanged(w);
|
||||
topWindowChanged(w);
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ void QFbScreen::raise(QFbWindow *window)
|
||||
mWindowStack.move(index, 0);
|
||||
setDirty(window->geometry());
|
||||
QWindow *w = topWindow();
|
||||
QWindowSystemInterface::handleWindowActivated(w);
|
||||
QWindowSystemInterface::handleFocusWindowChanged(w);
|
||||
topWindowChanged(w);
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ void QFbScreen::lower(QFbWindow *window)
|
||||
mWindowStack.move(index, mWindowStack.size() - 1);
|
||||
setDirty(window->geometry());
|
||||
QWindow *w = topWindow();
|
||||
QWindowSystemInterface::handleWindowActivated(w);
|
||||
QWindowSystemInterface::handleFocusWindowChanged(w);
|
||||
topWindowChanged(w);
|
||||
}
|
||||
|
||||
|
@ -184,7 +184,7 @@ void QAndroidPlatformScreen::addWindow(QAndroidPlatformWindow *window)
|
||||
}
|
||||
|
||||
QWindow *w = topWindow();
|
||||
QWindowSystemInterface::handleWindowActivated(w, Qt::ActiveWindowFocusReason);
|
||||
QWindowSystemInterface::handleFocusWindowChanged(w, Qt::ActiveWindowFocusReason);
|
||||
topWindowChanged(w);
|
||||
}
|
||||
|
||||
@ -204,7 +204,7 @@ void QAndroidPlatformScreen::removeWindow(QAndroidPlatformWindow *window)
|
||||
}
|
||||
|
||||
QWindow *w = topWindow();
|
||||
QWindowSystemInterface::handleWindowActivated(w, Qt::ActiveWindowFocusReason);
|
||||
QWindowSystemInterface::handleFocusWindowChanged(w, Qt::ActiveWindowFocusReason);
|
||||
topWindowChanged(w);
|
||||
}
|
||||
|
||||
@ -221,7 +221,7 @@ void QAndroidPlatformScreen::raise(QAndroidPlatformWindow *window)
|
||||
setDirty(window->geometry());
|
||||
}
|
||||
QWindow *w = topWindow();
|
||||
QWindowSystemInterface::handleWindowActivated(w, Qt::ActiveWindowFocusReason);
|
||||
QWindowSystemInterface::handleFocusWindowChanged(w, Qt::ActiveWindowFocusReason);
|
||||
topWindowChanged(w);
|
||||
}
|
||||
|
||||
@ -238,7 +238,7 @@ void QAndroidPlatformScreen::lower(QAndroidPlatformWindow *window)
|
||||
setDirty(window->geometry());
|
||||
}
|
||||
QWindow *w = topWindow();
|
||||
QWindowSystemInterface::handleWindowActivated(w, Qt::ActiveWindowFocusReason);
|
||||
QWindowSystemInterface::handleFocusWindowChanged(w, Qt::ActiveWindowFocusReason);
|
||||
topWindowChanged(w);
|
||||
}
|
||||
|
||||
|
@ -1261,8 +1261,8 @@ void QCocoaWindow::windowDidBecomeKey()
|
||||
return;
|
||||
|
||||
// See also [QNSView becomeFirstResponder]
|
||||
QWindowSystemInterface::handleWindowActivated<QWindowSystemInterface::SynchronousDelivery>(
|
||||
focusCocoaWindow->window(), Qt::ActiveWindowFocusReason);
|
||||
QWindowSystemInterface::handleFocusWindowChanged<QWindowSystemInterface::SynchronousDelivery>(
|
||||
window(), Qt::ActiveWindowFocusReason);
|
||||
}
|
||||
|
||||
void QCocoaWindow::windowDidResignKey()
|
||||
@ -1288,7 +1288,7 @@ void QCocoaWindow::windowDidResignKey()
|
||||
|
||||
// Lost key window, go ahead and set the active window to zero
|
||||
if (!windowIsPopupType()) {
|
||||
QWindowSystemInterface::handleWindowActivated<QWindowSystemInterface::SynchronousDelivery>(
|
||||
QWindowSystemInterface::handleFocusWindowChanged<QWindowSystemInterface::SynchronousDelivery>(
|
||||
nullptr, Qt::ActiveWindowFocusReason);
|
||||
}
|
||||
}
|
||||
|
@ -328,7 +328,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSViewMenuHelper);
|
||||
// QWindow activation from QCocoaWindow::windowDidBecomeKey instead. The only
|
||||
// exception is if the window can never become key, in which case we naturally
|
||||
// cannot wait for that to happen.
|
||||
QWindowSystemInterface::handleWindowActivated<QWindowSystemInterface::SynchronousDelivery>(
|
||||
QWindowSystemInterface::handleFocusWindowChanged<QWindowSystemInterface::SynchronousDelivery>(
|
||||
[self topLevelWindow], Qt::ActiveWindowFocusReason);
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ void QDirectFbInput::handleEnterLeaveEvents(const DFBEvent &event)
|
||||
void QDirectFbInput::handleGotFocusEvent(const DFBEvent &event)
|
||||
{
|
||||
QWindow *tlw = m_tlwMap.value(event.window.window_id);
|
||||
QWindowSystemInterface::handleWindowActivated(tlw, Qt::ActiveWindowFocusReason);
|
||||
QWindowSystemInterface::handleFocusWindowChanged(tlw, Qt::ActiveWindowFocusReason);
|
||||
}
|
||||
|
||||
void QDirectFbInput::handleCloseEvent(const DFBEvent &event)
|
||||
|
@ -263,7 +263,7 @@ void QEglFSWindow::requestActivateWindow()
|
||||
QOpenGLCompositor::instance()->moveToTop(this);
|
||||
#endif
|
||||
QWindow *wnd = window();
|
||||
QWindowSystemInterface::handleWindowActivated(wnd, Qt::ActiveWindowFocusReason);
|
||||
QWindowSystemInterface::handleFocusWindowChanged(wnd, Qt::ActiveWindowFocusReason);
|
||||
QWindowSystemInterface::handleExposeEvent(wnd, QRect(QPoint(0, 0), wnd->geometry().size()));
|
||||
}
|
||||
|
||||
|
@ -294,7 +294,7 @@ void QHaikuWindow::haikuWindowResized(const QSize &size, bool zoomInProgress)
|
||||
|
||||
void QHaikuWindow::haikuWindowActivated(bool activated)
|
||||
{
|
||||
QWindowSystemInterface::handleWindowActivated(activated ? window() : nullptr);
|
||||
QWindowSystemInterface::handleFocusWindowChanged(activated ? window() : nullptr);
|
||||
}
|
||||
|
||||
void QHaikuWindow::haikuWindowMinimized(bool minimize)
|
||||
|
@ -315,7 +315,7 @@ inline ulong getTimeStamp(UIEvent *event)
|
||||
}
|
||||
|
||||
if (qGuiApp->focusWindow() != self.platformWindow->window())
|
||||
QWindowSystemInterface::handleWindowActivated(self.platformWindow->window(), Qt::ActiveWindowFocusReason);
|
||||
QWindowSystemInterface::handleFocusWindowChanged(self.platformWindow->window(), Qt::ActiveWindowFocusReason);
|
||||
else
|
||||
qImDebug() << self.platformWindow->window() << "already active, not sending window activation";
|
||||
|
||||
@ -352,7 +352,7 @@ inline ulong getTimeStamp(UIEvent *event)
|
||||
|
||||
UIResponder *newResponder = FirstResponderCandidate::currentCandidate();
|
||||
if ([self responderShouldTriggerWindowDeactivation:newResponder])
|
||||
QWindowSystemInterface::handleWindowActivated(nullptr, Qt::ActiveWindowFocusReason);
|
||||
QWindowSystemInterface::handleFocusWindowChanged(nullptr, Qt::ActiveWindowFocusReason);
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ void QOffscreenWindow::setVisible(bool visible)
|
||||
|
||||
if (visible) {
|
||||
if (window()->type() != Qt::ToolTip)
|
||||
QWindowSystemInterface::handleWindowActivated(window(), Qt::ActiveWindowFocusReason);
|
||||
QWindowSystemInterface::handleFocusWindowChanged(window(), Qt::ActiveWindowFocusReason);
|
||||
|
||||
if (m_pendingGeometryChangeOnShow) {
|
||||
m_pendingGeometryChangeOnShow = false;
|
||||
@ -122,7 +122,7 @@ void QOffscreenWindow::setVisible(bool visible)
|
||||
void QOffscreenWindow::requestActivateWindow()
|
||||
{
|
||||
if (m_visible)
|
||||
QWindowSystemInterface::handleWindowActivated(window(), Qt::ActiveWindowFocusReason);
|
||||
QWindowSystemInterface::handleFocusWindowChanged(window(), Qt::ActiveWindowFocusReason);
|
||||
}
|
||||
|
||||
WId QOffscreenWindow::winId() const
|
||||
|
@ -710,7 +710,7 @@ void QQnxScreenEventHandler::handleKeyboardFocusPropertyEvent(screen_window_t wi
|
||||
}
|
||||
|
||||
if (focus && focusWindow != QGuiApplication::focusWindow())
|
||||
QWindowSystemInterface::handleWindowActivated(focusWindow, Qt::ActiveWindowFocusReason);
|
||||
QWindowSystemInterface::handleFocusWindowChanged(focusWindow, Qt::ActiveWindowFocusReason);
|
||||
else if (!focus && focusWindow == QGuiApplication::focusWindow())
|
||||
m_focusLostTimer = startTimer(50);
|
||||
}
|
||||
|
@ -1415,7 +1415,7 @@ void QWindowsContext::handleFocusEvent(QtWindows::WindowsEventType et,
|
||||
}
|
||||
if (nextActiveWindow != d->m_lastActiveWindow) {
|
||||
d->m_lastActiveWindow = nextActiveWindow;
|
||||
QWindowSystemInterface::handleWindowActivated(nextActiveWindow, Qt::ActiveWindowFocusReason);
|
||||
QWindowSystemInterface::handleFocusWindowChanged(nextActiveWindow, Qt::ActiveWindowFocusReason);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
|
||||
m_focusInTimer.setInterval(focusInDelay);
|
||||
m_focusInTimer.callOnTimeout(this, []() {
|
||||
// No FocusIn events for us, proceed with FocusOut normally.
|
||||
QWindowSystemInterface::handleWindowActivated(nullptr, Qt::ActiveWindowFocusReason);
|
||||
QWindowSystemInterface::handleFocusWindowChanged(nullptr, Qt::ActiveWindowFocusReason);
|
||||
});
|
||||
|
||||
sync();
|
||||
|
@ -854,7 +854,7 @@ void QXcbWindow::doFocusIn()
|
||||
return;
|
||||
QWindow *w = static_cast<QWindowPrivate *>(QObjectPrivate::get(window()))->eventReceiver();
|
||||
connection()->setFocusWindow(w);
|
||||
QWindowSystemInterface::handleWindowActivated(w, Qt::ActiveWindowFocusReason);
|
||||
QWindowSystemInterface::handleFocusWindowChanged(w, Qt::ActiveWindowFocusReason);
|
||||
}
|
||||
|
||||
void QXcbWindow::doFocusOut()
|
||||
@ -2477,15 +2477,15 @@ void QXcbWindow::sendXEmbedMessage(xcb_window_t window, quint32 message,
|
||||
xcb_send_event(xcb_connection(), false, window, XCB_EVENT_MASK_NO_EVENT, (const char *)&event);
|
||||
}
|
||||
|
||||
static bool activeWindowChangeQueued(const QWindow *window)
|
||||
static bool focusWindowChangeQueued(const QWindow *window)
|
||||
{
|
||||
/* Check from window system event queue if the next queued activation
|
||||
* targets a window other than @window.
|
||||
*/
|
||||
QWindowSystemInterfacePrivate::ActivatedWindowEvent *systemEvent =
|
||||
static_cast<QWindowSystemInterfacePrivate::ActivatedWindowEvent *>
|
||||
(QWindowSystemInterfacePrivate::peekWindowSystemEvent(QWindowSystemInterfacePrivate::ActivatedWindow));
|
||||
return systemEvent && systemEvent->activated != window;
|
||||
QWindowSystemInterfacePrivate::FocusWindowEvent *systemEvent =
|
||||
static_cast<QWindowSystemInterfacePrivate::FocusWindowEvent *>
|
||||
(QWindowSystemInterfacePrivate::peekWindowSystemEvent(QWindowSystemInterfacePrivate::FocusWindow));
|
||||
return systemEvent && systemEvent->focused != window;
|
||||
}
|
||||
|
||||
void QXcbWindow::handleXEmbedMessage(const xcb_client_message_event_t *event)
|
||||
@ -2515,13 +2515,13 @@ void QXcbWindow::handleXEmbedMessage(const xcb_client_message_event_t *event)
|
||||
break;
|
||||
}
|
||||
connection()->setFocusWindow(window());
|
||||
QWindowSystemInterface::handleWindowActivated(window(), reason);
|
||||
QWindowSystemInterface::handleFocusWindowChanged(window(), reason);
|
||||
break;
|
||||
case XEMBED_FOCUS_OUT:
|
||||
if (window() == QGuiApplication::focusWindow()
|
||||
&& !activeWindowChangeQueued(window())) {
|
||||
&& !focusWindowChangeQueued(window())) {
|
||||
connection()->setFocusWindow(nullptr);
|
||||
QWindowSystemInterface::handleWindowActivated(nullptr);
|
||||
QWindowSystemInterface::handleFocusWindowChanged(nullptr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user