From df141d9d82ee5fa2eba136703c1faab70d4d49f6 Mon Sep 17 00:00:00 2001 From: pontscho Date: Thu, 7 Mar 2002 17:50:25 +0000 Subject: [PATCH] rewrite fullscreen support in some libvo driver git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4982 b3059339-0415-0410-9bf9-f77b7e298cf2 --- Gui/mplayer/mw.h | 3 +-- Gui/mplayer/play.c | 41 ++++++++++++++++++++++++----------------- libvo/mga_common.c | 5 +++++ libvo/video_out.c | 7 +++++++ libvo/video_out.h | 6 ++++++ libvo/vo_xmga.c | 36 +++++++++++++++++------------------- libvo/vo_xv.c | 39 +++++++++++++++++++-------------------- libvo/vo_xvidix.c | 26 +++++++++++++------------- libvo/x11_common.c | 21 +++++++++++++++++++++ libvo/x11_common.h | 7 +++++++ mplayer.c | 2 +- mplayer.h | 1 + 12 files changed, 122 insertions(+), 72 deletions(-) diff --git a/Gui/mplayer/mw.h b/Gui/mplayer/mw.h index c4b5de0a1e..2f2388f567 100644 --- a/Gui/mplayer/mw.h +++ b/Gui/mplayer/mw.h @@ -374,7 +374,6 @@ NoPause: } break; case evFullScreen: - IZE("evFullS"); for ( j=0;j vo_screenwidth?vo_screenwidth:dwidth) ) / 2; @@ -262,7 +257,10 @@ static uint32_t config( uint32_t width, uint32_t height, uint32_t d_width, uint3 wndX=0; wndY=0; wndWidth=d_width; wndHeight=d_height; - mFullscreen=fullscreen&1; + vo_fs=fullscreen&1; + vo_dwidth=d_width; vo_dheight=d_height; + if ( vo_fs ) + { vo_old_width=d_width; vo_old_height=d_height; } switch ( vo_depthonscreen ) { @@ -279,7 +277,7 @@ static uint32_t config( uint32_t width, uint32_t height, uint32_t d_width, uint3 if ( vo_window == None ) { #endif - if ( mFullscreen ) + if ( vo_fs ) { wndWidth=vo_screenwidth; wndHeight=vo_screenheight; @@ -314,7 +312,7 @@ 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 ( mFullscreen ) vo_x11_decoration( mDisplay,vo_window,0 ); + if ( vo_fs ) vo_x11_decoration( mDisplay,vo_window,0 ); XGetNormalHints( mDisplay,vo_window,&hint ); hint.x=wndX; hint.y=wndY; diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c index da242c8b6e..d1f225ec23 100644 --- a/libvo/vo_xv.c +++ b/libvo/vo_xv.c @@ -92,7 +92,7 @@ static int flip_flag; static Window mRoot; static uint32_t drwX,drwY,drwWidth,drwHeight,drwBorderWidth,drwDepth; -static uint32_t drwcX,drwcY,dwidth,dheight,mFullscreen; +static uint32_t drwcX,drwcY,dwidth,dheight; #ifdef HAVE_NEW_GUI static uint32_t mdwidth,mdheight; @@ -342,7 +342,10 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32 mdheight=height; #endif - mFullscreen=flags&1; + vo_fs=flags&1; + if ( vo_fs ) + { vo_old_width=d_width; vo_old_height=d_height; } + #ifdef HAVE_XF86VM if( flags&0x02 ) vm = 1; #endif @@ -377,7 +380,7 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32 } else #endif - if ( mFullscreen ) + if ( vo_fs ) { hint.width=vo_screenwidth; hint.height=vo_screenheight; @@ -423,7 +426,7 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32 #endif ); XSetStandardProperties(mDisplay, vo_window, hello, hello, None, NULL, 0, &hint); - if ( mFullscreen ) vo_x11_decoration( mDisplay,vo_window,0 ); + if ( vo_fs ) vo_x11_decoration( mDisplay,vo_window,0 ); XMapWindow(mDisplay, vo_window); #ifdef HAVE_XINERAMA vo_x11_xinerama_move(mDisplay,vo_window); @@ -501,11 +504,9 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32 #ifdef HAVE_NEW_GUI if ( vo_window != None ) { - mFullscreen=0; dwidth=mdwidth; dheight=mdheight; - if ( ( vo_dwidth == vo_screenwidth )&&( vo_dheight == vo_screenheight ) ) + if ( vo_fs ) { - mFullscreen=1; dwidth=vo_screenwidth; dheight=vo_screenwidth * mdheight / mdwidth; } @@ -519,7 +520,7 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32 printf( "[xv] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); aspect(&dwidth,&dheight,A_NOZOOM); - if ( mFullscreen ) + if ( vo_fs ) { aspect(&dwidth,&dheight,A_ZOOM); drwX=( vo_screenwidth - (dwidth > vo_screenwidth?vo_screenwidth:dwidth) ) / 2; @@ -583,21 +584,16 @@ static void check_events(void) printf( "[xv] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); #ifdef HAVE_NEW_GUI - if ( vo_window != None ) + dwidth=mdwidth; dheight=mdheight; + if ( vo_fs ) { - mFullscreen=0; - dwidth=mdwidth; dheight=mdheight; - if ( ( vo_dwidth == vo_screenwidth )&&( vo_dheight == vo_screenheight ) ) - { - mFullscreen=1; - dwidth=vo_screenwidth; - dheight=vo_screenwidth * mdheight / mdwidth; - } + dwidth=vo_screenwidth; + dheight=vo_screenwidth * mdheight / mdwidth; } #endif aspect(&dwidth,&dheight,A_NOZOOM); - if ( mFullscreen ) + if ( vo_fs ) { aspect(&dwidth,&dheight,A_ZOOM); drwX=( vo_screenwidth - (dwidth > vo_screenwidth?vo_screenwidth:dwidth) ) / 2; @@ -612,7 +608,7 @@ static void check_events(void) if ( e & VO_EVENT_EXPOSE ) { XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc, xvimage[current_buf], 0, 0, image_width, image_height, drwX, drwY, 1, 1, False); - XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc, xvimage[current_buf], 0, 0, image_width, image_height, drwX,drwY,drwWidth,(mFullscreen?drwHeight - 1:drwHeight), False); + XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc, xvimage[current_buf], 0, 0, image_width, image_height, drwX,drwY,drwWidth,(vo_fs?drwHeight - 1:drwHeight), False); } } @@ -623,7 +619,7 @@ static void flip_page(void) { XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc, xvimage[current_buf], 0, 0, image_width, image_height, - drwX,drwY,drwWidth,(mFullscreen?drwHeight - 1:drwHeight), + drwX,drwY,drwWidth,(vo_fs?drwHeight - 1:drwHeight), False); if (num_buffers>1){ current_buf=(current_buf+1)%num_buffers; @@ -824,6 +820,9 @@ static uint32_t control(uint32_t request, void *data, ...) return query_format(*((uint32_t*)data)); case VOCTRL_GET_IMAGE: return get_image(data); + case VOCTRL_FULLSCREEN: + vo_x11_fullscreen(); + return VO_TRUE; } return VO_NOTIMPL; } diff --git a/libvo/vo_xvidix.c b/libvo/vo_xvidix.c index 31def1bd42..085a5dbc93 100644 --- a/libvo/vo_xvidix.c +++ b/libvo/vo_xvidix.c @@ -70,26 +70,21 @@ 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, mFullscreen; + drwDepth, drwcX, drwcY, dwidth, dheight; static void set_window(int force_update,const vo_tune_info_t *info) { #ifdef HAVE_NEW_GUI - if (vo_window != None) - { - if ((vo_dwidth == vo_screenwidth) && (vo_dheight == vo_screenheight)) + if (vo_fs) { - mFullscreen = 1; dwidth = vo_screenwidth; dheight = vo_screenwidth * vo_dheight / vo_dwidth; } else { - mFullscreen = 0; dwidth = vo_dwidth; dheight = vo_dheight; } - } #endif XGetGeometry(mDisplay, vo_window, &mRoot, &drwX, &drwY, &drwWidth, @@ -98,14 +93,14 @@ static void set_window(int force_update,const vo_tune_info_t *info) XTranslateCoordinates(mDisplay, vo_window, mRoot, 0, 0, &drwcX, &drwcY, &mRoot); - if (!mFullscreen) + if (!vo_fs) mp_msg(MSGT_VO, MSGL_V, "[xvidix] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n", drwcX, drwcY, drwX, drwY, drwWidth, drwHeight); /* following stuff copied from vo_xmga.c */ aspect(&dwidth, &dheight, A_NOZOOM); #if X11_FULLSCREEN - if (mFullscreen) + if (vo_fs) { aspect(&dwidth, &dheight, A_ZOOM); drwX = (vo_screenwidth - (dwidth > vo_screenwidth ? vo_screenwidth : dwidth)) / 2; @@ -175,7 +170,7 @@ static void set_window(int force_update,const vo_tune_info_t *info) XClearWindow( mDisplay,vo_window ); XSetForeground(mDisplay, vo_gc, fgColor); XFillRectangle(mDisplay, vo_window, vo_gc, drwX, drwY, drwWidth, - (mFullscreen ? drwHeight - 1 : drwHeight)); + (vo_fs ? drwHeight - 1 : drwHeight)); /* flush, update drawable */ XFlush(mDisplay); @@ -245,7 +240,9 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, window_width = d_width; window_height = d_height; - mFullscreen = flags&0x01; + vo_fs = flags&0x01; + if (vo_fs) + { vo_old_width=d_width; vo_old_height=d_height; } X_already_started++; @@ -275,7 +272,7 @@ if (vo_window == None) #endif #ifdef X11_FULLSCREEN - if (mFullscreen) /* fullscreen */ + if (vo_fs) /* fullscreen */ { if (flags & 0x04) { @@ -321,7 +318,7 @@ if (vo_window == None) vo_hidecursor(mDisplay, vo_window); #ifdef X11_FULLSCREEN - if (mFullscreen) /* fullscreen */ + if (vo_fs) /* fullscreen */ vo_x11_decoration(mDisplay, vo_window, 0); #endif @@ -456,6 +453,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; } diff --git a/libvo/x11_common.c b/libvo/x11_common.c index fc8909769a..537876f605 100644 --- a/libvo/x11_common.c +++ b/libvo/x11_common.c @@ -509,6 +509,27 @@ int vo_x11_check_events(Display *mydisplay){ return ret; } +void vo_x11_fullscreen( void ) +{ + XUnmapWindow( mDisplay,vo_window ); + if ( !vo_fs ) + { + vo_fs=VO_TRUE; + vo_old_x=vo_dx; vo_old_y=vo_dy; vo_old_width=vo_dwidth; vo_old_height=vo_dheight; + vo_dx=0; vo_dy=0; vo_dwidth=vo_screenwidth; vo_dheight=vo_screenheight; + vo_x11_decoration( mDisplay,vo_window,0 ); + } + else + { + vo_fs=VO_FALSE; + vo_dx=vo_old_x; vo_dy=vo_old_y; vo_dwidth=vo_old_width; vo_dheight=vo_old_height; + vo_x11_decoration( mDisplay,vo_window,1 ); + } + XMapWindow( mDisplay,vo_window ); + XMoveResizeWindow( mDisplay,vo_window,vo_dx,vo_dy,vo_dwidth,vo_dheight ); + return; +} + void saver_on(Display *mDisplay) { #ifdef HAVE_XDPMS diff --git a/libvo/x11_common.h b/libvo/x11_common.h index 102d4fb073..262bf3d6c6 100644 --- a/libvo/x11_common.h +++ b/libvo/x11_common.h @@ -1,4 +1,7 @@ +#ifndef X11_COMMON_H +#define X11_COMMON_H + #ifdef X11_FULLSCREEN extern int vo_depthonscreen; @@ -6,6 +9,7 @@ extern int vo_screenwidth; extern int vo_screenheight; extern int vo_dwidth; extern int vo_dheight; +extern int vo_fs; extern char *mDisplayName; extern Display *mDisplay; @@ -19,6 +23,7 @@ int vo_hidecursor ( Display* , Window ); void vo_x11_decoration( Display * vo_Display,Window w,int d ); void vo_x11_classhint( Display * display,Window window,char *name ); int vo_x11_check_events(Display *mydisplay); +void vo_x11_fullscreen( void ); #endif extern Window vo_window; @@ -43,3 +48,5 @@ void vo_x11_xinerama_move(Display *dsp, Window w); void vo_vm_switch(uint32_t, uint32_t, int*, int*); void vo_vm_close(Display*); #endif + +#endif diff --git a/mplayer.c b/mplayer.c index 85ff707b68..4804733417 100644 --- a/mplayer.c +++ b/mplayer.c @@ -261,7 +261,7 @@ static uint32_t our_n_frames=0; // screen info: char* video_driver=NULL; //"mga"; // default char* audio_driver=NULL; -static int fullscreen=0; +int fullscreen=0; static int vidmode=0; int softzoom=0; static int flip=-1; diff --git a/mplayer.h b/mplayer.h index 800cc0d415..76cfaa1af6 100644 --- a/mplayer.h +++ b/mplayer.h @@ -4,5 +4,6 @@ extern int use_gui; extern char* current_module; +extern int fullscreen; #endif \ No newline at end of file