After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 683382 - Add support for touch events (and ClutterGestureAction)
Add support for touch events (and ClutterGestureAction)
Status: RESOLVED OBSOLETE
Product: mutter
Classification: Core
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: mutter-maint
mutter-maint
touch
Depends on:
Blocks:
 
 
Reported: 2012-09-05 07:03 UTC by Tomeu Vizoso
Modified: 2013-01-16 16:37 UTC
See Also:
GNOME target: 3.8
GNOME version: ---



Description Tomeu Vizoso 2012-09-05 07:03:55 UTC
Rewriting Mutter's event handling to use XInput2 (bug 681082) instead of core events is probably a much bigger amount of work than what is actually required to handle touch events within Mutter.

http://cgit.collabora.com/git/user/tomeu/mutter/log/?h=touch-clutter

This branch leaves Gdk handling only core events but allows plugins to select for touch events through XInput2, and passes them to Clutter. As you can see, the changes to Mutter are minimal and not invasive at all, and the supporting changes to Clutter have been accepted upstream already.

All the API additions to libmutter could be implemented in plugins themselves, but I think it makes sense to have it in the library.

One of the changes is choosing the XInput input backend in Clutter instead of the core one, but it's anyway going to become the default soon on X11.

This is an example of a plugin that registers for all touch events before they reach any other client and accepts or rejects touch sequences depending on whether the gesture is recognized as system-wide:

http://cgit.collabora.com/git/user/tomeu/mutter-examples/tree/src/mutter-gesture-plugin.c
Comment 1 Jasper St. Pierre (not reading bugmail) 2012-09-05 13:40:05 UTC
So, right now mutter works by taking GDK events, doing some basic processing, and slapping them into mutter (and sometimes making fake GDK events and forwarding them to GTK+, ugh this is ugly)

http://git.gnome.org/browse/mutter/tree/src/ui/ui.c#n60

What you're doing is allowing an opportunity for random plugins to make up XInput2 events, and then slap them into Clutter as well?
Comment 2 Jasper St. Pierre (not reading bugmail) 2012-09-05 13:41:20 UTC
http://cgit.collabora.com/git/user/tomeu/mutter/commit/?h=touch-clutter&id=f5ab495527361037c41eef0b47a551a040711722

