Cocoa: Handle Qt::WindowDoesNotAcceptFocus
Make windows with the Qt::WindowDoesNotAcceptFocus flag refuse to become the key window. This is in addition to the existing refusal to become the first responder in QNSView. Refactor the common test into a new function: bool shouldRefuseKeyWindowAndFirstResponder() Task-number: QTBUG-32385 Change-Id: I31021b5d8895a17c48f94f3691e6590c90b68627 Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>bb10
parent
4f155b0535
commit
3c982a6384
|
|
@ -230,6 +230,7 @@ public:
|
|||
void obscureWindow();
|
||||
void updateExposedGeometry();
|
||||
QWindow *childWindowAt(QPoint windowPoint);
|
||||
bool shouldRefuseKeyWindowAndFirstResponder();
|
||||
protected:
|
||||
void recreateWindow(const QPlatformWindow *parentWindow);
|
||||
QCocoaNSWindow *createNSWindow();
|
||||
|
|
|
|||
|
|
@ -237,6 +237,9 @@ static bool isMouseEvent(NSEvent *ev)
|
|||
if (!pw || pw->m_isNSWindowChild)
|
||||
return NO;
|
||||
|
||||
if (pw->shouldRefuseKeyWindowAndFirstResponder())
|
||||
return NO;
|
||||
|
||||
// The default implementation returns NO for title-bar less windows,
|
||||
// override and return yes here to make sure popup windows such as
|
||||
// the combobox popup can become the key window.
|
||||
|
|
@ -314,6 +317,9 @@ static bool isMouseEvent(NSEvent *ev)
|
|||
if (!pw)
|
||||
return NO;
|
||||
|
||||
if (pw->shouldRefuseKeyWindowAndFirstResponder())
|
||||
return NO;
|
||||
|
||||
// Only tool or dialog windows should become key:
|
||||
Qt::WindowType type = pw->window()->type();
|
||||
if (type == Qt::Tool || type == Qt::Dialog)
|
||||
|
|
@ -1776,6 +1782,17 @@ QWindow *QCocoaWindow::childWindowAt(QPoint windowPoint)
|
|||
return targetWindow;
|
||||
}
|
||||
|
||||
bool QCocoaWindow::shouldRefuseKeyWindowAndFirstResponder()
|
||||
{
|
||||
// This function speaks up if there's any reason
|
||||
// to refuse key window or first responder state.
|
||||
|
||||
if (window()->flags() & Qt::WindowDoesNotAcceptFocus)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QMargins QCocoaWindow::frameMargins() const
|
||||
{
|
||||
NSRect frameW = [m_nsWindow frame];
|
||||
|
|
|
|||
|
|
@ -596,7 +596,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
|
|||
|
||||
- (BOOL)acceptsFirstResponder
|
||||
{
|
||||
if (m_window->flags() & Qt::WindowDoesNotAcceptFocus)
|
||||
if (m_platformWindow->shouldRefuseKeyWindowAndFirstResponder())
|
||||
return NO;
|
||||
if (m_window->flags() & Qt::WindowTransparentForInput)
|
||||
return NO;
|
||||
|
|
|
|||
Loading…
Reference in New Issue