Bug 5176 - Text editor should support zoom gesture on mac
Summary: Text editor should support zoom gesture on mac
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Text Editor ()
Version: Trunk
Hardware: PC Mac OS
: High enhancement
Target Milestone: ---
Assignee: Mikayla Hutchinson [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2012-05-18 13:10 UTC by Mikayla Hutchinson [MSFT]
Modified: 2012-09-24 18:27 UTC (History)
4 users (show)

Tags: gtk
Is this bug a regression?: ---
Last known good build:


Attachments
prototype patch (18.79 KB, patch)
2012-05-25 09:03 UTC, Kristian Rietveld (inactive)
Details
updated patch (20.21 KB, patch)
2012-05-26 05:13 UTC, Kristian Rietveld (inactive)
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Mikayla Hutchinson [MSFT] 2012-05-18 13:10:00 UTC

    
Comment 1 Mikayla Hutchinson [MSFT] 2012-05-18 13:10:45 UTC
Mitch, how hard would it be to expose the Zoom gesture in GTK?
Comment 2 Kristian Rietveld (inactive) 2012-05-18 13:15:43 UTC
For all clarity, you mean the two-finger pinch gesture that is exposed through NSEventTypeMagnify, right?


I would think we can handle this for example by adding a new GdkEvent. Perhaps Mitch has a different idea of how this is best handled.
Comment 3 Mikayla Hutchinson [MSFT] 2012-05-18 13:18:57 UTC
Yes, the trackpad gestures appear to be handleable via overridable methods on NSResponder. Swipe and Rotate may be useful too.

Link to Apple docs, for reference:
http://developer.apple.com/library/mac/#documentation/cocoa/conceptual/EventOverview/HandlingTouchEvents/HandlingTouchEvents.html
Comment 4 Michael Natterer 2012-05-18 14:48:59 UTC
It's absolutely no problem to add a new event, I'm just afraid
we're accumulating special hacks that won't make porting to gtk3
easier at some point :)
Comment 5 Mikayla Hutchinson [MSFT] 2012-05-18 16:00:08 UTC
Yes, that's a valid concern. How would we do this in an xplat way that could be landed into GTK3?
Comment 6 Kristian Rietveld (inactive) 2012-05-19 03:16:34 UTC
I think in GTK+ 3, you would either use the GTK+/GDK-based gesture framework that is in the works.  Or we need to make sure the GTK+/GDK-based gesture framework can "forward" existing native gestures without trying to re-invent the wheel.

This is not something that is easily backported to GTK+ 2.x, that is why I suggested to look into a GdkEvent-based approach.
Comment 7 Kristian Rietveld (inactive) 2012-05-25 09:03:26 UTC
Created attachment 1954 [details]
prototype patch

This patch seems to do the trick, it comes with a simple test program (test gestures).

If you want to see the test program in action, see http://lanedo.com/~kris/testgestures.mov  All three gestures are used: magnify (pinch), rotate and (three finger) swipe.


Items of consideration:
 - Currently there are three different events for Magnify, Rotate, Swipe.  Seemed cleanest to me, though merging into a single event is possible if desired.

 - Perhaps we want to prefix the event names with "gesture-" to avoid possible namespace clashes? So you get gesture-magnify-event and GDK_GESTURE_MAGNIFY.

 - Double check the event handling, but it seems to be doing the trick.


I will ask Mitch to review the code so it has seen two pairs of eyes.
Comment 8 Kristian Rietveld (inactive) 2012-05-25 09:09:05 UTC
About GTK+ 3 support; this patch will never make it upstream because a proper, generic gesture framework is in the works. What would be needed to do this in GTK+ 3 is:

 - The gesture framework has to be landed in GTK+ 3.
 - We need a GdkDevice class specific to the OS X touchpad API, such that multi touch events can be fed into the gesture framework.  (Two years ago I started working on this, but didn't complete it. The code which I still have around somewhere could work as a foundation to get this completed).


Until the gesture framework is in GTK+ 3, the proposed patch could also be applied to have a custom GTK+ 3 distribution.
Comment 9 Michael Natterer 2012-05-25 09:20:32 UTC
This looks very proper to me.
Comment 10 Mikayla Hutchinson [MSFT] 2012-05-25 12:08:27 UTC
Thanks, I've been able to apply it in bockbuild and build successfully.

The gesture- prefix sounds good. I don't know about merging into a single event. One thing that would be useful would be a gdk_supports_quartz_gestures() function, so we can test for the existence of the functionality before using the signal enum values.

Next, we'll have to add wrappers in GtkWorkarounds, and consume them from the zoomable widgets (text editor and pad trees).
Comment 11 Kristian Rietveld (inactive) 2012-05-26 05:13:56 UTC
Created attachment 1965 [details]
updated patch

Updated patch, changes:

 - Prefix event names and signal names with "gesture-"

 - Added symbol gdk_quartz_supports_gesture_events() so availability of functionality can be checked by attempting to resolve the symbol.
Comment 12 Mikayla Hutchinson [MSFT] 2012-05-29 23:41:35 UTC
The patch works great, thanks!

I had some trouble debugging marshalling the event into managed code, and it turned out Mono's struct layout didn't match the gcc one - it was trying to align the doubles to 8 bytes (filed as bug 5405). I was able to fix that without C getter functions, by overriding the struct packing, but it'll probably cause problems if/when we do a 64-bit port. But that's incredibly low on the priority list right now, and we have a bunch of similar cases in MD already, so IMO we should leave the patch as-is.

I've landed the patch in bockbuild and landed the wrapper code in MD. I'll land the patches for text editor zoom support after some cleanup.
Comment 13 Mikayla Hutchinson [MSFT] 2012-06-01 12:26:38 UTC
Fixed in master.
Comment 14 David Siegel 2012-09-24 18:27:37 UTC
This feels pretty horrid, guys...