summaryrefslogtreecommitdiffstats
path: root/Gui
diff options
context:
space:
mode:
authorpontscho <pontscho@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-05-06 15:05:07 +0000
committerpontscho <pontscho@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-05-06 15:05:07 +0000
commit92009fc2f5949a72452bb60b837ac436f924b6c1 (patch)
treeeb6d1b24b9f93d41d719de0c03f96540b5323bf6 /Gui
parent40c0d051f37881afe594099deb15d9538b6bec4c (diff)
downloadmpv-92009fc2f5949a72452bb60b837ac436f924b6c1.tar.bz2
mpv-92009fc2f5949a72452bb60b837ac436f924b6c1.tar.xz
add WM detection, and wm specific fullscreen code. (???)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@5998 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'Gui')
-rw-r--r--Gui/interface.c2
-rw-r--r--Gui/mplayer/play.c21
-rw-r--r--Gui/mplayer/sw.h36
-rw-r--r--Gui/mplayer/widgets.c16
-rw-r--r--Gui/wm/ws.c196
-rw-r--r--Gui/wm/ws.h13
6 files changed, 230 insertions, 54 deletions
diff --git a/Gui/interface.c b/Gui/interface.c
index 60cd8cd5e1..c425664940 100644
--- a/Gui/interface.c
+++ b/Gui/interface.c
@@ -104,7 +104,7 @@ void guiGetEvent( int type,char * arg )
wsMoveWindow( &appMPlayer.subWindow,True,appMPlayer.sub.x,appMPlayer.sub.y );
}
guiIntfStruct.MovieWidth=vo_dwidth;
- guiIntfStruct.MovieHeight=vo_dwidth;
+ guiIntfStruct.MovieHeight=vo_dheight;
}
break;
#ifdef USE_DVDREAD
diff --git a/Gui/mplayer/play.c b/Gui/mplayer/play.c
index 402ca81021..ec7791cc38 100644
--- a/Gui/mplayer/play.c
+++ b/Gui/mplayer/play.c
@@ -54,9 +54,26 @@ void mplFullScreen( void )
wsVisibleWindow( &appMPlayer.subWindow,wsShowWindow );
}// else { vo_x11_fullscreen(); appMPlayer.subWindow.isFullScreen=vo_fs; }
#else
+ if ( ( guiIntfStruct.Playing )&&( appMPlayer.subWindow.isFullScreen ) )
+ {
+ appMPlayer.subWindow.OldWidth=guiIntfStruct.MovieWidth; appMPlayer.subWindow.OldHeight=guiIntfStruct.MovieHeight;
+ switch ( appMPlayer.sub.x )
+ {
+ case -1: appMPlayer.subWindow.OldX=( wsMaxX / 2 ) - ( appMPlayer.subWindow.OldWidth / 2 ); break;
+ case -2: appMPlayer.subWindow.OldX=wsMaxX - appMPlayer.subWindow.OldWidth; break;
+ default: appMPlayer.subWindow.OldX=appMPlayer.sub.x; break;
+ }
+ switch ( appMPlayer.sub.y )
+ {
+ case -1: appMPlayer.subWindow.OldY=( wsMaxY / 2 ) - ( appMPlayer.subWindow.OldHeight / 2 ); break;
+ case -2: appMPlayer.subWindow.OldY=wsMaxY - appMPlayer.subWindow.OldHeight; break;
+ default: appMPlayer.subWindow.OldY=appMPlayer.sub.y; break;
+ }
+ }
wsFullScreen( &appMPlayer.subWindow );
- vo_fs=0;
- if ( appMPlayer.subWindow.isFullScreen ) vo_fs=1;
+ vo_fs=appMPlayer.subWindow.isFullScreen;
+ wsSetLayer( wsDisplay,appMPlayer.mainWindow.WindowID,appMPlayer.subWindow.isFullScreen );
+ wsSetLayer( wsDisplay,appMPlayer.menuWindow.WindowID,appMPlayer.subWindow.isFullScreen );
#endif
fullscreen=appMPlayer.subWindow.isFullScreen;
diff --git a/Gui/mplayer/sw.h b/Gui/mplayer/sw.h
index fd780cec9e..256ac50fc7 100644
--- a/Gui/mplayer/sw.h
+++ b/Gui/mplayer/sw.h
@@ -44,13 +44,6 @@ void mplSubMouseHandle( int Button,int X,int Y,int RX,int RY )
break;
// ---
case wsPLMouseButton:
- if ( appMPlayer.subWindow.isFullScreen )
- {
- if( ++SubVisible%2 ) wsMoveTopWindow( &appMPlayer.mainWindow );
- else wsMoveTopWindow( &appMPlayer.subWindow );
- mplSubMoved=1;
- break;
- }
gtkShow( evHidePopUpMenu,NULL );
sx=X; sy=Y;
msButton=wsPLMouseButton;
@@ -69,32 +62,11 @@ void mplSubMouseHandle( int Button,int X,int Y,int RX,int RY )
}
break;
case wsRLMouseButton:
- if ( !mplSubMoved )
+ if ( ( !mplSubMoved )&&( appMPlayer.subWindow.isFullScreen ) )
{
-#if 0
- if( SubVisible++%2 )
- {
- wsMoveTopWindow( &appMPlayer.mainWindow );
- fprintf( stderr,"[sw] MAIN TOP\n" );
- }
- else
- {
- wsMoveTopWindow( &appMPlayer.subWindow );
- fprintf( stderr,"[sw] SUB TOP\n" );
- }
-#else
- if ( appMPlayer.subWindow.Focused == 2 )
- {
- wsMoveTopWindow( &appMPlayer.mainWindow );
- fprintf( stderr,"[sw] MAIN TOP\n" );
- }
- else
- {
- wsMoveTopWindow( &appMPlayer.subWindow );
- fprintf( stderr,"[sw] SUB TOP\n" );
- }
-#endif
- }
+ if( SubVisible++%2 ) wsMoveTopWindow( &appMPlayer.mainWindow );
+ else wsMoveTopWindow( &appMPlayer.subWindow );
+ }
msButton=0;
mplSubMoved=0;
break;
diff --git a/Gui/mplayer/widgets.c b/Gui/mplayer/widgets.c
index ce7bd7fbf4..c5bf2c5a5c 100644
--- a/Gui/mplayer/widgets.c
+++ b/Gui/mplayer/widgets.c
@@ -18,6 +18,7 @@
#include "./mplayer.h"
#include "../events.h"
+#include "../app.h"
#include "gtk/menu.h"
#include "play.h"
@@ -128,6 +129,12 @@ void gtkMessageBox( int type,gchar * str )
gtk_widget_show( MessageBox );
}
+void gtkSetLayer( GtkWidget * wdg )
+{
+ GdkWindowPrivate * win = wdg->window;
+ wsSetLayer( gdk_display,win->xwindow,appMPlayer.subWindow.isFullScreen );
+}
+
void gtkShow( int type,char * param )
{
switch( type )
@@ -140,27 +147,34 @@ void gtkShow( int type,char * param )
gtkSetDefaultToCList( SkinList,param );
gtk_widget_show( SkinBrowser );
}
+ gtkSetLayer( SkinBrowser );
break;
case evPreferences:
gtk_widget_hide( Options );
gtk_widget_show( Options );
+ gtkSetLayer( Options );
break;
case evPlayList:
gtk_widget_hide( PlayList );
gtk_widget_show( PlayList );
+ gtkSetLayer( PlayList );
break;
case evLoad:
ShowFileSelect( fsVideoSelector );
+ gtkSetLayer( FileSelect );
break;
case evFirstLoad:
ShowFileSelect( fsVideoSelector );
+ gtkSetLayer( FileSelect );
break;
case evLoadSubtitle:
ShowFileSelect( fsSubtitleSelector );
+ gtkSetLayer( FileSelect );
break;
case evAbout:
gtk_widget_hide( AboutBox );
gtk_widget_show( AboutBox );
+ gtkSetLayer( AboutBox );
break;
case evShowPopUpMenu:
gtkPopupMenu=evNone;
@@ -174,3 +188,5 @@ void gtkShow( int type,char * param )
break;
}
}
+
+
diff --git a/Gui/wm/ws.c b/Gui/wm/ws.c
index b5b3b631b7..ceb98bdf3c 100644
--- a/Gui/wm/ws.c
+++ b/Gui/wm/ws.c
@@ -23,6 +23,7 @@
#include "wsconv.h"
#include "../../postproc/rgb2rgb.h"
#include "../../mp_msg.h"
+#include "../../mplayer.h"
#include <X11/extensions/XShm.h>
#ifdef HAVE_XSHAPE
@@ -51,11 +52,11 @@ int wsScreen;
Window wsRootWin;
XEvent wsEvent;
int wsWindowDepth;
-int wsWMType = 1;
-int wsIsKDE = 0;
+int wsWMType = wsWMUnknown;
GC wsHGC;
MotifWmHints wsMotifWmHints;
Atom wsTextProperlyAtom = None;
+int wsLayer = 0;
int wsDepthOnScreen = 0;
int wsRedMask = 0;
@@ -138,9 +139,59 @@ int wsErrorHandler( Display * dpy,XErrorEvent * Event )
fprintf(stderr,"[ws] Error code: %d ( %s )\n",Event->error_code,type );
fprintf(stderr,"[ws] Request code: %d\n",Event->request_code );
fprintf(stderr,"[ws] Minor code: %d\n",Event->minor_code );
+ fprintf(stderr,"[ws] Modules: %s\n",current_module );
exit( 0 );
}
+int wsWindowManagerType( void )
+{
+ Atom type;
+ int format;
+ 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;
+// }
+
+// --- 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;
+// }
+
+// --- 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" );
+ XFree( args );
+ return wsWMNetWM;
+ }
+
+ mp_dbg( MSGT_GPLAYER,MSGL_STATUS,"Unknow\n" );
+ return wsWMUnknown;
+}
+
void wsXInit( void* mDisplay )
{
int eventbase;
@@ -192,6 +243,8 @@ if(mDisplay){
wsMaxX=DisplayWidth( wsDisplay,wsScreen );
wsMaxY=DisplayHeight( wsDisplay,wsScreen );
+ wsWMType=wsWindowManagerType();
+
wsGetDepthOnScreen();
#ifdef DEBUG
{
@@ -253,6 +306,7 @@ if(mDisplay){
wsConvFunc=BGR8880_to_BGR555_c;
break;
}
+ XSetErrorHandler( wsErrorHandler );
}
// ----------------------------------------------------------------------------------------------
@@ -356,7 +410,7 @@ void wsCreateWindow( wsTWindow * win,int X,int Y,int wX,int hY,int bW,int cV,uns
wsClassHint.res_class="MPlayer";
XSetClassHint( wsDisplay,win->WindowID,&wsClassHint );
- win->SizeHint.flags=PPosition | PSize | PResizeInc | PWinGravity | PBaseSize;
+ win->SizeHint.flags=PPosition | PSize | PResizeInc | PWinGravity;// | PBaseSize;
win->SizeHint.x=win->X;
win->SizeHint.y=win->Y;
win->SizeHint.width=win->Width;
@@ -571,16 +625,25 @@ buttonreleased:
char * name = XGetAtomName( wsDisplay,Event->xproperty.atom );
if ( !name ) break;
- if ( !strncmp( name,"_ICEWM_TRAY",11 ) ||
- !strncmp( name,"_KDE_",5 ) ||
- !strncmp( name,"KWM_WIN_DESKTOP",15 ) ) wsWMType=0;
+ if ( !strncmp( name,"_ICEWM_TRAY",11 ) )
+ {
+ wsWMType=wsWMIceWM;
+ mp_dbg( MSGT_GPLAYER,MSGL_STATUS,"[ws] Detected wm is IceWM.\n" );
+ }
+ if ( !strncmp( name,"_KDE_",5 ) )
+ {
+ mp_dbg( MSGT_GPLAYER,MSGL_STATUS,"[ws] Detected wm is KDE.\n" );
+ wsWMType=wsWMKDE;
+ }
+ if ( !strncmp( name,"KWM_WIN_DESKTOP",15 ) )
+ {
+ mp_dbg( MSGT_GPLAYER,MSGL_STATUS,"[ws] Detected wm is WindowMaker style.\n" );
+ wsWMType=wsWMWMaker;
+ }
- if ( !strncmp( name,"_KDE_",5 ) ) wsIsKDE=1;
-
// fprintf(stderr,"[ws] PropertyNotify %s ( 0x%x )\n",name,Event->xproperty.atom );
XFree( name );
- break;
}
break;
@@ -639,12 +702,82 @@ while(wsTrue){
}
// ----------------------------------------------------------------------------------------------
+// Move window to selected layer
+// ----------------------------------------------------------------------------------------------
+
+#define WIN_LAYER_ONBOTTOM 2
+#define WIN_LAYER_NORMAL 4
+#define WIN_LAYER_ONTOP 6
+
+void wsSetLayer( Display * wsDisplay, Window win, int layer )
+{
+ Atom type;
+ int format;
+ unsigned long nitems, bytesafter;
+ unsigned char * args = NULL;
+
+ 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 )
+ {
+ XEvent e;
+ e.xclient.type=ClientMessage;
+ e.xclient.message_type=XInternAtom( wsDisplay,"_NET_WM_STATE",False );
+ e.xclient.display=wsDisplay;
+ e.xclient.window=win;
+ e.xclient.format=32;
+ e.xclient.data.l[0]=layer;
+ e.xclient.data.l[1]=XInternAtom( wsDisplay,"_NET_WM_STATE_STAYS_ON_TOP",False );
+ e.xclient.data.l[2]=0l;
+ e.xclient.data.l[3]=0l;
+ e.xclient.data.l[4]=0l;
+ XSendEvent( wsDisplay,wsRootWin,False,SubstructureRedirectMask,&e );
+
+ XFree( args );
+ return;
+ }
+ 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 )
+ {
+ XClientMessageEvent xev;
+
+ memset( &xev,0,sizeof( xev ) );
+ xev.type=ClientMessage;
+ xev.window=win;
+ xev.message_type=XInternAtom( wsDisplay,"_WIN_LAYER",False );
+ xev.format=32;
+ switch ( layer )
+ {
+ case -1: xev.data.l[0] = WIN_LAYER_ONBOTTOM; break;
+ case 0: xev.data.l[0] = WIN_LAYER_NORMAL; break;
+ case 1: xev.data.l[0] = WIN_LAYER_ONTOP; break;
+ }
+ XSendEvent( wsDisplay,wsRootWin,False,SubstructureNotifyMask,(XEvent*)&xev );
+ if ( layer ) XRaiseWindow( wsDisplay,win );
+
+ XFree( args );
+ return;
+ }
+}
+
+// ----------------------------------------------------------------------------------------------
// Switch to fullscreen.
// ----------------------------------------------------------------------------------------------
void wsFullScreen( wsTWindow * win )
{
int decoration = 0;
- if ( wsWMType ) XUnmapWindow( wsDisplay,win->WindowID );
+
+ if ( wsWMType == wsWMUnknown ) XUnmapWindow( wsDisplay,win->WindowID );
+
+ switch ( wsWMType )
+ {
+ case wsWMUnknown:
+ XUnmapWindow( wsDisplay,win->WindowID );
+ break;
+ case wsWMIceWM:
+ if ( !win->isFullScreen ) XUnmapWindow( wsDisplay,win->WindowID );
+ break;
+ }
+
if ( win->isFullScreen )
{
win->X=win->OldX;
@@ -665,10 +798,11 @@ void wsFullScreen( wsTWindow * win )
wsScreenSaverOff( wsDisplay );
}
- win->SizeHint.flags=PPosition | PSize | PWinGravity | PBaseSize;
+ win->SizeHint.flags=PPosition | PSize | PWinGravity;// | PBaseSize;
win->SizeHint.x=win->X; win->SizeHint.y=win->Y;
win->SizeHint.width=win->Width; win->SizeHint.height=win->Height;
win->SizeHint.base_width=win->Width; win->SizeHint.base_height=win->Height;
+
win->SizeHint.win_gravity=StaticGravity;
if ( win->Property & wsMaxSize )
{
@@ -684,6 +818,7 @@ void wsFullScreen( wsTWindow * win )
}
XSetWMNormalHints( wsDisplay,win->WindowID,&win->SizeHint );
+ wsSetLayer( wsDisplay,win->WindowID,win->isFullScreen );
XMoveResizeWindow( wsDisplay,win->WindowID,win->X,win->Y,win->Width,win->Height );
wsWindowDecoration( win,decoration );
XMapRaised( wsDisplay,win->WindowID );
@@ -772,12 +907,12 @@ void wsResizeWindow( wsTWindow * win,int sx, int sy )
win->Width=sx;
win->Height=sy;
- win->SizeHint.flags=PPosition | PSize | PWinGravity | PBaseSize;
+ win->SizeHint.flags=PPosition | PSize | PWinGravity;// | PBaseSize;
win->SizeHint.x=win->X;
win->SizeHint.y=win->Y;
win->SizeHint.width=win->Width;
win->SizeHint.height=win->Height;
-/*
+
if ( win->Property & wsMinSize )
{
win->SizeHint.flags|=PMinSize;
@@ -790,10 +925,12 @@ void wsResizeWindow( wsTWindow * win,int sx, int sy )
win->SizeHint.max_width=win->Width;
win->SizeHint.max_height=win->Height;
}
-*/
+
win->SizeHint.win_gravity=StaticGravity;
win->SizeHint.base_width=sx; win->SizeHint.base_height=sy;
- if ( !wsIsKDE ) XUnmapWindow( wsDisplay,win->WindowID );
+
+ if ( wsWMType == wsWMUnknown ) XUnmapWindow( wsDisplay,win->WindowID );
+
XSetWMNormalHints( wsDisplay,win->WindowID,&win->SizeHint );
XResizeWindow( wsDisplay,win->WindowID,sx,sy );
XMapRaised( wsDisplay,win->WindowID );
@@ -811,9 +948,30 @@ void wsIconify( wsTWindow win )
// ----------------------------------------------------------------------------------------------
void wsMoveTopWindow( wsTWindow * win )
{
- if ( wsIsKDE ) return;
- XMapRaised( wsDisplay,win->WindowID );
- XRaiseWindow( wsDisplay,win->WindowID );
+ if ( wsWMType == wsWMIceWM )
+ {
+ XUnmapWindow( wsDisplay,win->WindowID );
+ XMapWindow( wsDisplay,win->WindowID );
+ return;
+ }
+/*
+ if ( XInternAtom( wsDisplay,"_NET_ACTIVE_WINDOW",False ) != None )
+ {
+ XEvent e;
+
+ e.xclient.type=ClientMessage;
+ e.xclient.message_type=XInternAtom( wsDisplay,"_NET_ACTIVE_WINDOW",False );
+ e.xclient.display=wsDisplay;
+ e.xclient.window=win->WindowID;
+ e.xclient.format=32;
+ e.xclient.data.l[0]=0;
+ XSendEvent( wsDisplay,wsRootWin,False,SubstructureRedirectMask,&e );
+ }
+ else */
+ {
+ XMapRaised( wsDisplay,win->WindowID );
+ XRaiseWindow( wsDisplay,win->WindowID );
+ }
}
// ----------------------------------------------------------------------------------------------
@@ -929,7 +1087,7 @@ void wsVisibleWindow( wsTWindow * win,int show )
{
switch( show )
{
- case wsShowWindow: XMapWindow( wsDisplay,win->WindowID ); break;
+ case wsShowWindow: XMapRaised( wsDisplay,win->WindowID ); break;
case wsHideWindow: XUnmapWindow( wsDisplay,win->WindowID ); break;
}
XFlush( wsDisplay );
diff --git a/Gui/wm/ws.h b/Gui/wm/ws.h
index e35a5df8e6..aea0bc01d6 100644
--- a/Gui/wm/ws.h
+++ b/Gui/wm/ws.h
@@ -87,6 +87,15 @@
#define wsPVisible 5
#define wsRolled 6
+#define wsWMWMW 0
+#define wsWMUnknown 1
+#define wsWMNetWM 2
+#define wsWMKDE 3
+#define wsWMIceWM 4
+#define wsWMBlackBox 5
+#define wsWMGnome 6
+#define wsWMWMaker 7
+
#define wsParamDisplay Display *dpy,Window w
typedef void (*wsTReDraw)( wsParamDisplay );
@@ -167,9 +176,12 @@ typedef struct
extern int wsMaxX;
extern int wsMaxY;
+extern int wsWMType;
+
extern Display * wsDisplay;
extern int wsScreen;
extern Window wsRootWin;
+extern int wsLayer;
extern unsigned char * wsImageData;
@@ -219,6 +231,7 @@ extern void wsSetBackgroundRGB( wsTWindow * win,int r,int g,int b );
extern void wsSetTitle( wsTWindow * win,char * name );
extern void wsVisibleWindow( wsTWindow * win,int show );
extern void wsWindowDecoration( wsTWindow * win,long d );
+extern void wsSetLayer( Display * wsDisplay,Window win, int layer );
extern void wsFullScreen( wsTWindow * win );
extern void wsPostRedisplay( wsTWindow * win );
extern void wsSetShape( wsTWindow * win,char * data );