Index: XeeView.h
===================================================================
--- XeeView.h	(revision 17)
+++ XeeView.h	(working copy)
@@ -5,8 +5,12 @@
 
 @class XeeImage,XeeController,XeeTool;
 
-@interface XeeView:NSOpenGLView
+@interface XeeView:NSView
 {
+	NSOpenGLContext *openGLContext;
+	NSOpenGLContext *sharedOpenGLContext;
+	NSOpenGLPixelFormat *pixelFormat;
+	
 	XeeImage *image;
 	XeeTool *tool;
 
@@ -26,6 +30,7 @@
 	id delegate;
 }
 
+-(id)initWithFrame:(NSRect)frameRect sharedContext:(NSOpenGLContext *)sharedContext;
 -(id)initWithFrame:(NSRect)frameRect;
 -(void)dealloc;
 
@@ -75,6 +80,7 @@
 -(void)setDrawResizeCorner:(BOOL)draw;
 
 -(void)copyGLtoQuartz;
+-(NSOpenGLContext *)openGLContext;
 
 @end
 
Index: XeeView.m
===================================================================
--- XeeView.m	(revision 17)
+++ XeeView.m	(working copy)
@@ -12,9 +12,22 @@
 
 GLuint make_resize_texture();
 
+/* I changed it so it's a normal NSView subclass
+ * and followed reccomendations from this mail:
+ * http://lists.apple.com/archives/Mac-opengl/2002/Feb/msg00180.html
+ */
 
 @implementation XeeView
 
+-(id)initWithFrame:(NSRect)frameRect sharedContext:(NSOpenGLContext *)sharedContext
+{
+	if( (self = [self initWithFrame:frameRect]) ) {
+		sharedOpenGLContext = [sharedContext retain];
+	}
+	
+	return self;
+}
+
 -(id)initWithFrame:(NSRect)frameRect
 {
 	/*NSOpenGLPixelFormatAttribute attrs[]={ 
@@ -29,6 +42,10 @@
 */
 	if(self=[super initWithFrame:frameRect/* pixelFormat:format*/])
 	{
+		openGLContext = nil;
+		pixelFormat = nil;
+		sharedOpenGLContext = nil;
+		
 		image=nil;
 		tool=nil;
 
@@ -48,12 +65,6 @@
 		width=bounds.size.width;
 		height=bounds.size.height;
 
-		[[self openGLContext] makeCurrentContext];
-		resizetex=make_resize_texture();
-
-		long val=1;
-		[[self openGLContext] setValues:&val forParameter:NSOpenGLCPSwapInterval];
-
 		[self registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]];
 	}
 	return self;
@@ -61,8 +72,12 @@
 
 -(void)dealloc
 {
-	[[self openGLContext] makeCurrentContext];
+	[openGLContext makeCurrentContext];
 	glDeleteTextures(1,&resizetex);
+	
+	[openGLContext release];
+	[pixelFormat release];
+	[sharedOpenGLContext release];
 
 	[tool release];
 
@@ -90,8 +105,8 @@
 
 -(void)reshape
 {
-	[[self openGLContext] makeCurrentContext];
-	[[self openGLContext] update];
+	[openGLContext makeCurrentContext];
+	[openGLContext update];
 
 	NSPoint focus=[self focus];
 
@@ -104,11 +119,49 @@
 	[self setFocus:focus];
 }
 
+- (void)setFrame:(NSRect)aRect
+{
+	[super setFrame:aRect];
+	[self reshape];
+}
 
+- (void)globalFrameDidChange:(NSNotification *)aNotification
+{
+	if( [openGLContext view] == self )
+		[openGLContext update];
+}
 
+- (void)viewDidMoveToWindow
+{
+	NSWindow *window = [self window];
+	if( !window ) {
+		[openGLContext clearDrawable];
+		return;
+	}
+	
+	if( !openGLContext ) {
+		NSOpenGLPixelFormatAttribute attrs[]={ 
+			NSOpenGLPFANoRecovery,
+			NSOpenGLPFADoubleBuffer,
+			NSOpenGLPFAAccelerated,
+		(NSOpenGLPixelFormatAttribute)0};
+		pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs];
+		openGLContext = [[NSOpenGLContext alloc] initWithFormat:[NSOpenGLView defaultPixelFormat] shareContext:sharedOpenGLContext];
+		
+		[openGLContext makeCurrentContext];
+		resizetex=make_resize_texture();
+		
+		long val=1;
+		[openGLContext setValues:&val forParameter:NSOpenGLCPSwapInterval];
+	}
+	
+}
+
 -(void)drawRect:(NSRect)rect
 {
-	[[self openGLContext] makeCurrentContext];
+	if( [self superview] )
+		[openGLContext setView:self];
+	[openGLContext makeCurrentContext];
 
 	NSRect imgrect=[self imageRect];
 	NSRect bounds;
@@ -512,7 +565,7 @@
 	int bytesperrow=width*4;
     void *bitmap=malloc(bytesperrow*height);
 
-	[[self openGLContext] makeCurrentContext];
+	[openGLContext makeCurrentContext];
 
     glFinish(); // finish any pending OpenGL commands
 	glPushAttrib(GL_ALL_ATTRIB_BITS);
@@ -552,6 +605,11 @@
 	[[self window] flushWindow];
 }
 
