Re: listen to click events on global.stage/performance between actor button-press-event and stage button-press-event



Since we want clicks in windows to go to the appropriate place, we
have to do special magic to make sure that X is nice and cozy. I'm not
quite sure how expensive this work is for 50 penguin actors though,
and we could probably optimize it a lot, but the main thing is that
you need to add the actor to the chrome:

    let rect = new Clutter.Actor({ x: 50, y: 50, width: 200, height:
200, background_color:
Clutter.Color.from_static(Clutter.StaticColor.YELLOW), reactive: true
});
    rect.connect('button-press-event', function() { /* ... */ });
    Main.layoutManager.addChrome(rect);

This will track the actor's allocation and make sure the Shell is
aware that it wants to receive pointer events and things like that.

On Sun, Jun 3, 2012 at 11:09 PM, Amy C <mathematical coffee gmail com> wrote:
> Hi all,
>
> Is there a way to listen to click events on global.stage whilst
> gnome-shell is running?
>    global.stage.connect("button-press-event", ...)
>
> It connects up fine but clicks are only registered on the top panel
> (w/ activities bar, etc).
> Any click in the window area is not passed through to the stage - I
> assume it is absorbed by the Clutter.Group containing all the window
> actors or something.
>
> I have a bunch of toons running around that have been added to
> global.stage, and I'd like to click on them and have them react.
>
> My other alternative to listening to click events on the stage is to
> set each toon to reactive:true and listen to button-press events for
> each actor.
> However the impression I received from the Openismus Clutter
> documentation[0] was that this was less efficient than the former
> method of listening to the stage's click events and using
> .get_actor_at_pos.
>
> In gnome-shell is this the case? I understand other things like
> .set_motion_events_enabled and .set_throttle_motion_events are already
> true on the global.stage, so perhaps it might be different for this
> case. I can have up to 255 toons running around (well really only
> limited by the user's memory) and just want to know how 255
> button-press listeners compares to a single one + .get_actor_at_pos.
>
> cheers.
>
> [0]: http://www.openismus.com/documents/clutter_tutorial/1.0/docs/tutorial/html/sec-actors-events.html
> _______________________________________________
> gnome-shell-list mailing list
> gnome-shell-list gnome org
> https://mail.gnome.org/mailman/listinfo/gnome-shell-list



-- 
  Jasper


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]