[PATCH 06/10] fullscreen-shell: Support tracking active surfaces

Bryce Harrington bryce at osg.samsung.com
Sat Mar 5 00:18:43 UTC 2016


Surface activity is determined by what surface is being displayed
fullscreen.  Only a single surface can be active in the shell.

Signed-off-by: Bryce Harrington <bryce at osg.samsung.com>
---
 fullscreen-shell/fullscreen-shell.c | 36 ++++++++++++++++++++++++++++++++----
 1 file changed, 32 insertions(+), 4 deletions(-)

diff --git a/fullscreen-shell/fullscreen-shell.c b/fullscreen-shell/fullscreen-shell.c
index abc4e84..f04af0a 100644
--- a/fullscreen-shell/fullscreen-shell.c
+++ b/fullscreen-shell/fullscreen-shell.c
@@ -46,6 +46,7 @@ struct fullscreen_shell {
 	struct wl_listener output_created_listener;
 
 	struct wl_listener seat_created_listener;
+	struct weston_surface *active_surface;
 };
 
 struct fs_output {
@@ -84,12 +85,22 @@ struct pointer_focus_listener {
 };
 
 static void
-pointer_focus_changed(struct wl_listener *listener, void *data)
+pointer_focus_changed(struct wl_listener *l, void *data)
 {
 	struct weston_pointer *pointer = data;
+	struct weston_surface *old_surface;
+	struct pointer_focus_listener *listener;
+
+	listener = container_of(l, struct pointer_focus_listener,
+				seat_destroyed);
 
-	if (pointer->focus && pointer->focus->surface->resource)
+	if (pointer->focus && pointer->focus->surface->resource) {
+		old_surface = listener->shell->active_surface;
+		if (old_surface != NULL)
+			weston_surface_deactivate(old_surface, pointer->seat);
 		weston_surface_activate(pointer->focus->surface, pointer->seat);
+		listener->shell->active_surface = pointer->focus->surface;
+	}
 }
 
 static void
@@ -98,6 +109,7 @@ seat_caps_changed(struct wl_listener *l, void *data)
 	struct weston_seat *seat = data;
 	struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
 	struct weston_pointer *pointer = weston_seat_get_pointer(seat);
+	struct weston_surface *old_surface;
 	struct pointer_focus_listener *listener;
 	struct fs_output *fsout;
 
@@ -116,9 +128,13 @@ seat_caps_changed(struct wl_listener *l, void *data)
 	}
 
 	if (keyboard && keyboard->focus != NULL) {
+		old_surface = listener->shell->active_surface;
 		wl_list_for_each(fsout, &listener->shell->output_list, link) {
 			if (fsout->surface) {
+				if (old_surface != NULL)
+					weston_surface_deactivate(old_surface, seat);
 				weston_surface_activate(fsout->surface, seat);
+				listener->shell->active_surface = fsout->surface;
 				return;
 			}
 		}
@@ -671,6 +687,7 @@ fullscreen_shell_present_surface(struct wl_client *client,
 		wl_resource_get_user_data(resource);
 	struct weston_output *output;
 	struct weston_surface *surface;
+	struct weston_surface *old_surface;
 	struct weston_seat *seat;
 	struct fs_output *fsout;
 
@@ -703,8 +720,13 @@ fullscreen_shell_present_surface(struct wl_client *client,
 			struct weston_keyboard *keyboard =
 				weston_seat_get_keyboard(seat);
 
-			if (keyboard && !keyboard->focus)
+			if (keyboard && !keyboard->focus) {
+				old_surface = shell->active_surface;
+				if (old_surface != NULL)
+					weston_surface_deactivate(old_surface, seat);
 				weston_surface_activate(surface, seat);
+				shell->active_surface = surface;
+			}
 		}
 	}
 }
@@ -729,6 +751,7 @@ fullscreen_shell_present_surface_for_mode(struct wl_client *client,
 		wl_resource_get_user_data(resource);
 	struct weston_output *output;
 	struct weston_surface *surface;
+	struct weston_surface *old_surface;
 	struct weston_seat *seat;
 	struct fs_output *fsout;
 
@@ -754,8 +777,13 @@ fullscreen_shell_present_surface_for_mode(struct wl_client *client,
 		struct weston_keyboard *keyboard =
 			weston_seat_get_keyboard(seat);
 
-		if (keyboard && !keyboard->focus)
+		if (keyboard && !keyboard->focus) {
+			old_surface = shell->active_surface;
+			if (old_surface != NULL)
+				weston_surface_deactivate(old_surface, seat);
 			weston_surface_activate(surface, seat);
+			shell->active_surface = surface;
+		}
 	}
 }
 
-- 
1.9.1



More information about the wayland-devel mailing list