comparison libvo/vo_x11.c @ 4804:62a281be07ce

fix nexus's key bug :) 10l, sorry :)
author pontscho
date Fri, 22 Feb 2002 14:48:38 +0000
parents 7fcffc537252
children 79b753e2e84a
comparison
equal deleted inserted replaced
4803:5b4fd881200a 4804:62a281be07ce
63 /* local data */ 63 /* local data */
64 static unsigned char *ImageData; 64 static unsigned char *ImageData;
65 65
66 /* X11 related variables */ 66 /* X11 related variables */
67 //static Display *mDisplay; 67 //static Display *mDisplay;
68 static Window mywindow;
69 static GC mygc;
70 static XImage *myximage; 68 static XImage *myximage;
71 static int depth,bpp,mode; 69 static int depth,bpp,mode;
72 static XWindowAttributes attribs; 70 static XWindowAttributes attribs;
73 71
74 //static int vo_dwidth,vo_dheight; 72 //static int vo_dwidth,vo_dheight;
216 else 214 else
217 { 215 {
218 shmemerror: 216 shmemerror:
219 Shmem_Flag=0; 217 Shmem_Flag=0;
220 #endif 218 #endif
221 myximage=XGetImage( mDisplay,mywindow,0,0, 219 myximage=XGetImage( mDisplay,vo_window,0,0,
222 image_width,image_height,AllPlanes,ZPixmap ); 220 image_width,image_height,AllPlanes,ZPixmap );
223 ImageData=myximage->data; 221 ImageData=myximage->data;
224 #ifdef HAVE_SHM 222 #ifdef HAVE_SHM
225 } 223 }
226 224
290 image_height=height; 288 image_height=height;
291 289
292 aspect= ((1<<16)*d_width + d_height/2)/d_height; 290 aspect= ((1<<16)*d_width + d_height/2)/d_height;
293 291
294 #ifdef HAVE_NEW_GUI 292 #ifdef HAVE_NEW_GUI
295 if ( vo_window != None ) { mywindow=vo_window; mygc=vo_gc; } 293 if ( vo_window != None ) { vo_window=vo_window; vo_gc=vo_gc; }
296 else 294 else
297 #endif 295 #endif
298 { 296 {
299 if( !vo_init() ) return 0; // Can't open X11 297 if( !vo_init() ) return 0; // Can't open X11
300 298
350 xswamask|=CWOverrideRedirect; 348 xswamask|=CWOverrideRedirect;
351 } 349 }
352 #endif 350 #endif
353 351
354 if ( WinID>=0 ){ 352 if ( WinID>=0 ){
355 mywindow = WinID ? ((Window)WinID) : RootWindow( mDisplay,mScreen ); 353 vo_window = WinID ? ((Window)WinID) : RootWindow( mDisplay,mScreen );
356 XUnmapWindow( mDisplay,mywindow ); 354 XUnmapWindow( mDisplay,vo_window );
357 XChangeWindowAttributes( mDisplay,mywindow,xswamask,&xswa ); 355 XChangeWindowAttributes( mDisplay,vo_window,xswamask,&xswa );
358 } 356 }
359 else 357 else
360 mywindow=XCreateWindow( mDisplay,RootWindow( mDisplay,mScreen ), 358 vo_window=XCreateWindow( mDisplay,RootWindow( mDisplay,mScreen ),
361 hint.x,hint.y, 359 hint.x,hint.y,
362 hint.width,hint.height, 360 hint.width,hint.height,
363 xswa.border_pixel,depth,CopyFromParent,vinfo.visual,xswamask,&xswa ); 361 xswa.border_pixel,depth,CopyFromParent,vinfo.visual,xswamask,&xswa );
364 362
365 vo_x11_classhint( mDisplay,mywindow,"x11" ); 363 vo_x11_classhint( mDisplay,vo_window,"x11" );
366 vo_hidecursor(mDisplay,mywindow); 364 vo_hidecursor(mDisplay,vo_window);
367 if ( fullscreen ) vo_x11_decoration( mDisplay,mywindow,0 ); 365 if ( fullscreen ) vo_x11_decoration( mDisplay,vo_window,0 );
368 XSelectInput( mDisplay,mywindow,StructureNotifyMask ); 366 XSelectInput( mDisplay,vo_window,StructureNotifyMask );
369 XSetStandardProperties( mDisplay,mywindow,hello,hello,None,NULL,0,&hint ); 367 XSetStandardProperties( mDisplay,vo_window,hello,hello,None,NULL,0,&hint );
370 XMapWindow( mDisplay,mywindow ); 368 XMapWindow( mDisplay,vo_window );
371 #ifdef HAVE_XINERAMA 369 #ifdef HAVE_XINERAMA
372 vo_x11_xinerama_move(mDisplay,mywindow); 370 vo_x11_xinerama_move(mDisplay,vo_window);
373 #endif 371 #endif
374 do { XNextEvent( mDisplay,&xev ); } while ( xev.type != MapNotify || xev.xmap.event != mywindow ); 372 do { XNextEvent( mDisplay,&xev ); } while ( xev.type != MapNotify || xev.xmap.event != vo_window );
375 XSelectInput( mDisplay,mywindow,NoEventMask ); 373 XSelectInput( mDisplay,vo_window,NoEventMask );
376 374
377 XFlush( mDisplay ); 375 XFlush( mDisplay );
378 XSync( mDisplay,False ); 376 XSync( mDisplay,False );
379 mygc=XCreateGC( mDisplay,mywindow,0L,&xgcv ); 377 vo_gc=XCreateGC( mDisplay,vo_window,0L,&xgcv );
380 378
381 #ifdef HAVE_XF86VM 379 #ifdef HAVE_XF86VM
382 if ( vm ) 380 if ( vm )
383 { 381 {
384 /* Grab the mouse pointer in our window */ 382 /* Grab the mouse pointer in our window */
385 XGrabPointer(mDisplay, mywindow, True, 0, 383 XGrabPointer(mDisplay, vo_window, True, 0,
386 GrabModeAsync, GrabModeAsync, 384 GrabModeAsync, GrabModeAsync,
387 mywindow, None, CurrentTime); 385 vo_window, None, CurrentTime);
388 XSetInputFocus(mDisplay, mywindow, RevertToNone, CurrentTime); 386 XSetInputFocus(mDisplay, vo_window, RevertToNone, CurrentTime);
389 } 387 }
390 #endif 388 #endif
391 } 389 }
392 390
393 getMyXImage(); 391 getMyXImage();
435 433
436 #ifdef HAVE_NEW_GUI 434 #ifdef HAVE_NEW_GUI
437 if ( vo_window == None ) 435 if ( vo_window == None )
438 #endif 436 #endif
439 { 437 {
440 XSelectInput( mDisplay,mywindow,StructureNotifyMask | KeyPressMask 438 XSelectInput( mDisplay,vo_window,StructureNotifyMask | KeyPressMask
441 #ifdef HAVE_NEW_INPUT 439 #ifdef HAVE_NEW_INPUT
442 | ButtonPressMask | ButtonReleaseMask 440 | ButtonPressMask | ButtonReleaseMask
443 #endif 441 #endif
444 ); 442 );
445 } 443 }
454 { 452 {
455 #ifdef DISP 453 #ifdef DISP
456 #ifdef HAVE_SHM 454 #ifdef HAVE_SHM
457 if ( Shmem_Flag ) 455 if ( Shmem_Flag )
458 { 456 {
459 XShmPutImage( mDisplay,mywindow,mygc,myximage, 457 XShmPutImage( mDisplay,vo_window,vo_gc,myximage,
460 0,0, 458 0,0,
461 ( vo_dwidth - swsContext->dstW ) / 2,( vo_dheight - myximage->height ) / 2, 459 ( vo_dwidth - swsContext->dstW ) / 2,( vo_dheight - myximage->height ) / 2,
462 swsContext->dstW,myximage->height,True ); 460 swsContext->dstW,myximage->height,True );
463 } 461 }
464 else 462 else
465 #endif 463 #endif
466 { 464 {
467 XPutImage( mDisplay,mywindow,mygc,myximage, 465 XPutImage( mDisplay,vo_window,vo_gc,myximage,
468 0,0, 466 0,0,
469 ( vo_dwidth - swsContext->dstW ) / 2,( vo_dheight - myximage->height ) / 2, 467 ( vo_dwidth - swsContext->dstW ) / 2,( vo_dheight - myximage->height ) / 2,
470 swsContext->dstW,myximage->height); 468 swsContext->dstW,myximage->height);
471 } 469 }
472 #endif 470 #endif
577 575
578 #ifdef HAVE_XF86VM 576 #ifdef HAVE_XF86VM
579 vo_vm_close(mDisplay); 577 vo_vm_close(mDisplay);
580 #endif 578 #endif
581 579
582 vo_x11_uninit(mDisplay, mywindow); 580 vo_x11_uninit(mDisplay, vo_window);
583 581
584 freeSwsContext(swsContext); 582 freeSwsContext(swsContext);
585 } 583 }
586 584
587 static uint32_t preinit(const char *arg) 585 static uint32_t preinit(const char *arg)
616 if ((vo_fs_oldwidth == -1) && (vo_fs_oldheight == -1)) 614 if ((vo_fs_oldwidth == -1) && (vo_fs_oldheight == -1))
617 { 615 {
618 int foo; 616 int foo;
619 Window root; 617 Window root;
620 618
621 vo_x11_decoration( mDisplay,mywindow,0 ); 619 vo_x11_decoration( mDisplay,vo_window,0 );
622 XGetGeometry(mDisplay, mywindow, &root, &foo, &foo, 620 XGetGeometry(mDisplay, vo_window, &root, &foo, &foo,
623 &vo_fs_oldwidth, &vo_fs_oldheight, &foo, &foo); 621 &vo_fs_oldwidth, &vo_fs_oldheight, &foo, &foo);
624 622
625 XTranslateCoordinates(mDisplay, mywindow, root, 0, 0, 623 XTranslateCoordinates(mDisplay, vo_window, root, 0, 0,
626 &vo_fs_oldx, &vo_fs_oldy,(Window *) &foo); 624 &vo_fs_oldx, &vo_fs_oldy,(Window *) &foo);
627 625
628 mp_msg(MSGT_VO,MSGL_V,"X11 Fullscreen: saved old place: %dx%d-%dx%d\n", 626 mp_msg(MSGT_VO,MSGL_V,"X11 Fullscreen: saved old place: %dx%d-%dx%d\n",
629 vo_fs_oldx, vo_fs_oldy, vo_fs_oldwidth, vo_fs_oldheight); 627 vo_fs_oldx, vo_fs_oldy, vo_fs_oldwidth, vo_fs_oldheight);
630 628
631 /* resize */ 629 /* resize */
632 vo_dwidth = vo_screenwidth; 630 vo_dwidth = vo_screenwidth;
633 vo_dheight = vo_screenheight; 631 vo_dheight = vo_screenheight;
634 XMoveResizeWindow(mDisplay, mywindow, 0, 0, 632 XMoveResizeWindow(mDisplay, vo_window, 0, 0,
635 vo_screenwidth, vo_screenheight); 633 vo_screenwidth, vo_screenheight);
636 XSync(mDisplay, False); 634 XSync(mDisplay, False);
637 } 635 }
638 else 636 else
639 { 637 {
640 XMoveResizeWindow(mDisplay, mywindow, vo_fs_oldx, vo_fs_oldy, 638 XMoveResizeWindow(mDisplay, vo_window, vo_fs_oldx, vo_fs_oldy,
641 vo_fs_oldwidth, vo_fs_oldheight); 639 vo_fs_oldwidth, vo_fs_oldheight);
642 vo_x11_decoration( mDisplay,mywindow,1 ); 640 vo_x11_decoration( mDisplay,vo_window,1 );
643 641
644 /* restore */ 642 /* restore */
645 vo_dwidth = vo_fs_oldwidth; 643 vo_dwidth = vo_fs_oldwidth;
646 vo_dheight = vo_fs_oldheight; 644 vo_dheight = vo_fs_oldheight;
647 645