Mercurial > mplayer.hg
comparison libvo/x11_common.c @ 922:db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
author | lgb |
---|---|
date | Thu, 31 May 2001 22:32:58 +0000 |
parents | 00f97e760cbc |
children | b36fb1ae4b53 |
comparison
equal
deleted
inserted
replaced
921:6b02113cd41a | 922:db06ae8967eb |
---|---|
19 | 19 |
20 #include <X11/extensions/dpms.h> | 20 #include <X11/extensions/dpms.h> |
21 | 21 |
22 static int dpms_disabled=0; | 22 static int dpms_disabled=0; |
23 static int timeout_save=0; | 23 static int timeout_save=0; |
24 | |
25 char* mDisplayName=NULL; | |
26 Display* mDisplay; | |
27 Window mRootWin; | |
28 int mScreen; | |
29 int mLocalDisplay; | |
24 | 30 |
25 | 31 |
26 void vo_hidecursor ( Display *disp , Window win ) | 32 void vo_hidecursor ( Display *disp , Window win ) |
27 { | 33 { |
28 Cursor no_ptr; | 34 Cursor no_ptr; |
40 | 46 |
41 | 47 |
42 int vo_init( void ) | 48 int vo_init( void ) |
43 { | 49 { |
44 int CompletionType = -1; | 50 int CompletionType = -1; |
45 int mScreen; | 51 // int mScreen; |
46 int bpp; | 52 int bpp; |
47 char * DisplayName = ":0.0"; | 53 // char * DisplayName = ":0.0"; |
48 Display * mDisplay; | 54 // Display * mDisplay; |
49 XImage * mXImage; | 55 XImage * mXImage; |
50 Window mRootWin; | 56 // Window mRootWin; |
51 static XWindowAttributes attribs; | 57 static XWindowAttributes attribs; |
52 | 58 |
53 if(vo_depthonscreen) return 1; // already called | 59 if(vo_depthonscreen) return 1; // already called |
54 | 60 |
55 if ( getenv( "DISPLAY" ) ) DisplayName=getenv( "DISPLAY" ); | 61 if (!mDisplayName) |
56 mDisplay=XOpenDisplay( DisplayName ); | 62 if (!(mDisplayName=getenv("DISPLAY"))) |
63 mDisplayName=strdup(":0.0"); | |
64 | |
65 mDisplay=XOpenDisplay(mDisplayName); | |
57 if ( !mDisplay ) | 66 if ( !mDisplay ) |
58 { | 67 { |
59 printf( "vo: couldn't open the X11 display!\n" ); | 68 printf( "vo: couldn't open the X11 display (%s)!\n",mDisplayName ); |
60 return 0; | 69 return 0; |
61 } | 70 } |
62 mScreen=DefaultScreen( mDisplay ); // Screen ID. | 71 mScreen=DefaultScreen( mDisplay ); // Screen ID. |
63 mRootWin=RootWindow( mDisplay,mScreen );// Root window ID. | 72 mRootWin=RootWindow( mDisplay,mScreen );// Root window ID. |
64 vo_screenwidth=DisplayWidth( mDisplay,mScreen ); | 73 vo_screenwidth=DisplayWidth( mDisplay,mScreen ); |
70 // get bits/pixel: | 79 // get bits/pixel: |
71 mXImage=XGetImage( mDisplay,mRootWin,0,0,1,1,AllPlanes,ZPixmap ); | 80 mXImage=XGetImage( mDisplay,mRootWin,0,0,1,1,AllPlanes,ZPixmap ); |
72 bpp=mXImage->bits_per_pixel; | 81 bpp=mXImage->bits_per_pixel; |
73 XDestroyImage( mXImage ); | 82 XDestroyImage( mXImage ); |
74 if((vo_depthonscreen+7)/8 != (bpp+7)/8) vo_depthonscreen=bpp; // by A'rpi | 83 if((vo_depthonscreen+7)/8 != (bpp+7)/8) vo_depthonscreen=bpp; // by A'rpi |
75 XCloseDisplay( mDisplay ); | 84 // XCloseDisplay( mDisplay ); |
76 printf("X11 running at %dx%d depth: %d\n",vo_screenwidth,vo_screenheight,vo_depthonscreen); | 85 #warning Better local display detection method is needed. |
86 if (*mDisplayName==':') mLocalDisplay=1; else mLocalDisplay=0; | |
87 printf("X11 running at %dx%d depth: %d (\"%s\" => %s display)\n",vo_screenwidth,vo_screenheight,vo_depthonscreen,mDisplayName,mLocalDisplay?"local":"remote"); | |
77 return 1; | 88 return 1; |
78 } | 89 } |
79 | 90 |
80 #include "../linux/keycodes.h" | 91 #include "../linux/keycodes.h" |
81 #include "wskeys.h" | 92 #include "wskeys.h" |