mirror of
https://github.com/mpv-player/mpv
synced 2025-04-25 04:39:47 +00:00
wayland: avoid iterating over all outputs
If we use the output itself as user data we don't have to iterate over all outputs when the handle_mode event comes.
This commit is contained in:
parent
57e0a84715
commit
68d4cc4536
@ -138,20 +138,14 @@ static void output_handle_mode(void *data,
|
|||||||
int32_t height,
|
int32_t height,
|
||||||
int32_t refresh)
|
int32_t refresh)
|
||||||
{
|
{
|
||||||
struct vo_wayland_display *d = data;
|
struct vo_wayland_output *output = data;
|
||||||
struct vo_wayland_output *output;
|
|
||||||
|
|
||||||
wl_list_for_each(output, &d->output_list, link) {
|
if (!output)
|
||||||
if (wl_output == output->output) {
|
return;
|
||||||
output->width = width;
|
|
||||||
output->height = height;
|
|
||||||
if (flags)
|
|
||||||
output->flags = flags;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* one output is enough */
|
output->width = width;
|
||||||
d->output_mode_received = 1;
|
output->height = height;
|
||||||
|
output->flags = flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct wl_output_listener output_listener = {
|
const struct wl_output_listener output_listener = {
|
||||||
@ -486,7 +480,7 @@ static void registry_handle_global (void *data,
|
|||||||
&wl_output_interface,
|
&wl_output_interface,
|
||||||
1);
|
1);
|
||||||
|
|
||||||
wl_output_add_listener(output->output, &output_listener, d);
|
wl_output_add_listener(output->output, &output_listener, output);
|
||||||
wl_list_insert(&d->output_list, &output->link);
|
wl_list_insert(&d->output_list, &output->link);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -805,10 +799,9 @@ void vo_wayland_update_screeninfo (struct vo *vo)
|
|||||||
{
|
{
|
||||||
struct vo_wayland_state *wl = vo->wayland;
|
struct vo_wayland_state *wl = vo->wayland;
|
||||||
struct mp_vo_opts *opts = vo->opts;
|
struct mp_vo_opts *opts = vo->opts;
|
||||||
|
bool mode_received = false;
|
||||||
|
|
||||||
wl_display_roundtrip(wl->display->display);
|
wl_display_roundtrip(wl->display->display);
|
||||||
if (!wl->display->output_mode_received)
|
|
||||||
mp_msg(MSGT_VO, MSGL_ERR, "[wayland] no output mode detected\n");
|
|
||||||
|
|
||||||
vo->xinerama_x = vo->xinerama_y = 0;
|
vo->xinerama_x = vo->xinerama_y = 0;
|
||||||
|
|
||||||
@ -819,6 +812,11 @@ void vo_wayland_update_screeninfo (struct vo *vo)
|
|||||||
struct vo_wayland_output *fsscreen_output = NULL;
|
struct vo_wayland_output *fsscreen_output = NULL;
|
||||||
|
|
||||||
wl_list_for_each_reverse(output, &wl->display->output_list, link) {
|
wl_list_for_each_reverse(output, &wl->display->output_list, link) {
|
||||||
|
if (!output || !output->width)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
mode_received = true;
|
||||||
|
|
||||||
if (opts->fsscreen_id == screen_id)
|
if (opts->fsscreen_id == screen_id)
|
||||||
fsscreen_output = output;
|
fsscreen_output = output;
|
||||||
|
|
||||||
@ -828,6 +826,11 @@ void vo_wayland_update_screeninfo (struct vo *vo)
|
|||||||
screen_id++;
|
screen_id++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!mode_received) {
|
||||||
|
mp_msg(MSGT_VO, MSGL_ERR, "[wayland] no output mode detected\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (fsscreen_output) {
|
if (fsscreen_output) {
|
||||||
wl->display->fs_output = fsscreen_output->output;
|
wl->display->fs_output = fsscreen_output->output;
|
||||||
opts->screenwidth = fsscreen_output->width;
|
opts->screenwidth = fsscreen_output->width;
|
||||||
|
Loading…
Reference in New Issue
Block a user