changeset 6095:891cff8aba60

some cleanup, gl/gl2 updated to use vo_window
author arpi
date Tue, 14 May 2002 23:44:35 +0000
parents 0f4dbbe57c08
children f38c7228a094
files libvo/vo_gl.c libvo/vo_gl2.c libvo/vo_x11.c libvo/vo_xmga.c libvo/vo_xv.c libvo/vo_xvidix.c libvo/x11_common.c libvo/x11_common.h
diffstat 8 files changed, 72 insertions(+), 76 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/vo_gl.c	Tue May 14 22:33:30 2002 +0000
+++ b/libvo/vo_gl.c	Tue May 14 23:44:35 2002 +0000
@@ -52,13 +52,11 @@
 
 /* X11 related variables */
 //static Display *mydisplay;
-static Window mywindow;
+//static Window vo_window;
 //static GC mygc;
 //static XImage *myximage;
 //static int depth,mode;
 //static XWindowAttributes attribs;
-static int X_already_started = 0;
-
 //static int texture_id=1;
 
 static GLXContext wsGLXContext;
@@ -115,20 +113,17 @@
 	image_width = width;
 	image_format = format;
   
-	if (X_already_started) return -1;
 	if(!vo_init()) return -1;
 
 	aspect_save_orig(width,height);
 	aspect_save_prescale(d_width,d_height);
 	aspect_save_screenres(vo_screenwidth,vo_screenheight);
 
-	X_already_started++;
-
 	aspect(&d_width,&d_height,A_NOZOOM);
 #ifdef X11_FULLSCREEN
-        if( flags&0x01 ){ // (-fs)
-          aspect(&d_width,&d_height,A_ZOOM);
-        }
+//        if( flags&0x01 ){ // (-fs)
+//          aspect(&d_width,&d_height,A_ZOOM);
+//        }
 #endif
 	hint.x = 0;
 	hint.y = 0;
@@ -160,30 +155,31 @@
 	xswamask = CWBackPixel | CWBorderPixel | CWColormap;
 //  xswamask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWCursor | CWOverrideRedirect | CWSaveUnder | CWX | CWY | CWWidth | CWHeight;
 
