416
|
1
|
32
|
2 #include <stdio.h>
|
|
3 #include <stdlib.h>
|
416
|
4
|
|
5 #include "config.h"
|
|
6
|
|
7 #ifdef X11_FULLSCREEN
|
|
8
|
32
|
9 #include <string.h>
|
|
10 #include <unistd.h>
|
|
11 #include <sys/mman.h>
|
|
12
|
|
13 #include "video_out.h"
|
|
14
|
324
|
15 #include <X11/Xmd.h>
|
32
|
16 #include <X11/Xlib.h>
|
|
17 #include <X11/Xutil.h>
|
|
18 #include <X11/Xatom.h>
|
|
19
|
402
|
20 #include <X11/extensions/dpms.h>
|
|
21
|
324
|
22 static int dpms_disabled=0;
|
|
23 static int timeout_save=0;
|
|
24
|
384
|
25
|
|
26 void vo_hidecursor ( Display *disp , Window win )
|
|
27 {
|
|
28 Cursor no_ptr;
|
|
29 Pixmap bm_no;
|
|
30 XColor black,dummy;
|
|
31 Colormap colormap;
|
|
32 static unsigned char bm_no_data[] = { 0,0,0,0, 0,0,0,0 };
|
|
33
|
|
34 colormap = DefaultColormap(disp,DefaultScreen(disp));
|
|
35 XAllocNamedColor(disp,colormap,"black",&black,&dummy);
|
|
36 bm_no = XCreateBitmapFromData(disp, win, bm_no_data, 8,8);
|
|
37 no_ptr=XCreatePixmapCursor(disp, bm_no, bm_no,&black, &black,0, 0);
|
|
38 XDefineCursor(disp,win,no_ptr);
|
|
39 }
|
|
40
|
|
41
|
32
|
42 int vo_init( void )
|
|
43 {
|
|
44 int CompletionType = -1;
|
|
45 int mScreen;
|
|
46 int bpp;
|
|
47 char * DisplayName = ":0.0";
|
|
48 Display * mDisplay;
|
|
49 XImage * mXImage;
|
|
50 Window mRootWin;
|
|
51 static XWindowAttributes attribs;
|
|
52
|
|
53 if(vo_depthonscreen) return 1; // already called
|
|
54
|
|
55 if ( getenv( "DISPLAY" ) ) DisplayName=getenv( "DISPLAY" );
|
|
56 mDisplay=XOpenDisplay( DisplayName );
|
|
57 if ( !mDisplay )
|
|
58 {
|
|
59 fprintf( stderr,"vo: couldn't open the X11 display!\n" );
|
|
60 return 0;
|
|
61 }
|
|
62 mScreen=DefaultScreen( mDisplay ); // Screen ID.
|
|
63 mRootWin=RootWindow( mDisplay,mScreen );// Root window ID.
|
|
64 vo_screenwidth=DisplayWidth( mDisplay,mScreen );
|
|
65 vo_screenheight=DisplayHeight( mDisplay,mScreen );
|
|
66 // get color depth:
|
|
67 // XGetWindowAttributes(mydisplay, DefaultRootWindow(mDisplay), &attribs);
|
|
68 XGetWindowAttributes(mDisplay, mRootWin, &attribs);
|
|
69 vo_depthonscreen=attribs.depth;
|
|
70 // get bits/pixel:
|
|
71 mXImage=XGetImage( mDisplay,mRootWin,0,0,1,1,AllPlanes,ZPixmap );
|
|
72 bpp=mXImage->bits_per_pixel;
|
|
73 XDestroyImage( mXImage );
|
|
74 if((vo_depthonscreen+7)/8 != (bpp+7)/8) vo_depthonscreen=bpp; // by A'rpi
|
|
75 XCloseDisplay( mDisplay );
|
|
76 printf("X11 running at %dx%d depth: %d\n",vo_screenwidth,vo_screenheight,vo_depthonscreen);
|
|
77 return 1;
|
|
78 }
|
|
79
|
|
80 #include "../linux/keycodes.h"
|
|
81 #include "wskeys.h"
|
|
82
|
|
83 extern void mplayer_put_key(int code);
|
|
84
|
|
85 void vo_x11_putkey(int key){
|
|
86 switch ( key )
|
|
87 {
|
|
88 case wsLeft: mplayer_put_key(KEY_LEFT); break;
|
|
89 case wsRight: mplayer_put_key(KEY_RIGHT); break;
|
|
90 case wsUp: mplayer_put_key(KEY_UP); break;
|
|
91 case wsDown: mplayer_put_key(KEY_DOWN); break;
|
|
92 case wsSpace: mplayer_put_key(' '); break;
|
|
93 case wsEscape: mplayer_put_key(KEY_ESC); break;
|
|
94 case wsEnter: mplayer_put_key(KEY_ENTER); break;
|
|
95 case wsq:
|
|
96 case wsQ: mplayer_put_key('q'); break;
|
|
97 case wsp:
|
|
98 case wsP: mplayer_put_key('p'); break;
|
|
99 case wsMinus:
|
|
100 case wsGrayMinus: mplayer_put_key('-'); break;
|
|
101 case wsPlus:
|
|
102 case wsGrayPlus: mplayer_put_key('+'); break;
|
369
|
103 default: if((key>='a' && key<='z')||(key>='A' && key<='Z')) mplayer_put_key(key);
|
32
|
104 }
|
369
|
105
|
32
|
106 }
|
|
107
|
|
108
|
|
109 // ----- Motif header: -------
|
|
110
|
|
111 #define MWM_HINTS_DECORATIONS 2
|
|
112
|
|
113 typedef struct
|
|
114 {
|
|
115 long flags;
|
|
116 long functions;
|
|
117 long decorations;
|
|
118 long input_mode;
|
|
119 } MotifWmHints;
|
|
120
|
|
121 extern MotifWmHints vo_MotifWmHints;
|
|
122 extern Atom vo_MotifHints;
|
|
123 extern int vo_depthonscreen;
|
|
124 extern int vo_screenwidth;
|
|
125 extern int vo_screenheight;
|
|
126
|
|
127 static MotifWmHints vo_MotifWmHints;
|
|
128 static Atom vo_MotifHints = None;
|
|
129
|
|
130 void vo_x11_decoration( Display * vo_Display,Window w,int d )
|
|
131 {
|
|
132 vo_MotifHints=XInternAtom( vo_Display,"_MOTIF_WM_HINTS",0 );
|
|
133 if ( vo_MotifHints != None )
|
|
134 {
|
|
135 vo_MotifWmHints.flags=2;
|
|
136 vo_MotifWmHints.decorations=d;
|
|
137 XChangeProperty( vo_Display,w,vo_MotifHints,vo_MotifHints,32,
|
|
138 PropModeReplace,(unsigned char *)&vo_MotifWmHints,4 );
|
|
139 }
|
|
140 }
|
|
141
|
|
142 int vo_x11_check_events(Display *mydisplay){
|
|
143 int ret=0;
|
|
144 XEvent Event;
|
|
145 char buf[100];
|
|
146 KeySym keySym;
|
|
147 XComposeStatus stat;
|
|
148 // unsigned long vo_KeyTable[512];
|
|
149
|
|
150 while ( XPending( mydisplay ) )
|
|
151 {
|
|
152 XNextEvent( mydisplay,&Event );
|
|
153 switch( Event.type )
|
|
154 {
|
|
155 case Expose:
|
|
156 ret|=VO_EVENT_EXPOSE;
|
|
157 break;
|
|
158 case ConfigureNotify:
|
|
159 vo_dwidth=Event.xconfigure.width;
|
|
160 vo_dheight=Event.xconfigure.height;
|
|
161 ret|=VO_EVENT_RESIZE;
|
|
162 break;
|
|
163 case KeyPress:
|
|
164 XLookupString( &Event.xkey,buf,sizeof(buf),&keySym,&stat );
|
|
165 vo_x11_putkey( ( (keySym&0xff00) != 0?( (keySym&0x00ff) + 256 ):( keySym ) ) );
|
|
166 ret|=VO_EVENT_KEYPRESS;
|
|
167 break;
|
|
168 }
|
|
169 }
|
|
170
|
|
171 return ret;
|
|
172 }
|
|
173
|
324
|
174 void saver_on(Display *mDisplay) {
|
|
175
|
|
176 int nothing;
|
|
177 if (dpms_disabled)
|
|
178 {
|
|
179 if (DPMSQueryExtension(mDisplay, ¬hing, ¬hing))
|
|
180 {
|
|
181 printf ("Enabling DPMS\n");
|
|
182 DPMSEnable(mDisplay); // restoring power saving settings
|
|
183 DPMSQueryExtension(mDisplay, ¬hing, ¬hing);
|
|
184 }
|
|
185 }
|
|
186
|
|
187 if (timeout_save)
|
|
188 {
|
|
189 int dummy, interval, prefer_blank, allow_exp;
|
|
190 XGetScreenSaver(mDisplay, &dummy, &interval, &prefer_blank, &allow_exp);
|
|
191 XSetScreenSaver(mDisplay, timeout_save, interval, prefer_blank, allow_exp);
|
|
192 XGetScreenSaver(mDisplay, &timeout_save, &interval, &prefer_blank, &allow_exp);
|
|
193 }
|
|
194
|
|
195 }
|
|
196
|
|
197 void saver_off(Display *mDisplay) {
|
|
198
|
|
199 int interval, prefer_blank, allow_exp, nothing;
|
|
200
|
|
201 if (DPMSQueryExtension(mDisplay, ¬hing, ¬hing))
|
|
202 {
|
|
203 BOOL onoff;
|
|
204 CARD16 state;
|
|
205 DPMSInfo(mDisplay, &state, &onoff);
|
|
206 if (onoff)
|
|
207 {
|
|
208 printf ("Disabling DPMS\n");
|
|
209 dpms_disabled=1;
|
|
210 DPMSDisable(mDisplay); // monitor powersave off
|
|
211 }
|
|
212 }
|
|
213 XGetScreenSaver(mDisplay, &timeout_save, &interval, &prefer_blank, &allow_exp);
|
|
214 if (timeout_save)
|
|
215 XSetScreenSaver(mDisplay, 0, interval, prefer_blank, allow_exp);
|
|
216 // turning off screensaver
|
326
|
217 }
|
416
|
218
|
|
219 #endif
|