Mercurial > mplayer.hg
comparison libvo/vo_x11.c @ 4813:15e95b9cf191
using vo_dx, vo_dy
author | alex |
---|---|
date | Fri, 22 Feb 2002 19:52:09 +0000 |
parents | 4eaa205201b0 |
children | 178b524e5213 |
comparison
equal
deleted
inserted
replaced
4812:bad436339b03 | 4813:15e95b9cf191 |
---|---|
55 | 55 |
56 /* private prototypes */ | 56 /* private prototypes */ |
57 static void Display_Image ( XImage * myximage,unsigned char *ImageData ); | 57 static void Display_Image ( XImage * myximage,unsigned char *ImageData ); |
58 static void (*draw_alpha_fnc)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride); | 58 static void (*draw_alpha_fnc)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride); |
59 | 59 |
60 /* since it doesn't seem to be defined on some platforms */ | |
61 int XShmGetEventBase( Display* ); | |
62 | |
63 /* local data */ | 60 /* local data */ |
64 static unsigned char *ImageData; | 61 static unsigned char *ImageData; |
65 | 62 |
66 /* X11 related variables */ | 63 /* X11 related variables */ |
67 //static Display *mDisplay; | |
68 static XImage *myximage; | 64 static XImage *myximage; |
69 static int depth,bpp,mode; | 65 static int depth,bpp,mode; |
70 static XWindowAttributes attribs; | 66 static XWindowAttributes attribs; |
71 | 67 |
72 //static int vo_dwidth,vo_dheight; | |
73 | |
74 static int Flip_Flag; | 68 static int Flip_Flag; |
75 static int zoomFlag; | 69 static int zoomFlag; |
76 | 70 |
77 #ifdef HAVE_SHM | 71 #ifdef HAVE_SHM |
78 | |
79 #include <sys/ipc.h> | 72 #include <sys/ipc.h> |
80 #include <sys/shm.h> | 73 #include <sys/shm.h> |
81 #include <X11/extensions/XShm.h> | 74 #include <X11/extensions/XShm.h> |
82 | |
83 //static int HandleXError _ANSI_ARGS_( ( Display * dpy,XErrorEvent * event ) ); | |
84 static void InstallXErrorHandler ( void ); | |
85 static void DeInstallXErrorHandler ( void ); | |
86 | 75 |
87 static int Shmem_Flag; | 76 static int Shmem_Flag; |
88 static int Quiet_Flag; | 77 static int Quiet_Flag; |
89 static XShmSegmentInfo Shminfo[1]; | 78 static XShmSegmentInfo Shminfo[1]; |
90 static int gXErrorFlag; | 79 static int gXErrorFlag; |
91 static int CompletionType=-1; | 80 static int CompletionType=-1; |
92 | 81 |
93 static void InstallXErrorHandler() | 82 /* since it doesn't seem to be defined on some platforms */ |
94 { | 83 int XShmGetEventBase( Display* ); |
95 //XSetErrorHandler( HandleXError ); | |
96 XFlush( mDisplay ); | |
97 } | |
98 | |
99 static void DeInstallXErrorHandler() | |
100 { | |
101 XSetErrorHandler( NULL ); | |
102 XFlush( mDisplay ); | |
103 } | |
104 | |
105 #endif | 84 #endif |
106 | 85 |
107 static uint32_t image_width; | 86 static uint32_t image_width; |
108 static uint32_t image_height; | 87 static uint32_t image_height; |
109 static uint32_t in_format; | 88 static uint32_t in_format; |
155 { | 134 { |
156 Shmem_Flag=0; | 135 Shmem_Flag=0; |
157 if ( !Quiet_Flag ) printf( "Shared memory not supported\nReverting to normal Xlib\n" ); | 136 if ( !Quiet_Flag ) printf( "Shared memory not supported\nReverting to normal Xlib\n" ); |
158 } | 137 } |
159 if ( Shmem_Flag ) CompletionType=XShmGetEventBase( mDisplay ) + ShmCompletion; | 138 if ( Shmem_Flag ) CompletionType=XShmGetEventBase( mDisplay ) + ShmCompletion; |
160 | |
161 InstallXErrorHandler(); | |
162 | 139 |
163 if ( Shmem_Flag ) | 140 if ( Shmem_Flag ) |
164 { | 141 { |
165 myximage=XShmCreateImage( mDisplay,vinfo.visual,depth,ZPixmap,NULL,&Shminfo[0],image_width,image_height ); | 142 myximage=XShmCreateImage( mDisplay,vinfo.visual,depth,ZPixmap,NULL,&Shminfo[0],image_width,image_height ); |
166 if ( myximage == NULL ) | 143 if ( myximage == NULL ) |
226 myximage=XGetImage( mDisplay,vo_window,0,0, | 203 myximage=XGetImage( mDisplay,vo_window,0,0, |
227 image_width,image_height,AllPlanes,ZPixmap ); | 204 image_width,image_height,AllPlanes,ZPixmap ); |
228 ImageData=myximage->data; | 205 ImageData=myximage->data; |
229 #ifdef HAVE_SHM | 206 #ifdef HAVE_SHM |
230 } | 207 } |
231 | |
232 DeInstallXErrorHandler(); | |
233 #endif | 208 #endif |
234 } | 209 } |
235 | 210 |
236 static void freeMyXImage() | 211 static void freeMyXImage() |
237 { | 212 { |
254 // int screen; | 229 // int screen; |
255 int fullscreen=0; | 230 int fullscreen=0; |
256 int vm=0; | 231 int vm=0; |
257 // int interval, prefer_blank, allow_exp, nothing; | 232 // int interval, prefer_blank, allow_exp, nothing; |
258 unsigned int fg,bg; | 233 unsigned int fg,bg; |
259 char *hello=( title == NULL ) ? "X11 render" : title; | |
260 // char *name=":0.0"; | |
261 XSizeHints hint; | 234 XSizeHints hint; |
262 XEvent xev; | 235 XEvent xev; |
263 XGCValues xgcv; | 236 XGCValues xgcv; |
264 Colormap theCmap; | 237 Colormap theCmap; |
265 XSetWindowAttributes xswa; | 238 XSetWindowAttributes xswa; |
267 #ifdef HAVE_XF86VM | 240 #ifdef HAVE_XF86VM |
268 unsigned int modeline_width, modeline_height; | 241 unsigned int modeline_width, modeline_height; |
269 static uint32_t vm_width; | 242 static uint32_t vm_width; |
270 static uint32_t vm_height; | 243 static uint32_t vm_height; |
271 #endif | 244 #endif |
245 | |
246 if (!title) | |
247 title = strdup("MPlayer X11 (XImage/Shm) render"); | |
272 | 248 |
273 in_format=format; | 249 in_format=format; |
274 srcW= width; | 250 srcW= width; |
275 srcH= height; | 251 srcH= height; |
276 | 252 |
368 | 344 |
369 vo_x11_classhint( mDisplay,vo_window,"x11" ); | 345 vo_x11_classhint( mDisplay,vo_window,"x11" ); |
370 vo_hidecursor(mDisplay,vo_window); | 346 vo_hidecursor(mDisplay,vo_window); |
371 if ( fullscreen ) vo_x11_decoration( mDisplay,vo_window,0 ); | 347 if ( fullscreen ) vo_x11_decoration( mDisplay,vo_window,0 ); |
372 XSelectInput( mDisplay,vo_window,StructureNotifyMask ); | 348 XSelectInput( mDisplay,vo_window,StructureNotifyMask ); |
373 XSetStandardProperties( mDisplay,vo_window,hello,hello,None,NULL,0,&hint ); | 349 XSetStandardProperties( mDisplay,vo_window,title,title,None,NULL,0,&hint ); |
374 XMapWindow( mDisplay,vo_window ); | 350 XMapWindow( mDisplay,vo_window ); |
375 #ifdef HAVE_XINERAMA | 351 #ifdef HAVE_XINERAMA |
376 vo_x11_xinerama_move(mDisplay,vo_window); | 352 vo_x11_xinerama_move(mDisplay,vo_window); |
377 #endif | 353 #endif |
378 do { XNextEvent( mDisplay,&xev ); } while ( xev.type != MapNotify || xev.xmap.event != vo_window ); | 354 do { XNextEvent( mDisplay,&xev ); } while ( xev.type != MapNotify || xev.xmap.event != vo_window ); |
380 | 356 |
381 XFlush( mDisplay ); | 357 XFlush( mDisplay ); |
382 XSync( mDisplay,False ); | 358 XSync( mDisplay,False ); |
383 vo_gc=XCreateGC( mDisplay,vo_window,0L,&xgcv ); | 359 vo_gc=XCreateGC( mDisplay,vo_window,0L,&xgcv ); |
384 | 360 |
385 XSelectInput( mDisplay,vo_window,StructureNotifyMask | KeyPressMask | ButtonPressMask | ButtonReleaseMask ); | 361 XSelectInput( mDisplay,vo_window,StructureNotifyMask | KeyPressMask | ButtonPressMask | ButtonReleaseMask); |
386 | 362 |
387 #ifdef HAVE_XF86VM | 363 #ifdef HAVE_XF86VM |
388 if ( vm ) | 364 if ( vm ) |
389 { | 365 { |
390 /* Grab the mouse pointer in our window */ | 366 /* Grab the mouse pointer in our window */ |
608 { | 584 { |
609 int foo; | 585 int foo; |
610 Window root; | 586 Window root; |
611 | 587 |
612 vo_x11_decoration( mDisplay,vo_window,0 ); | 588 vo_x11_decoration( mDisplay,vo_window,0 ); |
589 #ifdef LOCAL_LOOKUP | |
613 XGetGeometry(mDisplay, vo_window, &root, &foo, &foo, | 590 XGetGeometry(mDisplay, vo_window, &root, &foo, &foo, |
614 &vo_fs_oldwidth, &vo_fs_oldheight, &foo, &foo); | 591 &vo_fs_oldwidth, &vo_fs_oldheight, &foo, &foo); |
615 | 592 |
616 XTranslateCoordinates(mDisplay, vo_window, root, 0, 0, | 593 XTranslateCoordinates(mDisplay, vo_window, root, 0, 0, |
617 &vo_fs_oldx, &vo_fs_oldy,(Window *) &foo); | 594 &vo_fs_oldx, &vo_fs_oldy,(Window *) &foo); |
595 #else | |
596 vo_fs_oldwidth = vo_dwidth; | |
597 vo_fs_oldheight = vo_dheight; | |
598 vo_fs_oldx = vo_dx; | |
599 vo_fs_oldy = vo_dy; | |
600 #endif | |
618 | 601 |
619 mp_msg(MSGT_VO,MSGL_V,"X11 Fullscreen: saved old place: %dx%d-%dx%d\n", | 602 mp_msg(MSGT_VO,MSGL_V,"X11 Fullscreen: saved old place: %dx%d-%dx%d\n", |
620 vo_fs_oldx, vo_fs_oldy, vo_fs_oldwidth, vo_fs_oldheight); | 603 vo_fs_oldx, vo_fs_oldy, vo_fs_oldwidth, vo_fs_oldheight); |
621 | 604 |
622 /* resize */ | 605 /* resize */ |
630 { | 613 { |
631 XMoveResizeWindow(mDisplay, vo_window, vo_fs_oldx, vo_fs_oldy, | 614 XMoveResizeWindow(mDisplay, vo_window, vo_fs_oldx, vo_fs_oldy, |
632 vo_fs_oldwidth, vo_fs_oldheight); | 615 vo_fs_oldwidth, vo_fs_oldheight); |
633 vo_x11_decoration( mDisplay,vo_window,1 ); | 616 vo_x11_decoration( mDisplay,vo_window,1 ); |
634 | 617 |
618 #ifdef LOCAL_LOOKUP | |
635 /* restore */ | 619 /* restore */ |
636 vo_dwidth = vo_fs_oldwidth; | 620 vo_dwidth = vo_fs_oldwidth; |
637 vo_dheight = vo_fs_oldheight; | 621 vo_dheight = vo_fs_oldheight; |
622 #endif | |
638 | 623 |
639 /* clean */ | 624 /* clean */ |
640 vo_fs_oldwidth = -1; | 625 vo_fs_oldwidth = -1; |
641 vo_fs_oldheight = -1; | 626 vo_fs_oldheight = -1; |
642 XSync(mDisplay, False); | 627 XSync(mDisplay, False); |