Skip to content

Add skeletal implementation of NSGestureRecognizer#364

Open
gcasa wants to merge 13 commits into
masterfrom
NSGestureRecognizer_branch
Open

Add skeletal implementation of NSGestureRecognizer#364
gcasa wants to merge 13 commits into
masterfrom
NSGestureRecognizer_branch

Conversation

@gcasa
Copy link
Copy Markdown
Member

@gcasa gcasa commented Sep 21, 2025

Implement Gesture recognition logic

@gcasa gcasa marked this pull request as ready for review September 21, 2025 22:43
@gcasa gcasa requested a review from fredkiefer as a code owner September 21, 2025 22:43
@gcasa gcasa requested review from Copilot and rfm September 21, 2025 22:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements skeletal implementations of several NSGestureRecognizer subclasses and enhances NSEvent to support magnification gestures. The implementation provides a comprehensive gesture recognition framework with concrete recognizers for common gesture types.

  • Implements NSGestureRecognizer base class with state management, target-action patterns, and delegate support
  • Adds concrete gesture recognizers for click, pan, press, rotation, and magnification gestures with complete event handling
  • Extends NSEvent to support magnification properties for enhanced gesture recognition capabilities

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
NSGestureRecognizer.m Core gesture recognizer base class implementation with state management and event handling
NSClickGestureRecognizer.m Click gesture recognizer with button mask and multi-click support
NSPanGestureRecognizer.m Pan gesture recognizer with translation/velocity tracking and multi-button support
NSPressGestureRecognizer.m Press-and-hold gesture recognizer with timer-based duration validation
NSRotationGestureRecognizer.m Rotation gesture recognizer supporting both mouse and scroll wheel input
NSMagnificationGestureRecognizer.m Magnification gesture recognizer for zoom operations
NSEvent.m Enhanced mouse event creation and serialization to support magnification data
Headers/AppKit/*.h Updated header files with comprehensive documentation and API definitions

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread Source/NSEvent.m
Comment thread Source/NSPressGestureRecognizer.m Outdated
Comment thread Source/NSPanGestureRecognizer.m
Comment thread Headers/AppKit/NSPressGestureRecognizer.h
Comment thread Source/NSMagnificationGestureRecognizer.m
gcasa and others added 3 commits September 21, 2025 18:46
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@gcasa
Copy link
Copy Markdown
Member Author

gcasa commented Sep 24, 2025

I think this PR is ready as well, @fredkiefer / @rfm

Comment thread Source/NSEvent.m
case NSOtherMouseDragged:
case NSRightMouseDragged:
[aDecoder decodeValuesOfObjCTypes: "iififff",
[aDecoder decodeValuesOfObjCTypes: "iififfff",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not change the encoding/decoding without changing the version number and checking on the version when decoding.

Comment thread Headers/AppKit/NSEvent.h
deltaY: (CGFloat)deltaY
deltaZ: (CGFloat)deltaZ;
deltaZ: (CGFloat)deltaZ
magnification: (CGFloat)magnificationValue;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remember correctly we actually use this method in the MS Windows backend. Changing it here without a change there will break things. The best way to process would be to add a new method here with the additional argument, add that argument to all the backend code that uses the old method and after the next GNUstep release, remove the old method without that argument.

*/

#import <AppKit/NSGestureRecognizer.h>
#import <AppKit/NSEvent.h>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally we would include the AppKit headers here with "" instead of <>. This allows local headers to be found before installed ones and could make a difference when headers change.

if (_state == state)
return;

NSGestureRecognizerState oldState = _state;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why store the old state when nothing gets done with it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants