[PATCH weston v2 03/10] compositor: Track surface activity

Bryce Harrington bryce at osg.samsung.com
Thu Apr 7 23:07:14 UTC 2016


On Mon, Mar 28, 2016 at 06:17:43PM -0700, Bryce Harrington wrote:
> On Mon, Mar 28, 2016 at 10:25:24AM +0300, Giulio Camuffo wrote:
> > 2016-03-24 20:27 GMT+02:00 Bryce Harrington <bryce at osg.samsung.com>:
> > > Surfaces flagged as 'active' are considered of primary urgency to the
> > > user.  It might be the surface with the keyboard focus or displaying
> > > something important; the exact specification of what 'active' means is
> > > left as shell-specific.
> > >
> > > An 'active' surface may be granted special treatment by the compositor.
> > > For instance, it may only honor inhibition requests by active surfaces.
> > >
> > > Signed-off-by: Bryce Harrington <bryce at osg.samsung.com>
> > > ---
> > >  src/compositor.c | 41 +++++++++++++++++++++++++++++++++++++++++
> > >  src/compositor.h | 20 +++++++++++++++++---
> > >  src/input.c      | 15 ---------------
> > >  3 files changed, 58 insertions(+), 18 deletions(-)
> > >
> > > diff --git a/src/compositor.c b/src/compositor.c
> > > index 4b091b0..574a0b8 100644
> > > --- a/src/compositor.c
> > > +++ b/src/compositor.c
> > > @@ -612,6 +612,7 @@ weston_surface_create(struct weston_compositor *compositor)
> > >         weston_matrix_init(&surface->buffer_to_surface_matrix);
> > >         weston_matrix_init(&surface->surface_to_buffer_matrix);
> > >
> > > +       surface->active = false;
> > >         surface->inhibit_screensaving = false;
> > >
> > >         return surface;
> > > @@ -3424,6 +3425,46 @@ weston_surface_copy_content(struct weston_surface *surface,
> > >                                          src_x, src_y, width, height);
> > >  }
> > >
> > > +/** Set surface as active.
> > > + *
> > > + *  Marks a surface as considered 'active' by the shell
> > > + *  and gives the surface keyboard focus.
> > > + */
> > > +WL_EXPORT void
> > > +weston_surface_activate(struct weston_surface *surface,
> > > +                        struct weston_seat *seat)
> > 
> > weston_surface_activate was previously only setting the keyboard
> > focus, even though the name of the function was maybe ill chosen. Now
> > you're giving it another meaning, that is it sets the 'active' state
> > of the surface (as the name of the function suggests) but you're
> > keeping the old meaning too.
> 
> Yeah, I know, it seems a bit awkward to me too.
> 
> > I would split them apart, a shell may
> > want to e.g. set also the pointer focus surface as active, while
> > keeping the keyboard focus where it is.
> 
> I was tempted to do this too, but wasn't sure if that might be too
> invasive of a change?

I went ahead and did this change and will post v3 directly.

In fact it did require tweaks to each of the shells, although the
changes were reasonably contained.

Thanks again,
Bryce
 
> Thanks for the review,
> Bryce
> 
> > Cheers,
> > Giulio
> > 
> > > +{
> > > +        struct weston_compositor *compositor = seat->compositor;
> > > +        struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
> > > +
> > > +       surface->active = true;
> > > +
> > > +        if (keyboard) {
> > > +                weston_keyboard_set_focus(keyboard, surface);
> > > +                wl_data_device_set_keyboard_focus(seat);
> > > +        }
> > > +
> > > +        wl_signal_emit(&compositor->activate_signal, surface);
> > > +}
> > > +
> > > +/** Set surface as inactive.
> > > + *
> > > + *  Marks a surface as no longer considered 'active' by the shell.
> > > + *  Note that this does not change keyboard focus.
> > > + */
> > > +WL_EXPORT void
> > > +weston_surface_deactivate(struct weston_surface *surface,
> > > +                          struct weston_seat *seat)
> > > +{
> > > +       surface->active = false;
> > > +}
> > > +
> > > +WL_EXPORT bool
> > > +weston_surface_is_active(struct weston_surface *surface)
> > > +{
> > > +       return surface->active;
> > > +}
> > > +
> > >  static void
> > >  subsurface_set_position(struct wl_client *client,
> > >                         struct wl_resource *resource, int32_t x, int32_t y)
> > > diff --git a/src/compositor.h b/src/compositor.h
> > > index d982feb..9a9ab1a 100644
> > > --- a/src/compositor.h
> > > +++ b/src/compositor.h
> > > @@ -1039,11 +1039,19 @@ struct weston_surface {
> > >         struct weston_timeline_object timeline;
> > >
> > >         /*
> > > +        * A shell-specific indicator that the surface is in immediate
> > > +        * use by the user.  For example, the surface might have keyboard
> > > +        * focus.
> > > +        */
> > > +       bool active;
> > > +
> > > +       /*
> > >          * Indicates the surface prefers no screenblanking, screensaving,
> > >          * or other automatic obscurement to kick in while the surface is
> > >          * considered "active" by the shell.
> > >          */
> > >         bool inhibit_screensaving;
> > > +
> > >  };
> > >
> > >  struct weston_subsurface {
> > > @@ -1129,9 +1137,6 @@ int
> > >  weston_spring_done(struct weston_spring *spring);
> > >
> > >  void
> > > -weston_surface_activate(struct weston_surface *surface,
> > > -                       struct weston_seat *seat);
> > > -void
> > >  notify_motion(struct weston_seat *seat, uint32_t time,
> > >               struct weston_pointer_motion_event *event);
> > >  void
> > > @@ -1409,6 +1414,15 @@ weston_surface_copy_content(struct weston_surface *surface,
> > >                             int src_x, int src_y,
> > >                             int width, int height);
> > >
> > > +void
> > > +weston_surface_activate(struct weston_surface *surface,
> > > +                       struct weston_seat *seat);
> > > +void
> > > +weston_surface_deactivate(struct weston_surface *surface,
> > > +                         struct weston_seat *seat);
> > > +bool
> > > +weston_surface_is_active(struct weston_surface *surface);
> > > +
> > >  struct weston_buffer *
> > >  weston_buffer_from_resource(struct wl_resource *resource);
> > >
> > > diff --git a/src/input.c b/src/input.c
> > > index a3d982e..6e35105 100644
> > > --- a/src/input.c
> > > +++ b/src/input.c
> > > @@ -1206,21 +1206,6 @@ notify_motion_absolute(struct weston_seat *seat,
> > >  }
> > >
> > >  WL_EXPORT void
> > > -weston_surface_activate(struct weston_surface *surface,
> > > -                       struct weston_seat *seat)
> > > -{
> > > -       struct weston_compositor *compositor = seat->compositor;
> > > -       struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
> > > -
> > > -       if (keyboard) {
> > > -               weston_keyboard_set_focus(keyboard, surface);
> > > -               wl_data_device_set_keyboard_focus(seat);
> > > -       }
> > > -
> > > -       wl_signal_emit(&compositor->activate_signal, surface);
> > > -}
> > > -
> > > -WL_EXPORT void
> > >  notify_button(struct weston_seat *seat, uint32_t time, int32_t button,
> > >               enum wl_pointer_button_state state)
> > >  {
> > > --
> > > 1.9.1
> > >
> > > _______________________________________________
> > > wayland-devel mailing list
> > > wayland-devel at lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/wayland-devel
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list