Commits

Ivan Vučica committed bdca917

Work-in-progress modifications to run better on actual hardware.

Comments (0)

Files changed (3)

FPManagedWindow.m

 
 #if !SAFE_MODE
 	#define HAVE_GL_COPY_TEX_IMAGE_2D 1
-	#define FORCE_TEXTURE_2D 1
+	#define FORCE_TEXTURE_2D 0
 	#define USE_GLXBINDTEXIMAGE 1
 #else
 	#define HAVE_GL_COPY_TEX_IMAGE_2D 0
-	#define FORCE_TEXTURE_2D 1
+	#define FORCE_TEXTURE_2D 0
 	#define USE_GLXBINDTEXIMAGE 0
 	#undef USE_GLX1_3
 	#define USE_GLX1_3 0
 }
 -(void)_buildResources
 {
+	NSLog(@"Building resources...");
 	FPX11Display * mainDisplay = [FPX11Display mainDisplay];
 	Display * display = [mainDisplay display];
 	
 	const int pixmap_attribs[] = {
-		GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
+		//GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
+		GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_RECTANGLE_EXT,
 		GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGBA_EXT,
 		None
 	};            
-	
+	NSLog(@"pixmap");
 	_pixmap = XCompositeNameWindowPixmap (display, _window);
 	if(!_pixmap)
 		NSLog(@"Failed to make a pixmap");
+NSLog(@"drawable");
 #if !USE_GLX1_3
 	_drawable = glXCreateGLXPixmap (display, [_manager visualInfo], _pixmap);
 #else
 #endif
 	if(!_drawable)
 		NSLog(@"Failed to make a drawable");
+NSLog(@"damage");
 	_damage = XDamageCreate (display, _window, XDamageReportDeltaRectangles);
 	if(!_texture)
 		glGenTextures (1, &_texture);
-
+NSLog(@"texture");
 	if(glXBindTexImageEXT)
 		glXBindTexImageEXT(display, _drawable, GLX_FRONT_EXT, NULL);
 }
 -(void)_freeResources
 {
+	NSLog(@"Freeing resources...");
 	FPX11Display * mainDisplay = [FPX11Display mainDisplay];
 	Display * display = [mainDisplay display];
 
-	if(glXReleaseTexImageEXT)
+	if(glXReleaseTexImageEXT && _drawable)
 		glXReleaseTexImageEXT(display, _drawable, GLX_FRONT_EXT);
 
 	/*
 #endif
 	if(_texture)
 		glDeleteTextures(1, &_texture);
+
+	_drawable = 0;
+	_damage = 0;
+	_pixmap = 0;
+	_drawable = 0;
+	_texture = 0;
 }
 -(void)_collectAttributes
 {
+	NSLog(@"Collecting attributes for %ld...", _window);
 	FPX11Display * mainDisplay = [FPX11Display mainDisplay];
 	Display * display = [mainDisplay display];
 	XWindowAttributes attr = { 0 };
 	XGetWindowAttributes (display, _window, &attr);
+	NSLog(@"Collected, saving...");
 	_width = attr.width;
 	_height = attr.height;
 	_x = attr.x;
 	_z = 0;
 	_isMapped = (attr.map_state == IsViewable);
 	_hasOutput = (attr.class == InputOutput);
-NSLog(@"%p", attr.visual);
 	_hasAlpha = attr.visual ? (attr.depth > 3 * attr.visual->bits_per_rgb) : NO;
 	_overrideRedirect = attr.override_redirect;
 	_opacity = 1.0; // FIXME: is this right?
 		}
 		break;
 
+		case ReparentNotify:
+		if(event.xreparent.window == _window)
+		{
+			// FIXME what if window is actually moved to root?
+			NSLog(@"Managed window %ld reparented - treating as unmapped", _window);
+			if(!_isMapped)
+				break;
+			[self _freeResources];
+			_pixmap = _drawable = _texture = 0;
+			_isMapped = NO;
+		}
+
 		case MapNotify:
 		if(event.xmap.window == _window)
 		{
 #if FORCE_TEXTURE_2D
 	_textureTarget = GLX_TEXTURE_2D_EXT; 
 #else
+	_textureTarget = 0;
+	NSLog(@"Querying drawable %p for texture target...", _drawable);
 	glXQueryDrawable(display, _drawable, GLX_TEXTURE_TARGET_EXT, &_textureTarget);
+	if(!_textureTarget)
+	{
+		NSLog(@"_textureTarget was 0; setting to GLX_TEXTURE_2D_EXT");
+		_textureTarget = GLX_TEXTURE_2D_EXT;
+	}
 #endif
 	switch(_textureTarget)
 	{
 		_textureTarget = GL_TEXTURE_RECTANGLE;
 		break;
 		default:
-		NSLog(@"Unknown texture target");
+		NSLog(@"Unknown texture target %d", _textureTarget);
 	}
 
 	if(glXBindTexImageEXT)
 	}
 	
 NSLog(@"Bound");
+//exit(0);
 }
 
 -(void)unbindTexture

FPWindowManager.m

 #import "FPX11Display.h"
 #import "FPManagedWindow.h"
 
-#define VBOXCOMPAT 1 // virtualbox compatibility
+#define VBOXCOMPAT 0 // virtualbox and xephyr compatibility
+#define USE_TEXTURE_RECTANGLE 0
 
 static int attrListSgl[] = {
     GLX_RGBA, GLX_RED_SIZE, 4,
 #if !VBOXCOMPAT
     GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT,
 #endif
+#if USE_TEXTURE_RECTANGLE
+    GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_RECTANGLE_BIT_EXT,
+#else
     GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_BIT_EXT,
+#endif
     GLX_Y_INVERTED_EXT, GLX_DONT_CARE,
     None
 };

test-with-real-X.sh

File contents unchanged.