mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2025-12-24 19:30:11 +01:00
kiosk-shell: Store kiosk_shell_output in kiosk_shell_surface
We end up doing some extra list walks and mildly awkward contortions to find the kiosk_shell_output from the weston_output. Store the kiosk_shell_output instead - it's always trivial to find the weston_output from that, and it just seems a bit cleaner conceptually for kiosk shell abstractions to point to other kiosk shell abstractions when available. Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
parent
a97ccc4a1a
commit
5ab5582981
2 changed files with 50 additions and 48 deletions
|
|
@ -137,7 +137,7 @@ xwayland_get_xwayland_name(struct kiosk_shell_surface *shsurf, enum window_atom_
|
||||||
|
|
||||||
static void
|
static void
|
||||||
kiosk_shell_surface_set_output(struct kiosk_shell_surface *shsurf,
|
kiosk_shell_surface_set_output(struct kiosk_shell_surface *shsurf,
|
||||||
struct weston_output *output);
|
struct kiosk_shell_output *shoutput);
|
||||||
static void
|
static void
|
||||||
kiosk_shell_surface_set_parent(struct kiosk_shell_surface *shsurf,
|
kiosk_shell_surface_set_parent(struct kiosk_shell_surface *shsurf,
|
||||||
struct kiosk_shell_surface *parent);
|
struct kiosk_shell_surface *parent);
|
||||||
|
|
@ -183,7 +183,7 @@ kiosk_shell_surface_get_parent_root(struct kiosk_shell_surface *shsurf)
|
||||||
static bool
|
static bool
|
||||||
kiosk_shell_output_has_app_id(char *config_app_ids, const char *app_id);
|
kiosk_shell_output_has_app_id(char *config_app_ids, const char *app_id);
|
||||||
|
|
||||||
static struct weston_output *
|
static struct kiosk_shell_output *
|
||||||
kiosk_shell_surface_find_best_output_for_xwayland(struct kiosk_shell_surface *shsurf)
|
kiosk_shell_surface_find_best_output_for_xwayland(struct kiosk_shell_surface *shsurf)
|
||||||
{
|
{
|
||||||
struct kiosk_shell_output *shoutput;
|
struct kiosk_shell_output *shoutput;
|
||||||
|
|
@ -208,7 +208,7 @@ kiosk_shell_surface_find_best_output_for_xwayland(struct kiosk_shell_surface *sh
|
||||||
|
|
||||||
if (found_wm_name && found_wm_class) {
|
if (found_wm_name && found_wm_class) {
|
||||||
shsurf->appid_output_assigned = true;
|
shsurf->appid_output_assigned = true;
|
||||||
return shoutput->output;
|
return shoutput;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -219,7 +219,7 @@ kiosk_shell_surface_find_best_output_for_xwayland(struct kiosk_shell_surface *sh
|
||||||
if (kiosk_shell_output_has_app_id(shoutput->x11_wm_name_app_ids,
|
if (kiosk_shell_output_has_app_id(shoutput->x11_wm_name_app_ids,
|
||||||
wm_name)) {
|
wm_name)) {
|
||||||
shsurf->appid_output_assigned = true;
|
shsurf->appid_output_assigned = true;
|
||||||
return shoutput->output;
|
return shoutput;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -229,7 +229,7 @@ kiosk_shell_surface_find_best_output_for_xwayland(struct kiosk_shell_surface *sh
|
||||||
if (kiosk_shell_output_has_app_id(shoutput->x11_wm_class_app_ids,
|
if (kiosk_shell_output_has_app_id(shoutput->x11_wm_class_app_ids,
|
||||||
wm_class)) {
|
wm_class)) {
|
||||||
shsurf->appid_output_assigned = true;
|
shsurf->appid_output_assigned = true;
|
||||||
return shoutput->output;
|
return shoutput;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -237,7 +237,7 @@ kiosk_shell_surface_find_best_output_for_xwayland(struct kiosk_shell_surface *sh
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct weston_output *
|
static struct kiosk_shell_output *
|
||||||
kiosk_shell_surface_find_best_output(struct kiosk_shell_surface *shsurf)
|
kiosk_shell_surface_find_best_output(struct kiosk_shell_surface *shsurf)
|
||||||
{
|
{
|
||||||
struct weston_output *output;
|
struct weston_output *output;
|
||||||
|
|
@ -255,14 +255,14 @@ kiosk_shell_surface_find_best_output(struct kiosk_shell_surface *shsurf)
|
||||||
wl_list_for_each(shoutput, &shsurf->shell->output_list, link) {
|
wl_list_for_each(shoutput, &shsurf->shell->output_list, link) {
|
||||||
if (kiosk_shell_output_has_app_id(shoutput->app_ids, app_id)) {
|
if (kiosk_shell_output_has_app_id(shoutput->app_ids, app_id)) {
|
||||||
shsurf->appid_output_assigned = true;
|
shsurf->appid_output_assigned = true;
|
||||||
return shoutput->output;
|
return shoutput;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
output = kiosk_shell_surface_find_best_output_for_xwayland(shsurf);
|
shoutput = kiosk_shell_surface_find_best_output_for_xwayland(shsurf);
|
||||||
if (output)
|
if (shoutput)
|
||||||
return output;
|
return shoutput;
|
||||||
|
|
||||||
/* Group all related windows in the same output. */
|
/* Group all related windows in the same output. */
|
||||||
root = kiosk_shell_surface_get_parent_root(shsurf);
|
root = kiosk_shell_surface_get_parent_root(shsurf);
|
||||||
|
|
@ -271,20 +271,21 @@ kiosk_shell_surface_find_best_output(struct kiosk_shell_surface *shsurf)
|
||||||
|
|
||||||
output = weston_shell_utils_get_focused_output(shsurf->shell->compositor);
|
output = weston_shell_utils_get_focused_output(shsurf->shell->compositor);
|
||||||
if (output)
|
if (output)
|
||||||
return output;
|
return kiosk_shell_find_shell_output(shsurf->shell,
|
||||||
|
output);
|
||||||
output = weston_shell_utils_get_default_output(shsurf->shell->compositor);
|
output = weston_shell_utils_get_default_output(shsurf->shell->compositor);
|
||||||
if (output)
|
if (output)
|
||||||
return output;
|
return kiosk_shell_find_shell_output(shsurf->shell,
|
||||||
|
output);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
kiosk_shell_surface_set_output(struct kiosk_shell_surface *shsurf,
|
kiosk_shell_surface_set_output(struct kiosk_shell_surface *shsurf,
|
||||||
struct weston_output *output)
|
struct kiosk_shell_output *shoutput)
|
||||||
{
|
{
|
||||||
shsurf->output = output;
|
shsurf->output = shoutput;
|
||||||
|
|
||||||
if (shsurf->output_destroy_listener.notify) {
|
if (shsurf->output_destroy_listener.notify) {
|
||||||
wl_list_remove(&shsurf->output_destroy_listener.link);
|
wl_list_remove(&shsurf->output_destroy_listener.link);
|
||||||
|
|
@ -296,39 +297,39 @@ kiosk_shell_surface_set_output(struct kiosk_shell_surface *shsurf,
|
||||||
|
|
||||||
shsurf->output_destroy_listener.notify =
|
shsurf->output_destroy_listener.notify =
|
||||||
kiosk_shell_surface_notify_output_destroy;
|
kiosk_shell_surface_notify_output_destroy;
|
||||||
wl_signal_add(&shsurf->output->destroy_signal,
|
wl_signal_add(&shsurf->output->output->destroy_signal,
|
||||||
&shsurf->output_destroy_listener);
|
&shsurf->output_destroy_listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
kiosk_shell_surface_set_fullscreen(struct kiosk_shell_surface *shsurf,
|
kiosk_shell_surface_set_fullscreen(struct kiosk_shell_surface *shsurf,
|
||||||
struct weston_output *output)
|
struct kiosk_shell_output *shoutput)
|
||||||
{
|
{
|
||||||
if (!output)
|
if (!shoutput)
|
||||||
output = kiosk_shell_surface_find_best_output(shsurf);
|
shoutput = kiosk_shell_surface_find_best_output(shsurf);
|
||||||
|
|
||||||
kiosk_shell_surface_set_output(shsurf, output);
|
kiosk_shell_surface_set_output(shsurf, shoutput);
|
||||||
|
|
||||||
weston_desktop_surface_set_fullscreen(shsurf->desktop_surface, true);
|
weston_desktop_surface_set_fullscreen(shsurf->desktop_surface, true);
|
||||||
if (shsurf->output)
|
if (shsurf->output)
|
||||||
weston_desktop_surface_set_size(shsurf->desktop_surface,
|
weston_desktop_surface_set_size(shsurf->desktop_surface,
|
||||||
shsurf->output->width,
|
shsurf->output->output->width,
|
||||||
shsurf->output->height);
|
shsurf->output->output->height);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
kiosk_shell_surface_set_maximized(struct kiosk_shell_surface *shsurf)
|
kiosk_shell_surface_set_maximized(struct kiosk_shell_surface *shsurf)
|
||||||
{
|
{
|
||||||
struct weston_output *output =
|
struct kiosk_shell_output *shoutput =
|
||||||
kiosk_shell_surface_find_best_output(shsurf);
|
kiosk_shell_surface_find_best_output(shsurf);
|
||||||
|
|
||||||
kiosk_shell_surface_set_output(shsurf, output);
|
kiosk_shell_surface_set_output(shsurf, shoutput);
|
||||||
|
|
||||||
weston_desktop_surface_set_maximized(shsurf->desktop_surface, true);
|
weston_desktop_surface_set_maximized(shsurf->desktop_surface, true);
|
||||||
if (shsurf->output)
|
if (shsurf->output)
|
||||||
weston_desktop_surface_set_size(shsurf->desktop_surface,
|
weston_desktop_surface_set_size(shsurf->desktop_surface,
|
||||||
shsurf->output->width,
|
shsurf->output->output->width,
|
||||||
shsurf->output->height);
|
shsurf->output->output->height);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -382,9 +383,7 @@ static void
|
||||||
kiosk_shell_surface_set_parent(struct kiosk_shell_surface *shsurf,
|
kiosk_shell_surface_set_parent(struct kiosk_shell_surface *shsurf,
|
||||||
struct kiosk_shell_surface *parent)
|
struct kiosk_shell_surface *parent)
|
||||||
{
|
{
|
||||||
struct kiosk_shell_output *shoutput =
|
struct kiosk_shell_output *shoutput = shsurf->output;
|
||||||
kiosk_shell_find_shell_output(shsurf->shell,
|
|
||||||
shsurf->output);
|
|
||||||
struct kiosk_shell_surface *shroot = parent ?
|
struct kiosk_shell_surface *shroot = parent ?
|
||||||
kiosk_shell_surface_get_parent_root(parent) :
|
kiosk_shell_surface_get_parent_root(parent) :
|
||||||
kiosk_shell_surface_get_parent_root(shsurf);
|
kiosk_shell_surface_get_parent_root(shsurf);
|
||||||
|
|
@ -436,20 +435,22 @@ static void
|
||||||
kiosk_shell_surface_reconfigure_for_output(struct kiosk_shell_surface *shsurf)
|
kiosk_shell_surface_reconfigure_for_output(struct kiosk_shell_surface *shsurf)
|
||||||
{
|
{
|
||||||
struct weston_desktop_surface *desktop_surface;
|
struct weston_desktop_surface *desktop_surface;
|
||||||
|
struct weston_output *w_output;
|
||||||
|
|
||||||
if (!shsurf->output)
|
if (!shsurf->output)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
w_output = shsurf->output->output;
|
||||||
desktop_surface = shsurf->desktop_surface;
|
desktop_surface = shsurf->desktop_surface;
|
||||||
|
|
||||||
if (weston_desktop_surface_get_maximized(desktop_surface) ||
|
if (weston_desktop_surface_get_maximized(desktop_surface) ||
|
||||||
weston_desktop_surface_get_fullscreen(desktop_surface)) {
|
weston_desktop_surface_get_fullscreen(desktop_surface)) {
|
||||||
weston_desktop_surface_set_size(desktop_surface,
|
weston_desktop_surface_set_size(desktop_surface,
|
||||||
shsurf->output->width,
|
w_output->width,
|
||||||
shsurf->output->height);
|
w_output->height);
|
||||||
}
|
}
|
||||||
|
|
||||||
weston_shell_utils_center_on_output(shsurf->view, shsurf->output);
|
weston_shell_utils_center_on_output(shsurf->view, w_output);
|
||||||
weston_view_update_transform(shsurf->view);
|
weston_view_update_transform(shsurf->view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -530,8 +531,7 @@ kiosk_shell_surface_activate(struct kiosk_shell_surface *shsurf,
|
||||||
struct weston_desktop_surface *dsurface = shsurf->desktop_surface;
|
struct weston_desktop_surface *dsurface = shsurf->desktop_surface;
|
||||||
struct weston_surface *surface =
|
struct weston_surface *surface =
|
||||||
weston_desktop_surface_get_surface(dsurface);
|
weston_desktop_surface_get_surface(dsurface);
|
||||||
struct kiosk_shell_output *shoutput =
|
struct kiosk_shell_output *shoutput = shsurf->output;
|
||||||
kiosk_shell_find_shell_output(shsurf->shell, shsurf->output);
|
|
||||||
|
|
||||||
/* keyboard focus */
|
/* keyboard focus */
|
||||||
weston_view_activate_input(shsurf->view, kiosk_seat->seat, activate_flags);
|
weston_view_activate_input(shsurf->view, kiosk_seat->seat, activate_flags);
|
||||||
|
|
@ -870,6 +870,9 @@ find_focus_successor(struct kiosk_shell_surface *shsurf,
|
||||||
struct weston_layer *layer;
|
struct weston_layer *layer;
|
||||||
struct weston_view *view;
|
struct weston_view *view;
|
||||||
|
|
||||||
|
if (!shsurf->output)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
wl_list_for_each(layer, layers, link) {
|
wl_list_for_each(layer, layers, link) {
|
||||||
struct kiosk_shell *shell = shsurf->shell;
|
struct kiosk_shell *shell = shsurf->shell;
|
||||||
|
|
||||||
|
|
@ -885,7 +888,7 @@ find_focus_successor(struct kiosk_shell_surface *shsurf,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* pick views only on the same output */
|
/* pick views only on the same output */
|
||||||
if (view->output != shsurf->output)
|
if (view->output != shsurf->output->output)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
view_shsurf = get_kiosk_shell_surface(view->surface);
|
view_shsurf = get_kiosk_shell_surface(view->surface);
|
||||||
|
|
@ -947,7 +950,7 @@ desktop_surface_removed(struct weston_desktop_surface *desktop_surface,
|
||||||
|
|
||||||
successor = find_focus_successor(shsurf,
|
successor = find_focus_successor(shsurf,
|
||||||
kiosk_seat->focused_surface);
|
kiosk_seat->focused_surface);
|
||||||
shoutput = kiosk_shell_find_shell_output(shsurf->shell, shsurf->output);
|
shoutput = shsurf->output;
|
||||||
if (shoutput && successor) {
|
if (shoutput && successor) {
|
||||||
enum weston_layer_position succesor_view_layer_pos;
|
enum weston_layer_position succesor_view_layer_pos;
|
||||||
|
|
||||||
|
|
@ -991,17 +994,17 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!shsurf->appid_output_assigned && app_id) {
|
if (!shsurf->appid_output_assigned && app_id) {
|
||||||
struct weston_output *output = NULL;
|
struct kiosk_shell_output *shoutput = NULL;
|
||||||
|
|
||||||
/* reset previous output being set in _added() as the output is
|
/* reset previous output being set in _added() as the output is
|
||||||
* being cached */
|
* being cached */
|
||||||
shsurf->output = NULL;
|
shsurf->output = NULL;
|
||||||
output = kiosk_shell_surface_find_best_output(shsurf);
|
shoutput = kiosk_shell_surface_find_best_output(shsurf);
|
||||||
|
|
||||||
kiosk_shell_surface_set_output(shsurf, output);
|
kiosk_shell_surface_set_output(shsurf, shoutput);
|
||||||
weston_desktop_surface_set_size(shsurf->desktop_surface,
|
weston_desktop_surface_set_size(shsurf->desktop_surface,
|
||||||
shsurf->output->width,
|
shoutput->output->width,
|
||||||
shsurf->output->height);
|
shoutput->output->height);
|
||||||
/* even if we couldn't find an appid set for a particular
|
/* even if we couldn't find an appid set for a particular
|
||||||
* output still flag the shsurf as to a avoid changing the
|
* output still flag the shsurf as to a avoid changing the
|
||||||
* output every time */
|
* output every time */
|
||||||
|
|
@ -1021,7 +1024,7 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface,
|
||||||
if (!weston_surface_is_mapped(surface) || (is_resized && is_fullscreen)) {
|
if (!weston_surface_is_mapped(surface) || (is_resized && is_fullscreen)) {
|
||||||
if (is_fullscreen || !shsurf->xwayland.is_set) {
|
if (is_fullscreen || !shsurf->xwayland.is_set) {
|
||||||
weston_shell_utils_center_on_output(shsurf->view,
|
weston_shell_utils_center_on_output(shsurf->view,
|
||||||
shsurf->output);
|
shsurf->output->output);
|
||||||
} else {
|
} else {
|
||||||
struct weston_coord_surface offset;
|
struct weston_coord_surface offset;
|
||||||
struct weston_geometry geometry =
|
struct weston_geometry geometry =
|
||||||
|
|
@ -1040,9 +1043,7 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface,
|
||||||
if (!weston_surface_is_mapped(surface)) {
|
if (!weston_surface_is_mapped(surface)) {
|
||||||
struct weston_seat *seat =
|
struct weston_seat *seat =
|
||||||
get_kiosk_shell_first_seat(shsurf->shell);
|
get_kiosk_shell_first_seat(shsurf->shell);
|
||||||
struct kiosk_shell_output *shoutput =
|
struct kiosk_shell_output *shoutput = shsurf->output;
|
||||||
kiosk_shell_find_shell_output(shsurf->shell,
|
|
||||||
shsurf->output);
|
|
||||||
struct kiosk_shell_seat *kiosk_seat;
|
struct kiosk_shell_seat *kiosk_seat;
|
||||||
|
|
||||||
weston_surface_map(surface);
|
weston_surface_map(surface);
|
||||||
|
|
@ -1134,7 +1135,8 @@ desktop_surface_fullscreen_requested(struct weston_desktop_surface *desktop_surf
|
||||||
{
|
{
|
||||||
struct kiosk_shell_surface *shsurf =
|
struct kiosk_shell_surface *shsurf =
|
||||||
weston_desktop_surface_get_user_data(desktop_surface);
|
weston_desktop_surface_get_user_data(desktop_surface);
|
||||||
|
struct kiosk_shell_output *shoutput =
|
||||||
|
kiosk_shell_find_shell_output(shsurf->shell, output);
|
||||||
/* We should normally be able to ignore fullscreen requests for
|
/* We should normally be able to ignore fullscreen requests for
|
||||||
* top-level surfaces, since we set them as fullscreen at creation
|
* top-level surfaces, since we set them as fullscreen at creation
|
||||||
* time. However, xwayland surfaces set their internal WM state
|
* time. However, xwayland surfaces set their internal WM state
|
||||||
|
|
@ -1148,7 +1150,7 @@ desktop_surface_fullscreen_requested(struct weston_desktop_surface *desktop_surf
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!shsurf->parent || fullscreen)
|
if (!shsurf->parent || fullscreen)
|
||||||
kiosk_shell_surface_set_fullscreen(shsurf, output);
|
kiosk_shell_surface_set_fullscreen(shsurf, shoutput);
|
||||||
else
|
else
|
||||||
kiosk_shell_surface_set_normal(shsurf);
|
kiosk_shell_surface_set_normal(shsurf);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ struct kiosk_shell_surface {
|
||||||
|
|
||||||
struct kiosk_shell *shell;
|
struct kiosk_shell *shell;
|
||||||
|
|
||||||
struct weston_output *output;
|
struct kiosk_shell_output *output;
|
||||||
struct wl_listener output_destroy_listener;
|
struct wl_listener output_destroy_listener;
|
||||||
|
|
||||||
struct wl_signal destroy_signal;
|
struct wl_signal destroy_signal;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue