From 3049e6394a3376f7fff1c8cde19fd7bb1a9252ec Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Sat, 5 Aug 2023 12:19:35 +0200 Subject: #733 partial: Adds rotation gesture event on MacOS --- src/Fl_cocoa.mm | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src') diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 8aef33780..f461505ee 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -965,6 +965,32 @@ static void cocoaMagnifyHandler(NSEvent *theEvent) #endif } +/* + * Cocoa Rotate Gesture Handler + */ +static void cocoaRotateHandler(NSEvent *theEvent) +{ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 + fl_lock_function(); + Fl_Window *window = (Fl_Window*)[(FLWindow*)[theEvent window] getFl_Window]; + if ( !window->shown() ) { + fl_unlock_function(); + return; + } + Fl::first_window(window); + Fl::e_dy = [theEvent rotation]*1000; + if ( Fl::e_dy) { + NSPoint pos = [theEvent locationInWindow]; + pos.y = window->h() - pos.y; + NSUInteger mods = [theEvent modifierFlags]; + mods_to_e_state( mods ); + update_e_xy_and_e_xy_root([theEvent window]); + Fl::handle( FL_ROTATE_GESTURE, window ); + } + fl_unlock_function(); +#endif +} + /* * Cocoa Mouse Button Handler */ @@ -2439,6 +2465,9 @@ static FLTextInputContext* fltextinputcontext_instance = nil; - (void)magnifyWithEvent:(NSEvent *)theEvent { cocoaMagnifyHandler(theEvent); } +- (void)rotateWithEvent:(NSEvent *)theEvent { + cocoaRotateHandler(theEvent); +} - (void)keyDown:(NSEvent *)theEvent { //NSLog(@"keyDown:%@",[theEvent characters]); fl_lock_function(); -- cgit v1.2.3