Mercurial > mplayer.hg
annotate libvo/x11_common.c @ 1109:a013b2124f05
-Wall like fixes
author | al3x |
---|---|
date | Tue, 12 Jun 2001 14:03:18 +0000 |
parents | b36fb1ae4b53 |
children | 4c7b219e126c |
rev | line source |
---|---|
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
1 |
32 | 2 #include <stdio.h> |
3 #include <stdlib.h> | |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
4 |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
5 #include "config.h" |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
6 |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
7 #ifdef X11_FULLSCREEN |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
8 |
440
d19a3da6ac13
Pontscho's mixer, select, and hell-a-lot-of-stuff patch ;)
gabucino
parents:
416
diff
changeset
|
9 #include <string.h> |
32 | 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 | |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
20 #include <X11/extensions/dpms.h> |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
21 |
324 | 22 static int dpms_disabled=0; |
23 static int timeout_save=0; | |
24 | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
25 char* mDisplayName=NULL; |
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
26 Display* mDisplay; |
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
27 Window mRootWin; |
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
28 int mScreen; |
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
29 int mLocalDisplay; |
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
30 |
384 | 31 |
32 void vo_hidecursor ( Display *disp , Window win ) | |
33 { | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
34 Cursor no_ptr; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
35 Pixmap bm_no; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
36 XColor black,dummy; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
37 Colormap colormap; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
38 static unsigned char bm_no_data[] = { 0,0,0,0, 0,0,0,0 }; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
39 |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
40 colormap = DefaultColormap(disp,DefaultScreen(disp)); |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
41 XAllocNamedColor(disp,colormap,"black",&black,&dummy); |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
42 bm_no = XCreateBitmapFromData(disp, win, bm_no_data, 8,8); |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
43 no_ptr=XCreatePixmapCursor(disp, bm_no, bm_no,&black, &black,0, 0); |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
44 XDefineCursor(disp,win,no_ptr); |
384 | 45 } |
46 | |
47 | |
32 | 48 int vo_init( void ) |
49 { | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
50 // int mScreen; |
32 | 51 int bpp; |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
52 // char * DisplayName = ":0.0"; |
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
53 // Display * mDisplay; |
32 | 54 XImage * mXImage; |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
55 // Window mRootWin; |
32 | 56 static XWindowAttributes attribs; |
57 | |
58 if(vo_depthonscreen) return 1; // already called | |
59 | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
60 if (!mDisplayName) |
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
61 if (!(mDisplayName=getenv("DISPLAY"))) |
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
62 mDisplayName=strdup(":0.0"); |
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
63 |
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
64 mDisplay=XOpenDisplay(mDisplayName); |
32 | 65 if ( !mDisplay ) |
66 { | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
67 printf( "vo: couldn't open the X11 display (%s)!\n",mDisplayName ); |
32 | 68 return 0; |
69 } | |
70 mScreen=DefaultScreen( mDisplay ); // Screen ID. | |
71 mRootWin=RootWindow( mDisplay,mScreen );// Root window ID. | |
72 vo_screenwidth=DisplayWidth( mDisplay,mScreen ); | |
73 vo_screenheight=DisplayHeight( mDisplay,mScreen ); | |
74 // get color depth: | |
75 // XGetWindowAttributes(mydisplay, DefaultRootWindow(mDisplay), &attribs); | |
76 XGetWindowAttributes(mDisplay, mRootWin, &attribs); | |
77 vo_depthonscreen=attribs.depth; | |
78 // get bits/pixel: | |
79 mXImage=XGetImage( mDisplay,mRootWin,0,0,1,1,AllPlanes,ZPixmap ); | |
80 bpp=mXImage->bits_per_pixel; | |
81 XDestroyImage( mXImage ); | |
82 if((vo_depthonscreen+7)/8 != (bpp+7)/8) vo_depthonscreen=bpp; // by A'rpi | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
83 // XCloseDisplay( mDisplay ); |
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
84 #warning Better local display detection method is needed. |
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
85 if (*mDisplayName==':') mLocalDisplay=1; else mLocalDisplay=0; |
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
86 printf("X11 running at %dx%d depth: %d (\"%s\" => %s display)\n",vo_screenwidth,vo_screenheight,vo_depthonscreen,mDisplayName,mLocalDisplay?"local":"remote"); |
32 | 87 return 1; |
88 } | |
89 | |
90 #include "../linux/keycodes.h" | |
91 #include "wskeys.h" | |
92 | |
93 extern void mplayer_put_key(int code); | |
94 | |
95 void vo_x11_putkey(int key){ | |
96 switch ( key ) | |
97 { | |
98 case wsLeft: mplayer_put_key(KEY_LEFT); break; | |
99 case wsRight: mplayer_put_key(KEY_RIGHT); break; | |
100 case wsUp: mplayer_put_key(KEY_UP); break; | |
101 case wsDown: mplayer_put_key(KEY_DOWN); break; | |
102 case wsSpace: mplayer_put_key(' '); break; | |
103 case wsEscape: mplayer_put_key(KEY_ESC); break; | |
104 case wsEnter: mplayer_put_key(KEY_ENTER); break; | |
651 | 105 case wsPageUp: mplayer_put_key(KEY_PAGE_UP); break; |
106 case wsPageDown: mplayer_put_key(KEY_PAGE_DOWN); break; | |
32 | 107 case wsq: |
108 case wsQ: mplayer_put_key('q'); break; | |
109 case wsp: | |
110 case wsP: mplayer_put_key('p'); break; | |
111 case wsMinus: | |
112 case wsGrayMinus: mplayer_put_key('-'); break; | |
113 case wsPlus: | |
114 case wsGrayPlus: mplayer_put_key('+'); break; | |
464 | 115 case wsGrayMul: |
116 case wsMul: mplayer_put_key('*'); break; | |
117 case wsGrayDiv: | |
118 case wsDiv: mplayer_put_key('/'); break; | |
516 | 119 case wsm: |
120 case wsM: mplayer_put_key('m'); break; | |
655 | 121 case wso: |
122 case wsO: mplayer_put_key('o'); break; | |
369 | 123 default: if((key>='a' && key<='z')||(key>='A' && key<='Z')) mplayer_put_key(key); |
32 | 124 } |
369 | 125 |
32 | 126 } |
127 | |
128 | |
129 // ----- Motif header: ------- | |
130 | |
131 #define MWM_HINTS_DECORATIONS 2 | |
132 | |
133 typedef struct | |
134 { | |
135 long flags; | |
136 long functions; | |
137 long decorations; | |
138 long input_mode; | |
139 } MotifWmHints; | |
140 | |
141 extern MotifWmHints vo_MotifWmHints; | |
142 extern Atom vo_MotifHints; | |
143 extern int vo_depthonscreen; | |
144 extern int vo_screenwidth; | |
145 extern int vo_screenheight; | |
146 | |
147 static MotifWmHints vo_MotifWmHints; | |
148 static Atom vo_MotifHints = None; | |
149 | |
150 void vo_x11_decoration( Display * vo_Display,Window w,int d ) | |
151 { | |
152 vo_MotifHints=XInternAtom( vo_Display,"_MOTIF_WM_HINTS",0 ); | |
153 if ( vo_MotifHints != None ) | |
154 { | |
155 vo_MotifWmHints.flags=2; | |
156 vo_MotifWmHints.decorations=d; | |
157 XChangeProperty( vo_Display,w,vo_MotifHints,vo_MotifHints,32, | |
158 PropModeReplace,(unsigned char *)&vo_MotifWmHints,4 ); | |
159 } | |
160 } | |
161 | |
723 | 162 #ifdef HAVE_GUI |
163 Window vo_window = None; | |
164 GC vo_gc; | |
165 int vo_xeventhandling = 1; | |
166 int vo_resize = 0; | |
167 int vo_expose = 0; | |
168 | |
169 void vo_setwindow( Window w,GC g ) | |
170 { vo_window=w; vo_gc=g; } | |
171 #endif | |
172 | |
32 | 173 int vo_x11_check_events(Display *mydisplay){ |
174 int ret=0; | |
175 XEvent Event; | |
176 char buf[100]; | |
177 KeySym keySym; | |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
922
diff
changeset
|
178 static XComposeStatus stat; |
32 | 179 // unsigned long vo_KeyTable[512]; |
180 | |
723 | 181 #ifdef HAVE_GUI |
182 if ( vo_xeventhandling ) | |
183 { | |
184 #endif | |
185 while ( XPending( mydisplay ) ) | |
186 { | |
187 XNextEvent( mydisplay,&Event ); | |
188 switch( Event.type ) | |
189 { | |
190 case Expose: | |
191 ret|=VO_EVENT_EXPOSE; | |
192 break; | |
193 case ConfigureNotify: | |
194 vo_dwidth=Event.xconfigure.width; | |
195 vo_dheight=Event.xconfigure.height; | |
196 ret|=VO_EVENT_RESIZE; | |
197 break; | |
198 case KeyPress: | |
199 XLookupString( &Event.xkey,buf,sizeof(buf),&keySym,&stat ); | |
200 vo_x11_putkey( ( (keySym&0xff00) != 0?( (keySym&0x00ff) + 256 ):( keySym ) ) ); | |
201 ret|=VO_EVENT_KEYPRESS; | |
202 break; | |
203 } | |
204 } | |
205 #ifdef HAVE_GUI | |
32 | 206 } |
723 | 207 else |
208 { | |
209 if ( vo_resize ) | |
210 { | |
211 vo_resize=0; | |
212 ret|=VO_EVENT_RESIZE; | |
213 } | |
214 if ( vo_expose ) | |
215 { | |
216 vo_expose=0; | |
217 ret|=VO_EVENT_EXPOSE; | |
218 } | |
219 } | |
220 #endif | |
32 | 221 |
222 return ret; | |
223 } | |
224 | |
324 | 225 void saver_on(Display *mDisplay) { |
226 | |
227 int nothing; | |
228 if (dpms_disabled) | |
229 { | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
230 if (DPMSQueryExtension(mDisplay, ¬hing, ¬hing)) |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
231 { |
741 | 232 if (!DPMSEnable(mDisplay)) { // restoring power saving settings |
233 printf("DPMS not available?\n"); | |
234 } else { | |
235 // DPMS does not seem to be enabled unless we call DPMSInfo | |
236 BOOL onoff; | |
237 CARD16 state; | |
238 DPMSInfo(mDisplay, &state, &onoff); | |
239 if (onoff) { | |
240 printf ("Successfully enabled DPMS\n"); | |
241 } else { | |
242 printf ("Could not enable DPMS\n"); | |
243 } | |
244 } | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
245 } |
324 | 246 } |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
247 |
324 | 248 if (timeout_save) |
249 { | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
250 int dummy, interval, prefer_blank, allow_exp; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
251 XGetScreenSaver(mDisplay, &dummy, &interval, &prefer_blank, &allow_exp); |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
252 XSetScreenSaver(mDisplay, timeout_save, interval, prefer_blank, allow_exp); |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
253 XGetScreenSaver(mDisplay, &timeout_save, &interval, &prefer_blank, &allow_exp); |
324 | 254 } |
255 | |
256 } | |
257 | |
258 void saver_off(Display *mDisplay) { | |
259 | |
260 int interval, prefer_blank, allow_exp, nothing; | |
261 | |
262 if (DPMSQueryExtension(mDisplay, ¬hing, ¬hing)) | |
263 { | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
264 BOOL onoff; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
265 CARD16 state; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
266 DPMSInfo(mDisplay, &state, &onoff); |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
267 if (onoff) |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
268 { |
741 | 269 Status stat; |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
270 printf ("Disabling DPMS\n"); |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
271 dpms_disabled=1; |
741 | 272 stat = DPMSDisable(mDisplay); // monitor powersave off |
273 printf ("stat: %d\n", stat); | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
274 } |
324 | 275 } |
276 XGetScreenSaver(mDisplay, &timeout_save, &interval, &prefer_blank, &allow_exp); | |
277 if (timeout_save) | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
278 XSetScreenSaver(mDisplay, 0, interval, prefer_blank, allow_exp); |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
279 // turning off screensaver |
326 | 280 } |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
281 |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
282 #endif |