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