summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
authorlgb <lgb@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-05-31 22:32:58 +0000
committerlgb <lgb@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-05-31 22:32:58 +0000
commitf61ffa92b939a9e4c1dbe22a15e0398ea17c3075 (patch)
tree68b27b581fced1a21cef5bf2c96c41a8d73dec8d /libvo
parentd7f6f3e341ae2a53c82ec0056257f110c10fdb57 (diff)
downloadmpv-f61ffa92b939a9e4c1dbe22a15e0398ea17c3075.tar.bz2
mpv-f61ffa92b939a9e4c1dbe22a15e0398ea17c3075.tar.xz
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@923 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo')
-rw-r--r--libvo/vo_x11.c37
-rw-r--r--libvo/vo_xmga.c14
-rw-r--r--libvo/vo_xv.c78
-rw-r--r--libvo/x11_common.c29
-rw-r--r--libvo/x11_common.h6
5 files changed, 75 insertions, 89 deletions
diff --git a/libvo/vo_x11.c b/libvo/vo_x11.c
index 5aaee7f9f9..39d8e67f91 100644
--- a/libvo/vo_x11.c
+++ b/libvo/vo_x11.c
@@ -61,7 +61,7 @@ XF86VidModeModeInfo **vidmodes=NULL;
#endif
/* X11 related variables */
-static Display *mDisplay;
+//static Display *mDisplay;
static Window mywindow;
static GC mygc;
static XImage *myximage;
@@ -120,7 +120,7 @@ static uint32_t init( uint32_t width,uint32_t height,uint32_t d_width,uint32_t d
int interval, prefer_blank, allow_exp, nothing;
unsigned int fg,bg;
char *hello=( title == NULL ) ? "X11 render" : title;
- char *name=":0.0";
+// char *name=":0.0";
XSizeHints hint;
XVisualInfo vinfo;
XEvent xev;
@@ -136,17 +136,6 @@ static uint32_t init( uint32_t width,uint32_t height,uint32_t d_width,uint32_t d
if ( X_already_started ) return -1;
if( !vo_init() ) return 0; // Can't open X11
- if( getenv( "DISPLAY" ) ) name=getenv( "DISPLAY" );
-
- mDisplay=XOpenDisplay( name );
-
- if ( mDisplay == NULL )
- {
- printf( "Can not open display\n" );
- return -1;
- }
- screen=DefaultScreen( mDisplay );
-
hint.x=0;
hint.y=0;
hint.width=image_width;
@@ -172,7 +161,7 @@ static uint32_t init( uint32_t width,uint32_t height,uint32_t d_width,uint32_t d
if (have_vm) {
if (vidmodes==NULL)
- XF86VidModeGetAllModeLines(mDisplay,screen,&modecount,&vidmodes);
+ XF86VidModeGetAllModeLines(mDisplay,mScreen,&modecount,&vidmodes);
j=0;
modeline_width=vidmodes[0]->hdisplay;
modeline_height=vidmodes[0]->vdisplay;
@@ -191,12 +180,12 @@ static uint32_t init( uint32_t width,uint32_t height,uint32_t d_width,uint32_t d
}
printf("XF86VM: Selected video mode %dx%d for image size %dx%d.\n",modeline_width, modeline_height, image_width, image_height);
- XF86VidModeLockModeSwitch(mDisplay,screen,0);
- XF86VidModeSwitchToMode(mDisplay,screen,vidmodes[j]);
- XF86VidModeSwitchToMode(mDisplay,screen,vidmodes[j]);
+ XF86VidModeLockModeSwitch(mDisplay,mScreen,0);
+ XF86VidModeSwitchToMode(mDisplay,mScreen,vidmodes[j]);
+ XF86VidModeSwitchToMode(mDisplay,mScreen,vidmodes[j]);
X=(vo_screenwidth-modeline_width)/2;
Y=(vo_screenheight-modeline_height)/2;
- XF86VidModeSetViewPort(mDisplay,screen,X,Y);
+ XF86VidModeSetViewPort(mDisplay,mScreen,X,Y);
}
}
#endif
@@ -211,16 +200,16 @@ static uint32_t init( uint32_t width,uint32_t height,uint32_t d_width,uint32_t d
vo_dheight=hint.height;
hint.flags=PPosition | PSize;
- bg=WhitePixel( mDisplay,screen );
- fg=BlackPixel( mDisplay,screen );
+ bg=WhitePixel( mDisplay,mScreen );
+ fg=BlackPixel( mDisplay,mScreen );
XGetWindowAttributes( mDisplay,DefaultRootWindow( mDisplay ),&attribs );
depth=attribs.depth;
if ( depth != 15 && depth != 16 && depth != 24 && depth != 32 ) depth=24;
- XMatchVisualInfo( mDisplay,screen,depth,TrueColor,&vinfo );
+ XMatchVisualInfo( mDisplay,mScreen,depth,TrueColor,&vinfo );
- theCmap =XCreateColormap( mDisplay,RootWindow( mDisplay,screen ),
+ theCmap =XCreateColormap( mDisplay,RootWindow( mDisplay,mScreen ),
vinfo.visual,AllocNone );
xswa.background_pixel=0;
@@ -228,7 +217,7 @@ static uint32_t init( uint32_t width,uint32_t height,uint32_t d_width,uint32_t d
xswa.colormap=theCmap;
xswamask=CWBackPixel | CWBorderPixel |CWColormap;
- mywindow=XCreateWindow( mDisplay,RootWindow( mDisplay,screen ),
+ mywindow=XCreateWindow( mDisplay,RootWindow( mDisplay,mScreen ),
hint.x,hint.y,
hint.width,hint.height,
xswa.border_pixel,depth,CopyFromParent,vinfo.visual,xswamask,&xswa );
@@ -248,7 +237,7 @@ static uint32_t init( uint32_t width,uint32_t height,uint32_t d_width,uint32_t d
mygc=XCreateGC( mDisplay,mywindow,0L,&xgcv );
#ifdef SH_MEM
- if ( XShmQueryExtension( mDisplay ) ) Shmem_Flag=1;
+ if ( mLocalDisplay && XShmQueryExtension( mDisplay ) ) Shmem_Flag=1;
else
{
Shmem_Flag=0;
diff --git a/libvo/vo_xmga.c b/libvo/vo_xmga.c
index 6a60cf29f5..f9c4dbce44 100644
--- a/libvo/vo_xmga.c
+++ b/libvo/vo_xmga.c
@@ -62,7 +62,7 @@ static vo_info_t vo_info =
""
};
-static Display * mDisplay;
+//static Display * mDisplay;
static Window mWindow;
static GC mGC;
static XGCValues wGCV;
@@ -225,17 +225,7 @@ static uint32_t init( uint32_t width, uint32_t height, uint32_t d_width, uint32_
if ( X_already_started ) return -1;
- vo_init();
-
- if ( getenv( "DISPLAY" ) ) name=getenv( "DISPLAY" );
- mDisplay=XOpenDisplay(name);
- if ( mDisplay == NULL )
- {
- printf( "Can not open X11 display\n" );
- return -1;
- }
-
- mScreen=DefaultScreen( mDisplay );
+ if (!vo_init()) return -1;
mvWidth=width; mvHeight=height;
diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c
index 0f1df47de4..07e540ff47 100644
--- a/libvo/vo_xv.c
+++ b/libvo/vo_xv.c
@@ -48,7 +48,7 @@ int XShmGetEventBase(Display*);
static unsigned char *ImageData;
/* X11 related variables */
-static Display *mydisplay;
+//static Display *mydisplay;
static Window mywindow;
static GC mygc;
static XImage *myximage;
@@ -95,9 +95,9 @@ static uint32_t drwcX,drwcY,dwidth,dheight,mFullscreen;
*/
static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format)
{
- int screen;
+// int screen;
char *hello = (title == NULL) ? "Xv render" : title;
- char *name = ":0.0";
+// char *name = ":0.0";
XSizeHints hint;
XVisualInfo vinfo;
XEvent xev;
@@ -112,18 +112,8 @@ static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t
mFullscreen=flags&1;
dwidth=d_width; dheight=d_height;
-
- if(getenv("DISPLAY")) name = getenv("DISPLAY");
-
- mydisplay = XOpenDisplay(name);
-
- if (mydisplay == NULL)
- {
- printf("Can't open display\n");
- return -1;
- }
-
- screen = DefaultScreen(mydisplay);
+
+ if (!vo_init()) return -1;
#ifdef HAVE_GUI
if ( vo_window == None )
@@ -139,26 +129,26 @@ static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t
hint.height=vo_screenheight;
}
hint.flags = PPosition | PSize;
- XGetWindowAttributes(mydisplay, DefaultRootWindow(mydisplay), &attribs);
+ XGetWindowAttributes(mDisplay, DefaultRootWindow(mDisplay), &attribs);
depth=attribs.depth;
if (depth != 15 && depth != 16 && depth != 24 && depth != 32) depth = 24;
- XMatchVisualInfo(mydisplay, screen, depth, TrueColor, &vinfo);
+ XMatchVisualInfo(mDisplay, mScreen, depth, TrueColor, &vinfo);
xswa.background_pixel = 0;
xswa.border_pixel = 0;
xswamask = CWBackPixel | CWBorderPixel;
- mywindow = XCreateWindow(mydisplay, RootWindow(mydisplay,screen),
+ mywindow = XCreateWindow(mDisplay, RootWindow(mDisplay,mScreen),
hint.x, hint.y, hint.width, hint.height,
0, depth,CopyFromParent,vinfo.visual,xswamask,&xswa);
- vo_hidecursor(mydisplay,mywindow);
-
- XSelectInput(mydisplay, mywindow, StructureNotifyMask | KeyPressMask );
- XSetStandardProperties(mydisplay, mywindow, hello, hello, None, NULL, 0, &hint);
- if ( mFullscreen ) vo_x11_decoration( mydisplay,mywindow,0 );
- XMapWindow(mydisplay, mywindow);
- XFlush(mydisplay);
- XSync(mydisplay, False);
+ vo_hidecursor(mDisplay,mywindow);
+
+ XSelectInput(mDisplay, mywindow, StructureNotifyMask | KeyPressMask );
+ XSetStandardProperties(mDisplay, mywindow, hello, hello, None, NULL, 0, &hint);
+ if ( mFullscreen ) vo_x11_decoration( mDisplay,mywindow,0 );
+ XMapWindow(mDisplay, mywindow);
+ XFlush(mDisplay);
+ XSync(mDisplay, False);
#ifdef HAVE_GUI
}
else
@@ -167,20 +157,20 @@ static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t
mygc=vo_gc;
if ( vo_screenwidth != d_width )
{
- XMoveWindow( mydisplay,mywindow,( vo_screenwidth - d_width ) / 2,( vo_screenheight - d_height ) / 2 );
- XResizeWindow( mydisplay,mywindow,d_width,d_height );
+ XMoveWindow( mDisplay,mywindow,( vo_screenwidth - d_width ) / 2,( vo_screenheight - d_height ) / 2 );
+ XResizeWindow( mDisplay,mywindow,d_width,d_height );
}
else mFullscreen=1;
}
#endif
- mygc = XCreateGC(mydisplay, mywindow, 0L, &xgcv);
+ mygc = XCreateGC(mDisplay, mywindow, 0L, &xgcv);
xv_port = 0;
- if (Success == XvQueryExtension(mydisplay,&ver,&rel,&req,&ev,&err))
+ if (Success == XvQueryExtension(mDisplay,&ver,&rel,&req,&ev,&err))
{
/* check for Xvideo support */
- if (Success != XvQueryAdaptors(mydisplay,DefaultRootWindow(mydisplay), &adaptors,&ai))
+ if (Success != XvQueryAdaptors(mDisplay,DefaultRootWindow(mDisplay), &adaptors,&ai))
{
printf("Xv: XvQueryAdaptors failed");
return -1;
@@ -193,7 +183,7 @@ static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t
/* check image formats */
if (xv_port != 0)
{
- fo = XvListImageFormats(mydisplay, xv_port, (int*)&formats);
+ fo = XvListImageFormats(mDisplay, xv_port, (int*)&formats);
xv_format=0;
for(i = 0; i < formats; i++)
{
@@ -216,9 +206,9 @@ static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t
current_buf=0;
- XGetGeometry( mydisplay,mywindow,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth );
+ XGetGeometry( mDisplay,mywindow,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth );
drwX=0; drwY=0;
- XTranslateCoordinates( mydisplay,mywindow,mRoot,0,0,&drwcX,&drwcY,&mRoot );
+ XTranslateCoordinates( mDisplay,mywindow,mRoot,0,0,&drwcX,&drwcY,&mRoot );
printf( "[xv] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight );
if ( mFullscreen )
@@ -232,7 +222,7 @@ static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t
printf( "[xv-fs] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight );
}
- saver_off(mydisplay); // turning off screen saver
+ saver_off(mDisplay); // turning off screen saver
return 0;
}
}
@@ -251,15 +241,15 @@ static void allocate_xvimage(int foo)
* allocate XvImages. FIXME: no error checking, without
* mit-shm this will bomb...
*/
- xvimage[foo] = XvShmCreateImage(mydisplay, xv_port, xv_format, 0, image_width, image_height, &Shminfo[foo]);
+ xvimage[foo] = XvShmCreateImage(mDisplay, xv_port, xv_format, 0, image_width, image_height, &Shminfo[foo]);
Shminfo[foo].shmid = shmget(IPC_PRIVATE, xvimage[foo]->data_size, IPC_CREAT | 0777);
Shminfo[foo].shmaddr = (char *) shmat(Shminfo[foo].shmid, 0, 0);
Shminfo[foo].readOnly = False;
xvimage[foo]->data = Shminfo[foo].shmaddr;
- XShmAttach(mydisplay, &Shminfo[foo]);
- XSync(mydisplay, False);
+ XShmAttach(mDisplay, &Shminfo[foo]);
+ XSync(mDisplay, False);
shmctl(Shminfo[foo].shmid, IPC_RMID, 0);
memset(xvimage[foo]->data,128,xvimage[foo]->data_size);
return;
@@ -267,12 +257,12 @@ static void allocate_xvimage(int foo)
static void check_events(void)
{
- int e=vo_x11_check_events(mydisplay);
+ int e=vo_x11_check_events(mDisplay);
if(e&VO_EVENT_RESIZE)
{
- XGetGeometry( mydisplay,mywindow,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth );
+ XGetGeometry( mDisplay,mywindow,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth );
drwX=0; drwY=0;
- XTranslateCoordinates( mydisplay,mywindow,mRoot,0,0,&drwcX,&drwcY,&mRoot );
+ XTranslateCoordinates( mDisplay,mywindow,mRoot,0,0,&drwcX,&drwcY,&mRoot );
printf( "[xv] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight );
#ifdef HAVE_GUI
@@ -327,11 +317,11 @@ static void flip_page(void)
{
vo_draw_text(image_width,image_height,draw_alpha);
check_events();
- XvShmPutImage(mydisplay, xv_port, mywindow, mygc, xvimage[current_buf],
+ XvShmPutImage(mDisplay, xv_port, mywindow, mygc, xvimage[current_buf],
0, 0, image_width, image_height,
drwX,drwY,drwWidth,(mFullscreen?drwHeight - 1:drwHeight),
False);
- XFlush(mydisplay);
+ XFlush(mDisplay);
current_buf=(current_buf+1)%NUM_BUFFERS;
return;
}
@@ -436,7 +426,7 @@ static uint32_t query_format(uint32_t format)
}
static void uninit(void) {
- saver_on(mydisplay); // screen saver back on
+ saver_on(mDisplay); // screen saver back on
}
diff --git a/libvo/x11_common.c b/libvo/x11_common.c
index c4d296c92e..b33cf7874f 100644
--- a/libvo/x11_common.c
+++ b/libvo/x11_common.c
@@ -22,6 +22,12 @@
static int dpms_disabled=0;
static int timeout_save=0;
+char* mDisplayName=NULL;
+Display* mDisplay;
+Window mRootWin;
+int mScreen;
+int mLocalDisplay;
+
void vo_hidecursor ( Display *disp , Window win )
{
@@ -42,21 +48,24 @@ void vo_hidecursor ( Display *disp , Window win )
int vo_init( void )
{
int CompletionType = -1;
- int mScreen;
+// int mScreen;
int bpp;
- char * DisplayName = ":0.0";
- Display * mDisplay;
+// char * DisplayName = ":0.0";
+// Display * mDisplay;
XImage * mXImage;
- Window mRootWin;
+// Window mRootWin;
static XWindowAttributes attribs;
if(vo_depthonscreen) return 1; // already called
- if ( getenv( "DISPLAY" ) ) DisplayName=getenv( "DISPLAY" );
- mDisplay=XOpenDisplay( DisplayName );
+ if (!mDisplayName)
+ if (!(mDisplayName=getenv("DISPLAY")))
+ mDisplayName=strdup(":0.0");
+
+ mDisplay=XOpenDisplay(mDisplayName);
if ( !mDisplay )
{
- printf( "vo: couldn't open the X11 display!\n" );
+ printf( "vo: couldn't open the X11 display (%s)!\n",mDisplayName );
return 0;
}
mScreen=DefaultScreen( mDisplay ); // Screen ID.
@@ -72,8 +81,10 @@ int vo_init( void )
bpp=mXImage->bits_per_pixel;
XDestroyImage( mXImage );
if((vo_depthonscreen+7)/8 != (bpp+7)/8) vo_depthonscreen=bpp; // by A'rpi
- XCloseDisplay( mDisplay );
- printf("X11 running at %dx%d depth: %d\n",vo_screenwidth,vo_screenheight,vo_depthonscreen);
+// XCloseDisplay( mDisplay );
+#warning Better local display detection method is needed.
+ if (*mDisplayName==':') mLocalDisplay=1; else mLocalDisplay=0;
+ printf("X11 running at %dx%d depth: %d (\"%s\" => %s display)\n",vo_screenwidth,vo_screenheight,vo_depthonscreen,mDisplayName,mLocalDisplay?"local":"remote");
return 1;
}
diff --git a/libvo/x11_common.h b/libvo/x11_common.h
index 47e2a39fab..5a5c7d9f44 100644
--- a/libvo/x11_common.h
+++ b/libvo/x11_common.h
@@ -7,6 +7,12 @@ extern int vo_screenheight;
extern int vo_dwidth;
extern int vo_dheight;
+extern char *mDisplayName;
+extern Display *mDisplay;
+extern Window *mRootWin;
+extern int mScreen;
+extern int mLocalDisplay;
+
int vo_init( void );
int vo_hidecursor ( Display* , Window );
void vo_x11_decoration( Display * vo_Display,Window w,int d );