Skip to content

Commit

Permalink
Cocoa: rename IsMouseOrKeyEvent -> isUserInputEvent
Browse files Browse the repository at this point in the history
This matches the intended use of this function. Reformat
to modern Qt style.

Change-Id: I076d2bdb3ac14b346f0dc6934f7a47765badc6b0
Reviewed-by: Timur Pocheptsov <[email protected]>
  • Loading branch information
Morten Johan Sørvig committed Oct 29, 2019
1 parent 58a67e4 commit b56e856
Showing 1 changed file with 32 additions and 36 deletions.
68 changes: 32 additions & 36 deletions src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
Original file line number Diff line number Diff line change
Expand Up @@ -293,46 +293,42 @@ static Boolean runLoopSourceEqualCallback(const void *info1, const void *info2)
return qGlobalPostedEventsCount() || (qt_is_gui_used && !CFRunLoopIsWaiting(CFRunLoopGetMain()));
}

static bool IsMouseOrKeyEvent( NSEvent* event )
static bool isUserInputEvent(NSEvent* event)
{
bool result = false;

switch( [event type] )
{
case NSEventTypeLeftMouseDown:
case NSEventTypeLeftMouseUp:
case NSEventTypeRightMouseDown:
case NSEventTypeRightMouseUp:
case NSEventTypeMouseMoved: // ??
case NSEventTypeLeftMouseDragged:
case NSEventTypeRightMouseDragged:
case NSEventTypeMouseEntered:
case NSEventTypeMouseExited:
case NSEventTypeKeyDown:
case NSEventTypeKeyUp:
case NSEventTypeFlagsChanged: // key modifiers changed?
case NSEventTypeCursorUpdate: // ??
case NSEventTypeScrollWheel:
case NSEventTypeTabletPoint:
case NSEventTypeTabletProximity:
case NSEventTypeOtherMouseDown:
case NSEventTypeOtherMouseUp:
case NSEventTypeOtherMouseDragged:
switch ([event type]) {
case NSEventTypeLeftMouseDown:
case NSEventTypeLeftMouseUp:
case NSEventTypeRightMouseDown:
case NSEventTypeRightMouseUp:
case NSEventTypeMouseMoved: // ??
case NSEventTypeLeftMouseDragged:
case NSEventTypeRightMouseDragged:
case NSEventTypeMouseEntered:
case NSEventTypeMouseExited:
case NSEventTypeKeyDown:
case NSEventTypeKeyUp:
case NSEventTypeFlagsChanged: // key modifiers changed?
case NSEventTypeCursorUpdate: // ??
case NSEventTypeScrollWheel:
case NSEventTypeTabletPoint:
case NSEventTypeTabletProximity:
case NSEventTypeOtherMouseDown:
case NSEventTypeOtherMouseUp:
case NSEventTypeOtherMouseDragged:
#ifndef QT_NO_GESTURES
case NSEventTypeGesture: // touch events
case NSEventTypeMagnify:
case NSEventTypeSwipe:
case NSEventTypeRotate:
case NSEventTypeBeginGesture:
case NSEventTypeEndGesture:
case NSEventTypeGesture: // touch events
case NSEventTypeMagnify:
case NSEventTypeSwipe:
case NSEventTypeRotate:
case NSEventTypeBeginGesture:
case NSEventTypeEndGesture:
#endif // QT_NO_GESTURES
result = true;
return true;
break;

default:
default:
break;
}
return result;
return false;
}

static inline void qt_mac_waitForMoreEvents(NSString *runLoopMode = NSDefaultRunLoopMode)
Expand Down Expand Up @@ -465,7 +461,7 @@ static inline void qt_mac_waitForMoreEvents(NSString *runLoopMode = NSDefaultRun
dequeue: YES];

if (event) {
if (IsMouseOrKeyEvent(event)) {
if (isUserInputEvent(event)) {
[event retain];
d->queuedUserInputEvents.append(event);
continue;
Expand All @@ -485,7 +481,7 @@ static inline void qt_mac_waitForMoreEvents(NSString *runLoopMode = NSDefaultRun

if (event) {
if (flags & QEventLoop::ExcludeUserInputEvents) {
if (IsMouseOrKeyEvent(event)) {
if (isUserInputEvent(event)) {
[event retain];
d->queuedUserInputEvents.append(event);
continue;
Expand Down

0 comments on commit b56e856

Please sign in to comment.