comparison libvo/vo_xmga.c @ 6043:421781c5b128

fix some small bug and -rootwin
author pontscho
date Sat, 11 May 2002 14:57:41 +0000
parents be9cd7d845c2
children c0ae8c0eda72
comparison
equal deleted inserted replaced
6042:c0fb4f38c8a7 6043:421781c5b128
77 77
78 static uint32_t mDepth, bpp, mode; 78 static uint32_t mDepth, bpp, mode;
79 static XWindowAttributes attribs; 79 static XWindowAttributes attribs;
80 static uint32_t X_already_started=0; 80 static uint32_t X_already_started=0;
81 81
82 static uint32_t wndX;
83 static uint32_t wndY;
84
85 static uint32_t fgColor; 82 static uint32_t fgColor;
86 83
87 static uint32_t mvHeight; 84 static uint32_t mvHeight;
88 static uint32_t mvWidth; 85 static uint32_t mvWidth;
89 86
106 XFlush( mDisplay ); 103 XFlush( mDisplay );
107 } 104 }
108 105
109 static void set_window(){ 106 static void set_window(){
110 107
111 XGetGeometry( mDisplay,vo_window,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth ); 108 if ( WinID )
112 fprintf( stderr,"[xmga] x: %d y: %d w: %d h: %d\n",drwX,drwY,drwWidth,drwHeight ); 109 {
113 drwX=0; drwY=0; 110 XGetGeometry( mDisplay,vo_window,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth );
114 XTranslateCoordinates( mDisplay,vo_window,mRoot,0,0,&drwcX,&drwcY,&mRoot ); 111 fprintf( stderr,"[xmga] x: %d y: %d w: %d h: %d\n",drwX,drwY,drwWidth,drwHeight );
115 fprintf( stderr,"[xmga] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); 112 drwX=0; drwY=0;
113 XTranslateCoordinates( mDisplay,vo_window,mRoot,0,0,&drwcX,&drwcY,&mRoot );
114 fprintf( stderr,"[xmga] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight );
115 }
116 else { drwX=drwcX=vo_dx; drwY=drwcY=vo_dy; drwWidth=vo_dwidth; drwHeight=vo_dheight; }
116 117
117 aspect(&dwidth,&dheight,A_NOZOOM); 118 aspect(&dwidth,&dheight,A_NOZOOM);
118 if ( vo_fs ) 119 if ( vo_fs )
119 { 120 {
120 aspect(&dwidth,&dheight,A_ZOOM); 121 aspect(&dwidth,&dheight,A_ZOOM);
164 static void check_events(void) 165 static void check_events(void)
165 { 166 {
166 int e=vo_x11_check_events(mDisplay); 167 int e=vo_x11_check_events(mDisplay);
167 if ( !(e&VO_EVENT_RESIZE) && !(e&VO_EVENT_EXPOSE) ) return; 168 if ( !(e&VO_EVENT_RESIZE) && !(e&VO_EVENT_EXPOSE) ) return;
168 set_window(); 169 set_window();
169 if(e&VO_EVENT_EXPOSE) mDrawColorKey(); 170 mDrawColorKey();
170 if ( ioctl( f,MGA_VID_CONFIG,&mga_vid_config ) ) 171 if ( ioctl( f,MGA_VID_CONFIG,&mga_vid_config ) ) printf( "Error in mga_vid_config ioctl (wrong mga_vid.o version?)" );
171 printf( "Error in mga_vid_config ioctl (wrong mga_vid.o version?)" );
172 } 172 }
173 173
174 static void draw_osd(void) 174 static void draw_osd(void)
175 { vo_draw_text(mga_vid_config.src_width,mga_vid_config.src_height,draw_alpha);} 175 { vo_draw_text(mga_vid_config.src_width,mga_vid_config.src_height,draw_alpha);}
176 176
186 vo_mga_flip_page(); 186 vo_mga_flip_page();
187 } 187 }
188 188
189 static int inited=0; 189 static int inited=0;
190 190
191 static uint32_t config( uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format,const vo_tune_info_t* info) 191 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,const vo_tune_info_t* info)
192 { 192 {
193 char * mTitle=(title == NULL) ? "XMGA render" : title; 193 char * mTitle=(title == NULL) ? "XMGA render" : title;
194 XVisualInfo vinfo; 194 XVisualInfo vinfo;
195 195
196 unsigned long xswamask; 196 unsigned long xswamask;
228 aspect_save_prescale(d_width,d_height); 228 aspect_save_prescale(d_width,d_height);
229 aspect_save_screenres(vo_screenwidth,vo_screenheight); 229 aspect_save_screenres(vo_screenwidth,vo_screenheight);
230 230
231 mvWidth=width; mvHeight=height; 231 mvWidth=width; mvHeight=height;
232 232
233 wndX=0; wndY=0; 233 vo_dx=( vo_screenwidth - d_width ) / 2; vo_dy=( vo_screenheight - d_height ) / 2;
234 vo_dwidth=d_width; vo_dheight=d_height; 234 vo_dwidth=d_width; vo_dheight=d_height;
235 vo_mouse_autohide=1; 235 vo_mouse_autohide=1;
236 236
237 switch ( vo_depthonscreen ) 237 switch ( vo_depthonscreen )
238 { 238 {
252 guiGetEvent( guiSetShVideo,0 ); // the GUI will set up / resize the window 252 guiGetEvent( guiSetShVideo,0 ); // the GUI will set up / resize the window
253 else 253 else
254 #endif 254 #endif
255 { 255 {
256 #ifdef X11_FULLSCREEN 256 #ifdef X11_FULLSCREEN
257 if ( fullscreen&1 ) aspect(&dwidth,&dheight,A_ZOOM); 257 if ( flags&1 ) aspect(&dwidth,&dheight,A_ZOOM);
258 #endif 258 #endif
259 259
260 XGetWindowAttributes( mDisplay,DefaultRootWindow( mDisplay ),&attribs ); 260 XGetWindowAttributes( mDisplay,mRootWin,&attribs );
261 mDepth=attribs.depth; 261 mDepth=attribs.depth;
262 if ( mDepth != 15 && mDepth != 16 && mDepth != 24 && mDepth != 32 ) mDepth=24; 262 if ( mDepth != 15 && mDepth != 16 && mDepth != 24 && mDepth != 32 ) mDepth=24;
263 XMatchVisualInfo( mDisplay,mScreen,mDepth,TrueColor,&vinfo ); 263 XMatchVisualInfo( mDisplay,mScreen,mDepth,TrueColor,&vinfo );
264 xWAttribs.colormap=XCreateColormap( mDisplay,RootWindow( mDisplay,mScreen ),vinfo.visual,AllocNone ); 264 xWAttribs.colormap=XCreateColormap( mDisplay,mRootWin,vinfo.visual,AllocNone );
265 xWAttribs.background_pixel=0; 265 xWAttribs.background_pixel=0;
266 xWAttribs.border_pixel=0; 266 xWAttribs.border_pixel=0;
267 xWAttribs.event_mask=StructureNotifyMask | ExposureMask | KeyPressMask | PropertyChangeMask | 267 xWAttribs.event_mask=StructureNotifyMask | ExposureMask | KeyPressMask |
268 ((WinID==0)?0:(ButtonPressMask | ButtonReleaseMask | PointerMotionMask)); 268 ((WinID==0)?0:(ButtonPressMask | ButtonReleaseMask | PointerMotionMask | PropertyChangeMask));
269 xswamask=CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; 269 xswamask=CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
270 270
271 if ( WinID>=0 ){ 271 if ( WinID>=0 ){
272 vo_window = WinID ? ((Window)WinID) : RootWindow(mDisplay,mScreen); 272
273 XUnmapWindow( mDisplay,vo_window ); 273 vo_window = WinID ? ((Window)WinID) : mRootWin;
274 XChangeWindowAttributes( mDisplay,vo_window,xswamask,&xWAttribs); 274 if ( WinID )
275 {
276 XUnmapWindow( mDisplay,vo_window );
277 XChangeWindowAttributes( mDisplay,vo_window,xswamask,&xWAttribs);
278 XSelectInput( mDisplay,vo_window,StructureNotifyMask | KeyPressMask | PropertyChangeMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | ExposureMask );
279 } else XSelectInput( mDisplay,vo_window,ExposureMask );
280
275 } else 281 } else
276 vo_window=XCreateWindow( mDisplay,mRootWin, 282 {
277 wndX,wndY, 283 vo_window=XCreateWindow( mDisplay,mRootWin,
278 vo_dwidth,vo_dheight, 284 vo_dx,vo_dy,
279 xWAttribs.border_pixel, 285 vo_dwidth,vo_dheight,
280 mDepth, 286 xWAttribs.border_pixel,
281 InputOutput, 287 mDepth,
282 vinfo.visual,xswamask,&xWAttribs ); 288 InputOutput,
283 vo_x11_classhint( mDisplay,vo_window,"xmga" ); 289 vinfo.visual,xswamask,&xWAttribs );
284 vo_hidecursor(mDisplay,vo_window); 290
285 291 vo_x11_classhint( mDisplay,vo_window,"xmga" );
286 XStoreName( mDisplay,vo_window,mTitle ); 292 vo_hidecursor(mDisplay,vo_window);
287 XMapWindow( mDisplay,vo_window ); 293 vo_x11_sizehint( vo_dx,vo_dy,vo_dwidth,vo_dheight,0 );
288 294
289 if ( fullscreen&1 ) vo_x11_fullscreen(); 295 XStoreName( mDisplay,vo_window,mTitle );
290 296 XMapWindow( mDisplay,vo_window );
297
298 if ( flags&1 ) vo_x11_fullscreen();
299
291 #ifdef HAVE_XINERAMA 300 #ifdef HAVE_XINERAMA
292 vo_x11_xinerama_move(mDisplay,vo_window); 301 vo_x11_xinerama_move(mDisplay,vo_window);
293 #endif 302 #endif
294 vo_gc=XCreateGC( mDisplay,vo_window,GCForeground,&wGCV ); 303 }
304 vo_gc=XCreateGC( mDisplay,vo_window,GCForeground,&wGCV );
295 } 305 }
296 306
307 if ( ( flags&1 )&&( !WinID ) ) { vo_dx=0; vo_dy=0; vo_dwidth=vo_screenwidth; vo_dheight=vo_screenheight; vo_fs=1; }
308
297 set_window(); 309 set_window();
298 310
299 mga_vid_config.src_width=width; 311 mga_vid_config.src_width=width;
300 mga_vid_config.src_height=height; 312 mga_vid_config.src_height=height;
301 313
304 mga_vid_config.colkey_green=0; 316 mga_vid_config.colkey_green=0;
305 mga_vid_config.colkey_blue=255; 317 mga_vid_config.colkey_blue=255;
306 318
307 if(mga_init()) return -1; 319 if(mga_init()) return -1;
308 320
309 set_window();
310
311 XFlush( mDisplay ); 321 XFlush( mDisplay );
312 XSync( mDisplay,False ); 322 XSync( mDisplay,False );
313 323
314 saver_off(mDisplay); 324 saver_off(mDisplay);
315 325