[PATCH weston v3 5/8] fullscreen-shell: Support tracking active surfaces

Bryce Harrington bryce at osg.samsung.com
Thu Apr 7 23:44:20 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 | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/fullscreen-shell/fullscreen-shell.c b/fullscreen-shell/fullscreen-shell.c
index e1f8a63..8b1930f 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,14 +85,23 @@ 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) {
+		old_surface = listener->shell->active_surface;
+		if (old_surface != NULL)
+			weston_surface_deactivate(old_surface);
 		weston_surface_assign_keyboard(pointer->focus->surface, pointer->seat);
 		if (pointer->focus->surface != NULL)
 			weston_surface_activate(pointer->focus->surface);
+		listener->shell->active_surface = pointer->focus->surface;
 	}
 }
 
@@ -101,6 +111,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;
 
@@ -119,11 +130,15 @@ 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);
 				weston_surface_assign_keyboard(fsout->surface, seat);
 				if (fsout->surface != NULL)
 					weston_surface_activate(fsout->surface);
+				listener->shell->active_surface = fsout->surface;
 				return;
 			}
 		}
@@ -676,6 +691,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;
 
@@ -709,9 +725,13 @@ fullscreen_shell_present_surface(struct wl_client *client,
 				weston_seat_get_keyboard(seat);
 
 			if (keyboard && !keyboard->focus) {
+				old_surface = shell->active_surface;
+				if (old_surface != NULL)
+					weston_surface_deactivate(old_surface);
 				weston_surface_assign_keyboard(surface, seat);
 				if (surface != NULL)
 					weston_surface_activate(surface);
+				shell->active_surface = surface;
 			}
 		}
 	}
@@ -737,6 +757,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;
 
@@ -763,9 +784,13 @@ fullscreen_shell_present_surface_for_mode(struct wl_client *client,
 			weston_seat_get_keyboard(seat);
 
 		if (keyboard && !keyboard->focus) {
+			old_surface = shell->active_surface;
+			if (old_surface != NULL)
+				weston_surface_deactivate(old_surface);
 			weston_surface_assign_keyboard(surface, seat);
 			if (surface != NULL)
 				weston_surface_activate(surface);
+			shell->active_surface = surface;
 		}
 	}
 }
-- 
1.9.1



More information about the wayland-devel mailing list