macOS: Add categorized logging of event and notification forwarding
Useful for debugging issues in this area. Change-Id: Ic343ef790e20b66371028265efe2ec1816c954bd Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
parent
3a92f7cf4f
commit
f4090b23b9
@ -79,6 +79,8 @@ static void qt_closePopups()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(lcCocoaNotifications, "qt.qpa.cocoa.notifications");
|
||||||
|
|
||||||
static void qRegisterNotificationCallbacks()
|
static void qRegisterNotificationCallbacks()
|
||||||
{
|
{
|
||||||
static const QLatin1String notificationHandlerPrefix(Q_NOTIFICATION_PREFIX);
|
static const QLatin1String notificationHandlerPrefix(Q_NOTIFICATION_PREFIX);
|
||||||
@ -110,11 +112,24 @@ static void qRegisterNotificationCallbacks()
|
|||||||
if (QNSView *qnsView = qnsview_cast(notification.object))
|
if (QNSView *qnsView = qnsview_cast(notification.object))
|
||||||
cocoaWindows += qnsView.platformWindow;
|
cocoaWindows += qnsView.platformWindow;
|
||||||
} else {
|
} else {
|
||||||
qCWarning(lcQpaCocoaWindow) << "Unhandled notifcation"
|
qCWarning(lcCocoaNotifications) << "Unhandled notifcation"
|
||||||
<< notification.name << "for" << notification.object;
|
<< notification.name << "for" << notification.object;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lcCocoaNotifications().isDebugEnabled()) {
|
||||||
|
if (cocoaWindows.isEmpty()) {
|
||||||
|
qCDebug(lcCocoaNotifications) << "Could not find forwarding target for" <<
|
||||||
|
qPrintable(notificationName) << "from" << notification.object;
|
||||||
|
} else {
|
||||||
|
QVector<QCocoaWindow *> debugWindows;
|
||||||
|
for (QCocoaWindow *cocoaWindow : cocoaWindows)
|
||||||
|
debugWindows += cocoaWindow;
|
||||||
|
qCDebug(lcCocoaNotifications) << "Forwarding" << qPrintable(notificationName) <<
|
||||||
|
"to" << debugWindows;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: Could be a foreign window, look up by iterating top level QWindows
|
// FIXME: Could be a foreign window, look up by iterating top level QWindows
|
||||||
|
|
||||||
for (QCocoaWindow *cocoaWindow : cocoaWindows) {
|
for (QCocoaWindow *cocoaWindow : cocoaWindows) {
|
||||||
|
@ -46,6 +46,8 @@
|
|||||||
#include <qpa/qwindowsysteminterface.h>
|
#include <qpa/qwindowsysteminterface.h>
|
||||||
#include <qoperatingsystemversion.h>
|
#include <qoperatingsystemversion.h>
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(lcCocoaEvents, "qt.qpa.cocoa.events");
|
||||||
|
|
||||||
static bool isMouseEvent(NSEvent *ev)
|
static bool isMouseEvent(NSEvent *ev)
|
||||||
{
|
{
|
||||||
switch ([ev type]) {
|
switch ([ev type]) {
|
||||||
@ -116,6 +118,22 @@ static bool isMouseEvent(NSEvent *ev)
|
|||||||
return qnsview_cast(self.contentView).platformWindow;
|
return qnsview_cast(self.contentView).platformWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSString *)description
|
||||||
|
{
|
||||||
|
NSMutableString *description = [NSMutableString stringWithString:qt_objcDynamicSuper()];
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG_STREAM
|
||||||
|
QString contentViewDescription;
|
||||||
|
QDebug debug(&contentViewDescription);
|
||||||
|
debug.nospace() << "; contentView=" << qnsview_cast(self.contentView) << ">";
|
||||||
|
|
||||||
|
NSRange lastCharacter = [description rangeOfComposedCharacterSequenceAtIndex:description.length - 1];
|
||||||
|
[description replaceCharactersInRange:lastCharacter withString:contentViewDescription.toNSString()];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL)canBecomeKeyWindow
|
- (BOOL)canBecomeKeyWindow
|
||||||
{
|
{
|
||||||
QCocoaWindow *pw = self.platformWindow;
|
QCocoaWindow *pw = self.platformWindow;
|
||||||
@ -177,6 +195,8 @@ static bool isMouseEvent(NSEvent *ev)
|
|||||||
|
|
||||||
- (void)sendEvent:(NSEvent*)theEvent
|
- (void)sendEvent:(NSEvent*)theEvent
|
||||||
{
|
{
|
||||||
|
qCDebug(lcCocoaEvents) << "Sending" << theEvent << "to" << self;
|
||||||
|
|
||||||
// We might get events for a NSWindow after the corresponding platform
|
// We might get events for a NSWindow after the corresponding platform
|
||||||
// window has been deleted, as the NSWindow can outlive the QCocoaWindow
|
// window has been deleted, as the NSWindow can outlive the QCocoaWindow
|
||||||
// e.g. if being retained by other parts of AppKit, or in an auto-release
|
// e.g. if being retained by other parts of AppKit, or in an auto-release
|
||||||
|
Loading…
x
Reference in New Issue
Block a user