Mercurial > mplayer.hg
annotate libvo/vo_xmga.c @ 8054:3d2ec2568659
fix for fs modes on widescreen displays
author | henry |
---|---|
date | Sat, 02 Nov 2002 18:56:16 +0000 |
parents | a57aac3a927a |
children | 5b39e79af5fe |
rev | line source |
---|---|
100 | 1 |
2 //#define SHOW_TIME | |
1 | 3 |
4 /* | |
7680 | 5 * vo_xmga.c |
1 | 6 * |
7 * Copyright (C) Zoltan Ponekker - Jan 2001 | |
8 * | |
9 */ | |
10 | |
11 #include <stdio.h> | |
12 #include <stdlib.h> | |
13 #include <string.h> | |
14 | |
15 #include "config.h" | |
6296 | 16 |
1 | 17 #include "video_out.h" |
18 #include "video_out_internal.h" | |
19 | |
20 LIBVO_EXTERN( xmga ) | |
21 | |
22 #include <sys/ioctl.h> | |
23 #include <unistd.h> | |
24 #include <fcntl.h> | |
25 #include <sys/mman.h> | |
26 | |
27 #include "drivers/mga_vid.h" | |
28 | |
29 #include <X11/Xlib.h> | |
30 #include <X11/Xutil.h> | |
31 #include <errno.h> | |
32 | |
4017 | 33 #ifdef HAVE_XINERAMA |
34 #include <X11/extensions/Xinerama.h> | |
35 #endif | |
36 | |
31 | 37 #include "x11_common.h" |
616 | 38 #include "sub.h" |
2057 | 39 #include "aspect.h" |
31 | 40 |
182 | 41 #ifdef SHOW_TIME |
100 | 42 #include "../linux/timer.h" |
43 static unsigned int timer=0; | |
44 static unsigned int timerd=0; | |
45 #endif | |
46 | |
5955
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
47 #ifdef HAVE_NEW_GUI |
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
48 #include "../Gui/interface.h" |
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
49 #endif |
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
50 |
1 | 51 static vo_info_t vo_info = |
52 { | |
7680 | 53 "Matrox G200/G4x0/G550 overlay in X11 window (using /dev/mga_vid)", |
1 | 54 "xmga", |
55 "Zoltan Ponekker <pontscho@makacs.poliod.hu>", | |
56 "" | |
57 }; | |
58 | |
59 static XGCValues wGCV; | |
60 | |
7472
c4434bdf6e51
tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents:
7124
diff
changeset
|
61 static uint32_t mDepth; |
1 | 62 static XWindowAttributes attribs; |
63 static uint32_t fgColor; | |
64 | |
65 static uint32_t mvHeight; | |
66 static uint32_t mvWidth; | |
67 | |
68 static Window mRoot; | |
69 | |
70 static XSetWindowAttributes xWAttribs; | |
71 | |
6311
da2dda48b7ec
add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents:
6307
diff
changeset
|
72 static int inited=0; |
da2dda48b7ec
add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents:
6307
diff
changeset
|
73 |
4981 | 74 #define VO_XMGA |
1 | 75 #include "mga_common.c" |
4981 | 76 #undef VO_XMGA |
1 | 77 |
78 static void mDrawColorKey( void ) | |
79 { | |
4795 | 80 XSetBackground( mDisplay,vo_gc,0 ); |
81 XClearWindow( mDisplay,vo_window ); | |
82 XSetForeground( mDisplay,vo_gc,fgColor ); | |
4981 | 83 XFillRectangle( mDisplay,vo_window,vo_gc,drwX,drwY,drwWidth,(vo_fs?drwHeight - 1:drwHeight) ); |
1 | 84 XFlush( mDisplay ); |
85 } | |
86 | |
31 | 87 static void check_events(void) |
1 | 88 { |
4303 | 89 int e=vo_x11_check_events(mDisplay); |
90 if ( !(e&VO_EVENT_RESIZE) && !(e&VO_EVENT_EXPOSE) ) return; | |
6382
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6311
diff
changeset
|
91 set_window(); |
6043 | 92 mDrawColorKey(); |
6296 | 93 if ( ioctl( f,MGA_VID_CONFIG,&mga_vid_config ) ) mp_msg(MSGT_VO,MSGL_WARN,"Error in mga_vid_config ioctl (wrong mga_vid.o version?)" ); |
1 | 94 } |
95 | |
31 | 96 static void flip_page(void){ |
182 | 97 #ifdef SHOW_TIME |
100 | 98 unsigned int t; |
99 t=GetTimer(); | |
6296 | 100 mp_msg(MSGT_VO,MSGL_STATUS," [timer: %08X diff: %6d dd: %6d ] \n",t,t-timer,(t-timer)-timerd); |
100 | 101 timerd=t-timer; |
102 timer=t; | |
182 | 103 #endif |
100 | 104 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1210
diff
changeset
|
105 vo_mga_flip_page(); |
31 | 106 } |
1 | 107 |
7124
eca7dbad0166
finally removed query_vaa, bes_da and vo_tune_info - the obsoleted libvo api
alex
parents:
6953
diff
changeset
|
108 static uint32_t config( uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) |
1 | 109 { |
110 char * mTitle=(title == NULL) ? "XMGA render" : title; | |
111 XVisualInfo vinfo; | |
112 unsigned long xswamask; | |
113 | |
7679 | 114 if(mga_init(width,height,format)) return -1; // ioctl errors? |
1 | 115 |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2057
diff
changeset
|
116 aspect_save_orig(width,height); |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2057
diff
changeset
|
117 aspect_save_prescale(d_width,d_height); |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2057
diff
changeset
|
118 aspect_save_screenres(vo_screenwidth,vo_screenheight); |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2057
diff
changeset
|
119 |
1 | 120 mvWidth=width; mvHeight=height; |
121 | |
6307 | 122 vo_panscan_x=vo_panscan_y=vo_panscan_amount=0; |
123 | |
7679 | 124 vo_dx=( vo_screenwidth - d_width ) / 2; |
125 vo_dy=( vo_screenheight - d_height ) / 2; | |
4981 | 126 vo_dwidth=d_width; vo_dheight=d_height; |
5955
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
127 vo_mouse_autohide=1; |
1 | 128 |
129 switch ( vo_depthonscreen ) | |
130 { | |
131 case 32: | |
132 case 24: fgColor=0x00ff00ffL; break; | |
133 case 16: fgColor=0xf81fL; break; | |
134 case 15: fgColor=0x7c1fL; break; | |
6296 | 135 default: mp_msg(MSGT_VO,MSGL_ERR,"Sorry, this (%d) color depth not supported.\n",vo_depthonscreen ); return -1; |
1 | 136 } |
137 | |
5158 | 138 inited=1; |
139 | |
6016 | 140 aspect(&vo_dwidth,&vo_dheight,A_NOZOOM); |
5985 | 141 |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1637
diff
changeset
|
142 #ifdef HAVE_NEW_GUI |
5985 | 143 if(use_gui) |
144 guiGetEvent( guiSetShVideo,0 ); // the GUI will set up / resize the window | |
145 else | |
146 #endif | |
723 | 147 { |
6043 | 148 if ( flags&1 ) aspect(&dwidth,&dheight,A_ZOOM); |
723 | 149 |
6043 | 150 XGetWindowAttributes( mDisplay,mRootWin,&attribs ); |
723 | 151 mDepth=attribs.depth; |
152 if ( mDepth != 15 && mDepth != 16 && mDepth != 24 && mDepth != 32 ) mDepth=24; | |
153 XMatchVisualInfo( mDisplay,mScreen,mDepth,TrueColor,&vinfo ); | |
6043 | 154 xWAttribs.colormap=XCreateColormap( mDisplay,mRootWin,vinfo.visual,AllocNone ); |
723 | 155 xWAttribs.background_pixel=0; |
156 xWAttribs.border_pixel=0; | |
6043 | 157 xWAttribs.event_mask=StructureNotifyMask | ExposureMask | KeyPressMask | |
158 ((WinID==0)?0:(ButtonPressMask | ButtonReleaseMask | PointerMotionMask | PropertyChangeMask)); | |
723 | 159 xswamask=CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; |
1 | 160 |
3847 | 161 if ( WinID>=0 ){ |
6043 | 162 |
163 vo_window = WinID ? ((Window)WinID) : mRootWin; | |
164 if ( WinID ) | |
165 { | |
166 XUnmapWindow( mDisplay,vo_window ); | |
167 XChangeWindowAttributes( mDisplay,vo_window,xswamask,&xWAttribs); | |
6953
ce67cc1f0beb
ignore BadAccess error at XSelectInput() (grabbing mouse etc) with warning
arpi
parents:
6755
diff
changeset
|
168 vo_x11_selectinput_witherr( mDisplay,vo_window,StructureNotifyMask | KeyPressMask | PropertyChangeMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | ExposureMask ); |
6043 | 169 } else XSelectInput( mDisplay,vo_window,ExposureMask ); |
170 | |
7679 | 171 } else { |
172 | |
7777 | 173 if ( vo_window == None ) |
174 { | |
175 vo_window=XCreateWindow( mDisplay,mRootWin, | |
6043 | 176 vo_dx,vo_dy, |
177 vo_dwidth,vo_dheight, | |
178 xWAttribs.border_pixel, | |
179 mDepth, | |
180 InputOutput, | |
181 vinfo.visual,xswamask,&xWAttribs ); | |
182 | |
7777 | 183 vo_x11_classhint( mDisplay,vo_window,"xmga" ); |
184 vo_hidecursor(mDisplay,vo_window); | |
185 vo_x11_sizehint( vo_dx,vo_dy,vo_dwidth,vo_dheight,0 ); | |
723 | 186 |
7777 | 187 XStoreName( mDisplay,vo_window,mTitle ); |
188 XMapWindow( mDisplay,vo_window ); | |
6043 | 189 |
7777 | 190 if ( flags&1 ) vo_x11_fullscreen(); |
5999 | 191 |
3990 | 192 #ifdef HAVE_XINERAMA |
7777 | 193 vo_x11_xinerama_move(mDisplay,vo_window); |
3990 | 194 #endif |
7777 | 195 } else if ( !(flags&1) ) XMoveResizeWindow( mDisplay,vo_window,vo_dx,vo_dy,vo_dwidth,vo_dheight ); |
6043 | 196 } |
7679 | 197 |
7777 | 198 if ( vo_gc != None ) XFreeGC( mDisplay,vo_gc ); |
6043 | 199 vo_gc=XCreateGC( mDisplay,vo_window,GCForeground,&wGCV ); |
7679 | 200 |
201 } // !GUI | |
1 | 202 |
6043 | 203 if ( ( flags&1 )&&( !WinID ) ) { vo_dx=0; vo_dy=0; vo_dwidth=vo_screenwidth; vo_dheight=vo_screenheight; vo_fs=1; } |
6382
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6311
diff
changeset
|
204 |
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6311
diff
changeset
|
205 panscan_calc(); |
7679 | 206 |
207 mga_vid_config.colkey_on=1; | |
208 mga_vid_config.colkey_red=255; | |
209 mga_vid_config.colkey_green=0; | |
210 mga_vid_config.colkey_blue=255; | |
211 | |
212 set_window(); // set up mga_vid_config.dest_width etc | |
1 | 213 |
6755 | 214 saver_off(mDisplay); |
215 | |
216 XFlush( mDisplay ); | |
217 XSync( mDisplay,False ); | |
7777 | 218 |
219 ioctl(f,MGA_VID_ON,0); | |
6755 | 220 |
7679 | 221 return 0; |
1 | 222 } |
223 | |
7679 | 224 static const vo_info_t* get_info( void ){ return &vo_info; } |
1 | 225 |
7679 | 226 static void uninit(void){ |
227 mp_msg(MSGT_VO,MSGL_V,"vo: uninit!\n"); | |
228 mga_uninit(); | |
229 if(!inited) return; // no window? | |
5158 | 230 inited=0; |
4316 | 231 saver_on(mDisplay); |
7679 | 232 vo_x11_uninit(); // destroy the window |
1 | 233 } |
4352 | 234 |