[PATCH weston v6 04/73] libweston: make wl_output point to weston_head

Pekka Paalanen ppaalanen at gmail.com
Fri Feb 16 14:56:49 UTC 2018


From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

The user data of a wl_resource representing a wl_output protocol object
used to be a pointer to weston_output. Now that weston_output is being
split, wl_output more accurately refers to weston_head which is a single
monitor.

Change the wl_output user data to point to weston_head.
weston_output_from_resource() is replaced with
weston_head_from_resource().

This change is not strictly necessary, but architecturally it is the
right thing to do. In the future there might appear the need to refer to
a specific head of a cloned pair, for instance.

Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
v5 Reviewed-by: Derek Foreman <derekf at osg.samsung.com>
---
 compositor/weston-screenshooter.c   | 2 +-
 desktop-shell/input-panel.c         | 4 +++-
 desktop-shell/shell.c               | 4 ++--
 fullscreen-shell/fullscreen-shell.c | 4 ++--
 ivi-shell/input-panel-ivi.c         | 4 +++-
 libweston-desktop/wl-shell.c        | 2 +-
 libweston-desktop/xdg-shell-v6.c    | 2 +-
 libweston/compositor.c              | 6 +++---
 libweston/compositor.h              | 4 ++--
 tests/weston-test.c                 | 2 +-
 10 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/compositor/weston-screenshooter.c b/compositor/weston-screenshooter.c
