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 648788 - StScrollBar: use clutter_grab_pointer()
StScrollBar: use clutter_grab_pointer()
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: st
unspecified
Other All
: Normal normal
: ---
Assigned To: Colin Walters
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2011-04-27 17:02 UTC by Dan Winship
Modified: 2013-02-15 00:22 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
StScrollBar: use clutter_grab_pointer() (6.50 KB, patch)
2011-04-27 17:02 UTC, Dan Winship
reviewed Details | Review
StScrollBar: use clutter_grab_pointer() (6.94 KB, patch)
2011-10-29 01:19 UTC, Jasper St. Pierre (not reading bugmail)
none Details | Review

Description Dan Winship 2011-04-27 17:02:19 UTC
StScrollBar was intercepting motion events by using captured-event on
the stage, which required additional dirty tricks, which required
additional hacks. Simplify it by just using clutter_grab_pointer()
instead.
Comment 1 Dan Winship 2011-04-27 17:02:20 UTC
Created attachment 186758 [details] [review]
StScrollBar: use clutter_grab_pointer()
Comment 2 Dan Winship 2011-05-16 10:40:19 UTC
poke
Comment 3 Colin Walters 2011-05-16 19:18:30 UTC
There was a reason we weren't grabbing the pointer before, no?  Probably because it breaks if we already had a pointer grab?

I guess this behavior was imported from Mx.  For reference, the current Mx sources still use a capture handler:
https://github.com/clutter-project/mx/blob/master/mx/mx-scroll-bar.c

From some grepping around it looks unlikely we'd hit this situation, but...

"which required additional dirty tricks, which required
additional hacks. "

Code cleanup can be good, but I'd like to know the underlying motivation.  Does this fix a bug you were actually hitting? Or you were just hacking on the popup code and thought it was ugly?
Comment 4 Dan Winship 2011-05-16 19:56:38 UTC
(In reply to comment #3)
> There was a reason we weren't grabbing the pointer before, no?
> ...
> I guess this behavior was imported from Mx.

Hm... it appears that it originally used a pointer grab and was then changed:

https://github.com/clutter-project/mx/commit/2475dd491cf9e0379c0847d268c13378f5b293e8#nbtk/nbtk-scroll-bar.c

The commit message doesn't explain why though.

> Code cleanup can be good, but I'd like to know the underlying motivation.  Does
> this fix a bug you were actually hitting? Or you were just hacking on the popup
> code and thought it was ugly?

Bug 643687 would have required porting PopupMenuManager's "passEvents" hack over to GrabHelper, and it made more sense to just make the hack unnecessary.
Comment 5 Dan Winship 2011-05-16 19:58:54 UTC
Emmanuele: any idea why MxScrollBar would have switched away from using clutter_grab_pointer()? (see comment above)
Comment 6 Emmanuele Bassi (:ebassi) 2011-05-16 23:26:30 UTC
(In reply to comment #5)
> Emmanuele: any idea why MxScrollBar would have switched away from using
> clutter_grab_pointer()? (see comment above)

because grabs are generally evil, and we tend to use the capture event as a "soft grab", since it allows other code to run, including stacking gestures and pointer operations.

I honestly have no idea what kinds of hacks did you feel were necessary: the patch seems to just use the capture to disable the motion events while the pointer is pressed, and do other things with scrolling. can you describe what the "pass event" hack is? the whole point of using the capture event is to allow children to get events even though the parent is currently inside a pointer-related operation.
Comment 7 Dan Winship 2011-05-17 14:17:43 UTC
(In reply to comment #6)
> I honestly have no idea what kinds of hacks did you feel were necessary

The shell PopupMenu also uses captured-event, to block events outside the menu. (Eg, a click outside the menu should get eaten after dismissing the menu, and so therefore also, enter/leave events outside the menu should get eaten, because things outside the menu shouldn't prelight when the menu is up.) But StScrollBar calls clutter_set_motion_events_enabled(FALSE) and then watches for motion events on the stage, but our captured-event handler blocks those events, since the stage isn't inside the menu. So we had to add a hack to set a flag when scroll-start is emitted, and then just immediately return false from the captured-event handler if that flag is set.

Changing StScrollBar to use clutter_grab_pointer() instead fixes the problem without needing any changes to PopupMenu, because when the scroll bar has the pointer grab, our captured-event handler doesn't get a chance to run.

> the whole point of using the capture event is to
> allow children to get events even though the parent is currently inside a
> pointer-related operation.

No, not here. StScrollBar's handle_capture_event_cb() always returns TRUE, so no one else gets any events. Which is the desired behavior, I think, which is why using a pointer grab makes sense.
Comment 8 Emmanuele Bassi (:ebassi) 2011-05-23 14:57:05 UTC
(In reply to comment #7)
 
> > the whole point of using the capture event is to
> > allow children to get events even though the parent is currently inside a
> > pointer-related operation.
> 
> No, not here. StScrollBar's handle_capture_event_cb() always returns TRUE, so
> no one else gets any events. Which is the desired behavior, I think, which is
> why using a pointer grab makes sense.

then yes: if you're preventing every other actor from receiving events then using a real grab makes more sense than using a capture. that is not always the case, and especially with touches and gestures you really don't want to have exclusive grabs in place.
Comment 9 Dan Winship 2011-06-06 18:32:23 UTC
(In reply to comment #8)
> then yes: if you're preventing every other actor from receiving events then
> using a real grab makes more sense than using a capture.

ok, so, Colin? rereview?
Comment 10 Colin Walters 2011-08-02 20:51:38 UTC
Review of attachment 186758 [details] [review]:

One very minor comment.

::: src/st/st-scroll-bar.c
@@ +867,3 @@
   priv->x_origin += clutter_actor_get_x (priv->trough);
   priv->y_origin += clutter_actor_get_y (priv->trough);
 

A g_assert (!priv->grabbed) might be nice here.
Comment 11 Jasper St. Pierre (not reading bugmail) 2011-10-29 01:19:47 UTC
Created attachment 200230 [details] [review]
StScrollBar: use clutter_grab_pointer()

StScrollBar was intercepting motion events by using captured-event on
the stage, which required additional dirty tricks, which required
additional hacks. Simplify it by just using clutter_grab_pointer()
instead.



I'm picking these patches up now. Sorry Dan.
Comment 12 Jasper St. Pierre (not reading bugmail) 2013-02-15 00:22:32 UTC
Patch was committed as part of grab helper work in 3.6 message tray.