Cocoa: Allow popups to grab mouse and keyboard
According to the QWindow documentation this should happen regardless of the window type. (It also mimics the current behavior on Linux and Windows). Change-Id: I1b0959ad8cf19bce452fd79a13b07d0a3a3c49e9 Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
This commit is contained in:
parent
14b7400de9
commit
a25e6528d3
@ -201,6 +201,7 @@ public: // for QNSView
|
||||
bool m_isExposed;
|
||||
int m_registerTouchCount;
|
||||
bool m_resizableTransientParent;
|
||||
bool m_overrideBecomeKey;
|
||||
|
||||
static const int NoAlertRequest;
|
||||
NSInteger m_alertRequest;
|
||||
|
@ -160,7 +160,9 @@ static bool isMouseEvent(NSEvent *ev)
|
||||
|
||||
// Only tool or dialog windows should become key:
|
||||
if (m_cocoaPlatformWindow
|
||||
&& (m_cocoaPlatformWindow->window()->type() == Qt::Tool || m_cocoaPlatformWindow->window()->type() == Qt::Dialog))
|
||||
&& (m_cocoaPlatformWindow->m_overrideBecomeKey ||
|
||||
m_cocoaPlatformWindow->window()->type() == Qt::Tool ||
|
||||
m_cocoaPlatformWindow->window()->type() == Qt::Dialog))
|
||||
return YES;
|
||||
return NO;
|
||||
}
|
||||
@ -212,6 +214,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
|
||||
, m_isExposed(false)
|
||||
, m_registerTouchCount(0)
|
||||
, m_resizableTransientParent(false)
|
||||
, m_overrideBecomeKey(false)
|
||||
, m_alertRequest(NoAlertRequest)
|
||||
, monitor(nil)
|
||||
{
|
||||
@ -677,6 +680,8 @@ bool QCocoaWindow::setKeyboardGrabEnabled(bool grab)
|
||||
if (!m_nsWindow)
|
||||
return false;
|
||||
|
||||
m_overrideBecomeKey = grab;
|
||||
|
||||
if (grab && ![m_nsWindow isKeyWindow])
|
||||
[m_nsWindow makeKeyWindow];
|
||||
else if (!grab && [m_nsWindow isKeyWindow])
|
||||
@ -689,6 +694,8 @@ bool QCocoaWindow::setMouseGrabEnabled(bool grab)
|
||||
if (!m_nsWindow)
|
||||
return false;
|
||||
|
||||
m_overrideBecomeKey = grab;
|
||||
|
||||
if (grab && ![m_nsWindow isKeyWindow])
|
||||
[m_nsWindow makeKeyWindow];
|
||||
else if (!grab && [m_nsWindow isKeyWindow])
|
||||
|
Loading…
Reference in New Issue
Block a user