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:
Alexander Preisinger 2013-05-02 20:56:59 +02:00
parent 57e0a84715
commit 68d4cc4536
1 changed files with 18 additions and 15 deletions

View File

@ -138,20 +138,14 @@ static void output_handle_mode(void *data,
int32_t height,
int32_t refresh)
{
struct vo_wayland_display *d = data;
struct vo_wayland_output *output;
struct vo_wayland_output *output = data;
wl_list_for_each(output, &d->output_list, link) {
if (wl_output == output->output) {
output->width = width;
output->height = height;
if (flags)
output->flags = flags;
}
}
if (!output)
return;
/* one output is enough */
d->output_mode_received = 1;
output->width = width;
output->height = height;
output->flags = flags;
}
const struct wl_output_listener output_listener = {
@ -486,7 +480,7 @@ static void registry_handle_global (void *data,
&wl_output_interface,
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);
}
@ -805,10 +799,9 @@ void vo_wayland_update_screeninfo (struct vo *vo)
{
struct vo_wayland_state *wl = vo->wayland;
struct mp_vo_opts *opts = vo->opts;
bool mode_received = false;
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;
@ -819,6 +812,11 @@ void vo_wayland_update_screeninfo (struct vo *vo)
struct vo_wayland_output *fsscreen_output = NULL;
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)
fsscreen_output = output;
@ -828,6 +826,11 @@ void vo_wayland_update_screeninfo (struct vo *vo)
screen_id++;
}
if (!mode_received) {
mp_msg(MSGT_VO, MSGL_ERR, "[wayland] no output mode detected\n");
return;
}
if (fsscreen_output) {
wl->display->fs_output = fsscreen_output->output;
opts->screenwidth = fsscreen_output->width;