Use WS_EX_NOACTIVATE to prevent window from getting focused
On top of handling ActivateWindowEvent,MouseActivateWindowEvent and PointerActivateWindowEvent events and returning MA_NOACTIVATE we can also set the window extended style to prevent windows from stealing focus in special cases. Also on top all those mentioned events, when the window is requested to get keyboard focus, it should check if the window accepts focus or not. If it does not, then it should inform the underlying system that the window does not accept the focusIn event. [ChangeLog][Windows] Windows with flag Qt::WindowDoesNotAcceptFocus no longer have a taskbar entry. Fixes: QTBUG-131714 Change-Id: I79f767b1622449ba05b41f8b80bf390d8cecfff8 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Zhao Yuhang <2546789017@qq.com> (cherry picked from commit c2bdf7636eb46e56760f3e2f6d457c8f14627576) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
2a613662a3
commit
c3e0c0099f
@ -2345,6 +2345,8 @@
|
||||
\value WindowDoesNotAcceptFocus Informs the window system that this window should
|
||||
not receive the input focus.
|
||||
|
||||
\note On Windows, this prevents the window from appearing in the taskbar.
|
||||
|
||||
\value MaximizeUsingFullscreenGeometryHint Deprecated alias for Qt::ExpandedClientAreaHint
|
||||
|
||||
\value [since 6.9] ExpandedClientAreaHint Requests that the window's client area is
|
||||
|
@ -1217,6 +1217,8 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
|
||||
case QtWindows::PointerEvent:
|
||||
return sessionManagerInteractionBlocked() || d->m_pointerHandler.translatePointerEvent(platformWindow->window(), hwnd, et, msg, result);
|
||||
case QtWindows::FocusInEvent: // see QWindowsWindow::requestActivateWindow().
|
||||
if (platformWindow->window()->flags() & Qt::WindowDoesNotAcceptFocus)
|
||||
return false;
|
||||
case QtWindows::FocusOutEvent:
|
||||
handleFocusEvent(et, platformWindow);
|
||||
return true;
|
||||
|
@ -819,6 +819,9 @@ void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flag
|
||||
|
||||
style |= WS_CLIPSIBLINGS | WS_CLIPCHILDREN ;
|
||||
|
||||
if (flags & Qt::WindowDoesNotAcceptFocus)
|
||||
exStyle |= WS_EX_NOACTIVATE;
|
||||
|
||||
if (topLevel) {
|
||||
if ((type == Qt::Window || dialog || tool)) {
|
||||
if (!(flags & Qt::FramelessWindowHint)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user