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