OSX: WindowTransparentForInput QNSView pass events to next responder
The default implementation (in the super class) passes the event to the next responder. This seems to be one valid way to handle the Qt::WindowTransparentForInput flag. So if a non-alien widget for which a native NSView is created has the flag WA_TransparentForMouseEvents, that means the window will have Qt::WindowTransparentForInput, and the NSView which is created on its behalf will pass on each event so that other NSViews have a chance to handle it. (It will also try to reject becoming first responder, but that doesn't seem to be enough for the following events to be passed on.) This is a followup to I979be9f72f7d225d7b960fc5db4c3956d2749982 which purported to obey the WindowTransparentForInput flag, but actually doesn't. Change-Id: Ia72a3573c2e3cbfa7ede70bee41ac36df6924598 Task-number: QTBUG-28816 Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
This commit is contained in:
parent
795468bdc6
commit
5c6b2ede3b
@ -410,6 +410,8 @@ static QTouchDevice *touchDevice = 0;
|
|||||||
|
|
||||||
- (BOOL)becomeFirstResponder
|
- (BOOL)becomeFirstResponder
|
||||||
{
|
{
|
||||||
|
if (m_window->flags() & Qt::WindowTransparentForInput)
|
||||||
|
return NO;
|
||||||
QWindow *focusWindow = m_window;
|
QWindow *focusWindow = m_window;
|
||||||
|
|
||||||
// For widgets we need to do a bit of trickery as the window
|
// For widgets we need to do a bit of trickery as the window
|
||||||
@ -427,6 +429,8 @@ static QTouchDevice *touchDevice = 0;
|
|||||||
{
|
{
|
||||||
if (m_window->flags() & Qt::WindowDoesNotAcceptFocus)
|
if (m_window->flags() & Qt::WindowDoesNotAcceptFocus)
|
||||||
return NO;
|
return NO;
|
||||||
|
if (m_window->flags() & Qt::WindowTransparentForInput)
|
||||||
|
return NO;
|
||||||
if ((m_window->flags() & Qt::ToolTip) == Qt::ToolTip)
|
if ((m_window->flags() & Qt::ToolTip) == Qt::ToolTip)
|
||||||
return NO;
|
return NO;
|
||||||
return YES;
|
return YES;
|
||||||
@ -434,7 +438,9 @@ static QTouchDevice *touchDevice = 0;
|
|||||||
|
|
||||||
- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
|
- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
Q_UNUSED(theEvent);
|
Q_UNUSED(theEvent)
|
||||||
|
if (m_window->flags() & Qt::WindowTransparentForInput)
|
||||||
|
return NO;
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,6 +545,8 @@ static QTouchDevice *touchDevice = 0;
|
|||||||
|
|
||||||
- (void)mouseDown:(NSEvent *)theEvent
|
- (void)mouseDown:(NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
|
if (m_window->flags() & Qt::WindowTransparentForInput)
|
||||||
|
return [super mouseDown:theEvent];
|
||||||
m_sendUpAsRightButton = false;
|
m_sendUpAsRightButton = false;
|
||||||
if (m_platformWindow->m_activePopupWindow) {
|
if (m_platformWindow->m_activePopupWindow) {
|
||||||
QWindowSystemInterface::handleCloseEvent(m_platformWindow->m_activePopupWindow);
|
QWindowSystemInterface::handleCloseEvent(m_platformWindow->m_activePopupWindow);
|
||||||
@ -563,6 +571,8 @@ static QTouchDevice *touchDevice = 0;
|
|||||||
|
|
||||||
- (void)mouseDragged:(NSEvent *)theEvent
|
- (void)mouseDragged:(NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
|
if (m_window->flags() & Qt::WindowTransparentForInput)
|
||||||
|
return [super mouseDragged:theEvent];
|
||||||
if (!(m_buttons & Qt::LeftButton))
|
if (!(m_buttons & Qt::LeftButton))
|
||||||
qWarning("QNSView mouseDragged: Internal mouse button tracking invalid (missing Qt::LeftButton)");
|
qWarning("QNSView mouseDragged: Internal mouse button tracking invalid (missing Qt::LeftButton)");
|
||||||
[self handleMouseEvent:theEvent];
|
[self handleMouseEvent:theEvent];
|
||||||
@ -570,6 +580,8 @@ static QTouchDevice *touchDevice = 0;
|
|||||||
|
|
||||||
- (void)mouseUp:(NSEvent *)theEvent
|
- (void)mouseUp:(NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
|
if (m_window->flags() & Qt::WindowTransparentForInput)
|
||||||
|
return [super mouseUp:theEvent];
|
||||||
if (m_sendUpAsRightButton) {
|
if (m_sendUpAsRightButton) {
|
||||||
m_buttons &= ~Qt::RightButton;
|
m_buttons &= ~Qt::RightButton;
|
||||||
m_sendUpAsRightButton = false;
|
m_sendUpAsRightButton = false;
|
||||||
@ -614,11 +626,15 @@ static QTouchDevice *touchDevice = 0;
|
|||||||
|
|
||||||
- (void)mouseMoved:(NSEvent *)theEvent
|
- (void)mouseMoved:(NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
|
if (m_window->flags() & Qt::WindowTransparentForInput)
|
||||||
|
return [super mouseMoved:theEvent];
|
||||||
[self handleMouseEvent:theEvent];
|
[self handleMouseEvent:theEvent];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)mouseEntered:(NSEvent *)theEvent
|
- (void)mouseEntered:(NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
|
if (m_window->flags() & Qt::WindowTransparentForInput)
|
||||||
|
return [super mouseEntered:theEvent];
|
||||||
QPoint windowPoint, screenPoint;
|
QPoint windowPoint, screenPoint;
|
||||||
[self convertFromEvent:theEvent toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
|
[self convertFromEvent:theEvent toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
|
||||||
QWindowSystemInterface::handleEnterEvent(m_window, windowPoint, screenPoint);
|
QWindowSystemInterface::handleEnterEvent(m_window, windowPoint, screenPoint);
|
||||||
@ -626,18 +642,23 @@ static QTouchDevice *touchDevice = 0;
|
|||||||
|
|
||||||
- (void)mouseExited:(NSEvent *)theEvent
|
- (void)mouseExited:(NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
Q_UNUSED(theEvent);
|
if (m_window->flags() & Qt::WindowTransparentForInput)
|
||||||
|
return [super mouseExited:theEvent];
|
||||||
QWindowSystemInterface::handleLeaveEvent(m_window);
|
QWindowSystemInterface::handleLeaveEvent(m_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)rightMouseDown:(NSEvent *)theEvent
|
- (void)rightMouseDown:(NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
|
if (m_window->flags() & Qt::WindowTransparentForInput)
|
||||||
|
return [super rightMouseDown:theEvent];
|
||||||
m_buttons |= Qt::RightButton;
|
m_buttons |= Qt::RightButton;
|
||||||
[self handleMouseEvent:theEvent];
|
[self handleMouseEvent:theEvent];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)rightMouseDragged:(NSEvent *)theEvent
|
- (void)rightMouseDragged:(NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
|
if (m_window->flags() & Qt::WindowTransparentForInput)
|
||||||
|
return [super rightMouseDragged:theEvent];
|
||||||
if (!(m_buttons & Qt::RightButton))
|
if (!(m_buttons & Qt::RightButton))
|
||||||
qWarning("QNSView rightMouseDragged: Internal mouse button tracking invalid (missing Qt::RightButton)");
|
qWarning("QNSView rightMouseDragged: Internal mouse button tracking invalid (missing Qt::RightButton)");
|
||||||
[self handleMouseEvent:theEvent];
|
[self handleMouseEvent:theEvent];
|
||||||
@ -645,18 +666,24 @@ static QTouchDevice *touchDevice = 0;
|
|||||||
|
|
||||||
- (void)rightMouseUp:(NSEvent *)theEvent
|
- (void)rightMouseUp:(NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
|
if (m_window->flags() & Qt::WindowTransparentForInput)
|
||||||
|
return [super rightMouseUp:theEvent];
|
||||||
m_buttons &= ~Qt::RightButton;
|
m_buttons &= ~Qt::RightButton;
|
||||||
[self handleMouseEvent:theEvent];
|
[self handleMouseEvent:theEvent];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)otherMouseDown:(NSEvent *)theEvent
|
- (void)otherMouseDown:(NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
|
if (m_window->flags() & Qt::WindowTransparentForInput)
|
||||||
|
return [super otherMouseDown:theEvent];
|
||||||
m_buttons |= cocoaButton2QtButton([theEvent buttonNumber]);
|
m_buttons |= cocoaButton2QtButton([theEvent buttonNumber]);
|
||||||
[self handleMouseEvent:theEvent];
|
[self handleMouseEvent:theEvent];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)otherMouseDragged:(NSEvent *)theEvent
|
- (void)otherMouseDragged:(NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
|
if (m_window->flags() & Qt::WindowTransparentForInput)
|
||||||
|
return [super otherMouseDragged:theEvent];
|
||||||
if (!(m_buttons & ~(Qt::LeftButton | Qt::RightButton)))
|
if (!(m_buttons & ~(Qt::LeftButton | Qt::RightButton)))
|
||||||
qWarning("QNSView otherMouseDragged: Internal mouse button tracking invalid (missing Qt::MiddleButton or Qt::ExtraButton*)");
|
qWarning("QNSView otherMouseDragged: Internal mouse button tracking invalid (missing Qt::MiddleButton or Qt::ExtraButton*)");
|
||||||
[self handleMouseEvent:theEvent];
|
[self handleMouseEvent:theEvent];
|
||||||
@ -664,6 +691,8 @@ static QTouchDevice *touchDevice = 0;
|
|||||||
|
|
||||||
- (void)otherMouseUp:(NSEvent *)theEvent
|
- (void)otherMouseUp:(NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
|
if (m_window->flags() & Qt::WindowTransparentForInput)
|
||||||
|
return [super otherMouseUp:theEvent];
|
||||||
m_buttons &= ~cocoaButton2QtButton([theEvent buttonNumber]);
|
m_buttons &= ~cocoaButton2QtButton([theEvent buttonNumber]);
|
||||||
[self handleMouseEvent:theEvent];
|
[self handleMouseEvent:theEvent];
|
||||||
}
|
}
|
||||||
@ -699,6 +728,8 @@ static QTouchDevice *touchDevice = 0;
|
|||||||
#ifndef QT_NO_WHEELEVENT
|
#ifndef QT_NO_WHEELEVENT
|
||||||
- (void)scrollWheel:(NSEvent *)theEvent
|
- (void)scrollWheel:(NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
|
if (m_window->flags() & Qt::WindowTransparentForInput)
|
||||||
|
return [super scrollWheel:theEvent];
|
||||||
const EventRef carbonEvent = (EventRef)[theEvent eventRef];
|
const EventRef carbonEvent = (EventRef)[theEvent eventRef];
|
||||||
const UInt32 carbonEventKind = carbonEvent ? ::GetEventKind(carbonEvent) : 0;
|
const UInt32 carbonEventKind = carbonEvent ? ::GetEventKind(carbonEvent) : 0;
|
||||||
const bool scrollEvent = carbonEventKind == kEventMouseScroll;
|
const bool scrollEvent = carbonEventKind == kEventMouseScroll;
|
||||||
@ -864,11 +895,15 @@ static QTouchDevice *touchDevice = 0;
|
|||||||
|
|
||||||
- (void)keyDown:(NSEvent *)nsevent
|
- (void)keyDown:(NSEvent *)nsevent
|
||||||
{
|
{
|
||||||
|
if (m_window->flags() & Qt::WindowTransparentForInput)
|
||||||
|
return [super keyDown:nsevent];
|
||||||
[self handleKeyEvent:nsevent eventType:int(QEvent::KeyPress)];
|
[self handleKeyEvent:nsevent eventType:int(QEvent::KeyPress)];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)keyUp:(NSEvent *)nsevent
|
- (void)keyUp:(NSEvent *)nsevent
|
||||||
{
|
{
|
||||||
|
if (m_window->flags() & Qt::WindowTransparentForInput)
|
||||||
|
return [super keyUp:nsevent];
|
||||||
[self handleKeyEvent:nsevent eventType:int(QEvent::KeyRelease)];
|
[self handleKeyEvent:nsevent eventType:int(QEvent::KeyRelease)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1083,7 +1083,8 @@ void QWidgetPrivate::adjustFlags(Qt::WindowFlags &flags, QWidget *w)
|
|||||||
else
|
else
|
||||||
flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint |
|
flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint |
|
||||||
Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint | Qt::WindowFullscreenButtonHint;
|
Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint | Qt::WindowFullscreenButtonHint;
|
||||||
|
if (w->testAttribute(Qt::WA_TransparentForMouseEvents))
|
||||||
|
flags |= Qt::WindowTransparentForInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
|
void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
|
||||||
|
Loading…
Reference in New Issue
Block a user