Mercurial > mplayer.hg
annotate libvo/x11_common.c @ 5540:80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
author | arpi |
---|---|
date | Tue, 09 Apr 2002 14:02:55 +0000 |
parents | 70725449c947 |
children | b8d8d72776f2 |
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 |
2149
6358db6ad3d0
Xinerama screen size fix by Lev Babiev <harley@hosers.org>
arpi
parents:
1746
diff
changeset
|
24 #ifdef HAVE_XINERAMA |
6358db6ad3d0
Xinerama screen size fix by Lev Babiev <harley@hosers.org>
arpi
parents:
1746
diff
changeset
|
25 #include <X11/extensions/Xinerama.h> |
6358db6ad3d0
Xinerama screen size fix by Lev Babiev <harley@hosers.org>
arpi
parents:
1746
diff
changeset
|
26 #endif |
1732 | 27 |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
28 #ifdef HAVE_XF86VM |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
29 #include <X11/extensions/xf86vmode.h> |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
30 #endif |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
31 |
4658 | 32 #ifdef HAVE_NEW_INPUT |
33 #include "../input/input.h" | |
34 #include "../input/mouse.h" | |
35 #endif | |
36 | |
4798 | 37 #ifdef HAVE_NEW_GUI |
38 #include "../Gui/interface.h" | |
39 #endif | |
40 | |
1732 | 41 /* |
42 * If SCAN_VISUALS is defined, vo_init() scans all available TrueColor | |
43 * visuals for the 'best' visual for MPlayer video display. Note that | |
44 * the 'best' visual might be different from the default visual that | |
45 * is in use on the root window of the display/screen. | |
46 */ | |
47 #define SCAN_VISUALS | |
48 | |
49 | |
4812 | 50 extern int verbose; |
1456
8c57a5a3c645
printfs cleanup - moved to higher -v level or moved to stderr
arpi
parents:
1447
diff
changeset
|
51 |
324 | 52 static int dpms_disabled=0; |
53 static int timeout_save=0; | |
54 | |
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 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
|
56 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
|
57 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
|
58 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
|
59 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
|
60 |
3830 | 61 /* output window id */ |
62 int WinID=-1; | |
384 | 63 |
4017 | 64 #ifdef HAVE_XINERAMA |
65 int xinerama_screen = 0; | |
66 int xinerama_x = 0; | |
67 int xinerama_y = 0; | |
68 #endif | |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
69 #ifdef HAVE_XF86VM |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
70 XF86VidModeModeInfo **vidmodes=NULL; |
4977
7b65a4f0b74e
vm pecs applied from daniel carter <hedonist@win.co.nz>
pontscho
parents:
4974
diff
changeset
|
71 XF86VidModeModeLine modeline; |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
72 #endif |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
73 |
384 | 74 void vo_hidecursor ( Display *disp , Window win ) |
75 { | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
76 Cursor no_ptr; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
77 Pixmap bm_no; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
78 XColor black,dummy; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
79 Colormap colormap; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
80 static unsigned char bm_no_data[] = { 0,0,0,0, 0,0,0,0 }; |
3954 | 81 |
82 if(WinID==0) return; // do not hide, if we're playing at rootwin | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
83 |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
84 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
|
85 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
|
86 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
|
87 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
|
88 XDefineCursor(disp,win,no_ptr); |
384 | 89 } |
90 | |
91 | |
1732 | 92 #ifdef SCAN_VISUALS |
93 /* | |
94 * Scan the available visuals on this Display/Screen. Try to find | |
95 * the 'best' available TrueColor visual that has a decent color | |
96 * depth (at least 15bit). If there are multiple visuals with depth | |
97 * >= 15bit, we prefer visuals with a smaller color depth. | |
98 */ | |
99 int vo_find_depth_from_visuals(Display *dpy, int screen, Visual **visual_return) | |
100 { | |
101 XVisualInfo visual_tmpl; | |
102 XVisualInfo *visuals; | |
103 int nvisuals, i; | |
104 int bestvisual = -1; | |
105 int bestvisual_depth = -1; | |
106 | |
107 visual_tmpl.screen = screen; | |
108 visual_tmpl.class = TrueColor; | |
109 visuals = XGetVisualInfo(dpy, | |
110 VisualScreenMask | VisualClassMask, &visual_tmpl, | |
111 &nvisuals); | |
112 if (visuals != NULL) { | |
113 for (i = 0; i < nvisuals; i++) { | |
114 if (verbose) | |
115 printf("vo: X11 truecolor visual %#x, depth %d, R:%lX G:%lX B:%lX\n", | |
116 visuals[i].visualid, visuals[i].depth, | |
117 visuals[i].red_mask, visuals[i].green_mask, | |
118 visuals[i].blue_mask); | |
119 /* | |
120 * save the visual index and it's depth, if this is the first | |
121 * truecolor visul, or a visual that is 'preferred' over the | |
122 * previous 'best' visual | |
123 */ | |
124 if (bestvisual_depth == -1 | |
125 || (visuals[i].depth >= 15 | |
126 && ( visuals[i].depth < bestvisual_depth | |
127 || bestvisual_depth < 15))) { | |
128 bestvisual = i; | |
129 bestvisual_depth = visuals[i].depth; | |
130 } | |
131 } | |
132 | |
133 if (bestvisual != -1 && visual_return != NULL) | |
134 *visual_return = visuals[bestvisual].visual; | |
135 | |
136 XFree(visuals); | |
137 } | |
138 return bestvisual_depth; | |
139 } | |
140 #endif | |
141 | |
4742 | 142 static void x11_errorhandler(Display *display, XErrorEvent *event) |
143 { | |
144 #define MSGLEN 60 | |
145 char msg[MSGLEN]; | |
146 | |
4812 | 147 XGetErrorText(display, event->error_code, (char *)&msg, MSGLEN); |
4742 | 148 |
149 printf("X11 error: %s\n", msg); | |
150 | |
151 if (verbose) | |
152 { | |
153 printf("Type: %x, display: %x, resourceid: %x, serial: %x\n", | |
154 event->type, event->display, event->resourceid, event->serial); | |
155 printf("Error code: %x, request code: %x, minor code: %x\n", | |
156 event->error_code, event->request_code, event->minor_code); | |
157 } | |
158 | |
159 exit_player("X11 error"); | |
160 #undef MSGLEN | |
161 } | |
1732 | 162 |
32 | 163 int vo_init( void ) |
164 { | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
165 // int mScreen; |
1732 | 166 int depth, bpp; |
1137
4c7b219e126c
patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents:
1109
diff
changeset
|
167 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
|
168 // 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
|
169 // Display * mDisplay; |
1732 | 170 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
|
171 // Window mRootWin; |
1732 | 172 XWindowAttributes attribs; |
4815
178b524e5213
Bugfix in x11_common.c mainly. Don't screw up the display name,
albeu
parents:
4812
diff
changeset
|
173 char* dispName; |
32 | 174 |
175 if(vo_depthonscreen) return 1; // already called | |
176 | |
4812 | 177 XSetErrorHandler(x11_errorhandler); |
178 | |
179 #if 0 | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
180 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
|
181 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
|
182 mDisplayName=strdup(":0.0"); |
4812 | 183 #else |
4815
178b524e5213
Bugfix in x11_common.c mainly. Don't screw up the display name,
albeu
parents:
4812
diff
changeset
|
184 dispName = XDisplayName(mDisplayName); |
4812 | 185 #endif |
186 | |
187 if (verbose) | |
4815
178b524e5213
Bugfix in x11_common.c mainly. Don't screw up the display name,
albeu
parents:
4812
diff
changeset
|
188 printf("X11 opening display: %s\n", dispName); |
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 |
4815
178b524e5213
Bugfix in x11_common.c mainly. Don't screw up the display name,
albeu
parents:
4812
diff
changeset
|
190 mDisplay=XOpenDisplay(dispName); |
32 | 191 if ( !mDisplay ) |
192 { | |
4815
178b524e5213
Bugfix in x11_common.c mainly. Don't screw up the display name,
albeu
parents:
4812
diff
changeset
|
193 printf( "vo: couldn't open the X11 display (%s)!\n",dispName ); |
32 | 194 return 0; |
195 } | |
196 mScreen=DefaultScreen( mDisplay ); // Screen ID. | |
197 mRootWin=RootWindow( mDisplay,mScreen );// Root window ID. | |
2149
6358db6ad3d0
Xinerama screen size fix by Lev Babiev <harley@hosers.org>
arpi
parents:
1746
diff
changeset
|
198 |
6358db6ad3d0
Xinerama screen size fix by Lev Babiev <harley@hosers.org>
arpi
parents:
1746
diff
changeset
|
199 #ifdef HAVE_XINERAMA |
6358db6ad3d0
Xinerama screen size fix by Lev Babiev <harley@hosers.org>
arpi
parents:
1746
diff
changeset
|
200 if(XineramaIsActive(mDisplay)) |
6358db6ad3d0
Xinerama screen size fix by Lev Babiev <harley@hosers.org>
arpi
parents:
1746
diff
changeset
|
201 { |
6358db6ad3d0
Xinerama screen size fix by Lev Babiev <harley@hosers.org>
arpi
parents:
1746
diff
changeset
|
202 XineramaScreenInfo *screens; |
6358db6ad3d0
Xinerama screen size fix by Lev Babiev <harley@hosers.org>
arpi
parents:
1746
diff
changeset
|
203 int num_screens; |
3990 | 204 |
2149
6358db6ad3d0
Xinerama screen size fix by Lev Babiev <harley@hosers.org>
arpi
parents:
1746
diff
changeset
|
205 screens = XineramaQueryScreens(mDisplay, &num_screens); |
4017 | 206 if(xinerama_screen >= num_screens) xinerama_screen = 0; |
3461
6b4ff1eb79bf
xinerama: allow to override xinerama screen_w/screen_h and setting size of screen where the window is placed
alex
parents:
2364
diff
changeset
|
207 if (! vo_screenwidth) |
4017 | 208 vo_screenwidth=screens[xinerama_screen].width; |
3461
6b4ff1eb79bf
xinerama: allow to override xinerama screen_w/screen_h and setting size of screen where the window is placed
alex
parents:
2364
diff
changeset
|
209 if (! vo_screenheight) |
4017 | 210 vo_screenheight=screens[xinerama_screen].height; |
211 xinerama_x = screens[xinerama_screen].x_org; | |
212 xinerama_y = screens[xinerama_screen].y_org; | |
213 | |
3990 | 214 XFree(screens); |
2149
6358db6ad3d0
Xinerama screen size fix by Lev Babiev <harley@hosers.org>
arpi
parents:
1746
diff
changeset
|
215 } |
6358db6ad3d0
Xinerama screen size fix by Lev Babiev <harley@hosers.org>
arpi
parents:
1746
diff
changeset
|
216 else |
6358db6ad3d0
Xinerama screen size fix by Lev Babiev <harley@hosers.org>
arpi
parents:
1746
diff
changeset
|
217 #endif |
4977
7b65a4f0b74e
vm pecs applied from daniel carter <hedonist@win.co.nz>
pontscho
parents:
4974
diff
changeset
|
218 #ifdef HAVE_XF86VM |
7b65a4f0b74e
vm pecs applied from daniel carter <hedonist@win.co.nz>
pontscho
parents:
4974
diff
changeset
|
219 { |
7b65a4f0b74e
vm pecs applied from daniel carter <hedonist@win.co.nz>
pontscho
parents:
4974
diff
changeset
|
220 int clock; |
7b65a4f0b74e
vm pecs applied from daniel carter <hedonist@win.co.nz>
pontscho
parents:
4974
diff
changeset
|
221 XF86VidModeGetModeLine( mDisplay,mScreen,&clock ,&modeline ); |
7b65a4f0b74e
vm pecs applied from daniel carter <hedonist@win.co.nz>
pontscho
parents:
4974
diff
changeset
|
222 if ( !vo_screenwidth ) vo_screenwidth=modeline.hdisplay; |
7b65a4f0b74e
vm pecs applied from daniel carter <hedonist@win.co.nz>
pontscho
parents:
4974
diff
changeset
|
223 if ( !vo_screenheight ) vo_screenheight=modeline.vdisplay; |
7b65a4f0b74e
vm pecs applied from daniel carter <hedonist@win.co.nz>
pontscho
parents:
4974
diff
changeset
|
224 } |
7b65a4f0b74e
vm pecs applied from daniel carter <hedonist@win.co.nz>
pontscho
parents:
4974
diff
changeset
|
225 #endif |
2149
6358db6ad3d0
Xinerama screen size fix by Lev Babiev <harley@hosers.org>
arpi
parents:
1746
diff
changeset
|
226 { |
2364 | 227 if (! vo_screenwidth) |
228 vo_screenwidth=DisplayWidth( mDisplay,mScreen ); | |
229 if (! vo_screenheight) | |
230 vo_screenheight=DisplayHeight( mDisplay,mScreen ); | |
2149
6358db6ad3d0
Xinerama screen size fix by Lev Babiev <harley@hosers.org>
arpi
parents:
1746
diff
changeset
|
231 } |
1732 | 232 // get color depth (from root window, or the best visual): |
32 | 233 XGetWindowAttributes(mDisplay, mRootWin, &attribs); |
1732 | 234 depth=attribs.depth; |
235 | |
236 #ifdef SCAN_VISUALS | |
237 if (depth != 15 && depth != 16 && depth != 24 && depth != 32) { | |
238 Visual *visual; | |
239 | |
240 depth = vo_find_depth_from_visuals(mDisplay, mScreen, &visual); | |
241 if (depth != -1) | |
242 mXImage=XCreateImage(mDisplay, visual, depth, ZPixmap, | |
243 0, NULL, 1, 1, 8, 1); | |
244 } else | |
245 #endif | |
246 mXImage=XGetImage( mDisplay,mRootWin,0,0,1,1,AllPlanes,ZPixmap ); | |
247 | |
248 vo_depthonscreen = depth; // display depth on screen | |
249 | |
250 // get bits/pixel from XImage structure: | |
251 if (mXImage == NULL) { | |
252 mask = 0; | |
253 } else { | |
254 /* | |
255 * for the depth==24 case, the XImage structures might use | |
256 * 24 or 32 bits of data per pixel. The global variable | |
257 * vo_depthonscreen stores the amount of data per pixel in the | |
258 * XImage structure! | |
259 * | |
260 * Maybe we should rename vo_depthonscreen to (or add) vo_bpp? | |
261 */ | |
32 | 262 bpp=mXImage->bits_per_pixel; |
1137
4c7b219e126c
patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents:
1109
diff
changeset
|
263 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
|
264 mask=mXImage->red_mask|mXImage->green_mask|mXImage->blue_mask; |
1456
8c57a5a3c645
printfs cleanup - moved to higher -v level or moved to stderr
arpi
parents:
1447
diff
changeset
|
265 if(verbose) |
1732 | 266 printf("vo: X11 color mask: %X (R:%lX G:%lX B:%lX)\n", |
267 mask,mXImage->red_mask,mXImage->green_mask,mXImage->blue_mask); | |
4181 | 268 XDestroyImage( mXImage ); |
1732 | 269 } |
270 if(((vo_depthonscreen+7)/8)==2){ | |
271 if(mask==0x7FFF) vo_depthonscreen=15; else | |
272 if(mask==0xFFFF) vo_depthonscreen=16; | |
273 } | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
274 // XCloseDisplay( mDisplay ); |
1447
e82fbd67ae60
better local display connection patch by Adam Tla/lka atlka@pg.gda.pl
arpi
parents:
1415
diff
changeset
|
275 /* slightly improved local display detection AST */ |
4815
178b524e5213
Bugfix in x11_common.c mainly. Don't screw up the display name,
albeu
parents:
4812
diff
changeset
|
276 if ( strncmp(dispName, "unix:", 5) == 0) |
178b524e5213
Bugfix in x11_common.c mainly. Don't screw up the display name,
albeu
parents:
4812
diff
changeset
|
277 dispName += 4; |
178b524e5213
Bugfix in x11_common.c mainly. Don't screw up the display name,
albeu
parents:
4812
diff
changeset
|
278 else if ( strncmp(dispName, "localhost:", 10) == 0) |
178b524e5213
Bugfix in x11_common.c mainly. Don't screw up the display name,
albeu
parents:
4812
diff
changeset
|
279 dispName += 9; |
178b524e5213
Bugfix in x11_common.c mainly. Don't screw up the display name,
albeu
parents:
4812
diff
changeset
|
280 if (*dispName==':') mLocalDisplay=1; else mLocalDisplay=0; |
1732 | 281 printf("vo: X11 running at %dx%d with depth %d and %d bits/pixel (\"%s\" => %s display)\n", |
282 vo_screenwidth,vo_screenheight, | |
283 depth, vo_depthonscreen, | |
4815
178b524e5213
Bugfix in x11_common.c mainly. Don't screw up the display name,
albeu
parents:
4812
diff
changeset
|
284 dispName,mLocalDisplay?"local":"remote"); |
4742 | 285 |
32 | 286 return 1; |
287 } | |
288 | |
4436 | 289 |
32 | 290 #include "../linux/keycodes.h" |
291 #include "wskeys.h" | |
292 | |
293 extern void mplayer_put_key(int code); | |
294 | |
295 void vo_x11_putkey(int key){ | |
296 switch ( key ) | |
297 { | |
298 case wsLeft: mplayer_put_key(KEY_LEFT); break; | |
299 case wsRight: mplayer_put_key(KEY_RIGHT); break; | |
300 case wsUp: mplayer_put_key(KEY_UP); break; | |
301 case wsDown: mplayer_put_key(KEY_DOWN); break; | |
302 case wsSpace: mplayer_put_key(' '); break; | |
303 case wsEscape: mplayer_put_key(KEY_ESC); break; | |
304 case wsEnter: mplayer_put_key(KEY_ENTER); break; | |
651 | 305 case wsPageUp: mplayer_put_key(KEY_PAGE_UP); break; |
306 case wsPageDown: mplayer_put_key(KEY_PAGE_DOWN); break; | |
32 | 307 case wsq: |
308 case wsQ: mplayer_put_key('q'); break; | |
309 case wsp: | |
310 case wsP: mplayer_put_key('p'); break; | |
311 case wsMinus: | |
312 case wsGrayMinus: mplayer_put_key('-'); break; | |
313 case wsPlus: | |
314 case wsGrayPlus: mplayer_put_key('+'); break; | |
464 | 315 case wsGrayMul: |
316 case wsMul: mplayer_put_key('*'); break; | |
317 case wsGrayDiv: | |
318 case wsDiv: mplayer_put_key('/'); break; | |
3490 | 319 case wsLess: mplayer_put_key('<'); break; |
320 case wsMore: mplayer_put_key('>'); break; | |
516 | 321 case wsm: |
322 case wsM: mplayer_put_key('m'); break; | |
655 | 323 case wso: |
324 case wsO: mplayer_put_key('o'); break; | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1456
diff
changeset
|
325 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
|
326 (key>='0' && key<='9')) mplayer_put_key(key); |
32 | 327 } |
369 | 328 |
32 | 329 } |
330 | |
331 | |
332 // ----- Motif header: ------- | |
333 | |
1236 | 334 #define MWM_HINTS_FUNCTIONS (1L << 0) |
335 #define MWM_HINTS_DECORATIONS (1L << 1) | |
336 #define MWM_HINTS_INPUT_MODE (1L << 2) | |
337 #define MWM_HINTS_STATUS (1L << 3) | |
338 | |
339 #define MWM_FUNC_ALL (1L << 0) | |
340 #define MWM_FUNC_RESIZE (1L << 1) | |
341 #define MWM_FUNC_MOVE (1L << 2) | |
342 #define MWM_FUNC_MINIMIZE (1L << 3) | |
343 #define MWM_FUNC_MAXIMIZE (1L << 4) | |
344 #define MWM_FUNC_CLOSE (1L << 5) | |
345 | |
346 #define MWM_DECOR_ALL (1L << 0) | |
347 #define MWM_DECOR_BORDER (1L << 1) | |
348 #define MWM_DECOR_RESIZEH (1L << 2) | |
349 #define MWM_DECOR_TITLE (1L << 3) | |
350 #define MWM_DECOR_MENU (1L << 4) | |
351 #define MWM_DECOR_MINIMIZE (1L << 5) | |
352 #define MWM_DECOR_MAXIMIZE (1L << 6) | |
353 | |
354 #define MWM_INPUT_MODELESS 0 | |
355 #define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1 | |
356 #define MWM_INPUT_SYSTEM_MODAL 2 | |
357 #define MWM_INPUT_FULL_APPLICATION_MODAL 3 | |
358 #define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL | |
359 | |
360 #define MWM_TEAROFF_WINDOW (1L<<0) | |
32 | 361 |
362 typedef struct | |
363 { | |
364 long flags; | |
365 long functions; | |
366 long decorations; | |
367 long input_mode; | |
1236 | 368 long state; |
32 | 369 } MotifWmHints; |
370 | |
371 extern MotifWmHints vo_MotifWmHints; | |
372 extern Atom vo_MotifHints; | |
373 extern int vo_depthonscreen; | |
374 extern int vo_screenwidth; | |
375 extern int vo_screenheight; | |
376 | |
377 static MotifWmHints vo_MotifWmHints; | |
378 static Atom vo_MotifHints = None; | |
379 | |
1266 | 380 // Note: always d==0 ! |
32 | 381 void vo_x11_decoration( Display * vo_Display,Window w,int d ) |
382 { | |
1266 | 383 |
384 if(vo_fsmode&1){ | |
385 XSetWindowAttributes attr; | |
386 attr.override_redirect = True; | |
387 XChangeWindowAttributes(vo_Display, w, CWOverrideRedirect, &attr); | |
4437 | 388 // XMapWindow(vo_Display, w); |
1266 | 389 } |
390 | |
1415 | 391 if(vo_fsmode&8){ |
392 XSetTransientForHint (vo_Display, w, RootWindow(vo_Display,mScreen)); | |
393 } | |
394 | |
32 | 395 vo_MotifHints=XInternAtom( vo_Display,"_MOTIF_WM_HINTS",0 ); |
396 if ( vo_MotifHints != None ) | |
397 { | |
1236 | 398 memset( &vo_MotifWmHints,0,sizeof( MotifWmHints ) ); |
399 vo_MotifWmHints.flags=MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS; | |
4993 | 400 if ( d ) |
401 { | |
402 vo_MotifWmHints.functions=MWM_FUNC_MOVE | MWM_FUNC_CLOSE | MWM_FUNC_MINIMIZE | MWM_FUNC_MAXIMIZE; | |
403 d=MWM_DECOR_ALL; | |
404 } | |
405 #if 0 | |
1266 | 406 vo_MotifWmHints.decorations=d|((vo_fsmode&2)?0:MWM_DECOR_MENU); |
4993 | 407 #else |
408 vo_MotifWmHints.decorations=d|((vo_fsmode&2)?MWM_DECOR_MENU:0); | |
409 #endif | |
32 | 410 XChangeProperty( vo_Display,w,vo_MotifHints,vo_MotifHints,32, |
1266 | 411 PropModeReplace,(unsigned char *)&vo_MotifWmHints,(vo_fsmode&4)?4:5 ); |
32 | 412 } |
413 } | |
414 | |
1137
4c7b219e126c
patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents:
1109
diff
changeset
|
415 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
|
416 XClassHint wmClass; |
4c7b219e126c
patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents:
1109
diff
changeset
|
417 wmClass.res_name = name; |
4c7b219e126c
patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents:
1109
diff
changeset
|
418 wmClass.res_class = "MPlayer"; |
4c7b219e126c
patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents:
1109
diff
changeset
|
419 XSetClassHint(display,window,&wmClass); |
4c7b219e126c
patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents:
1109
diff
changeset
|
420 } |
4c7b219e126c
patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents:
1109
diff
changeset
|
421 |
4993 | 422 Window vo_window = None; |
423 GC vo_gc; | |
424 XSizeHints vo_hint; | |
4795 | 425 |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1501
diff
changeset
|
426 #ifdef HAVE_NEW_GUI |
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1501
diff
changeset
|
427 void vo_setwindow( Window w,GC g ) { |
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1501
diff
changeset
|
428 vo_window=w; vo_gc=g; |
1746 | 429 } |
723 | 430 #endif |
431 | |
4437 | 432 int vo_x11_uninit(Display *display, Window window) |
433 { | |
4742 | 434 XSetErrorHandler(NULL); |
435 | |
4437 | 436 #ifdef HAVE_NEW_GUI |
437 /* destroy window only if it's not controlled by GUI */ | |
438 if (vo_window == None) | |
439 #endif | |
440 { | |
441 /* and -wid is set */ | |
442 if (!(WinID > 0)) | |
443 XDestroyWindow(display, window); | |
4438
e01ee848935f
grr, 10l. vo_x11_uninit: close display only if window not created by GUI
alex
parents:
4437
diff
changeset
|
444 XCloseDisplay(display); |
4815
178b524e5213
Bugfix in x11_common.c mainly. Don't screw up the display name,
albeu
parents:
4812
diff
changeset
|
445 vo_depthonscreen = 0; |
4437 | 446 } |
447 return(1); | |
448 } | |
449 | |
32 | 450 int vo_x11_check_events(Display *mydisplay){ |
451 int ret=0; | |
452 XEvent Event; | |
453 char buf[100]; | |
454 KeySym keySym; | |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by Jrgen Keil <jk@tools.de>
arpi_esp
parents:
922
diff
changeset
|
455 static XComposeStatus stat; |
32 | 456 // unsigned long vo_KeyTable[512]; |
457 | |
4795 | 458 while ( XPending( mydisplay ) ) |
459 { | |
460 XNextEvent( mydisplay,&Event ); | |
4798 | 461 #ifdef HAVE_NEW_GUI |
5061 | 462 if ( use_gui ) |
463 { | |
464 guiGetEvent( 0,(char*)&Event ); | |
465 if ( vo_window != Event.xany.window ) continue; | |
466 } | |
4798 | 467 #endif |
4795 | 468 switch( Event.type ) |
469 { | |
470 case Expose: | |
471 ret|=VO_EVENT_EXPOSE; | |
472 break; | |
473 case ConfigureNotify: | |
474 vo_dwidth=Event.xconfigure.width; | |
475 vo_dheight=Event.xconfigure.height; | |
4812 | 476 #if 0 |
477 /* when resizing, x and y are zero :( */ | |
478 vo_dx=Event.xconfigure.x; | |
479 vo_dy=Event.xconfigure.y; | |
480 #else | |
481 { | |
482 Window root; | |
483 int foo; | |
484 XGetGeometry(mydisplay, vo_window, &root, &foo, &foo, | |
485 &foo/*width*/, &foo/*height*/, &foo, &foo); | |
486 XTranslateCoordinates(mydisplay, vo_window, root, 0, 0, | |
487 &vo_dx, &vo_dy, (Window *)&foo); | |
488 } | |
489 #endif | |
490 if (verbose) | |
491 printf("X11 Window %dx%d-%dx%d\n", vo_dx, vo_dy, vo_dwidth, vo_dheight); | |
4795 | 492 ret|=VO_EVENT_RESIZE; |
493 break; | |
494 case KeyPress: | |
4974 | 495 { |
496 int key; | |
497 XLookupString( &Event.xkey,buf,sizeof(buf),&keySym,&stat ); | |
498 key=( (keySym&0xff00) != 0?( (keySym&0x00ff) + 256 ):( keySym ) ); | |
499 #ifdef HAVE_NEW_GUI | |
500 if ( ( use_gui )&&( key == wsEnter ) ) break; | |
501 #endif | |
502 vo_x11_putkey( key ); | |
503 ret|=VO_EVENT_KEYPRESS; | |
504 } | |
4795 | 505 break; |
4658 | 506 #ifdef HAVE_NEW_INPUT |
4795 | 507 case ButtonPress: |
508 // Ignore mouse whell press event | |
5061 | 509 if(Event.xbutton.button == 4 || Event.xbutton.button == 5) break; |
5062 | 510 #ifdef HAVE_NEW_GUI |
511 // Ignor mouse button 1 - 3 under gui | |
512 if ( use_gui && ( Event.xbutton.button >= 1 )&&( Event.xbutton.button <= 3 ) ) break; | |
513 #endif | |
4795 | 514 mplayer_put_key((MOUSE_BTN0+Event.xbutton.button-1)|MP_KEY_DOWN); |
515 break; | |
516 case ButtonRelease: | |
5062 | 517 #ifdef HAVE_NEW_GUI |
518 // Ignor mouse button 1 - 3 under gui | |
519 if ( use_gui && ( Event.xbutton.button >= 1 )&&( Event.xbutton.button <= 3 ) ) break; | |
520 #endif | |
4795 | 521 mplayer_put_key(MOUSE_BTN0+Event.xbutton.button-1); |
522 break; | |
4658 | 523 #endif |
723 | 524 } |
4795 | 525 } |
32 | 526 |
527 return ret; | |
528 } | |
529 | |
4993 | 530 void vo_x11_sizehint( int x, int y, int width, int height ) |
531 { | |
532 vo_hint.flags=PPosition | PSize | PWinGravity; | |
533 vo_hint.x=x; vo_hint.y=y; vo_hint.width=width; vo_hint.height=height; | |
534 vo_hint.win_gravity=StaticGravity; | |
535 XSetWMNormalHints( mDisplay,vo_window,&vo_hint ); | |
536 } | |
537 | |
4981 | 538 void vo_x11_fullscreen( void ) |
539 { | |
540 XUnmapWindow( mDisplay,vo_window ); | |
541 if ( !vo_fs ) | |
542 { | |
543 vo_fs=VO_TRUE; | |
544 vo_old_x=vo_dx; vo_old_y=vo_dy; vo_old_width=vo_dwidth; vo_old_height=vo_dheight; | |
5061 | 545 // { |
546 // Window root; int foo, foo2; | |
4993 | 547 // XGetGeometry( mDisplay,vo_window,&root,&vo_old_x,&vo_old_y,&vo_old_width,vo_old_height,&foo,&foo2 ); |
548 // XTranslateCoordinates( mDisplay,vo_window,root,0,0,&vo_old_x,&vo_old_y,(Window *)&foo); | |
5061 | 549 // } |
4981 | 550 vo_dx=0; vo_dy=0; vo_dwidth=vo_screenwidth; vo_dheight=vo_screenheight; |
551 vo_x11_decoration( mDisplay,vo_window,0 ); | |
552 } | |
553 else | |
554 { | |
555 vo_fs=VO_FALSE; | |
556 vo_dx=vo_old_x; vo_dy=vo_old_y; vo_dwidth=vo_old_width; vo_dheight=vo_old_height; | |
557 vo_x11_decoration( mDisplay,vo_window,1 ); | |
558 } | |
4993 | 559 vo_x11_sizehint( vo_dx,vo_dy,vo_dwidth,vo_dheight ); |
4981 | 560 XMoveResizeWindow( mDisplay,vo_window,vo_dx,vo_dy,vo_dwidth,vo_dheight ); |
4993 | 561 XMapWindow( mDisplay,vo_window ); |
562 XSync( mDisplay,False ); | |
4981 | 563 } |
564 | |
324 | 565 void saver_on(Display *mDisplay) { |
566 | |
1345
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
567 #ifdef HAVE_XDPMS |
324 | 568 int nothing; |
569 if (dpms_disabled) | |
570 { | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
571 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
|
572 { |
741 | 573 if (!DPMSEnable(mDisplay)) { // restoring power saving settings |
574 printf("DPMS not available?\n"); | |
575 } else { | |
576 // DPMS does not seem to be enabled unless we call DPMSInfo | |
577 BOOL onoff; | |
578 CARD16 state; | |
579 DPMSInfo(mDisplay, &state, &onoff); | |
580 if (onoff) { | |
581 printf ("Successfully enabled DPMS\n"); | |
582 } else { | |
583 printf ("Could not enable DPMS\n"); | |
584 } | |
585 } | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
586 } |
324 | 587 } |
1345
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
588 #endif |
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
589 |
324 | 590 if (timeout_save) |
591 { | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
592 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
|
593 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
|
594 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
|
595 XGetScreenSaver(mDisplay, &timeout_save, &interval, &prefer_blank, &allow_exp); |
324 | 596 } |
597 | |
598 } | |
599 | |
600 void saver_off(Display *mDisplay) { | |
601 | |
1345
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
602 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
|
603 #ifdef HAVE_XDPMS |
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
604 int nothing; |
324 | 605 |
606 if (DPMSQueryExtension(mDisplay, ¬hing, ¬hing)) | |
607 { | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
608 BOOL onoff; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
609 CARD16 state; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
610 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
|
611 if (onoff) |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
612 { |
741 | 613 Status stat; |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
456
diff
changeset
|
614 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
|
615 dpms_disabled=1; |
741 | 616 stat = DPMSDisable(mDisplay); // monitor powersave off |
617 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
|
618 } |
324 | 619 } |
1345
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
620 #endif |
324 | 621 XGetScreenSaver(mDisplay, &timeout_save, &interval, &prefer_blank, &allow_exp); |
622 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
|
623 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
|
624 // turning off screensaver |
326 | 625 } |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
626 |
3990 | 627 |
628 | |
629 #ifdef HAVE_XINERAMA | |
630 void vo_x11_xinerama_move(Display *dsp, Window w) | |
631 { | |
632 if(XineramaIsActive(dsp)) | |
633 { | |
4017 | 634 /* printf("XXXX Xinerama screen: x: %hd y: %hd\n",xinerama_x,xinerama_y); */ |
635 XMoveWindow(dsp,w,xinerama_x,xinerama_y); | |
3990 | 636 } |
637 } | |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
638 #endif |
3990 | 639 |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
640 #ifdef HAVE_XF86VM |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
641 void vo_vm_switch(uint32_t X, uint32_t Y, int* modeline_width, int* modeline_height) |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
642 { |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
643 unsigned int vm_event, vm_error; |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
644 unsigned int vm_ver, vm_rev; |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
645 int i,j,have_vm=0; |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
646 |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
647 int modecount; |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
648 |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
649 if (XF86VidModeQueryExtension(mDisplay, &vm_event, &vm_error)) { |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
650 XF86VidModeQueryVersion(mDisplay, &vm_ver, &vm_rev); |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
651 printf("XF86VidMode Extension v%i.%i\n", vm_ver, vm_rev); |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
652 have_vm=1; |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
653 } else |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
654 printf("XF86VidMode Extenstion not available.\n"); |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
655 |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
656 if (have_vm) { |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
657 if (vidmodes==NULL) |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
658 XF86VidModeGetAllModeLines(mDisplay,mScreen,&modecount,&vidmodes); |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
659 j=0; |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
660 *modeline_width=vidmodes[0]->hdisplay; |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
661 *modeline_height=vidmodes[0]->vdisplay; |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
662 |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
663 for (i=1; i<modecount; i++) |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
664 if ((vidmodes[i]->hdisplay >= X) && (vidmodes[i]->vdisplay >= Y)) |
5538 | 665 if ( (vidmodes[i]->hdisplay <= *modeline_width ) && (vidmodes[i]->vdisplay <= *modeline_height) ) |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
666 { |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
667 *modeline_width=vidmodes[i]->hdisplay; |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
668 *modeline_height=vidmodes[i]->vdisplay; |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
669 j=i; |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
670 } |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
671 |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
672 printf("XF86VM: Selected video mode %dx%d for image size %dx%d.\n",*modeline_width, *modeline_height, X, Y); |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
673 XF86VidModeLockModeSwitch(mDisplay,mScreen,0); |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
674 XF86VidModeSwitchToMode(mDisplay,mScreen,vidmodes[j]); |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
675 XF86VidModeSwitchToMode(mDisplay,mScreen,vidmodes[j]); |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
676 X=(vo_screenwidth-*modeline_width)/2; |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
677 Y=(vo_screenheight-*modeline_height)/2; |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
678 XF86VidModeSetViewPort(mDisplay,mScreen,X,Y); |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
679 } |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
680 } |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
681 |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
682 void vo_vm_close(Display *dpy) |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
683 { |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
684 #ifdef HAVE_NEW_GUI |
5019 | 685 if (vidmodes!=NULL && vo_window != None) |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
686 #else |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
687 if (vidmodes!=NULL) |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
688 #endif |
5019 | 689 { |
690 int i, modecount; | |
691 int screen; screen=DefaultScreen( dpy ); | |
692 | |
693 free(vidmodes); vidmodes=NULL; | |
694 XF86VidModeGetAllModeLines(mDisplay,mScreen,&modecount,&vidmodes); | |
695 for (i=0; i<modecount; i++) | |
696 if ((vidmodes[i]->hdisplay == vo_screenwidth) && (vidmodes[i]->vdisplay == vo_screenheight)) | |
697 { | |
698 printf("\nReturning to original mode %dx%d\n", vo_screenwidth, vo_screenheight); | |
699 break; | |
700 } | |
701 | |
702 XF86VidModeSwitchToMode(dpy,screen,vidmodes[i]); | |
703 XF86VidModeSwitchToMode(dpy,screen,vidmodes[i]); | |
704 free(vidmodes); | |
705 } | |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
706 } |
3990 | 707 #endif |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
708 |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
709 #endif |