Mercurial > mplayer.hg
annotate libvo/x11_common.c @ 1971:7d6116e415a3
cleanup
author | arpi |
---|---|
date | Wed, 26 Sep 2001 18:40:57 +0000 |
parents | 6e7da6f362ab |
children | 6358db6ad3d0 |
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 | |
1345
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
20 #ifdef HAVE_XDPMS |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
21 #include <X11/extensions/dpms.h> |
1345
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
22 #endif |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
23 |
1732 | 24 |
25 /* | |
26 * If SCAN_VISUALS is defined, vo_init() scans all available TrueColor | |
27 * visuals for the 'best' visual for MPlayer video display. Note that | |
28 * the 'best' visual might be different from the default visual that | |
29 * is in use on the root window of the display/screen. | |
30 */ | |
31 #define SCAN_VISUALS | |
32 | |
33 | |
1456
8c57a5a3c645
printfs cleanup - moved to higher -v level or moved to stderr
arpi
parents:
1447
diff
changeset
|
34 extern verbose; |
8c57a5a3c645
printfs cleanup - moved to higher -v level or moved to stderr
arpi
parents:
1447
diff
changeset
|
35 |
324 | 36 static int dpms_disabled=0; |
37 static int timeout_save=0; | |
38 | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
39 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
|
40 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
|
41 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
|
42 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
|
43 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
|
44 |
384 | 45 |
46 void vo_hidecursor ( Display *disp , Window win ) | |
47 { | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
48 Cursor no_ptr; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
49 Pixmap bm_no; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
50 XColor black,dummy; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
51 Colormap colormap; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
52 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
|
53 |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
54 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
|
55 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
|
56 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
|
57 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
|
58 XDefineCursor(disp,win,no_ptr); |
384 | 59 } |
60 | |
61 | |
1732 | 62 #ifdef SCAN_VISUALS |
63 /* | |
64 * Scan the available visuals on this Display/Screen. Try to find | |
65 * the 'best' available TrueColor visual that has a decent color | |
66 * depth (at least 15bit). If there are multiple visuals with depth | |
67 * >= 15bit, we prefer visuals with a smaller color depth. | |
68 */ | |
69 int vo_find_depth_from_visuals(Display *dpy, int screen, Visual **visual_return) | |
70 { | |
71 XVisualInfo visual_tmpl; | |
72 XVisualInfo *visuals; | |
73 int nvisuals, i; | |
74 int bestvisual = -1; | |
75 int bestvisual_depth = -1; | |
76 | |
77 visual_tmpl.screen = screen; | |
78 visual_tmpl.class = TrueColor; | |
79 visuals = XGetVisualInfo(dpy, | |
80 VisualScreenMask | VisualClassMask, &visual_tmpl, | |
81 &nvisuals); | |
82 if (visuals != NULL) { | |
83 for (i = 0; i < nvisuals; i++) { | |
84 if (verbose) | |
85 printf("vo: X11 truecolor visual %#x, depth %d, R:%lX G:%lX B:%lX\n", | |
86 visuals[i].visualid, visuals[i].depth, | |
87 visuals[i].red_mask, visuals[i].green_mask, | |
88 visuals[i].blue_mask); | |
89 /* | |
90 * save the visual index and it's depth, if this is the first | |
91 * truecolor visul, or a visual that is 'preferred' over the | |
92 * previous 'best' visual | |
93 */ | |
94 if (bestvisual_depth == -1 | |
95 || (visuals[i].depth >= 15 | |
96 && ( visuals[i].depth < bestvisual_depth | |
97 || bestvisual_depth < 15))) { | |
98 bestvisual = i; | |
99 bestvisual_depth = visuals[i].depth; | |
100 } | |
101 } | |
102 | |
103 if (bestvisual != -1 && visual_return != NULL) | |
104 *visual_return = visuals[bestvisual].visual; | |
105 | |
106 XFree(visuals); | |
107 } | |
108 return bestvisual_depth; | |
109 } | |
110 #endif | |
111 | |
112 | |
32 | 113 int vo_init( void ) |
114 { | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
115 // int mScreen; |
1732 | 116 int depth, bpp; |
1137
4c7b219e126c
patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents:
1109
diff
changeset
|
117 unsigned int mask; |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
118 // 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
|
119 // Display * mDisplay; |
1732 | 120 XImage * mXImage = NULL; |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
121 // Window mRootWin; |
1732 | 122 XWindowAttributes attribs; |
32 | 123 |
124 if(vo_depthonscreen) return 1; // already called | |
125 | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
126 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
|
127 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
|
128 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
|
129 |
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
130 mDisplay=XOpenDisplay(mDisplayName); |
32 | 131 if ( !mDisplay ) |
132 { | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
133 printf( "vo: couldn't open the X11 display (%s)!\n",mDisplayName ); |
32 | 134 return 0; |
135 } | |
136 mScreen=DefaultScreen( mDisplay ); // Screen ID. | |
137 mRootWin=RootWindow( mDisplay,mScreen );// Root window ID. | |
138 vo_screenwidth=DisplayWidth( mDisplay,mScreen ); | |
139 vo_screenheight=DisplayHeight( mDisplay,mScreen ); | |
1732 | 140 |
141 // get color depth (from root window, or the best visual): | |
32 | 142 XGetWindowAttributes(mDisplay, mRootWin, &attribs); |
1732 | 143 depth=attribs.depth; |
144 | |
145 #ifdef SCAN_VISUALS | |
146 if (depth != 15 && depth != 16 && depth != 24 && depth != 32) { | |
147 Visual *visual; | |
148 | |
149 depth = vo_find_depth_from_visuals(mDisplay, mScreen, &visual); | |
150 if (depth != -1) | |
151 mXImage=XCreateImage(mDisplay, visual, depth, ZPixmap, | |
152 0, NULL, 1, 1, 8, 1); | |
153 } else | |
154 #endif | |
155 mXImage=XGetImage( mDisplay,mRootWin,0,0,1,1,AllPlanes,ZPixmap ); | |
156 | |
157 vo_depthonscreen = depth; // display depth on screen | |
158 | |
159 // get bits/pixel from XImage structure: | |
160 if (mXImage == NULL) { | |
161 mask = 0; | |
162 } else { | |
163 /* | |
164 * for the depth==24 case, the XImage structures might use | |
165 * 24 or 32 bits of data per pixel. The global variable | |
166 * vo_depthonscreen stores the amount of data per pixel in the | |
167 * XImage structure! | |
168 * | |
169 * Maybe we should rename vo_depthonscreen to (or add) vo_bpp? | |
170 */ | |
32 | 171 bpp=mXImage->bits_per_pixel; |
1137
4c7b219e126c
patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents:
1109
diff
changeset
|
172 if((vo_depthonscreen+7)/8 != (bpp+7)/8) vo_depthonscreen=bpp; // by A'rpi |
4c7b219e126c
patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents:
1109
diff
changeset
|
173 mask=mXImage->red_mask|mXImage->green_mask|mXImage->blue_mask; |
1732 | 174 XDestroyImage( mXImage ); |
1456
8c57a5a3c645
printfs cleanup - moved to higher -v level or moved to stderr
arpi
parents:
1447
diff
changeset
|
175 if(verbose) |
1732 | 176 printf("vo: X11 color mask: %X (R:%lX G:%lX B:%lX)\n", |
177 mask,mXImage->red_mask,mXImage->green_mask,mXImage->blue_mask); | |
178 } | |
179 if(((vo_depthonscreen+7)/8)==2){ | |
180 if(mask==0x7FFF) vo_depthonscreen=15; else | |
181 if(mask==0xFFFF) vo_depthonscreen=16; | |
182 } | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
183 // XCloseDisplay( mDisplay ); |
1447
e82fbd67ae60
better local display connection patch by Adam Tla/lka atlka@pg.gda.pl
arpi
parents:
1415
diff
changeset
|
184 /* slightly improved local display detection AST */ |
e82fbd67ae60
better local display connection patch by Adam Tla/lka atlka@pg.gda.pl
arpi
parents:
1415
diff
changeset
|
185 if ( strncmp(mDisplayName, "unix:", 5) == 0) |
e82fbd67ae60
better local display connection patch by Adam Tla/lka atlka@pg.gda.pl
arpi
parents:
1415
diff
changeset
|
186 mDisplayName += 4; |
e82fbd67ae60
better local display connection patch by Adam Tla/lka atlka@pg.gda.pl
arpi
parents:
1415
diff
changeset
|
187 else if ( strncmp(mDisplayName, "localhost:", 10) == 0) |
e82fbd67ae60
better local display connection patch by Adam Tla/lka atlka@pg.gda.pl
arpi
parents:
1415
diff
changeset
|
188 mDisplayName += 9; |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
189 if (*mDisplayName==':') mLocalDisplay=1; else mLocalDisplay=0; |
1732 | 190 printf("vo: X11 running at %dx%d with depth %d and %d bits/pixel (\"%s\" => %s display)\n", |
191 vo_screenwidth,vo_screenheight, | |
192 depth, vo_depthonscreen, | |
193 mDisplayName,mLocalDisplay?"local":"remote"); | |
32 | 194 return 1; |
195 } | |
196 | |
197 #include "../linux/keycodes.h" | |
198 #include "wskeys.h" | |
199 | |
200 extern void mplayer_put_key(int code); | |
201 | |
202 void vo_x11_putkey(int key){ | |
203 switch ( key ) | |
204 { | |
205 case wsLeft: mplayer_put_key(KEY_LEFT); break; | |
206 case wsRight: mplayer_put_key(KEY_RIGHT); break; | |
207 case wsUp: mplayer_put_key(KEY_UP); break; | |
208 case wsDown: mplayer_put_key(KEY_DOWN); break; | |
209 case wsSpace: mplayer_put_key(' '); break; | |
210 case wsEscape: mplayer_put_key(KEY_ESC); break; | |
211 case wsEnter: mplayer_put_key(KEY_ENTER); break; | |
651 | 212 case wsPageUp: mplayer_put_key(KEY_PAGE_UP); break; |
213 case wsPageDown: mplayer_put_key(KEY_PAGE_DOWN); break; | |
32 | 214 case wsq: |
215 case wsQ: mplayer_put_key('q'); break; | |
216 case wsp: | |
217 case wsP: mplayer_put_key('p'); break; | |
218 case wsMinus: | |
219 case wsGrayMinus: mplayer_put_key('-'); break; | |
220 case wsPlus: | |
221 case wsGrayPlus: mplayer_put_key('+'); break; | |
464 | 222 case wsGrayMul: |
223 case wsMul: mplayer_put_key('*'); break; | |
224 case wsGrayDiv: | |
225 case wsDiv: mplayer_put_key('/'); break; | |
516 | 226 case wsm: |
227 case wsM: mplayer_put_key('m'); break; | |
655 | 228 case wso: |
229 case wsO: mplayer_put_key('o'); break; | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1456
diff
changeset
|
230 default: if((key>='a' && key<='z')||(key>='A' && key<='Z')|| |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1456
diff
changeset
|
231 (key>='0' && key<='9')) mplayer_put_key(key); |
32 | 232 } |
369 | 233 |
32 | 234 } |
235 | |
236 | |
237 // ----- Motif header: ------- | |
238 | |
1236 | 239 #define MWM_HINTS_FUNCTIONS (1L << 0) |
240 #define MWM_HINTS_DECORATIONS (1L << 1) | |
241 #define MWM_HINTS_INPUT_MODE (1L << 2) | |
242 #define MWM_HINTS_STATUS (1L << 3) | |
243 | |
244 #define MWM_FUNC_ALL (1L << 0) | |
245 #define MWM_FUNC_RESIZE (1L << 1) | |
246 #define MWM_FUNC_MOVE (1L << 2) | |
247 #define MWM_FUNC_MINIMIZE (1L << 3) | |
248 #define MWM_FUNC_MAXIMIZE (1L << 4) | |
249 #define MWM_FUNC_CLOSE (1L << 5) | |
250 | |
251 #define MWM_DECOR_ALL (1L << 0) | |
252 #define MWM_DECOR_BORDER (1L << 1) | |
253 #define MWM_DECOR_RESIZEH (1L << 2) | |
254 #define MWM_DECOR_TITLE (1L << 3) | |
255 #define MWM_DECOR_MENU (1L << 4) | |
256 #define MWM_DECOR_MINIMIZE (1L << 5) | |
257 #define MWM_DECOR_MAXIMIZE (1L << 6) | |
258 | |
259 #define MWM_INPUT_MODELESS 0 | |
260 #define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1 | |
261 #define MWM_INPUT_SYSTEM_MODAL 2 | |
262 #define MWM_INPUT_FULL_APPLICATION_MODAL 3 | |
263 #define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL | |
264 | |
265 #define MWM_TEAROFF_WINDOW (1L<<0) | |
32 | 266 |
267 typedef struct | |
268 { | |
269 long flags; | |
270 long functions; | |
271 long decorations; | |
272 long input_mode; | |
1236 | 273 long state; |
32 | 274 } MotifWmHints; |
275 | |
276 extern MotifWmHints vo_MotifWmHints; | |
277 extern Atom vo_MotifHints; | |
278 extern int vo_depthonscreen; | |
279 extern int vo_screenwidth; | |
280 extern int vo_screenheight; | |
281 | |
282 static MotifWmHints vo_MotifWmHints; | |
283 static Atom vo_MotifHints = None; | |
284 | |
1266 | 285 // Note: always d==0 ! |
32 | 286 void vo_x11_decoration( Display * vo_Display,Window w,int d ) |
287 { | |
1266 | 288 |
289 if(vo_fsmode&1){ | |
290 XSetWindowAttributes attr; | |
291 attr.override_redirect = True; | |
292 XChangeWindowAttributes(vo_Display, w, CWOverrideRedirect, &attr); | |
293 // XMapWindow(vo_Display], w); | |
294 } | |
295 | |
1415 | 296 if(vo_fsmode&8){ |
297 XSetTransientForHint (vo_Display, w, RootWindow(vo_Display,mScreen)); | |
298 } | |
299 | |
32 | 300 vo_MotifHints=XInternAtom( vo_Display,"_MOTIF_WM_HINTS",0 ); |
301 if ( vo_MotifHints != None ) | |
302 { | |
1236 | 303 memset( &vo_MotifWmHints,0,sizeof( MotifWmHints ) ); |
304 vo_MotifWmHints.flags=MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS; | |
305 vo_MotifWmHints.functions=MWM_FUNC_MOVE | MWM_FUNC_CLOSE | MWM_FUNC_MINIMIZE | MWM_FUNC_MAXIMIZE; | |
306 if ( d ) d=MWM_DECOR_ALL; | |
1266 | 307 vo_MotifWmHints.decorations=d|((vo_fsmode&2)?0:MWM_DECOR_MENU); |
32 | 308 XChangeProperty( vo_Display,w,vo_MotifHints,vo_MotifHints,32, |
1266 | 309 PropModeReplace,(unsigned char *)&vo_MotifWmHints,(vo_fsmode&4)?4:5 ); |
32 | 310 } |
311 } | |
312 | |
1137
4c7b219e126c
patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents:
1109
diff
changeset
|
313 void vo_x11_classhint( Display * display,Window window,char *name ){ |
4c7b219e126c
patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents:
1109
diff
changeset
|
314 XClassHint wmClass; |
4c7b219e126c
patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents:
1109
diff
changeset
|
315 wmClass.res_name = name; |
4c7b219e126c
patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents:
1109
diff
changeset
|
316 wmClass.res_class = "MPlayer"; |
4c7b219e126c
patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents:
1109
diff
changeset
|
317 XSetClassHint(display,window,&wmClass); |
4c7b219e126c
patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents:
1109
diff
changeset
|
318 } |
4c7b219e126c
patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents:
1109
diff
changeset
|
319 |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1501
diff
changeset
|
320 #ifdef HAVE_NEW_GUI |
723 | 321 Window vo_window = None; |
322 GC vo_gc; | |
323 int vo_xeventhandling = 1; | |
324 int vo_resize = 0; | |
325 int vo_expose = 0; | |
326 | |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1501
diff
changeset
|
327 void vo_setwindow( Window w,GC g ) { |
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1501
diff
changeset
|
328 vo_window=w; vo_gc=g; |
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1501
diff
changeset
|
329 vo_xeventhandling=0; |
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1501
diff
changeset
|
330 } |
1746 | 331 void vo_setwindowsize( int w,int h ) { |
332 vo_dwidth=w; vo_dheight=h; | |
333 } | |
723 | 334 #endif |
335 | |
32 | 336 int vo_x11_check_events(Display *mydisplay){ |
337 int ret=0; | |
338 XEvent Event; | |
339 char buf[100]; | |
340 KeySym keySym; | |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J«ärgen Keil <jk@tools.de>
arpi_esp
parents:
922
diff
changeset
|
341 static XComposeStatus stat; |
32 | 342 // unsigned long vo_KeyTable[512]; |
343 | |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1501
diff
changeset
|
344 #ifdef HAVE_NEW_GUI |
723 | 345 if ( vo_xeventhandling ) |
346 { | |
347 #endif | |
348 while ( XPending( mydisplay ) ) | |
349 { | |
350 XNextEvent( mydisplay,&Event ); | |
351 switch( Event.type ) | |
352 { | |
353 case Expose: | |
354 ret|=VO_EVENT_EXPOSE; | |
355 break; | |
356 case ConfigureNotify: | |
357 vo_dwidth=Event.xconfigure.width; | |
358 vo_dheight=Event.xconfigure.height; | |
359 ret|=VO_EVENT_RESIZE; | |
360 break; | |
361 case KeyPress: | |
362 XLookupString( &Event.xkey,buf,sizeof(buf),&keySym,&stat ); | |
363 vo_x11_putkey( ( (keySym&0xff00) != 0?( (keySym&0x00ff) + 256 ):( keySym ) ) ); | |
364 ret|=VO_EVENT_KEYPRESS; | |
365 break; | |
366 } | |
367 } | |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1501
diff
changeset
|
368 #ifdef HAVE_NEW_GUI |
32 | 369 } |
723 | 370 else |
371 { | |
372 if ( vo_resize ) | |
373 { | |
374 vo_resize=0; | |
375 ret|=VO_EVENT_RESIZE; | |
376 } | |
377 if ( vo_expose ) | |
378 { | |
379 vo_expose=0; | |
380 ret|=VO_EVENT_EXPOSE; | |
381 } | |
382 } | |
383 #endif | |
32 | 384 |
385 return ret; | |
386 } | |
387 | |
324 | 388 void saver_on(Display *mDisplay) { |
389 | |
1345
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
390 #ifdef HAVE_XDPMS |
324 | 391 int nothing; |
392 if (dpms_disabled) | |
393 { | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
394 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
|
395 { |
741 | 396 if (!DPMSEnable(mDisplay)) { // restoring power saving settings |
397 printf("DPMS not available?\n"); | |
398 } else { | |
399 // DPMS does not seem to be enabled unless we call DPMSInfo | |
400 BOOL onoff; | |
401 CARD16 state; | |
402 DPMSInfo(mDisplay, &state, &onoff); | |
403 if (onoff) { | |
404 printf ("Successfully enabled DPMS\n"); | |
405 } else { | |
406 printf ("Could not enable DPMS\n"); | |
407 } | |
408 } | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
409 } |
324 | 410 } |
1345
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
411 #endif |
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
412 |
324 | 413 if (timeout_save) |
414 { | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
415 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
|
416 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
|
417 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
|
418 XGetScreenSaver(mDisplay, &timeout_save, &interval, &prefer_blank, &allow_exp); |
324 | 419 } |
420 | |
421 } | |
422 | |
423 void saver_off(Display *mDisplay) { | |
424 | |
1345
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
425 int interval, prefer_blank, allow_exp; |
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
426 #ifdef HAVE_XDPMS |
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
427 int nothing; |
324 | 428 |
429 if (DPMSQueryExtension(mDisplay, ¬hing, ¬hing)) | |
430 { | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
431 BOOL onoff; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
432 CARD16 state; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
433 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
|
434 if (onoff) |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
435 { |
741 | 436 Status stat; |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
437 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
|
438 dpms_disabled=1; |
741 | 439 stat = DPMSDisable(mDisplay); // monitor powersave off |
440 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
|
441 } |
324 | 442 } |
1345
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
443 #endif |
324 | 444 XGetScreenSaver(mDisplay, &timeout_save, &interval, &prefer_blank, &allow_exp); |
445 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
|
446 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
|
447 // turning off screensaver |
326 | 448 } |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
449 |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
450 #endif |