+- (NSOpenGLContext *)openGLContext
+{
+	return openGLContext;
+}
+
 /*-(NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
 {
 	return NSDragOperationGeneric;
Index: XeeController.h
===================================================================
--- XeeController.h	(revision 17)
+++ XeeController.h	(working copy)
@@ -30,7 +30,7 @@
 	NSUndoManager *undo;
 
 	XeeFullScreenWindow *fullscreenwindow;
-	NSView *savedsuperview;
+	XeeView *savedImageview;
 	NSRect savedframe;
 
 	NSTimer *slideshowtimer;
Index: XeeController.m
===================================================================
--- XeeController.m	(revision 17)
+++ XeeController.m	(working copy)
@@ -979,10 +979,15 @@
 
 		[window orderOut:nil];
 
-		savedsuperview=[imageview superview];
 		savedframe=[imageview frame];
-		[imageview removeFromSuperview];
+		savedImageview = imageview;
+		
+		// create new view for fullscreen window and pass the context used by the windowed
+		// image view so they can share textures.
+		imageview = [[XeeView alloc] initWithFrame:[[fullscreenwindow contentView] bounds] sharedContext:[savedImageview openGLContext]];
 		[[fullscreenwindow contentView] addSubview:imageview];
+		[self setImage:currimage];
+		
 		[fullscreenwindow makeFirstResponder:imageview];
 
 		[imageview setFrame:[[fullscreenwindow contentView] bounds]];
@@ -1002,19 +1007,21 @@
 	{
 		[fullscreenwindow orderOut:nil];
 
-		[imageview removeFromSuperview];
-		[savedsuperview addSubview:imageview];
+		XeeView *windowedImageView = savedImageview;
+		savedImageview = imageview;
+		imageview = windowedImageView;
+		
 		[window makeFirstResponder:imageview];
-
-		[imageview setFrame:savedframe];
-
 		[imageview setMenu:nil];
+		[self setImage:currimage];
 
 		[[maindelegate propertiesController] setFullscreenMode:NO];
 		SetSystemUIMode(kUIModeNormal,0);
 
 		[fullscreenwindow release];
 		fullscreenwindow=nil;
+		[savedImageview release];
+		savedImageview = nil;
 
 		[self setStandardImageSize];
 		[window makeKeyAndOrderFront:nil];
Index: exiftags/exifutil.c
===================================================================
--- exiftags/exifutil.c	(revision 17)
+++ exiftags/exifutil.c	(working copy)
@@ -410,10 +410,12 @@
 
 	/* Fetch any remaining ones. */
 
-	while (offset) {
-		offset = readifd(offset, &(curifd->next), tagset, md);
+	u_int32_t newOffset = offset;
+	do {
+		offset = newOffset;
+		newOffset = readifd(offset, &(curifd->next), tagset, md);
 		curifd = curifd->next;
-	}
+	} while (offset && offset != newOffset);
 	return (firstifd);
 }
 
