Mercurial > mplayer.hg
annotate libvo/x11_common.c @ 455:166239ec8a7b
add ASLA SUS PnP
author | pontscho |
---|---|
date | Sun, 15 Apr 2001 23:05:12 +0000 |
parents | 198b46b739d8 |
children | 884ea555b1a2 |
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 { | |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
28 Cursor no_ptr; |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
29 Pixmap bm_no; |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
30 XColor black,dummy; |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
31 Colormap colormap; |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
32 static unsigned char bm_no_data[] = { 0,0,0,0, 0,0,0,0 }; |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
33 |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
34 colormap = DefaultColormap(disp,DefaultScreen(disp)); |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
35 XAllocNamedColor(disp,colormap,"black",&black,&dummy); |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
36 bm_no = XCreateBitmapFromData(disp, win, bm_no_data, 8,8); |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
37 no_ptr=XCreatePixmapCursor(disp, bm_no, bm_no,&black, &black,0, 0); |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
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; | |
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: | |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
156 ret|=VO_EVENT_EXPOSE; |
32 | 157 break; |
158 case ConfigureNotify: | |
159 vo_dwidth=Event.xconfigure.width; | |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
160 vo_dheight=Event.xconfigure.height; |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
161 ret|=VO_EVENT_RESIZE; |
32 | 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 ) ) ); | |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
166 ret|=VO_EVENT_KEYPRESS; |
32 | 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 { | |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
179 if (DPMSQueryExtension(mDisplay, ¬hing, ¬hing)) |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
180 { |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
181 printf ("Enabling DPMS\n"); |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
182 DPMSEnable(mDisplay); // restoring power saving settings |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
183 DPMSQueryExtension(mDisplay, ¬hing, ¬hing); |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
184 } |
324 | 185 } |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
186 |
324 | 187 if (timeout_save) |
188 { | |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
189 int dummy, interval, prefer_blank, allow_exp; |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
190 XGetScreenSaver(mDisplay, &dummy, &interval, &prefer_blank, &allow_exp); |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
191 XSetScreenSaver(mDisplay, timeout_save, interval, prefer_blank, allow_exp); |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
192 XGetScreenSaver(mDisplay, &timeout_save, &interval, &prefer_blank, &allow_exp); |
324 | 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 { | |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
203 BOOL onoff; |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
204 CARD16 state; |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
205 DPMSInfo(mDisplay, &state, &onoff); |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
206 if (onoff) |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
207 { |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
208 printf ("Disabling DPMS\n"); |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
209 dpms_disabled=1; |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
210 DPMSDisable(mDisplay); // monitor powersave off |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
211 } |
324 | 212 } |
213 XGetScreenSaver(mDisplay, &timeout_save, &interval, &prefer_blank, &allow_exp); | |
214 if (timeout_save) | |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
215 XSetScreenSaver(mDisplay, 0, interval, prefer_blank, allow_exp); |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
216 // turning off screensaver |
326 | 217 } |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
218 |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
219 #endif |