mirror of
https://github.com/mpv-player/mpv
synced 2024-12-28 06:03:45 +01:00
wm detection -- round two
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6010 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
68330a49a6
commit
916a1d5dea
71
Gui/wm/ws.c
71
Gui/wm/ws.c
@ -150,45 +150,58 @@ int wsWindowManagerType( void )
|
||||
unsigned long nitems, bytesafter;
|
||||
unsigned char * args = NULL;
|
||||
|
||||
mp_dbg( MSGT_GPLAYER,MSGL_STATUS,"[ws] Detected wm is " );
|
||||
// --- icewm
|
||||
// type=XInternAtom( wsDisplay,"_ICEWM_TRAY",False );
|
||||
// if ( Success == XGetWindowProperty( wsDisplay,wsRootWin,type,0,65536 / sizeof( long ),False,AnyPropertyType,&type,&format,&nitems,&bytesafter,&args ) && nitems > 0 )
|
||||
// {
|
||||
// mp_dbg( MSGT_GPLAYER,MSGL_STATUS,"IceWM\n" );
|
||||
// XFree( args );
|
||||
// return wsWMIceWM;
|
||||
// }
|
||||
Window win;
|
||||
XEvent xev;
|
||||
int c = 0;
|
||||
int wm = wsWMUnknown;
|
||||
|
||||
// --- gnome
|
||||
// type=XInternAtom( wsDisplay,"_WIN_SUPPORTING_WM_CHECK",False );
|
||||
// if ( Success == XGetWindowProperty( wsDisplay,wsRootWin,type,0,65536 / sizeof( long ),False,AnyPropertyType,&type,&format,&nitems,&bytesafter,&args ) && nitems > 0 )
|
||||
// {
|
||||
// mp_dbg( MSGT_GPLAYER,MSGL_STATUS,"Gnome\n" );
|
||||
// XFree( args );
|
||||
// return wsWMGnome;
|
||||
// }
|
||||
|
||||
// --- kde
|
||||
// type=XInternAtom( wsDisplay,"_KDE_NET_WM_FRAME_STRUT",False );
|
||||
//// type=XInternAtom( wsDisplay,"_KDE_NET_USER_TIME",False );
|
||||
// if ( Success == XGetWindowProperty( wsDisplay,wsRootWin,type,0,65536 / sizeof( long ),False,AnyPropertyType,&type,&format,&nitems,&bytesafter,&args ) && nitems > 0 )
|
||||
// {
|
||||
// mp_dbg( MSGT_GPLAYER,MSGL_STATUS,"KDE\n" );
|
||||
// XFree( args );
|
||||
// return wsWMKDE;
|
||||
// }
|
||||
type=XInternAtom( wsDisplay,"_WIN_SUPPORTING_WM_CHECK",False );
|
||||
if ( Success == XGetWindowProperty( wsDisplay,wsRootWin,type,0,65536 / sizeof( long ),False,AnyPropertyType,&type,&format,&nitems,&bytesafter,&args ) && nitems > 0 )
|
||||
{
|
||||
mp_dbg( MSGT_GPLAYER,MSGL_STATUS,"[ws] Detected wm is Gnome\n" );
|
||||
XFree( args );
|
||||
return wsWMGnome;
|
||||
}
|
||||
|
||||
// --- net wm
|
||||
type=XInternAtom( wsDisplay,"_NET_SUPPORTED",False );
|
||||
if ( Success == XGetWindowProperty( wsDisplay,wsRootWin,type,0,65536 / sizeof( long ),False,AnyPropertyType,&type,&format,&nitems,&bytesafter,&args ) && nitems > 0 )
|
||||
{
|
||||
mp_dbg( MSGT_GPLAYER,MSGL_STATUS,"NetWM\n" );
|
||||
mp_dbg( MSGT_GPLAYER,MSGL_STATUS,"[ws] Detected wm is NetWM\n" );
|
||||
XFree( args );
|
||||
return wsWMNetWM;
|
||||
}
|
||||
|
||||
mp_dbg( MSGT_GPLAYER,MSGL_STATUS,"Unknow\n" );
|
||||
|
||||
// --- other wm
|
||||
mp_dbg( MSGT_VO,MSGL_STATUS,"[ws] Create window for WM detect ...\n" );
|
||||
win=XCreateSimpleWindow( wsDisplay,wsRootWin,wsMaxX,wsMaxY,1,1,0,0,0 );
|
||||
XSelectInput( wsDisplay,win,PropertyChangeMask | StructureNotifyMask );
|
||||
XMapWindow( wsDisplay,win );
|
||||
XMoveWindow( wsDisplay,win,wsMaxX,wsMaxY );
|
||||
do
|
||||
{
|
||||
XCheckWindowEvent( wsDisplay,win,PropertyChangeMask | StructureNotifyMask,&xev );
|
||||
|
||||
if ( xev.type == PropertyNotify )
|
||||
{
|
||||
char * name = XGetAtomName( wsDisplay,xev.xproperty.atom );
|
||||
if ( !name ) break;
|
||||
|
||||
if ( !strncmp( name,"_ICEWM_TRAY",11 ) )
|
||||
{ mp_dbg( MSGT_VO,MSGL_STATUS,"[ws] Detected wm is IceWM.\n" ); wm=wsWMIceWM; break; }
|
||||
if ( !strncmp( name,"_KDE_",5 ) )
|
||||
{ mp_dbg( MSGT_VO,MSGL_STATUS,"[ws] Detected wm is KDE.\n" ); wm=wsWMKDE; break; }
|
||||
if ( !strncmp( name,"KWM_WIN_DESKTOP",15 ) )
|
||||
{ mp_dbg( MSGT_VO,MSGL_STATUS,"[ws] Detected wm is WindowMaker style.\n" ); wm=wsWMWMaker; break; }
|
||||
// fprintf(stderr,"[ws] PropertyNotify ( 0x%x ) %s ( 0x%x )\n",win,name,xev.xproperty.atom );
|
||||
XFree( name );
|
||||
}
|
||||
} while( c++ < 25 );
|
||||
XDestroyWindow( wsDisplay,win );
|
||||
#ifdef MP_DEBUG
|
||||
if ( wm == wsWMUnknown ) mp_dbg( MSGT_VO,MSGL_STATUS,"[ws] Unknown wm type...\n" );
|
||||
#endif
|
||||
return wsWMUnknown;
|
||||
}
|
||||
|
||||
|
@ -276,6 +276,10 @@ static uint32_t control(uint32_t request, void *data, ...)
|
||||
mga_fullscreen();
|
||||
#endif
|
||||
return VO_TRUE;
|
||||
#if defined( VO_XMGA ) && defined( HAVE_NEW_GUI )
|
||||
case VOCTRL_GUISUPPORT:
|
||||
return VO_TRUE;
|
||||
#endif
|
||||
}
|
||||
return VO_NOTIMPL;
|
||||
}
|
||||
|
@ -292,8 +292,6 @@ static uint32_t config( uint32_t width, uint32_t height, uint32_t d_width, uint3
|
||||
vo_x11_classhint( mDisplay,vo_window,"xmga" );
|
||||
vo_hidecursor(mDisplay,vo_window);
|
||||
|
||||
// if ( vo_fs ) vo_x11_decoration( mDisplay,vo_window,0 );
|
||||
|
||||
XStoreName( mDisplay,vo_window,mTitle );
|
||||
XMapWindow( mDisplay,vo_window );
|
||||
|
||||
|
@ -437,7 +437,6 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32
|
||||
);
|
||||
XSetStandardProperties(mDisplay, vo_window, hello, hello, None, NULL, 0, &hint);
|
||||
XSetWMNormalHints( mDisplay,vo_window,&hint );
|
||||
// if ( vo_fs ) vo_x11_decoration( mDisplay,vo_window,0 );
|
||||
XMapWindow(mDisplay, vo_window);
|
||||
if ( flags&1 ) vo_x11_fullscreen();
|
||||
#ifdef HAVE_XINERAMA
|
||||
|
@ -33,6 +33,10 @@
|
||||
#include "vosub_vidix.h"
|
||||
#include "../vidix/vidixlib.h"
|
||||
|
||||
#ifdef HAVE_NEW_GUI
|
||||
#include "../Gui/interface.h"
|
||||
#endif
|
||||
|
||||
LIBVO_EXTERN(xvidix)
|
||||
|
||||
static vo_info_t vo_info =
|
||||
@ -228,9 +232,9 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width,
|
||||
window_width = d_width;
|
||||
window_height = d_height;
|
||||
|
||||
vo_fs = flags&0x01;
|
||||
if (vo_fs)
|
||||
{ vo_old_width=d_width; vo_old_height=d_height; }
|
||||
// vo_fs = flags&0x01;
|
||||
// if (vo_fs)
|
||||
// { vo_old_width=d_width; vo_old_height=d_height; }
|
||||
|
||||
X_already_started++;
|
||||
|
||||
@ -254,26 +258,29 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width,
|
||||
}
|
||||
|
||||
aspect(&d_width, &d_height, A_NOZOOM);
|
||||
|
||||
vo_dwidth=d_width; vo_dheight=d_height;
|
||||
|
||||
#ifdef HAVE_NEW_GUI
|
||||
if (vo_window == None)
|
||||
if(use_gui) guiGetEvent( guiSetShVideo,0 ); // the GUI will set up / resize the window
|
||||
else
|
||||
{
|
||||
#endif
|
||||
|
||||
#ifdef X11_FULLSCREEN
|
||||
if (vo_fs) /* fullscreen */
|
||||
if ( flags&1 ) /* fullscreen */
|
||||
{
|
||||
if (flags & 0x04)
|
||||
{
|
||||
aspect(&d_width, &d_height, A_ZOOM);
|
||||
}
|
||||
else
|
||||
{
|
||||
d_width = vo_screenwidth;
|
||||
d_height = vo_screenheight;
|
||||
}
|
||||
window_width = vo_screenwidth;
|
||||
window_height = vo_screenheight;
|
||||
// else
|
||||
// {
|
||||
// d_width = vo_screenwidth;
|
||||
// d_height = vo_screenheight;
|
||||
// }
|
||||
// window_width = vo_screenwidth;
|
||||
// window_height = vo_screenheight;
|
||||
}
|
||||
#endif
|
||||
dwidth = d_width;
|
||||
@ -310,10 +317,10 @@ if (vo_window == None)
|
||||
vo_x11_classhint(mDisplay, vo_window, "xvidix");
|
||||
vo_hidecursor(mDisplay, vo_window);
|
||||
|
||||
#ifdef X11_FULLSCREEN
|
||||
if (vo_fs) /* fullscreen */
|
||||
vo_x11_decoration(mDisplay, vo_window, 0);
|
||||
#endif
|
||||
//#ifdef X11_FULLSCREEN
|
||||
// if (vo_fs && vo_wm_type == 0) /* fullscreen */
|
||||
// vo_x11_decoration(mDisplay, vo_window, 0);
|
||||
//#endif
|
||||
|
||||
XGetNormalHints(mDisplay, vo_window, &hint);
|
||||
hint.x = window_x;
|
||||
@ -327,13 +334,16 @@ if (vo_window == None)
|
||||
/* Map window. */
|
||||
|
||||
XMapWindow(mDisplay, vo_window);
|
||||
|
||||
if ( flags&1 ) vo_x11_fullscreen();
|
||||
|
||||
#ifdef HAVE_XINERAMA
|
||||
vo_x11_xinerama_move(mDisplay, vo_window);
|
||||
#endif
|
||||
|
||||
vo_gc = XCreateGC(mDisplay, vo_window, GCForeground, &mGCV);
|
||||
|
||||
XSelectInput( mDisplay,vo_window,StructureNotifyMask | KeyPressMask | ButtonPressMask | ButtonReleaseMask );
|
||||
// XSelectInput( mDisplay,vo_window,StructureNotifyMask | KeyPressMask | ButtonPressMask | ButtonReleaseMask );
|
||||
#ifdef HAVE_NEW_GUI
|
||||
}
|
||||
#endif
|
||||
|
@ -174,6 +174,59 @@ static void x11_errorhandler(Display *display, XErrorEvent *event)
|
||||
#undef MSGLEN
|
||||
}
|
||||
|
||||
int vo_wm_detect( void )
|
||||
{
|
||||
Atom type;
|
||||
Window win;
|
||||
XEvent xev;
|
||||
int c = 0;
|
||||
int wm = vo_wm_Unknown;
|
||||
int format;
|
||||
unsigned long nitems, bytesafter;
|
||||
unsigned char * args = NULL;
|
||||
#if 1
|
||||
// --- netwm
|
||||
type=XInternAtom( mDisplay,"_NET_SUPPORTED",False );
|
||||
if ( Success == XGetWindowProperty( mDisplay,mRootWin,type,0,65536 / sizeof( long ),False,AnyPropertyType,&type,&format,&nitems,&bytesafter,&args ) && nitems > 0 )
|
||||
{
|
||||
mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Detected wm is NetWM.\n" );
|
||||
XFree( args );
|
||||
return vo_wm_NetWM;
|
||||
}
|
||||
#endif
|
||||
// --- other wm
|
||||
mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Create window for WM detect ...\n" );
|
||||
win=XCreateSimpleWindow( mDisplay,mRootWin,vo_screenwidth,vo_screenheight,1,1,0,0,0 );
|
||||
XSelectInput( mDisplay,win,PropertyChangeMask | StructureNotifyMask );
|
||||
XMapWindow( mDisplay,win );
|
||||
XMoveWindow( mDisplay,win,vo_screenwidth,vo_screenheight );
|
||||
do
|
||||
{
|
||||
XCheckWindowEvent( mDisplay,win,PropertyChangeMask | StructureNotifyMask,&xev );
|
||||
|
||||
if ( xev.type == PropertyNotify )
|
||||
{
|
||||
char * name = XGetAtomName( mDisplay,xev.xproperty.atom );
|
||||
if ( !name ) break;
|
||||
|
||||
if ( !strncmp( name,"_ICEWM_TRAY",11 ) )
|
||||
{ mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Detected wm is IceWM.\n" ); wm=vo_wm_IceWM; break; }
|
||||
if ( !strncmp( name,"_KDE_",5 ) )
|
||||
{ mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Detected wm is KDE.\n" ); wm=vo_wm_KDE; break; }
|
||||
if ( !strncmp( name,"KWM_WIN_DESKTOP",15 ) )
|
||||
{ mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Detected wm is WindowMaker style.\n" ); wm=vo_wm_WMakerStyle; break; }
|
||||
// fprintf(stderr,"[ws] PropertyNotify ( 0x%x ) %s ( 0x%x )\n",win,name,xev.xproperty.atom );
|
||||
|
||||
XFree( name );
|
||||
}
|
||||
} while( c++ < 25 );
|
||||
XDestroyWindow( mDisplay,win );
|
||||
#ifdef MP_DEBUG
|
||||
if ( wm == vo_wm_Unknown ) mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Unknown wm type...\n" );
|
||||
#endif
|
||||
return wm;
|
||||
}
|
||||
|
||||
int vo_init( void )
|
||||
{
|
||||
// int mScreen;
|
||||
@ -297,19 +350,7 @@ int vo_init( void )
|
||||
depth, vo_depthonscreen,
|
||||
dispName,mLocalDisplay?"local":"remote");
|
||||
|
||||
{
|
||||
Atom type;
|
||||
int format;
|
||||
unsigned long nitems, bytesafter;
|
||||
unsigned char * args = NULL;
|
||||
type=XInternAtom( mDisplay,"_NET_SUPPORTED",False );
|
||||
if ( Success == XGetWindowProperty( mDisplay,mRootWin,type,0,65536 / sizeof( long ),False,AnyPropertyType,&type,&format,&nitems,&bytesafter,&args ) && nitems > 0 )
|
||||
{
|
||||
mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Detected wm is NetWM.\n" );
|
||||
XFree( args );
|
||||
vo_wm_type=vo_wm_NetWM;
|
||||
}
|
||||
}
|
||||
vo_wm_type=vo_wm_detect();
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -564,6 +605,7 @@ int vo_x11_check_events(Display *mydisplay){
|
||||
mplayer_put_key(MOUSE_BTN0+Event.xbutton.button-1);
|
||||
break;
|
||||
#endif
|
||||
#if 1
|
||||
case PropertyNotify:
|
||||
{
|
||||
char * name = XGetAtomName( mydisplay,Event.xproperty.atom );
|
||||
@ -590,9 +632,9 @@ int vo_x11_check_events(Display *mydisplay){
|
||||
XFree( name );
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -675,7 +717,11 @@ void vo_x11_fullscreen( void )
|
||||
|
||||
switch ( vo_wm_type )
|
||||
{
|
||||
// case vo_wm_WMakerStyle:
|
||||
// vo_x11_decoration( mDisplay,vo_window,(vo_fs) ? 1 : 0 );
|
||||
break;
|
||||
case vo_wm_Unknown:
|
||||
vo_x11_decoration( mDisplay,vo_window,(vo_fs) ? 1 : 0 );
|
||||
XUnmapWindow( mDisplay,vo_window );
|
||||
break;
|
||||
case vo_wm_IceWM:
|
||||
|
Loading…
Reference in New Issue
Block a user