Mercurial > mplayer.hg
annotate libvo/x11_common.c @ 552:c2a449f90087
dvd sub support reading
author | arpi_esp |
---|---|
date | Fri, 20 Apr 2001 22:35:15 +0000 |
parents | bdca96b27ceb |
children | f83ec60bce49 |
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 { | |
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; | |
464 | 103 case wsGrayMul: |
104 case wsMul: mplayer_put_key('*'); break; | |
105 case wsGrayDiv: | |
106 case wsDiv: mplayer_put_key('/'); break; | |
516 | 107 case wsm: |
108 case wsM: mplayer_put_key('m'); break; | |
369 | 109 default: if((key>='a' && key<='z')||(key>='A' && key<='Z')) mplayer_put_key(key); |
32 | 110 } |
369 | 111 |
32 | 112 } |
113 | |
114 | |
115 // ----- Motif header: ------- | |
116 | |
117 #define MWM_HINTS_DECORATIONS 2 | |
118 | |
119 typedef struct | |
120 { | |
121 long flags; | |
122 long functions; | |
123 long decorations; | |
124 long input_mode; | |
125 } MotifWmHints; | |
126 | |
127 extern MotifWmHints vo_MotifWmHints; | |
128 extern Atom vo_MotifHints; | |
129 extern int vo_depthonscreen; | |
130 extern int vo_screenwidth; | |
131 extern int vo_screenheight; | |
132 | |
133 static MotifWmHints vo_MotifWmHints; | |
134 static Atom vo_MotifHints = None; | |
135 | |
136 void vo_x11_decoration( Display * vo_Display,Window w,int d ) | |
137 { | |
138 vo_MotifHints=XInternAtom( vo_Display,"_MOTIF_WM_HINTS",0 ); | |
139 if ( vo_MotifHints != None ) | |
140 { | |
141 vo_MotifWmHints.flags=2; | |
142 vo_MotifWmHints.decorations=d; | |
143 XChangeProperty( vo_Display,w,vo_MotifHints,vo_MotifHints,32, | |
144 PropModeReplace,(unsigned char *)&vo_MotifWmHints,4 ); | |
145 } | |
146 } | |
147 | |
148 int vo_x11_check_events(Display *mydisplay){ | |
149 int ret=0; | |
150 XEvent Event; | |
151 char buf[100]; | |
152 KeySym keySym; | |
153 XComposeStatus stat; | |
154 // unsigned long vo_KeyTable[512]; | |
155 | |
156 while ( XPending( mydisplay ) ) | |
157 { | |
158 XNextEvent( mydisplay,&Event ); | |
159 switch( Event.type ) | |
160 { | |
161 case Expose: | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
162 ret|=VO_EVENT_EXPOSE; |
32 | 163 break; |
164 case ConfigureNotify: | |
165 vo_dwidth=Event.xconfigure.width; | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
166 vo_dheight=Event.xconfigure.height; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
167 ret|=VO_EVENT_RESIZE; |
32 | 168 break; |
169 case KeyPress: | |
170 XLookupString( &Event.xkey,buf,sizeof(buf),&keySym,&stat ); | |
171 vo_x11_putkey( ( (keySym&0xff00) != 0?( (keySym&0x00ff) + 256 ):( keySym ) ) ); | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
172 ret|=VO_EVENT_KEYPRESS; |
32 | 173 break; |
174 } | |
175 } | |
176 | |
177 return ret; | |
178 } | |
179 | |
324 | 180 void saver_on(Display *mDisplay) { |
181 | |
182 int nothing; | |
183 if (dpms_disabled) | |
184 { | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
185 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
|
186 { |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
187 printf ("Enabling DPMS\n"); |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
188 DPMSEnable(mDisplay); // restoring power saving settings |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
189 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
|
190 } |
324 | 191 } |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
192 |
324 | 193 if (timeout_save) |
194 { | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
195 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
|
196 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
|
197 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
|
198 XGetScreenSaver(mDisplay, &timeout_save, &interval, &prefer_blank, &allow_exp); |
324 | 199 } |
200 | |
201 } | |
202 | |
203 void saver_off(Display *mDisplay) { | |
204 | |
205 int interval, prefer_blank, allow_exp, nothing; | |
206 | |
207 if (DPMSQueryExtension(mDisplay, ¬hing, ¬hing)) | |
208 { | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
209 BOOL onoff; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
210 CARD16 state; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
211 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
|
212 if (onoff) |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
213 { |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
214 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
|
215 dpms_disabled=1; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
216 DPMSDisable(mDisplay); // monitor powersave off |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
217 } |
324 | 218 } |
219 XGetScreenSaver(mDisplay, &timeout_save, &interval, &prefer_blank, &allow_exp); | |
220 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
|
221 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
|
222 // turning off screensaver |
326 | 223 } |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
224 |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
225 #endif |