diff options
author | pontscho <pontscho@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2001-05-08 12:17:03 +0000 |
---|---|---|
committer | pontscho <pontscho@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2001-05-08 12:17:03 +0000 |
commit | 8ffaf8a85e22704616b16e4c489fe8cb471fcf13 (patch) | |
tree | 19d25d4b6156ba0c3dacf9a2cadd95832ee77515 /libvo | |
parent | 1350b62e4a4241dc99465179333e1b830309f225 (diff) |
add gui support
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@724 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo')
-rw-r--r-- | libvo/vo_xmga.c | 121 | ||||
-rw-r--r-- | libvo/vo_xv.c | 92 | ||||
-rw-r--r-- | libvo/x11_common.c | 69 | ||||
-rw-r--r-- | libvo/x11_common.h | 11 |
4 files changed, 208 insertions, 85 deletions
diff --git a/libvo/vo_xmga.c b/libvo/vo_xmga.c index d3325ba989..a069b34dff 100644 --- a/libvo/vo_xmga.c +++ b/libvo/vo_xmga.c @@ -87,6 +87,10 @@ static Window mRoot; static uint32_t drwX,drwY,drwWidth,drwHeight,drwBorderWidth,drwDepth; static uint32_t drwcX,drwcY,dwidth,dheight,mFullscreen; +#ifdef HAVE_GUI + static uint32_t mdwidth,mdheight; +#endif + static XSetWindowAttributes xWAttribs; #include "mga_common.c" @@ -106,6 +110,20 @@ static void set_window(){ XTranslateCoordinates( mDisplay,mWindow,mRoot,0,0,&drwcX,&drwcY,&mRoot ); //fprintf( stderr,"[xmga] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); + #ifdef HAVE_GUI + if ( vo_window != None ) + { + mFullscreen=0; + dwidth=mdwidth; dheight=mdheight; + if ( ( drwWidth == vo_screenwidth )&&( drwHeight == vo_screenheight ) ) + { + mFullscreen=1; + dwidth=vo_screenwidth; + dheight=vo_screenwidth * mdheight / mdwidth; + } + } + #endif + if ( mFullscreen ) { drwX=( vo_screenwidth - (dwidth > vo_screenwidth?vo_screenwidth:dwidth) ) / 2; @@ -224,19 +242,11 @@ static uint32_t init( uint32_t width, uint32_t height, uint32_t d_width, uint32_ wndX=0; wndY=0; wndWidth=d_width; wndHeight=d_height; dwidth=d_width; dheight=d_height; + #ifdef HAVE_GUI + mdwidth=d_width; mdheight=d_height; + #endif mFullscreen=fullscreen; - if ( fullscreen ) - { - wndWidth=vo_screenwidth; - wndHeight=vo_screenheight; - } - - XGetWindowAttributes( mDisplay,DefaultRootWindow( mDisplay ),&attribs ); - mDepth=attribs.depth; - if ( mDepth != 15 && mDepth != 16 && mDepth != 24 && mDepth != 32 ) mDepth=24; - XMatchVisualInfo( mDisplay,mScreen,mDepth,TrueColor,&vinfo ); - xWAttribs.colormap=XCreateColormap( mDisplay,RootWindow( mDisplay,mScreen ),vinfo.visual,AllocNone ); switch ( vo_depthonscreen ) { case 32: @@ -245,34 +255,62 @@ static uint32_t init( uint32_t width, uint32_t height, uint32_t d_width, uint32_ case 15: fgColor=0x7c1fL; break; default: printf( "Sorry, this (%d) color depth not supported.\n",vo_depthonscreen ); return -1; } - xWAttribs.background_pixel=0; - xWAttribs.border_pixel=0; - xWAttribs.event_mask=StructureNotifyMask | ExposureMask | KeyPressMask; - xswamask=CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; - - mWindow=XCreateWindow( mDisplay,RootWindow( mDisplay,mScreen ), - wndX,wndY, - wndWidth,wndHeight, - xWAttribs.border_pixel, - mDepth, - InputOutput, - vinfo.visual,xswamask,&xWAttribs ); - vo_hidecursor(mDisplay,mWindow); - - if ( fullscreen ) vo_x11_decoration( mDisplay,mWindow,0 ); - - XGetNormalHints( mDisplay,mWindow,&hint ); - hint.x=wndX; hint.y=wndY; - hint.width=wndWidth; hint.height=wndHeight; - hint.base_width=wndWidth; hint.base_height=wndHeight; - hint.flags=USPosition | USSize; - XSetNormalHints( mDisplay,mWindow,&hint ); - XStoreName( mDisplay,mWindow,mTitle ); +#ifdef HAVE_GUI + if ( vo_window == None ) + { +#endif + if ( fullscreen ) + { + wndWidth=vo_screenwidth; + wndHeight=vo_screenheight; + } + + XGetWindowAttributes( mDisplay,DefaultRootWindow( mDisplay ),&attribs ); + mDepth=attribs.depth; + if ( mDepth != 15 && mDepth != 16 && mDepth != 24 && mDepth != 32 ) mDepth=24; + XMatchVisualInfo( mDisplay,mScreen,mDepth,TrueColor,&vinfo ); + xWAttribs.colormap=XCreateColormap( mDisplay,RootWindow( mDisplay,mScreen ),vinfo.visual,AllocNone ); + xWAttribs.background_pixel=0; + xWAttribs.border_pixel=0; + xWAttribs.event_mask=StructureNotifyMask | ExposureMask | KeyPressMask; + xswamask=CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; + + mWindow=XCreateWindow( mDisplay,RootWindow( mDisplay,mScreen ), + wndX,wndY, + wndWidth,wndHeight, + xWAttribs.border_pixel, + mDepth, + InputOutput, + vinfo.visual,xswamask,&xWAttribs ); + vo_hidecursor(mDisplay,mWindow); + + if ( fullscreen ) vo_x11_decoration( mDisplay,mWindow,0 ); + + XGetNormalHints( mDisplay,mWindow,&hint ); + hint.x=wndX; hint.y=wndY; + hint.width=wndWidth; hint.height=wndHeight; + hint.base_width=wndWidth; hint.base_height=wndHeight; + hint.flags=USPosition | USSize; + XSetNormalHints( mDisplay,mWindow,&hint ); + XStoreName( mDisplay,mWindow,mTitle ); + XMapWindow( mDisplay,mWindow ); +#ifdef HAVE_GUI + } + else + { + mWindow=vo_window; + fprintf( stderr,"[xmga] width: %d height: %d d_width: %d d_height: %d\n",width,height,d_width,d_height ); + if ( vo_screenwidth != d_width ) + { + XMoveWindow( mDisplay,mWindow,( vo_screenwidth - d_width ) / 2,( vo_screenheight - d_height ) / 2 ); + XResizeWindow( mDisplay,mWindow,d_width,d_height ); + } + else mFullscreen=1; + } +#endif mGC=XCreateGC( mDisplay,mWindow,GCForeground,&wGCV ); - XMapWindow( mDisplay,mWindow ); - set_window(); mga_vid_config.src_width=width; @@ -285,8 +323,15 @@ static uint32_t init( uint32_t width, uint32_t height, uint32_t d_width, uint32_ if(mga_init()) return -1; - XFlush( mDisplay ); - XSync( mDisplay,False ); +#ifdef HAVE_GUI + if ( vo_window == None ) + { +#endif + XFlush( mDisplay ); + XSync( mDisplay,False ); +#ifdef HAVE_GUI + } +#endif saver_off(mDisplay); diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c index 2e013b8f5b..82d727cef5 100644 --- a/libvo/vo_xv.c +++ b/libvo/vo_xv.c @@ -85,6 +85,10 @@ static Window mRoot; static uint32_t drwX,drwY,drwWidth,drwHeight,drwBorderWidth,drwDepth; static uint32_t drwcX,drwcY,dwidth,dheight,mFullscreen; +#ifdef HAVE_GUI + static uint32_t mdwidth,mdheight; +#endif + /* * connect to server, create and map window, * allocate colors and (shared) memory @@ -121,36 +125,54 @@ static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t screen = DefaultScreen(mydisplay); - hint.x = 0; - hint.y = 0; - hint.width = d_width; - hint.height = d_height; - if ( fullscreen ) +#ifdef HAVE_GUI + if ( vo_window == None ) { - hint.width=vo_screenwidth; - hint.height=vo_screenheight; +#endif + hint.x = 0; + hint.y = 0; + hint.width = d_width; + hint.height = d_height; + if ( fullscreen ) + { + hint.width=vo_screenwidth; + hint.height=vo_screenheight; + } + hint.flags = PPosition | PSize; + XGetWindowAttributes(mydisplay, DefaultRootWindow(mydisplay), &attribs); + depth=attribs.depth; + if (depth != 15 && depth != 16 && depth != 24 && depth != 32) depth = 24; + XMatchVisualInfo(mydisplay, screen, depth, TrueColor, &vinfo); + + xswa.background_pixel = 0; + xswa.border_pixel = 0; + xswamask = CWBackPixel | CWBorderPixel; + + mywindow = XCreateWindow(mydisplay, RootWindow(mydisplay,screen), + hint.x, hint.y, hint.width, hint.height, + 0, depth,CopyFromParent,vinfo.visual,xswamask,&xswa); + vo_hidecursor(mydisplay,mywindow); + + XSelectInput(mydisplay, mywindow, StructureNotifyMask | KeyPressMask ); + XSetStandardProperties(mydisplay, mywindow, hello, hello, None, NULL, 0, &hint); + if ( fullscreen ) vo_x11_decoration( mydisplay,mywindow,0 ); + XMapWindow(mydisplay, mywindow); + XFlush(mydisplay); + XSync(mydisplay, False); +#ifdef HAVE_GUI } - hint.flags = PPosition | PSize; - XGetWindowAttributes(mydisplay, DefaultRootWindow(mydisplay), &attribs); - depth=attribs.depth; - if (depth != 15 && depth != 16 && depth != 24 && depth != 32) depth = 24; - XMatchVisualInfo(mydisplay, screen, depth, TrueColor, &vinfo); - - xswa.background_pixel = 0; - xswa.border_pixel = 0; - xswamask = CWBackPixel | CWBorderPixel; - - mywindow = XCreateWindow(mydisplay, RootWindow(mydisplay,screen), - hint.x, hint.y, hint.width, hint.height, - 0, depth,CopyFromParent,vinfo.visual,xswamask,&xswa); - vo_hidecursor(mydisplay,mywindow); - - XSelectInput(mydisplay, mywindow, StructureNotifyMask | KeyPressMask ); - XSetStandardProperties(mydisplay, mywindow, hello, hello, None, NULL, 0, &hint); - if ( fullscreen ) vo_x11_decoration( mydisplay,mywindow,0 ); - XMapWindow(mydisplay, mywindow); - XFlush(mydisplay); - XSync(mydisplay, False); + else + { + mywindow=vo_window; + mygc=vo_gc; + if ( vo_screenwidth != d_width ) + { + XMoveWindow( mydisplay,mywindow,( vo_screenwidth - d_width ) / 2,( vo_screenheight - d_height ) / 2 ); + XResizeWindow( mydisplay,mywindow,d_width,d_height ); + } + else mFullscreen=1; + } +#endif mygc = XCreateGC(mydisplay, mywindow, 0L, &xgcv); @@ -253,6 +275,20 @@ static void check_events(void) XTranslateCoordinates( mydisplay,mywindow,mRoot,0,0,&drwcX,&drwcY,&mRoot ); printf( "[xv] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); + #ifdef HAVE_GUI + if ( vo_window != None ) + { + mFullscreen=0; + dwidth=mdwidth; dheight=mdheight; + if ( ( drwWidth == vo_screenwidth )&&( drwHeight == vo_screenheight ) ) + { + mFullscreen=1; + dwidth=vo_screenwidth; + dheight=vo_screenwidth * mdheight / mdwidth; + } + } + #endif + if ( mFullscreen ) { drwX=( vo_screenwidth - (dwidth > vo_screenwidth?vo_screenwidth:dwidth) ) / 2; diff --git a/libvo/x11_common.c b/libvo/x11_common.c index afbfd4ad05..2a6e25f949 100644 --- a/libvo/x11_common.c +++ b/libvo/x11_common.c @@ -149,6 +149,17 @@ void vo_x11_decoration( Display * vo_Display,Window w,int d ) } } +#ifdef HAVE_GUI + Window vo_window = None; + GC vo_gc; + int vo_xeventhandling = 1; + int vo_resize = 0; + int vo_expose = 0; + + void vo_setwindow( Window w,GC g ) + { vo_window=w; vo_gc=g; } +#endif + int vo_x11_check_events(Display *mydisplay){ int ret=0; XEvent Event; @@ -157,26 +168,46 @@ int vo_x11_check_events(Display *mydisplay){ XComposeStatus stat; // unsigned long vo_KeyTable[512]; - while ( XPending( mydisplay ) ) - { - XNextEvent( mydisplay,&Event ); - switch( Event.type ) - { - case Expose: - ret|=VO_EVENT_EXPOSE; - break; - case ConfigureNotify: - vo_dwidth=Event.xconfigure.width; - vo_dheight=Event.xconfigure.height; - ret|=VO_EVENT_RESIZE; - break; - case KeyPress: - XLookupString( &Event.xkey,buf,sizeof(buf),&keySym,&stat ); - vo_x11_putkey( ( (keySym&0xff00) != 0?( (keySym&0x00ff) + 256 ):( keySym ) ) ); - ret|=VO_EVENT_KEYPRESS; - break; +#ifdef HAVE_GUI + if ( vo_xeventhandling ) + { +#endif + while ( XPending( mydisplay ) ) + { + XNextEvent( mydisplay,&Event ); + switch( Event.type ) + { + case Expose: + ret|=VO_EVENT_EXPOSE; + break; + case ConfigureNotify: + vo_dwidth=Event.xconfigure.width; + vo_dheight=Event.xconfigure.height; + ret|=VO_EVENT_RESIZE; + break; + case KeyPress: + XLookupString( &Event.xkey,buf,sizeof(buf),&keySym,&stat ); + vo_x11_putkey( ( (keySym&0xff00) != 0?( (keySym&0x00ff) + 256 ):( keySym ) ) ); + ret|=VO_EVENT_KEYPRESS; + break; + } + } +#ifdef HAVE_GUI } - } + else + { + if ( vo_resize ) + { + vo_resize=0; + ret|=VO_EVENT_RESIZE; + } + if ( vo_expose ) + { + vo_expose=0; + ret|=VO_EVENT_EXPOSE; + } + } +#endif return ret; } diff --git a/libvo/x11_common.h b/libvo/x11_common.h index 8dab26385f..47e2a39fab 100644 --- a/libvo/x11_common.h +++ b/libvo/x11_common.h @@ -13,5 +13,16 @@ void vo_x11_decoration( Display * vo_Display,Window w,int d ); int vo_x11_check_events(Display *mydisplay); #endif +#ifdef HAVE_GUI + extern Window vo_window; + extern Display * vo_display; + extern GC vo_gc; + extern int vo_xeventhandling; + extern int vo_expose; + extern int vo_resize; + + extern void vo_setwindow( Window w,GC g ); +#endif + void saver_off( Display * ); void saver_on( Display * ); |