Mercurial > mplayer.hg
annotate libvo/x11_common.c @ 882:6d9ceb757640
alaw/ulaw tables, generated with TOOLS/alaw-gen.c
author | arpi_esp |
---|---|
date | Fri, 25 May 2001 18:26:01 +0000 |
parents | 00f97e760cbc |
children | db06ae8967eb |
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 | |
384 | 25 |
26 void vo_hidecursor ( Display *disp , Window win ) | |
27 { | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
28 Cursor no_ptr; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
29 Pixmap bm_no; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
30 XColor black,dummy; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
31 Colormap colormap; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
32 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
|
33 |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
34 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
|
35 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
|
36 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
|
37 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
|
38 XDefineCursor(disp,win,no_ptr); |
384 | 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 { | |
614 | 59 printf( "vo: couldn't open the X11 display!\n" ); |
32 | 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; | |
651 | 95 case wsPageUp: mplayer_put_key(KEY_PAGE_UP); break; |
96 case wsPageDown: mplayer_put_key(KEY_PAGE_DOWN); break; | |
32 | 97 case wsq: |
98 case wsQ: mplayer_put_key('q'); break; | |
99 case wsp: | |
100 case wsP: mplayer_put_key('p'); break; | |
101 case wsMinus: | |
102 case wsGrayMinus: mplayer_put_key('-'); break; | |
103 case wsPlus: | |
104 case wsGrayPlus: mplayer_put_key('+'); break; | |
464 | 105 case wsGrayMul: |
106 case wsMul: mplayer_put_key('*'); break; | |
107 case wsGrayDiv: | |
108 case wsDiv: mplayer_put_key('/'); break; | |
516 | 109 case wsm: |
110 case wsM: mplayer_put_key('m'); break; | |
655 | 111 case wso: |
112 case wsO: mplayer_put_key('o'); break; | |
369 | 113 default: if((key>='a' && key<='z')||(key>='A' && key<='Z')) mplayer_put_key(key); |
32 | 114 } |
369 | 115 |
32 | 116 } |
117 | |
118 | |
119 // ----- Motif header: ------- | |
120 | |
121 #define MWM_HINTS_DECORATIONS 2 | |
122 | |
123 typedef struct | |
124 { | |
125 long flags; | |
126 long functions; | |
127 long decorations; | |
128 long input_mode; | |
129 } MotifWmHints; | |
130 | |
131 extern MotifWmHints vo_MotifWmHints; | |
132 extern Atom vo_MotifHints; | |
133 extern int vo_depthonscreen; | |
134 extern int vo_screenwidth; | |
135 extern int vo_screenheight; | |
136 | |
137 static MotifWmHints vo_MotifWmHints; | |
138 static Atom vo_MotifHints = None; | |
139 | |
140 void vo_x11_decoration( Display * vo_Display,Window w,int d ) | |
141 { | |
142 vo_MotifHints=XInternAtom( vo_Display,"_MOTIF_WM_HINTS",0 ); | |
143 if ( vo_MotifHints != None ) | |
144 { | |
145 vo_MotifWmHints.flags=2; | |
146 vo_MotifWmHints.decorations=d; | |
147 XChangeProperty( vo_Display,w,vo_MotifHints,vo_MotifHints,32, | |
148 PropModeReplace,(unsigned char *)&vo_MotifWmHints,4 ); | |
149 } | |
150 } | |
151 | |
723 | 152 #ifdef HAVE_GUI |
153 Window vo_window = None; | |
154 GC vo_gc; | |
155 int vo_xeventhandling = 1; | |
156 int vo_resize = 0; | |
157 int vo_expose = 0; | |
158 | |
159 void vo_setwindow( Window w,GC g ) | |
160 { vo_window=w; vo_gc=g; } | |
161 #endif | |
162 | |
32 | 163 int vo_x11_check_events(Display *mydisplay){ |
164 int ret=0; | |
165 XEvent Event; | |
166 char buf[100]; | |
167 KeySym keySym; | |
168 XComposeStatus stat; | |
169 // unsigned long vo_KeyTable[512]; | |
170 | |
723 | 171 #ifdef HAVE_GUI |
172 if ( vo_xeventhandling ) | |
173 { | |
174 #endif | |
175 while ( XPending( mydisplay ) ) | |
176 { | |
177 XNextEvent( mydisplay,&Event ); | |
178 switch( Event.type ) | |
179 { | |
180 case Expose: | |
181 ret|=VO_EVENT_EXPOSE; | |
182 break; | |
183 case ConfigureNotify: | |
184 vo_dwidth=Event.xconfigure.width; | |
185 vo_dheight=Event.xconfigure.height; | |
186 ret|=VO_EVENT_RESIZE; | |
187 break; | |
188 case KeyPress: | |
189 XLookupString( &Event.xkey,buf,sizeof(buf),&keySym,&stat ); | |
190 vo_x11_putkey( ( (keySym&0xff00) != 0?( (keySym&0x00ff) + 256 ):( keySym ) ) ); | |
191 ret|=VO_EVENT_KEYPRESS; | |
192 break; | |
193 } | |
194 } | |
195 #ifdef HAVE_GUI | |
32 | 196 } |
723 | 197 else |
198 { | |
199 if ( vo_resize ) | |
200 { | |
201 vo_resize=0; | |
202 ret|=VO_EVENT_RESIZE; | |
203 } | |
204 if ( vo_expose ) | |
205 { | |
206 vo_expose=0; | |
207 ret|=VO_EVENT_EXPOSE; | |
208 } | |
209 } | |
210 #endif | |
32 | 211 |
212 return ret; | |
213 } | |
214 | |
324 | 215 void saver_on(Display *mDisplay) { |
216 | |
217 int nothing; | |
218 if (dpms_disabled) | |
219 { | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
220 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
|
221 { |
741 | 222 if (!DPMSEnable(mDisplay)) { // restoring power saving settings |
223 printf("DPMS not available?\n"); | |
224 } else { | |
225 // DPMS does not seem to be enabled unless we call DPMSInfo | |
226 BOOL onoff; | |
227 CARD16 state; | |
228 DPMSInfo(mDisplay, &state, &onoff); | |
229 if (onoff) { | |
230 printf ("Successfully enabled DPMS\n"); | |
231 } else { | |
232 printf ("Could not enable DPMS\n"); | |
233 } | |
234 } | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
235 } |
324 | 236 } |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
237 |
324 | 238 if (timeout_save) |
239 { | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
240 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
|
241 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
|
242 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
|
243 XGetScreenSaver(mDisplay, &timeout_save, &interval, &prefer_blank, &allow_exp); |
324 | 244 } |
245 | |
246 } | |
247 | |
248 void saver_off(Display *mDisplay) { | |
249 | |
250 int interval, prefer_blank, allow_exp, nothing; | |
251 | |
252 if (DPMSQueryExtension(mDisplay, ¬hing, ¬hing)) | |
253 { | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
254 BOOL onoff; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
255 CARD16 state; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
256 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
|
257 if (onoff) |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
258 { |
741 | 259 Status stat; |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
260 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
|
261 dpms_disabled=1; |
741 | 262 stat = DPMSDisable(mDisplay); // monitor powersave off |
263 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
|
264 } |
324 | 265 } |
266 XGetScreenSaver(mDisplay, &timeout_save, &interval, &prefer_blank, &allow_exp); | |
267 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
|
268 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
|
269 // turning off screensaver |
326 | 270 } |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
271 |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
272 #endif |