some cleanup, gl/gl2 updated to use vo_window

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6096 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
arpi 2002-05-14 23:44:35 +00:00
parent 17a2a90da8
commit e6bcec1c6b
8 changed files with 72 additions and 76 deletions

View File

@ -52,13 +52,11 @@ static unsigned char *ImageData=NULL;
/* X11 related variables */
//static Display *mydisplay;
static Window mywindow;
//static Window vo_window;
//static GC mygc;
//static XImage *myximage;
//static int depth,mode;
//static XWindowAttributes attribs;
static int X_already_started = 0;
//static int texture_id=1;
static GLXContext wsGLXContext;
@ -115,20 +113,17 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
image_width = width;
image_format = format;
if (X_already_started) return -1;
if(!vo_init()) return -1;
aspect_save_orig(width,height);
aspect_save_prescale(d_width,d_height);
aspect_save_screenres(vo_screenwidth,vo_screenheight);
X_already_started++;
aspect(&d_width,&d_height,A_NOZOOM);
#ifdef X11_FULLSCREEN
if( flags&0x01 ){ // (-fs)
aspect(&d_width,&d_height,A_ZOOM);
}
// if( flags&0x01 ){ // (-fs)
// aspect(&d_width,&d_height,A_ZOOM);
// }
#endif
hint.x = 0;
hint.y = 0;
@ -160,30 +155,31 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
xswamask = CWBackPixel | CWBorderPixel | CWColormap;
// xswamask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWCursor | CWOverrideRedirect | CWSaveUnder | CWX | CWY | CWWidth | CWHeight;
mywindow = XCreateWindow(mDisplay, RootWindow(mDisplay,mScreen),
vo_window = XCreateWindow(mDisplay, mRootWin,
hint.x, hint.y, hint.width, hint.height, 4, vinfo->depth,CopyFromParent,vinfo->visual,xswamask,&xswa);
vo_x11_classhint( mDisplay,mywindow,"gl" );
vo_hidecursor(mDisplay,mywindow);
vo_x11_classhint( mDisplay,vo_window,"gl" );
vo_hidecursor(mDisplay,vo_window);
wsGLXContext=glXCreateContext( mDisplay,vinfo,NULL,True );
// XStoreName( wsDisplay,wsMyWin,wsSysName );
// printf("GLXcontext ok\n");
if ( flags&0x01 ) vo_x11_decoration( mDisplay,mywindow,0 );
// if ( flags&0x01 ) vo_x11_decoration( mDisplay,vo_window,0 );
XSelectInput(mDisplay, mywindow, StructureNotifyMask);
XSelectInput(mDisplay, vo_window, StructureNotifyMask);
/* Tell other applications about this window */
XSetStandardProperties(mDisplay, mywindow, hello, hello, None, NULL, 0, &hint);
XSetStandardProperties(mDisplay, vo_window, hello, hello, None, NULL, 0, &hint);
/* Map window. */
XMapWindow(mDisplay, mywindow);
XMapWindow(mDisplay, vo_window);
if ( flags&1 ) vo_x11_fullscreen();
#ifdef HAVE_XINERAMA
vo_x11_xinerama_move(mDisplay,mywindow);
vo_x11_xinerama_move(mDisplay,vo_window);
#endif
/* Wait for map. */
@ -191,24 +187,24 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
{
XNextEvent(mDisplay, &xev);
}
while (xev.type != MapNotify || xev.xmap.event != mywindow);
while (xev.type != MapNotify || xev.xmap.event != vo_window);
XSelectInput(mDisplay, mywindow, NoEventMask);
XSelectInput(mDisplay, vo_window, NoEventMask);
glXMakeCurrent( mDisplay,mywindow,wsGLXContext );
glXMakeCurrent( mDisplay,vo_window,wsGLXContext );
XFlush(mDisplay);
XSync(mDisplay, False);
// mygc = XCreateGC(mDisplay, mywindow, 0L, &xgcv);
// mygc = XCreateGC(mDisplay, vo_window, 0L, &xgcv);
// myximage = XGetImage(mDisplay, mywindow, 0, 0,
// myximage = XGetImage(mDisplay, vo_window, 0, 0,
// width, image_height, AllPlanes, ZPixmap);
// ImageData = myximage->data;
// bpp = myximage->bits_per_pixel;
//XSelectInput(mDisplay, mywindow, StructureNotifyMask); // !!!!
XSelectInput(mDisplay, mywindow, StructureNotifyMask | KeyPressMask | PointerMotionMask
//XSelectInput(mDisplay, vo_window, StructureNotifyMask); // !!!!
XSelectInput(mDisplay, vo_window, StructureNotifyMask | KeyPressMask | PointerMotionMask
#ifdef HAVE_NEW_INPUT
| ButtonPressMask | ButtonReleaseMask
#endif
@ -325,8 +321,8 @@ flip_page(void)
// glFlush();
glFinish();
glXSwapBuffers( mDisplay,mywindow );
glXSwapBuffers( mDisplay,vo_window );
}
//static inline uint32_t draw_slice_x11(uint8_t *src[], uint32_t slice_num)
@ -469,9 +465,9 @@ query_format(uint32_t format)
static void
uninit(void)
{
if ( !vo_config_count ) return;
saver_on(mDisplay); // screen saver back on
vo_x11_uninit(mDisplay, mywindow);
vo_x11_uninit();
}
static uint32_t preinit(const char *arg)
@ -489,6 +485,9 @@ static uint32_t control(uint32_t request, void *data, ...)
switch (request) {
case VOCTRL_QUERY_FORMAT:
return query_format(*((uint32_t*)data));
case VOCTRL_FULLSCREEN:
vo_x11_fullscreen();
return VO_TRUE;
}
return VO_NOTIMPL;
}

View File

@ -56,8 +56,7 @@ static unsigned char *ImageDataLocal=NULL;
static unsigned char *ImageData=NULL;
/* X11 related variables */
static Window mywindow;
static int X_already_started = 0;
//static Window vo_window;
//static int texture_id=1;
@ -623,7 +622,6 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
image_width = width;
image_format = format;
if (X_already_started) return -1;
if(!vo_init()) return -1;
aspect_save_orig(width,height);
@ -632,8 +630,6 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
aspect(&d_width,&d_height,A_NOZOOM);
X_already_started++;
if( flags&0x01 )
{
isFullscreen = GL_TRUE;
@ -673,46 +669,46 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
xswa.colormap = XCreateColormap(mDisplay, mRootWin, vinfo->visual, AllocNone);
xswamask = CWBackPixel | CWBorderPixel | CWColormap;
mywindow = XCreateWindow(mDisplay, RootWindow(mDisplay,mScreen),
vo_window = XCreateWindow(mDisplay, RootWindow(mDisplay,mScreen),
hint.x, hint.y, hint.width, hint.height, 4, vinfo->depth,CopyFromParent,vinfo->visual,xswamask,&xswa);
vo_x11_classhint( mDisplay,mywindow,"gl2" );
vo_hidecursor(mDisplay,mywindow);
vo_x11_classhint( mDisplay,vo_window,"gl2" );
vo_hidecursor(mDisplay,vo_window);
wsGLXContext=glXCreateContext( mDisplay,vinfo,NULL,True );
if ( flags&0x01 ) vo_x11_decoration( mDisplay,mywindow,0 );
if ( flags&0x01 ) vo_x11_decoration( mDisplay,vo_window,0 );
XSelectInput(mDisplay, mywindow, StructureNotifyMask);
XSelectInput(mDisplay, vo_window, StructureNotifyMask);
/* Tell other applications about this window */
XSetStandardProperties(mDisplay, mywindow, hello, hello, None, NULL, 0, &hint);
XSetStandardProperties(mDisplay, vo_window, hello, hello, None, NULL, 0, &hint);
/* Map window. */
XMapWindow(mDisplay, mywindow);
XMapWindow(mDisplay, vo_window);
#ifdef HAVE_XINERAMA
vo_x11_xinerama_move(mDisplay,mywindow);
vo_x11_xinerama_move(mDisplay,vo_window);
#endif
XClearWindow(mDisplay,mywindow);
XClearWindow(mDisplay,vo_window);
/* Wait for map. */
do
{
XNextEvent(mDisplay, &xev);
}
while (xev.type != MapNotify || xev.xmap.event != mywindow);
while (xev.type != MapNotify || xev.xmap.event != vo_window);
XSelectInput(mDisplay, mywindow, NoEventMask);
XSelectInput(mDisplay, vo_window, NoEventMask);
glXMakeCurrent( mDisplay,mywindow,wsGLXContext );
glXMakeCurrent( mDisplay,vo_window,wsGLXContext );
XFlush(mDisplay);
XSync(mDisplay, False);
//XSelectInput(mDisplay, mywindow, StructureNotifyMask); // !!!!
XSelectInput(mDisplay, mywindow, StructureNotifyMask | KeyPressMask | PointerMotionMask
//XSelectInput(mDisplay, vo_window, StructureNotifyMask); // !!!!
XSelectInput(mDisplay, vo_window, StructureNotifyMask | KeyPressMask | PointerMotionMask
#ifdef HAVE_NEW_INPUT
| ButtonPressMask | ButtonReleaseMask
#endif
@ -1009,7 +1005,7 @@ flip_page(void)
// glFlush();
glFinish();
glXSwapBuffers( mDisplay,mywindow );
glXSwapBuffers( mDisplay,vo_window );
if(!used_info_done)
{
@ -1096,9 +1092,9 @@ query_format(uint32_t format)
static void
uninit(void)
{
if ( !vo_config_count ) return;
saver_on(mDisplay); // screen saver back on
vo_x11_uninit(mDisplay, mywindow);
vo_x11_uninit();
}
static uint32_t preinit(const char *arg)

View File

@ -601,7 +601,7 @@ uninit(void)
#endif
zoomFlag=0;
vo_x11_uninit(mDisplay, vo_window);
vo_x11_uninit();
freeSwsContext(swsContext);
}

View File

@ -77,8 +77,6 @@ static XImage * myximage;
static uint32_t mDepth, bpp, mode;
static XWindowAttributes attribs;
static uint32_t X_already_started=0;
static uint32_t fgColor;
static uint32_t mvHeight;
@ -195,7 +193,6 @@ static uint32_t config( uint32_t width, uint32_t height, uint32_t d_width, uint3
unsigned long xswamask;
if ( X_already_started ) return -1;
if (!vo_init()) return -1;
width+=width&1;
@ -337,7 +334,7 @@ uninit(void)
inited=0;
mga_uninit();
saver_on(mDisplay);
vo_x11_uninit(mDisplay, vo_window);
vo_x11_uninit();
printf("vo: uninit!\n");
}

View File

@ -794,7 +794,7 @@ static void uninit(void)
#ifdef HAVE_XF86VM
vo_vm_close(mDisplay);
#endif
if(vo_config_count) vo_x11_uninit(mDisplay, vo_window);
if(vo_config_count) vo_x11_uninit();
#else
@ -804,7 +804,7 @@ static void uninit(void)
#ifdef HAVE_XF86VM
vo_vm_close(mDisplay);
#endif
vo_x11_uninit(mDisplay, vo_window);
vo_x11_uninit();
#endif
}

View File

@ -50,8 +50,6 @@ static vo_info_t vo_info =
#define UNUSED(x) ((void)(x)) /* Removes warning about unused arguments */
/* X11 related variables */
static int X_already_started = 0;
/* Colorkey handling */
static XGCValues mGCV;
static uint32_t fgColor;
@ -72,12 +70,12 @@ static uint32_t image_depth;
static uint32_t window_width, window_height;
/* used by XGetGeometry & XTranslateCoordinates for moving/resizing window */
static Window mRoot;
static uint32_t drwX, drwY, drwWidth, drwHeight, drwBorderWidth,
drwDepth, drwcX, drwcY, dwidth, dheight;
static void set_window(int force_update,const vo_tune_info_t *info)
{
Window mRoot;
if ( WinID )
{
XGetGeometry(mDisplay, vo_window, &mRoot, &drwX, &drwY, &drwWidth,
@ -417,7 +415,7 @@ static void uninit(void)
vidix_term();
saver_on(mDisplay); /* screen saver back on */
vo_x11_uninit(mDisplay, vo_window);
vo_x11_uninit();
}
static uint32_t preinit(const char *arg)

View File

@ -171,7 +171,8 @@ static int x11_errorhandler(Display *display, XErrorEvent *event)
event->error_code, event->request_code, event->minor_code);
}
exit_player("X11 error");
abort();
//exit_player("X11 error");
#undef MSGLEN
}
@ -517,7 +518,7 @@ void vo_x11_classhint( Display * display,Window window,char *name ){
}
Window vo_window = None;
GC vo_gc;
GC vo_gc = NULL;
XSizeHints vo_hint;
#ifdef HAVE_NEW_GUI
@ -526,27 +527,29 @@ XSizeHints vo_hint;
}
#endif
int vo_x11_uninit(Display *display, Window window)
void vo_x11_uninit()
{
vo_showcursor( display,window );
if(vo_window!=None) vo_showcursor( mDisplay,vo_window );
#ifdef HAVE_NEW_GUI
/* destroy window only if it's not controlled by GUI */
if ( !use_gui )
#endif
{
XSetBackground( mDisplay,vo_gc,0 );
XClearWindow( mDisplay,vo_window );
/* and -wid is set */
if (WinID < 0)
{
XUnmapWindow( display,window );
XDestroyWindow(display, window);
}
if(vo_gc){
XSetBackground( mDisplay,vo_gc,0 );
vo_gc=NULL;
}
if(vo_window!=None){
XClearWindow( mDisplay,vo_window );
if (WinID < 0){
XUnmapWindow( mDisplay,vo_window );
XDestroyWindow(mDisplay, vo_window);
}
vo_window=None;
}
vo_fs=0;
}
return(1);
}
int vo_mouse_timer_const = 30;
@ -562,7 +565,7 @@ int vo_x11_check_events(Display *mydisplay){
// unsigned long vo_KeyTable[512];
if ( ( vo_mouse_autohide )&&( --vo_mouse_counter == 0 ) ) vo_hidecursor( mydisplay,vo_window );
while ( XPending( mydisplay ) )
{
XNextEvent( mydisplay,&Event );
@ -573,6 +576,7 @@ int vo_x11_check_events(Display *mydisplay){
if ( vo_window != Event.xany.window ) continue;
}
#endif
// printf("\rEvent.type=%X \n",Event.type);
switch( Event.type )
{
case Expose:

View File

@ -34,6 +34,8 @@ extern void vo_x11_classhint( Display * display,Window window,char *name );
extern void vo_x11_sizehint( int x, int y, int width, int height, int max );
extern int vo_x11_check_events(Display *mydisplay);
extern void vo_x11_fullscreen( void );
extern void vo_x11_uninit();
#endif
extern Window vo_window;