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 <[email protected]>
---
 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)
+{
+        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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to