-  mywindow = XCreateWindow(mDisplay, RootWindow(mDisplay,mScreen),
+  vo_window = XCreateWindow(mDisplay, mRootWin,
     hint.x, hint.y, hint.width, hint.height, 4, vinfo->depth,CopyFromParent,vinfo->visual,xswamask,&xswa);
 
-  vo_x11_classhint( mDisplay,mywindow,"gl" );
-  vo_hidecursor(mDisplay,mywindow);
+  vo_x11_classhint( mDisplay,vo_window,"gl" );
+  vo_hidecursor(mDisplay,vo_window);
 
   wsGLXContext=glXCreateContext( mDisplay,vinfo,NULL,True );
 //  XStoreName( wsDisplay,wsMyWin,wsSysName );
 
 //  printf("GLXcontext ok\n");
 
-  if ( flags&0x01 ) vo_x11_decoration( mDisplay,mywindow,0 );
+//  if ( flags&0x01 ) vo_x11_decoration( mDisplay,vo_window,0 );
 
-	XSelectInput(mDisplay, mywindow, StructureNotifyMask);
+	XSelectInput(mDisplay, vo_window, StructureNotifyMask);
 
 	/* Tell other applications about this window */
 
-	XSetStandardProperties(mDisplay, mywindow, hello, hello, None, NULL, 0, &hint);
+	XSetStandardProperties(mDisplay, vo_window, hello, hello, None, NULL, 0, &hint);
 
 	/* Map window. */
 
-	XMapWindow(mDisplay, mywindow);
+	XMapWindow(mDisplay, vo_window);
+	if ( flags&1 ) vo_x11_fullscreen();
 #ifdef HAVE_XINERAMA
-	vo_x11_xinerama_move(mDisplay,mywindow);
+	vo_x11_xinerama_move(mDisplay,vo_window);
 #endif
 
 	/* Wait for map. */
@@ -191,24 +187,24 @@
 	{
 		XNextEvent(mDisplay, &xev);
 	}
-	while (xev.type != MapNotify || xev.xmap.event != mywindow);
+	while (xev.type != MapNotify || xev.xmap.event != vo_window);
 
-	XSelectInput(mDisplay, mywindow, NoEventMask);
+	XSelectInput(mDisplay, vo_window, NoEventMask);
 
-  glXMakeCurrent( mDisplay,mywindow,wsGLXContext );
+  glXMakeCurrent( mDisplay,vo_window,wsGLXContext );
 
 	XFlush(mDisplay);
 	XSync(mDisplay, False);
 
-//	mygc = XCreateGC(mDisplay, mywindow, 0L, &xgcv);
+//	mygc = XCreateGC(mDisplay, vo_window, 0L, &xgcv);
 
-//		myximage = XGetImage(mDisplay, mywindow, 0, 0,
+//		myximage = XGetImage(mDisplay, vo_window, 0, 0,
 //		width, image_height, AllPlanes, ZPixmap);
 //		ImageData = myximage->data;
 //	bpp = myximage->bits_per_pixel;
 
-	//XSelectInput(mDisplay, mywindow, StructureNotifyMask); // !!!!
-        XSelectInput(mDisplay, mywindow, StructureNotifyMask | KeyPressMask | PointerMotionMask
+	//XSelectInput(mDisplay, vo_window, StructureNotifyMask); // !!!!
+        XSelectInput(mDisplay, vo_window, StructureNotifyMask | KeyPressMask | PointerMotionMask
 #ifdef HAVE_NEW_INPUT
 		     | ButtonPressMask | ButtonReleaseMask
 #endif
@@ -325,8 +321,8 @@
 
 //  glFlush();
   glFinish();
-  glXSwapBuffers( mDisplay,mywindow );
-  
+  glXSwapBuffers( mDisplay,vo_window );
+ 
 }
 
 //static inline uint32_t draw_slice_x11(uint8_t *src[], uint32_t slice_num)
@@ -469,9 +465,9 @@
 static void
 uninit(void)
 {
+  if ( !vo_config_count ) return;
   saver_on(mDisplay); // screen saver back on
-
-  vo_x11_uninit(mDisplay, mywindow);
+  vo_x11_uninit();
 }
 
 static uint32_t preinit(const char *arg)
@@ -489,6 +485,9 @@
   switch (request) {
   case VOCTRL_QUERY_FORMAT:
     return query_format(*((uint32_t*)data));
+  case VOCTRL_FULLSCREEN:
+    vo_x11_fullscreen();
+    return VO_TRUE;
   }
   return VO_NOTIMPL;
 }
--- a/libvo/vo_gl2.c	Tue May 14 22:33:30 2002 +0000
+++ b/libvo/vo_gl2.c	Tue May 14 23:44:35 2002 +0000
@@ -56,8 +56,7 @@
 static unsigned char *ImageData=NULL;
 
 /* X11 related variables */
-static Window mywindow;
-static int X_already_started = 0;
+//static Window vo_window;
 
 //static int texture_id=1;
 
@@ -623,7 +622,6 @@
 	image_width = width;
 	image_format = format;
   
-	if (X_already_started) return -1;
 	if(!vo_init()) return -1;
 
 	aspect_save_orig(width,height);
@@ -632,8 +630,6 @@
 
 	aspect(&d_width,&d_height,A_NOZOOM);
 
-	X_already_started++;
-
         if( flags&0x01 )
         {
 	        isFullscreen = GL_TRUE;
@@ -673,46 +669,46 @@
 	xswa.colormap         = XCreateColormap(mDisplay, mRootWin, vinfo->visual, AllocNone);
 	xswamask = CWBackPixel | CWBorderPixel | CWColormap;
 
-  mywindow = XCreateWindow(mDisplay, RootWindow(mDisplay,mScreen),
+  vo_window = XCreateWindow(mDisplay, RootWindow(mDisplay,mScreen),
     hint.x, hint.y, hint.width, hint.height, 4, vinfo->depth,CopyFromParent,vinfo->visual,xswamask,&xswa);
 
-  vo_x11_classhint( mDisplay,mywindow,"gl2" );
-  vo_hidecursor(mDisplay,mywindow);
+  vo_x11_classhint( mDisplay,vo_window,"gl2" );
+  vo_hidecursor(mDisplay,vo_window);
 
   wsGLXContext=glXCreateContext( mDisplay,vinfo,NULL,True );
 
-  if ( flags&0x01 ) vo_x11_decoration( mDisplay,mywindow,0 );
+  if ( flags&0x01 ) vo_x11_decoration( mDisplay,vo_window,0 );
 
-	XSelectInput(mDisplay, mywindow, StructureNotifyMask);
+	XSelectInput(mDisplay, vo_window, StructureNotifyMask);
 
 	/* Tell other applications about this window */
 
-	XSetStandardProperties(mDisplay, mywindow, hello, hello, None, NULL, 0, &hint);
+	XSetStandardProperties(mDisplay, vo_window, hello, hello, None, NULL, 0, &hint);
 
 	/* Map window. */
 
-	XMapWindow(mDisplay, mywindow);
+	XMapWindow(mDisplay, vo_window);
 #ifdef HAVE_XINERAMA
-	vo_x11_xinerama_move(mDisplay,mywindow);
+	vo_x11_xinerama_move(mDisplay,vo_window);
 #endif
-        XClearWindow(mDisplay,mywindow);
+        XClearWindow(mDisplay,vo_window);
 
 	/* Wait for map. */
 	do 
 	{
 		XNextEvent(mDisplay, &xev);
 	}
-	while (xev.type != MapNotify || xev.xmap.event != mywindow);
+	while (xev.type != MapNotify || xev.xmap.event != vo_window);
 
-	XSelectInput(mDisplay, mywindow, NoEventMask);
+	XSelectInput(mDisplay, vo_window, NoEventMask);
 
-  glXMakeCurrent( mDisplay,mywindow,wsGLXContext );
+  glXMakeCurrent( mDisplay,vo_window,wsGLXContext );
 
 	XFlush(mDisplay);
 	XSync(mDisplay, False);
 
-	//XSelectInput(mDisplay, mywindow, StructureNotifyMask); // !!!!
-        XSelectInput(mDisplay, mywindow, StructureNotifyMask | KeyPressMask | PointerMotionMask
+	//XSelectInput(mDisplay, vo_window, StructureNotifyMask); // !!!!
+        XSelectInput(mDisplay, vo_window, StructureNotifyMask | KeyPressMask | PointerMotionMask
 #ifdef HAVE_NEW_INPUT
 		 | ButtonPressMask | ButtonReleaseMask
 #endif
@@ -1009,7 +1005,7 @@
 
 //  glFlush();
   glFinish();
-  glXSwapBuffers( mDisplay,mywindow );
+  glXSwapBuffers( mDisplay,vo_window );
   
   if(!used_info_done)
   {
@@ -1096,9 +1092,9 @@
 static void
 uninit(void)
 {
+  if ( !vo_config_count ) return;
   saver_on(mDisplay); // screen saver back on
-
-  vo_x11_uninit(mDisplay, mywindow);
+  vo_x11_uninit();
 }
 
 static uint32_t preinit(const char *arg)
--- a/libvo/vo_x11.c	Tue May 14 22:33:30 2002 +0000
+++ b/libvo/vo_x11.c	Tue May 14 23:44:35 2002 +0000
@@ -601,7 +601,7 @@
 #endif
 
  zoomFlag=0;
- vo_x11_uninit(mDisplay, vo_window);
+ vo_x11_uninit();
 
  freeSwsContext(swsContext);
 }
--- a/libvo/vo_xmga.c	Tue May 14 22:33:30 2002 +0000
+++ b/libvo/vo_xmga.c	Tue May 14 23:44:35 2002 +0000
@@ -77,8 +77,6 @@
 
 static uint32_t               mDepth, bpp, mode;
 static XWindowAttributes      attribs;
-static uint32_t               X_already_started=0;
-
 static uint32_t               fgColor;
 
 static uint32_t               mvHeight;
@@ -195,7 +193,6 @@
 
  unsigned long          xswamask;
 
- if ( X_already_started ) return -1;
  if (!vo_init()) return -1;
 
  width+=width&1;
@@ -337,7 +334,7 @@
  inited=0;
  mga_uninit();
  saver_on(mDisplay);
- vo_x11_uninit(mDisplay, vo_window);
+ vo_x11_uninit();
  printf("vo: uninit!\n");
 }
 
--- a/libvo/vo_xv.c	Tue May 14 22:33:30 2002 +0000
+++ b/libvo/vo_xv.c	Tue May 14 23:44:35 2002 +0000
@@ -794,7 +794,7 @@
 #ifdef HAVE_XF86VM
  vo_vm_close(mDisplay);
 #endif
- if(vo_config_count) vo_x11_uninit(mDisplay, vo_window);
+ if(vo_config_count) vo_x11_uninit();
 
 #else
 
@@ -804,7 +804,7 @@
 #ifdef HAVE_XF86VM
  vo_vm_close(mDisplay);
 #endif
- vo_x11_uninit(mDisplay, vo_window);
+ vo_x11_uninit();
 
 #endif
 }
--- a/libvo/vo_xvidix.c	Tue May 14 22:33:30 2002 +0000
+++ b/libvo/vo_xvidix.c	Tue May 14 23:44:35 2002 +0000
@@ -50,8 +50,6 @@
 #define UNUSED(x) ((void)(x)) /* Removes warning about unused arguments */
 
 /* X11 related variables */
-static int X_already_started = 0;
-
 /* Colorkey handling */
 static XGCValues mGCV;
 static uint32_t	fgColor;
@@ -72,12 +70,12 @@
 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;
 
 static void set_window(int force_update,const vo_tune_info_t *info)
 {
+    Window mRoot;
     if ( WinID )
      {
       XGetGeometry(mDisplay, vo_window, &mRoot, &drwX, &drwY, &drwWidth,
@@ -417,7 +415,7 @@
     vidix_term();
 
     saver_on(mDisplay); /* screen saver back on */
-    vo_x11_uninit(mDisplay, vo_window);
+    vo_x11_uninit();
 }
 
 static uint32_t preinit(const char *arg)
--- a/libvo/x11_common.c	Tue May 14 22:33:30 2002 +0000
+++ b/libvo/x11_common.c	Tue May 14 23:44:35 2002 +0000
@@ -171,7 +171,8 @@
 	    event->error_code, event->request_code, event->minor_code);
     }
     
-    exit_player("X11 error");
+    abort();
+    //exit_player("X11 error");
 #undef MSGLEN
 }
 
@@ -517,7 +518,7 @@
 }
 
 Window     vo_window = None;
-GC         vo_gc;
+GC         vo_gc = NULL;
 XSizeHints vo_hint;
 
 #ifdef HAVE_NEW_GUI
@@ -526,27 +527,29 @@
  }
 #endif
 
