Commit 38c54d65 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

XCB-XV: get visual and depth from XV adaptor rather than root window

parent 1ea1c3f9
...@@ -320,6 +320,7 @@ static int Open (vlc_object_t *obj) ...@@ -320,6 +320,7 @@ static int Open (vlc_object_t *obj)
/* */ /* */
p_sys->att = NULL; p_sys->att = NULL;
p_sys->pool = NULL; p_sys->pool = NULL;
p_sys->window = xcb_generate_id (conn);
/* Cache adaptors infos */ /* Cache adaptors infos */
xcb_xv_query_adaptors_reply_t *adaptors = xcb_xv_query_adaptors_reply_t *adaptors =
...@@ -418,14 +419,13 @@ static int Open (vlc_object_t *obj) ...@@ -418,14 +419,13 @@ static int Open (vlc_object_t *obj)
if (result == 0) if (result == 0)
{ {
p_sys->port = port; p_sys->port = port;
found_adaptor = true; goto grabbed_port;
break;
} }
msg_Dbg (vd, "cannot grab port %"PRIu32, port); msg_Dbg (vd, "cannot grab port %"PRIu32, port);
} }
if (!found_adaptor) continue; /* No usable port */
continue;
grabbed_port:
/* Found port - initialize selected format */ /* Found port - initialize selected format */
name = strndup (xcb_xv_adaptor_info_name (a), a->name_size); name = strndup (xcb_xv_adaptor_info_name (a), a->name_size);
if (name != NULL) if (name != NULL)
...@@ -435,32 +435,45 @@ static int Open (vlc_object_t *obj) ...@@ -435,32 +435,45 @@ static int Open (vlc_object_t *obj)
} }
msg_Dbg (vd, "using port %"PRIu32, p_sys->port); msg_Dbg (vd, "using port %"PRIu32, p_sys->port);
msg_Dbg (vd, "using image format 0x%"PRIx32, p_sys->id); msg_Dbg (vd, "using image format 0x%"PRIx32, p_sys->id);
}
free (adaptors);
if (!found_adaptor)
{
msg_Err (vd, "no available XVideo adaptor");
goto error;
}
/* Create window */ /* Look for an X11 visual, create a window */
xcb_xv_format_t *f = xcb_xv_adaptor_info_formats (a);
for (uint_fast16_t i = a->num_formats; i > 0; i--, f++)
{ {
const uint32_t mask = const uint32_t mask =
/* XCB_CW_EVENT_MASK */ /* XCB_CW_EVENT_MASK */
XCB_EVENT_MASK_VISIBILITY_CHANGE; XCB_EVENT_MASK_VISIBILITY_CHANGE;
xcb_void_cookie_t c; xcb_void_cookie_t c;
xcb_window_t window = xcb_generate_id (conn);
c = xcb_create_window_checked (conn, screen->root_depth, window, c = xcb_create_window_checked (conn, f->depth, p_sys->window,
p_sys->embed->handle.xid, 0, 0, 1, 1, 0, p_sys->embed->handle.xid, 0, 0, 1, 1, 0,
XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_WINDOW_CLASS_INPUT_OUTPUT, f->visual,
screen->root_visual,
XCB_CW_EVENT_MASK, &mask); XCB_CW_EVENT_MASK, &mask);
if (CheckError (vd, conn, "cannot create X11 window", c))
if (!CheckError (vd, conn, "cannot create X11 window", c))
{
msg_Dbg (vd, "using X11 visual ID 0x%"PRIx32
" (depth: %"PRIu8")", f->visual, f->depth);
msg_Dbg (vd, "using X11 window 0x%08"PRIx32, p_sys->window);
goto created_window;
}
}
xcb_xv_ungrab_port (conn, p_sys->port, XCB_CURRENT_TIME);
continue; /* No workable XVideo format (visual/depth) */
created_window:
found_adaptor = true;
break;
}
free (adaptors);
if (!found_adaptor)
{
msg_Err (vd, "no available XVideo adaptor");
goto error; goto error;
p_sys->window = window; }
msg_Dbg (vd, "using X11 window 0x%08"PRIx32, window); else
xcb_map_window (conn, window); {
xcb_map_window (conn, p_sys->window);
vout_display_place_t place; vout_display_place_t place;
...@@ -469,10 +482,12 @@ static int Open (vlc_object_t *obj) ...@@ -469,10 +482,12 @@ static int Open (vlc_object_t *obj)
p_sys->height = place.height; p_sys->height = place.height;
/* */ /* */
const uint32_t values[] = { place.x, place.y, place.width, place.height }; const uint32_t values[] = {
xcb_configure_window (conn, window, place.x, place.y, place.width, place.height };
xcb_configure_window (conn, p_sys->window,
XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y |
XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, XCB_CONFIG_WINDOW_WIDTH |
XCB_CONFIG_WINDOW_HEIGHT,
values); values);
} }
p_sys->visible = false; p_sys->visible = false;
......
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