ignore BadAccess error at XSelectInput() (grabbing mouse etc) with warning

patch Kazunori Ueno <jagarl@creator.club.ne.jp>


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6954 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
arpi 2002-08-09 17:43:49 +00:00
parent cb0e37959b
commit 1d17fa69c3
8 changed files with 37 additions and 8 deletions

View File

@ -204,7 +204,7 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
// bpp = myximage->bits_per_pixel;
//XSelectInput(mDisplay, vo_window, StructureNotifyMask); // !!!!
XSelectInput(mDisplay, vo_window, StructureNotifyMask | KeyPressMask | PointerMotionMask
vo_x11_selectinput_witherr(mDisplay, vo_window, StructureNotifyMask | KeyPressMask | PointerMotionMask
#ifdef HAVE_NEW_INPUT
| ButtonPressMask | ButtonReleaseMask
#endif

View File

@ -708,7 +708,7 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
XSync(mDisplay, False);
//XSelectInput(mDisplay, vo_window, StructureNotifyMask); // !!!!
XSelectInput(mDisplay, vo_window, StructureNotifyMask | KeyPressMask | PointerMotionMask
vo_x11_selectinput_witherr(mDisplay, vo_window, StructureNotifyMask | KeyPressMask | PointerMotionMask
#ifdef HAVE_NEW_INPUT
| ButtonPressMask | ButtonReleaseMask
#endif

View File

@ -332,7 +332,7 @@ static uint32_t config( uint32_t width,uint32_t height,uint32_t d_width,uint32_t
{
XUnmapWindow( mDisplay,vo_window );
XChangeWindowAttributes( mDisplay,vo_window,xswamask,&xswa );
XSelectInput( mDisplay,vo_window,StructureNotifyMask | KeyPressMask | PropertyChangeMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | ExposureMask );
vo_x11_selectinput_witherr( mDisplay,vo_window,StructureNotifyMask | KeyPressMask | PropertyChangeMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | ExposureMask );
XMapWindow( mDisplay,vo_window );
} else XSelectInput( mDisplay,vo_window,ExposureMask );
}
@ -362,7 +362,7 @@ static uint32_t config( uint32_t width,uint32_t height,uint32_t d_width,uint32_t
XSync( mDisplay,False );
// we cannot grab mouse events on root window :(
XSelectInput( mDisplay,vo_window,StructureNotifyMask | KeyPressMask | PropertyChangeMask | ExposureMask |
vo_x11_selectinput_witherr( mDisplay,vo_window,StructureNotifyMask | KeyPressMask | PropertyChangeMask | ExposureMask |
((WinID==0)?0:(ButtonPressMask | ButtonReleaseMask | PointerMotionMask)) );
#ifdef HAVE_XF86VM

View File

@ -293,7 +293,7 @@ static uint32_t config( uint32_t width, uint32_t height, uint32_t d_width, uint3
{
XUnmapWindow( mDisplay,vo_window );
XChangeWindowAttributes( mDisplay,vo_window,xswamask,&xWAttribs);
XSelectInput( mDisplay,vo_window,StructureNotifyMask | KeyPressMask | PropertyChangeMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | ExposureMask );
vo_x11_selectinput_witherr( mDisplay,vo_window,StructureNotifyMask | KeyPressMask | PropertyChangeMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | ExposureMask );
} else XSelectInput( mDisplay,vo_window,ExposureMask );
} else

View File

@ -383,7 +383,7 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32
{
XUnmapWindow( mDisplay,vo_window );
XChangeWindowAttributes( mDisplay,vo_window,xswamask,&xswa );
XSelectInput( mDisplay,vo_window,StructureNotifyMask | KeyPressMask | PropertyChangeMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | ExposureMask );
vo_x11_selectinput_witherr( mDisplay,vo_window,StructureNotifyMask | KeyPressMask | PropertyChangeMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | ExposureMask );
XMapWindow( mDisplay,vo_window );
} else { drwX=vo_dx; drwY=vo_dy; }
} else
@ -395,7 +395,7 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32
vo_x11_classhint( mDisplay,vo_window,"xv" );
vo_hidecursor(mDisplay,vo_window);
XSelectInput(mDisplay, vo_window, StructureNotifyMask | KeyPressMask | PropertyChangeMask |
vo_x11_selectinput_witherr(mDisplay, vo_window, StructureNotifyMask | KeyPressMask | PropertyChangeMask |
((WinID==0) ? 0 : (PointerMotionMask
#ifdef HAVE_NEW_INPUT
| ButtonPressMask | ButtonReleaseMask

View File

@ -292,7 +292,7 @@ else
{
XUnmapWindow(mDisplay, vo_window);
XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xswa);
XSelectInput( mDisplay,vo_window,StructureNotifyMask | KeyPressMask | PropertyChangeMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | ExposureMask );
vo_x11_selectinput_witherr( mDisplay,vo_window,StructureNotifyMask | KeyPressMask | PropertyChangeMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | ExposureMask );
} else XSelectInput( mDisplay,vo_window,ExposureMask );
}
else

View File

@ -840,7 +840,35 @@ void saver_off(Display *mDisplay) {
// turning off screensaver
}
static XErrorHandler old_handler = NULL;
static int selectinput_err = 0;
static int x11_selectinput_errorhandler(Display *display, XErrorEvent *event)
{
if (event->error_code == BadAccess) {
selectinput_err = 1;
mp_msg(MSGT_VO, MSGL_ERR, "X11 error : BadAccess during XSelectInput Call\n");
mp_msg(MSGT_VO, MSGL_ERR, "X11 error : The 'ButtonPressMask' mask of specified window has probably already used by another appication(see man XSelectInput) \n");
/* If you think mplayer should shutdown with this error, comments out following line */
return 0;
}
if (old_handler != NULL) old_handler(display, event);
else x11_errorhandler(display, event);
return 0;
}
void vo_x11_selectinput_witherr(Display *display, Window w, long event_mask)
{
XSync(display, False);
old_handler = XSetErrorHandler(x11_selectinput_errorhandler);
selectinput_err = 0;
XSelectInput(display, w, event_mask);
XSync(display, False);
XSetErrorHandler(old_handler);
if (selectinput_err) {
mp_msg(MSGT_VO, MSGL_ERR, "X11 error : Mplayer discards mouse control and retry XSelectInput...\n");
XSelectInput(display, w, event_mask & (~(ButtonPressMask | ButtonReleaseMask | PointerMotionMask)) );
}
}
#ifdef HAVE_XINERAMA
void vo_x11_xinerama_move(Display *dsp, Window w)

View File

@ -33,6 +33,7 @@ extern void vo_x11_decoration( Display * vo_Display,Window w,int d );
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_selectinput_witherr(Display *display, Window w, long event_mask);
extern void vo_x11_fullscreen( void );
extern void vo_x11_uninit();