index f0bc0e1e..70afed4a 100644
--- a/compositor/weston-screenshooter.c
+++ b/compositor/weston-screenshooter.c
@@ -66,7 +66,7 @@ screenshooter_shoot(struct wl_client *client,
 		    struct wl_resource *buffer_resource)
 {
 	struct weston_output *output =
-		weston_output_from_resource(output_resource);
+		weston_head_from_resource(output_resource)->output;
 	struct weston_buffer *buffer =
 		weston_buffer_from_resource(buffer_resource);
 
diff --git a/desktop-shell/input-panel.c b/desktop-shell/input-panel.c
index e6b1541a..8292f20a 100644
--- a/desktop-shell/input-panel.c
+++ b/desktop-shell/input-panel.c
@@ -270,11 +270,13 @@ input_panel_surface_set_toplevel(struct wl_client *client,
 	struct input_panel_surface *input_panel_surface =
 		wl_resource_get_user_data(resource);
 	struct desktop_shell *shell = input_panel_surface->shell;
+	struct weston_head *head;
 
 	wl_list_insert(&shell->input_panel.surfaces,
 		       &input_panel_surface->link);
 
-	input_panel_surface->output = weston_output_from_resource(output_resource);
+	head = weston_head_from_resource(output_resource);
+	input_panel_surface->output = head->output;
 	input_panel_surface->panel = 0;
 }
 
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index ceb45c74..b846e305 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -2969,7 +2969,7 @@ desktop_shell_set_background(struct wl_client *client,
 	surface->committed = background_committed;
 	surface->committed_private = shell;
 	weston_surface_set_label_func(surface, background_get_label);
-	surface->output = weston_output_from_resource(output_resource);
+	surface->output = weston_head_from_resource(output_resource)->output;
 	view->output = surface->output;
 
 	sh_output = find_shell_output_from_weston_output(shell, surface->output);
@@ -3066,7 +3066,7 @@ desktop_shell_set_panel(struct wl_client *client,
 	surface->committed = panel_committed;
 	surface->committed_private = shell;
 	weston_surface_set_label_func(surface, panel_get_label);
-	surface->output = weston_output_from_resource(output_resource);
+	surface->output = weston_head_from_resource(output_resource)->output;
 	view->output = surface->output;
 
 	sh_output = find_shell_output_from_weston_output(shell, surface->output);
diff --git a/fullscreen-shell/fullscreen-shell.c b/fullscreen-shell/fullscreen-shell.c
index 6f4565a7..89884794 100644
--- a/fullscreen-shell/fullscreen-shell.c
+++ b/fullscreen-shell/fullscreen-shell.c
@@ -769,7 +769,7 @@ fullscreen_shell_present_surface(struct wl_client *client,
 	}
 
 	if (output_res) {
-		output = weston_output_from_resource(output_res);
+		output = weston_head_from_resource(output_res)->output;
 		fsout = fs_output_for_output(output);
 		fs_output_set_surface(fsout, surface, method, 0, 0);
 	} else {
@@ -813,7 +813,7 @@ fullscreen_shell_present_surface_for_mode(struct wl_client *client,
 	struct weston_seat *seat;
 	struct fs_output *fsout;
 
-	output = weston_output_from_resource(output_res);
+	output = weston_head_from_resource(output_res)->output;
 	fsout = fs_output_for_output(output);
 
 	if (surface_res == NULL) {
diff --git a/ivi-shell/input-panel-ivi.c b/ivi-shell/input-panel-ivi.c
index 0008a52d..219494dc 100644
--- a/ivi-shell/input-panel-ivi.c
+++ b/ivi-shell/input-panel-ivi.c
@@ -271,11 +271,13 @@ input_panel_surface_set_toplevel(struct wl_client *client,
 	struct input_panel_surface *input_panel_surface =
 		wl_resource_get_user_data(resource);
 	struct ivi_shell *shell = input_panel_surface->shell;
+	struct weston_head *head;
 
 	wl_list_insert(&shell->input_panel.surfaces,
 		       &input_panel_surface->link);
 
-	input_panel_surface->output = weston_output_from_resource(output_resource);
+	head = weston_head_from_resource(output_resource);
+	input_panel_surface->output = head->output;
 	input_panel_surface->panel = 0;
 }
 
diff --git a/libweston-desktop/wl-shell.c b/libweston-desktop/wl-shell.c
index 8467dfb8..37720acb 100644
--- a/libweston-desktop/wl-shell.c
+++ b/libweston-desktop/wl-shell.c
@@ -308,7 +308,7 @@ weston_desktop_wl_shell_surface_protocol_set_fullscreen(struct wl_client *wl_cli
 	struct weston_output *output = NULL;
 
 	if (output_resource != NULL)
-		output = weston_output_from_resource(output_resource);
+		output = weston_head_from_resource(output_resource)->output;
 
 	weston_desktop_wl_shell_change_state(surface, FULLSCREEN, NULL, 0, 0);
 	weston_desktop_api_fullscreen_requested(surface->desktop, dsurface,
diff --git a/libweston-desktop/xdg-shell-v6.c b/libweston-desktop/xdg-shell-v6.c
index f9902ff0..654af9c6 100644
--- a/libweston-desktop/xdg-shell-v6.c
+++ b/libweston-desktop/xdg-shell-v6.c
@@ -515,7 +515,7 @@ weston_desktop_xdg_toplevel_protocol_set_fullscreen(struct wl_client *wl_client,
 	struct weston_output *output = NULL;
 
 	if (output_resource != NULL)
-		output = weston_output_from_resource(output_resource);
+		output = weston_head_from_resource(output_resource)->output;
 
 	weston_desktop_xdg_toplevel_ensure_added(toplevel);
 	weston_desktop_api_fullscreen_requested(toplevel->base.desktop, dsurface,
diff --git a/libweston/compositor.c b/libweston/compositor.c
index aa636341..50b6f639 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -4329,7 +4329,7 @@ bind_output(struct wl_client *client,
 	}
 
 	wl_list_insert(&head->resource_list, wl_resource_get_link(resource));
-	wl_resource_set_implementation(resource, &output_interface, output,
+	wl_resource_set_implementation(resource, &output_interface, head,
 				       unbind_resource);
 
 	assert(output);
@@ -4363,8 +4363,8 @@ bind_output(struct wl_client *client,
  * \return The backing object (user data) of a wl_resource representing a
  * wl_output protocol object.
  */
-WL_EXPORT struct weston_output *
-weston_output_from_resource(struct wl_resource *resource)
+WL_EXPORT struct weston_head *
+weston_head_from_resource(struct wl_resource *resource)
 {
 	assert(wl_resource_instance_of(resource, &wl_output_interface,
 				       &output_interface));
diff --git a/libweston/compositor.h b/libweston/compositor.h
index 4e8797c7..941d933a 100644
--- a/libweston/compositor.h
+++ b/libweston/compositor.h
@@ -1989,8 +1989,8 @@ weston_output_disable(struct weston_output *output);
 void
 weston_pending_output_coldplug(struct weston_compositor *compositor);
 
-struct weston_output *
-weston_output_from_resource(struct wl_resource *resource);
+struct weston_head *
+weston_head_from_resource(struct wl_resource *resource);
 
 #ifdef  __cplusplus
 }
diff --git a/tests/weston-test.c b/tests/weston-test.c
index 9a2fd286..73409cac 100644
--- a/tests/weston-test.c
+++ b/tests/weston-test.c
@@ -530,7 +530,7 @@ capture_screenshot(struct wl_client *client,
 		   struct wl_resource *buffer_resource)
 {
 	struct weston_output *output =
-		weston_output_from_resource(output_resource);
+		weston_head_from_resource(output_resource)->output;
 	struct weston_buffer *buffer =
 		weston_buffer_from_resource(buffer_resource);
 
-- 
2.13.6



More information about the wayland-devel mailing list