Commit 2dc30918 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Port panoramix to X RandR with XCB (incomplete)

parent 6cd2ef8a
......@@ -3915,10 +3915,6 @@ CPPFLAGS="${CPPFLAGS_save} ${X_CFLAGS}"
AS_IF([test "${enable_x11}" != "no"], [
AC_CHECK_HEADERS(X11/Xlib.h, [
VLC_ADD_PLUGIN([panoramix])
VLC_ADD_LIBS([panoramix],[${X_LIBS} ${X_PRE_LIBS} -lX11])
VLC_ADD_CPPFLAGS([panoramix],[${X_CFLAGS}])
VLC_ADD_PLUGIN([x11])
VLC_ADD_LIBS([x11],[${X_LIBS} ${X_PRE_LIBS} -lX11])
VLC_ADD_CPPFLAGS([x11],[${X_CFLAGS}])
......@@ -4098,6 +4094,12 @@ AS_IF([test "${enable_xcb}" != "no"], [
])
])
PKG_CHECK_MODULES(XCB_RANDR, [xcb-randr], [
VLC_ADD_PLUGIN([panoramix])
VLC_ADD_LIBS([panoramix],[${XCB_RANDR_LIBS} ${XCB_LIBS}])
VLC_ADD_CFLAGS([panoramix],[${XCB_RANDR_CFLAGS} ${XCB_CFLAGS}])
], [true])
dnl xcb-utils
PKG_CHECK_MODULES(XCB_KEYSYMS, [xcb-keysyms])
......
......@@ -46,7 +46,8 @@
# ifdef WIN32
# include <windows.h>
# else
# include <X11/Xlib.h>
# include <xcb/xcb.h>
# include <xcb/randr.h>
# endif
#endif
......@@ -336,6 +337,71 @@ static const panoramix_chroma_t p_chroma_array[] = {
{ 0, {0, }, { 0, }, { 0, 0, 0 }, false }
};
#ifndef WIN32
/* Get the number of outputs */
static unsigned CountMonitors (vlc_object_t *obj)
{
char *psz_display = var_CreateGetNonEmptyString( obj, "x11-display" );
int snum;
xcb_connection_t *conn = xcb_connect( psz_display, &snum );
if( xcb_connection_has_error( conn ) )
return 0;
const xcb_setup_t *setup = xcb_get_setup( conn );
xcb_screen_t *scr = NULL;
for( xcb_screen_iterator_t i = xcb_setup_roots_iterator( setup );
i.rem > 0; xcb_screen_next( &i ) )
{
if (snum == 0)
{
scr = i.data;
break;
}
snum--;
}
unsigned n = 0;
if( scr == NULL )
goto error;
xcb_randr_query_version_reply_t *v =
xcb_randr_query_version_reply( conn,
xcb_randr_query_version( conn, 1, 2 ), NULL );
if( v == NULL )
goto error;
msg_Dbg( obj, "using X RandR extension v%"PRIu32".%"PRIu32,
v->major_version, v->minor_version );
free( v );
xcb_randr_get_screen_resources_reply_t *r =
xcb_randr_get_screen_resources_reply( conn,
xcb_randr_get_screen_resources( conn, scr->root ), NULL );
if( r == NULL )
goto error;
const xcb_randr_output_t *outputs =
xcb_randr_get_screen_resources_outputs( r );
for( unsigned i = 0; i < r->num_outputs; i++ )
{
xcb_randr_get_output_info_reply_t *output =
xcb_randr_get_output_info_reply( conn,
xcb_randr_get_output_info( conn, outputs[i], 0 ), NULL );
if( output == NULL )
continue;
/* FIXME: do not count cloned outputs multiple times */
/* XXX: what to do with UNKNOWN state connections? */
n += output->connection == XCB_RANDR_CONNECTION_CONNECTED;
free( output );
}
free( r );
msg_Dbg( obj, "X randr has %u outputs", n );
error:
xcb_disconnect( conn );
return n;
}
#endif
/*****************************************************************************
* Open: allocates Wall video thread output method
*****************************************************************************
......@@ -394,14 +460,21 @@ static int Open( vlc_object_t *p_this )
}
}
#else
/* TODO linux */
const unsigned i_monitors = CountMonitors( p_this );
if( i_monitors > 1 ) /* Find closest to square */
for( unsigned w = 1; (i_monitors / w) >= w ; w++ )
{
if( i_monitors % w )
continue;
p_sys->i_row = w;
p_sys->i_col = i_monitors / w;
}
#endif
/* By default do 2x1 */
if( p_sys->i_col < 0 || p_sys->i_row < 0 )
{
p_sys->i_col = 2;
if( p_sys->i_row < 0 )
p_sys->i_row = 1;
}
if( p_sys->i_col < 0 )
p_sys->i_col = 2;
var_SetInteger( p_splitter, CFG_PREFIX "cols", p_sys->i_col);
var_SetInteger( p_splitter, CFG_PREFIX "rows", p_sys->i_row);
}
......
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