Commit 595ee79e authored by myfreeweb's avatar myfreeweb

libweston: make get_focused_output a public libweston function

It is useful for plugins.
parent 182d3771
Pipeline #14308 passed with stage
in 4 minutes and 9 seconds
......@@ -2189,37 +2189,6 @@ shell_map_fullscreen(struct shell_surface *shsurf)
shell_configure_fullscreen(shsurf);
}
static struct weston_output *
get_focused_output(struct weston_compositor *compositor)
{
struct weston_seat *seat;
struct weston_output *output = NULL;
wl_list_for_each(seat, &compositor->seat_list, link) {
struct weston_touch *touch = weston_seat_get_touch(seat);
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
struct weston_keyboard *keyboard =
weston_seat_get_keyboard(seat);
/* Priority has touch focus, then pointer and
* then keyboard focus. We should probably have
* three for loops and check frist for touch,
* then for pointer, etc. but unless somebody has some
* objections, I think this is sufficient. */
if (touch && touch->focus)
output = touch->focus->output;
else if (pointer && pointer->focus)
output = pointer->focus->output;
else if (keyboard && keyboard->focus)
output = keyboard->focus->output;
if (output)
break;
}
return output;
}
static void
destroy_shell_seat(struct wl_listener *listener, void *data)
{
......@@ -2654,7 +2623,7 @@ set_fullscreen(struct shell_surface *shsurf, bool fullscreen,
/* handle clients launching in fullscreen */
if (output == NULL && !weston_surface_is_mapped(surface)) {
/* Set the output to the one that has focus currently. */
output = get_focused_output(surface->compositor);
output = weston_compositor_get_focused_output(surface->compositor);
}
shell_surface_set_output(shsurf, output);
......@@ -2750,7 +2719,7 @@ set_maximized(struct shell_surface *shsurf, bool maximized)
struct weston_output *output;
if (!weston_surface_is_mapped(surface))
output = get_focused_output(surface->compositor);
output = weston_compositor_get_focused_output(surface->compositor);
else
output = surface->output;
......
......@@ -5980,6 +5980,37 @@ weston_compositor_find_output_by_name(struct weston_compositor *compositor,
return NULL;
}
WL_EXPORT struct weston_output *
weston_compositor_get_focused_output(struct weston_compositor *compositor)
{
struct weston_seat *seat;
struct weston_output *output = NULL;
wl_list_for_each(seat, &compositor->seat_list, link) {
struct weston_touch *touch = weston_seat_get_touch(seat);
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
struct weston_keyboard *keyboard =
weston_seat_get_keyboard(seat);
/* Priority has touch focus, then pointer and
* then keyboard focus. We should probably have
* three for loops and check frist for touch,
* then for pointer, etc. but unless somebody has some
* objections, I think this is sufficient. */
if (touch && touch->focus)
output = touch->focus->output;
else if (pointer && pointer->focus)
output = pointer->focus->output;
else if (keyboard && keyboard->focus)
output = keyboard->focus->output;
if (output)
break;
}
return output;
}
/** Create a named output
*
* \param compositor The compositor.
......
......@@ -2284,6 +2284,9 @@ struct weston_output *
weston_compositor_find_output_by_name(struct weston_compositor *compositor,
const char *name);
struct weston_output *
weston_compositor_get_focused_output(struct weston_compositor *compositor);
struct weston_output *
weston_compositor_create_output(struct weston_compositor *compositor,
const char *name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment