From b077e67fd2538bc972eb5f050c7e0d28681a30ca Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 21 Jan 2013 15:23:26 +0100 Subject: Cocoa: Backport Qt 4's QCocoaView tracking areas into QNSView Task-number: QTBUG-29153 Change-Id: Ib190c074defaa459a8acc738f09af4a65e5d91d1 Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/cocoa/qnsview.mm | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 678f88baa0..5060d7dc25 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -472,6 +472,39 @@ static QTouchDevice *touchDevice = 0; [self handleMouseEvent:theEvent]; } +- (void)updateTrackingAreas +{ + [super updateTrackingAreas]; + + // [NSView addTrackingArea] is slow, so bail out early if we can: + if (NSIsEmptyRect([self visibleRect])) + return; + + QCocoaAutoReleasePool pool; + if (NSArray *trackingArray = [self trackingAreas]) { + NSUInteger size = [trackingArray count]; + for (NSUInteger i = 0; i < size; ++i) { + NSTrackingArea *t = [trackingArray objectAtIndex:i]; + [self removeTrackingArea:t]; + } + } + + // Ideally, we shouldn't have NSTrackingMouseMoved events included below, it should + // only be turned on if mouseTracking, hover is on or a tool tip is set. + // Unfortunately, Qt will send "tooltip" events on mouse moves, so we need to + // turn it on in ALL case. That means EVERY QCocoaView gets to pay the cost of + // mouse moves delivered to it (Apple recommends keeping it OFF because there + // is a performance hit). So it goes. + NSUInteger trackingOptions = NSTrackingMouseEnteredAndExited | NSTrackingActiveInActiveApp + | NSTrackingInVisibleRect | NSTrackingMouseMoved; + NSTrackingArea *ta = [[[NSTrackingArea alloc] initWithRect:[self frame] + options:trackingOptions + owner:self + userInfo:nil] + autorelease]; + [self addTrackingArea:ta]; +} + - (void)mouseMoved:(NSEvent *)theEvent { [self handleMouseEvent:theEvent]; -- cgit v1.2.3 From d4f4ee4e033a62858aaf4f29970bc404d9b4c009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 23 Jan 2013 08:37:12 +0100 Subject: Fixed copy text bug as well as potential other latent xcb plugin bugs. As Gatis found out the copy text bug is caused by the xcb plugin's handleEnterNotifyEvent() receiving an event with a seemingly random "time" member. That is however not due to a bug in the X server but rather due to a missing break statement in the event dispatching in qxcbconnection.cpp, causing an xcb_client_message_event_t to be treated as an xcb_enter_notify_event_t, and thus an xcb_window_t to be treated as an xcb_timestamp_t. The other xcb_enter_notify_event_t values would of course also be complete garbage. Task-number: QTCREATORBUG-8476 Task-number: QTBUG-28398 Change-Id: Id8c09a6682f78b646a0d1d27b0650248bbfa1046 Reviewed-by: Gunnar Sletta Reviewed-by: Gatis Paeglis --- src/plugins/platforms/xcb/qxcbconnection.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 1192894693..d261655cbd 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -770,6 +770,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event) HANDLE_PLATFORM_WINDOW_EVENT(xcb_unmap_notify_event_t, event, handleUnmapNotifyEvent); case XCB_CLIENT_MESSAGE: handleClientMessageEvent((xcb_client_message_event_t *)event); + break; case XCB_ENTER_NOTIFY: HANDLE_PLATFORM_WINDOW_EVENT(xcb_enter_notify_event_t, event, handleEnterNotifyEvent); case XCB_LEAVE_NOTIFY: -- cgit v1.2.3