-int vo_x11_uninit(Display *display, Window window)
+void vo_x11_uninit()
 {
-    vo_showcursor( display,window );
+    if(vo_window!=None) vo_showcursor( mDisplay,vo_window );
 
 #ifdef HAVE_NEW_GUI
     /* destroy window only if it's not controlled by GUI */
     if ( !use_gui )
 #endif
     {
-	XSetBackground( mDisplay,vo_gc,0 );
-	XClearWindow( mDisplay,vo_window );
-  
-	/* and -wid is set */
-	if (WinID < 0)
-	 {
-	  XUnmapWindow( display,window );
-	  XDestroyWindow(display, window);
-	 }
+	if(vo_gc){
+	  XSetBackground( mDisplay,vo_gc,0 );
+	  vo_gc=NULL;
+	}
+	if(vo_window!=None){
+	  XClearWindow( mDisplay,vo_window );
+	  if (WinID < 0){
+	    XUnmapWindow( mDisplay,vo_window );
+	    XDestroyWindow(mDisplay, vo_window);
+	  }
+	  vo_window=None;
+	}
 	vo_fs=0;
     }
-    return(1);
 }
 
        int vo_mouse_timer_const = 30;
@@ -562,7 +565,7 @@
 // unsigned long  vo_KeyTable[512];
 
  if ( ( vo_mouse_autohide )&&( --vo_mouse_counter == 0 ) ) vo_hidecursor( mydisplay,vo_window );
- 
+
  while ( XPending( mydisplay ) )
   {
    XNextEvent( mydisplay,&Event );
@@ -573,6 +576,7 @@
       if ( vo_window != Event.xany.window ) continue;
      }
    #endif
+//       printf("\rEvent.type=%X  \n",Event.type);
     switch( Event.type )
      {
       case Expose:
--- a/libvo/x11_common.h	Tue May 14 22:33:30 2002 +0000
+++ b/libvo/x11_common.h	Tue May 14 23:44:35 2002 +0000
@@ -34,6 +34,8 @@
 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_fullscreen( void );
+extern void vo_x11_uninit();
+
 #endif
 
 extern Window     vo_window;