diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2017-10-25 13:05:49 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2017-11-02 15:22:41 +0000 |
commit | f4090b23b98c132c47237e4695bc4dc93170cbe0 (patch) | |
tree | d1d3cc0949a884960f2d7c401e2ebbfedcdf73cc /src/plugins/platforms/cocoa/qnswindow.mm | |
parent | 3a92f7cf4f1abd7ad91bdfc7251b1f3e82bdf89f (diff) |
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>
Diffstat (limited to 'src/plugins/platforms/cocoa/qnswindow.mm')
-rw-r--r-- | src/plugins/platforms/cocoa/qnswindow.mm | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/plugins/platforms/cocoa/qnswindow.mm b/src/plugins/platforms/cocoa/qnswindow.mm index 5213008bd4..e846fa043c 100644 --- a/src/plugins/platforms/cocoa/qnswindow.mm +++ b/src/plugins/platforms/cocoa/qnswindow.mm @@ -46,6 +46,8 @@ #include <qpa/qwindowsysteminterface.h> #include <qoperatingsystemversion.h> +Q_LOGGING_CATEGORY(lcCocoaEvents, "qt.qpa.cocoa.events"); + static bool isMouseEvent(NSEvent *ev) { switch ([ev type]) { @@ -116,6 +118,22 @@ static bool isMouseEvent(NSEvent *ev) 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 { QCocoaWindow *pw = self.platformWindow; @@ -177,6 +195,8 @@ static bool isMouseEvent(NSEvent *ev) - (void)sendEvent:(NSEvent*)theEvent { + qCDebug(lcCocoaEvents) << "Sending" << theEvent << "to" << self; + // We might get events for a NSWindow after the corresponding platform // 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 |