It doesn't seem like you ever initialize xi_opcode here. You need to call XInputQueryExtension and all that.
Comment 3 Tomeu Vizoso 2012-09-05 13:56:06 UTC
(In reply to comment #1)
> So, right now mutter works by taking GDK events, doing some basic processing,
> and slapping them into mutter (and sometimes making fake GDK events and
> forwarding them to GTK+, ugh this is ugly)
> 
> http://git.gnome.org/browse/mutter/tree/src/ui/ui.c#n60
> 
> What you're doing is allowing an opportunity for random plugins to make up
> XInput2 events

I'm adding API to libmutter for doing that, plugins already have that opportunity.

> and then slap them into Clutter as well?

Well, events end up in Clutter already, by default and also explicitly in GNOME Shell:

http://git.gnome.org/browse/gnome-shell/tree/src/gnome-shell-plugin.c#n337
http://git.gnome.org/browse/mutter/tree/src/compositor/meta-plugin-manager.c#n311
Comment 4 Tomeu Vizoso 2012-09-05 13:56:59 UTC
(In reply to comment #2)
> http://cgit.collabora.com/git/user/tomeu/mutter/commit/?h=touch-clutter&id=f5ab495527361037c41eef0b47a551a040711722
> 
> It doesn't seem like you ever initialize xi_opcode here. You need to call
> XInputQueryExtension and all that.

That's done in meta_screen_grab_touch_events:

http://cgit.collabora.com/git/user/tomeu/mutter/commit/?h=touch-clutter&id=93194c3b2ba65bcbd633a302fbdde1665073a1ec
Comment 5 Jasper St. Pierre (not reading bugmail) 2012-09-05 14:13:27 UTC
(In reply to comment #4)
> (In reply to comment #2)
> > http://cgit.collabora.com/git/user/tomeu/mutter/commit/?h=touch-clutter&id=f5ab495527361037c41eef0b47a551a040711722
> > 
> > It doesn't seem like you ever initialize xi_opcode here. You need to call
> > XInputQueryExtension and all that.
> 
> That's done in meta_screen_grab_touch_events:
> 
> http://cgit.collabora.com/git/user/tomeu/mutter/commit/?h=touch-clutter&id=93194c3b2ba65bcbd633a302fbdde1665073a1ec

Bad commit order, then. You introduce xi_opcode in the display structure after that commit.
Comment 6 Jasper St. Pierre (not reading bugmail) 2012-09-05 14:13:49 UTC
http://cgit.collabora.com/git/user/tomeu/mutter/commit/?h=touch-clutter&id=3e354b1267d0414f51e4b265979906aac5786453

Looks fine, commit to master please.
Comment 7 Tomeu Vizoso 2012-09-05 14:59:04 UTC
(In reply to comment #6)
> http://cgit.collabora.com/git/user/tomeu/mutter/commit/?h=touch-clutter&id=3e354b1267d0414f51e4b265979906aac5786453
> 
> Looks fine, commit to master please.

Done

(In reply to comment #5)
> 
> Bad commit order, then. You introduce xi_opcode in the display structure after
> that commit.

You are right, have moved it to the commit where it belongs.
Comment 8 Frederic Plourde 2012-10-18 14:03:34 UTC
Hi Jasper, I'm newly assigned to upstreaming Mutter support for touch events, which my colleague Tomeu wrote.

If you don't mind, I'd like us to consider once more the five last changes of :
http://cgit.collabora.com/git/user/tomeu/mutter/log/?h=touch-clutter

... see if you would accept it in Mutter as-is. In our opinion, it's a rather small/non-invasive patch. What do you think ?

tnx.
Comment 9 Jasper St. Pierre (not reading bugmail) 2012-10-18 14:13:05 UTC
In my opinion, this is a temporary solution until we rebase Carlos's wip/xinput2 and wip/multitouch branches properly, but I'm not the mutter maintainer. Florian or Owen would be better people to ask for that.

Having someone do at least the wip/xinput2 branch would be more than enough for what you want, I think. If you want to take a stab at that, that's fine with me. If not, I'll take a very basic shot today and see what I can accomplish.
Comment 10 Tomeu Vizoso 2012-10-18 15:19:55 UTC
(In reply to comment #9)
> In my opinion, this is a temporary solution until we rebase Carlos's
> wip/xinput2 and wip/multitouch branches properly, but I'm not the mutter
> maintainer. Florian or Owen would be better people to ask for that.
> 
> Having someone do at least the wip/xinput2 branch would be more than enough for
> what you want, I think. If you want to take a stab at that, that's fine with
> me. If not, I'll take a very basic shot today and see what I can accomplish.

I gave that a try (see bug 681082), and besides the massive bitrot (it basically refactors all the event handling), it's not really that related to multitouch gestures.
Comment 11 Jasper St. Pierre (not reading bugmail) 2012-10-18 21:08:22 UTC
I just spent the afternoon updating the wip/xinput2 branch. It's building now, will push when it's as good as the first one.
Comment 12 Jasper St. Pierre (not reading bugmail) 2012-11-03 22:09:59 UTC
XI2 should land in 3.8, as it's required for pointer barrier work. After that, you can rebase your patches on top of this. Are you going to be looking at the wip/multitouch branch at all?
Comment 13 Tomeu Vizoso 2012-11-07 07:37:39 UTC
(In reply to comment #12)
> XI2 should land in 3.8, as it's required for pointer barrier work. After that,
> you can rebase your patches on top of this. Are you going to be looking at the
> wip/multitouch branch at all?

Not sure, as I have for one moved to other things, but I think that at some point we are going to want to rebase on top of Mutter 3.8 the ability of plugins to use touch-based ClutterGestureAction subclasses. AFAIR, wip/multitouch handles touch gestures using the XI2 API directly.
Comment 14 Jasper St. Pierre (not reading bugmail) 2012-11-07 07:52:16 UTC
Simply porting mutter to XI2 and having the events fall through to Clutter like it happens normally with the event filter should be enough, right? That will happen for 3.8.
Comment 15 Tomeu Vizoso 2012-11-07 14:22:14 UTC
(In reply to comment #14)
> Simply porting mutter to XI2 and having the events fall through to Clutter like
> it happens normally with the event filter should be enough, right?

Yup, I expect so.
Comment 16 Jasper St. Pierre (not reading bugmail) 2012-11-15 23:27:58 UTC
Update on this:

I don't think these patches are appropriate quite yet. If you are comfortable using raw XI2 in your plugin for multitouch, that only leaves:

http://cgit.collabora.com/git/user/tomeu/mutter/commit/?h=touch-clutter&id=2f7ae608484690492ec15c36d1de8a2b64d105c1

and

http://cgit.collabora.com/git/user/tomeu/mutter/commit/?h=touch-clutter&id=beccb0f3394ee4f7691ec2eeaa62063e3ec58606

as the commits that need to land in mutter. The first will obviously be part of the XI2 port; the second seems like an extremely awkward workaround. Why not just grab the stage window instead?
Comment 17 Emmanuele Bassi (:ebassi) 2012-12-19 09:48:15 UTC
(In reply to comment #16)
> Update on this:
> 
> I don't think these patches are appropriate quite yet. If you are comfortable
> using raw XI2 in your plugin for multitouch, that only leaves:
> 
> http://cgit.collabora.com/git/user/tomeu/mutter/commit/?h=touch-clutter&id=2f7ae608484690492ec15c36d1de8a2b64d105c1

as of Clutter 1.13.2, this is not necessary any more, as I switched Clutter/X11 to use XInput by default:

http://git.gnome.org/browse/clutter/commit/?id=47c1e26385a3451048f6e2166576b931ed8895aa

the clutter_x11_enable_xinput() function does not do anything, and it's been deprecated; if something does break, I can still revert it, but given that clutter-gtk has been enabling XInput for a couple of years, I think we're on the safe side for XInput interaction with an embedding environment like Mutter.
Comment 18 Jasper St. Pierre (not reading bugmail) 2012-12-19 09:57:21 UTC
mutter has been ported to XI2. Future regressions and things that may be necessary to allow ClutterGestureAction will be in future patches.