X11 OpenGL windows now placed properly

some event loop fixes
This commit is contained in:
Johannes Fortmann 2009-01-04 14:09:32 +00:00
parent 37a8a79d90
commit 319bee628c
7 changed files with 226 additions and 34 deletions

View File

@ -102,6 +102,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
_eventMask=mask;
if([_eventQueue count])
untilDate=[NSDate date];
[[NSRunLoop currentRunLoop] runMode:mode beforeDate:untilDate];
if([_eventQueue count]==0)

View File

@ -18,7 +18,6 @@
@interface NSOpenGLDrawable_X11 : NSOpenGLDrawable {
NSOpenGLPixelFormat *_format;
NSView *_view;
Display *_dpy;
XVisualInfo *_vi;
Window _window;

View File

@ -35,7 +35,6 @@ void CGLContextDelete(void *glContext)
-initWithPixelFormat:(NSOpenGLPixelFormat *)pixelFormat view:(NSView *)view {
if(self = [super init]) {
_format=[pixelFormat retain];
_view=view;
_dpy=[(X11Display*)[NSDisplay currentDisplay] display];
GLint att[] = { GLX_RGBA, None };
@ -46,16 +45,10 @@ void CGLContextDelete(void *glContext)
XSetWindowAttributes xattr;
xattr.colormap=cmap;
xattr.event_mask = ExposureMask | KeyPressMask;
_window = XCreateWindow(_dpy, DefaultRootWindow(_dpy), 0, 0, 600, 600, 0, _vi->depth, InputOutput, _vi->visual, CWColormap | CWEventMask, &xattr);
_window = XCreateWindow(_dpy, DefaultRootWindow(_dpy), 0, 0, 100, 100, 0, _vi->depth, InputOutput, _vi->visual, CWColormap | CWEventMask, &xattr);
[X11Window removeDecorationForWindow:_window onDisplay:_dpy];
NSRect frame=[_view frame];
frame=[view convertRect:frame toView:nil];
XMoveResizeWindow(_dpy, _window, frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
XReparentWindow(_dpy, _window, [[[view window] platformWindow] drawable], frame.origin.x, frame.origin.y);
[self updateWithView:view];
XMapWindow(_dpy, _window);
}
@ -72,8 +65,8 @@ void CGLContextDelete(void *glContext)
if(!_vi)
return NULL;
glc = glXCreateContext(_dpy, _vi, NULL, GL_FALSE);
glXMakeCurrent(_dpy, _window, glc);
glc = glXCreateContext(_dpy, _vi, NULL, GL_TRUE);
// glXMakeCurrent(_dpy, _window, glc);
return glc;
}
@ -81,6 +74,16 @@ void CGLContextDelete(void *glContext)
}
-(void)updateWithView:(NSView *)view {
NSRect frame=[view frame];
frame=[[view superview] convertRect:frame toView:nil];
X11Window *wnd=(X11Window*)[[view window] platformWindow];
NSRect wndFrame=[wnd frame];
frame.origin.y=wndFrame.size.height-(frame.origin.y+frame.size.height);
XMoveResizeWindow(_dpy, _window, frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
XReparentWindow(_dpy, _window, [(X11Window*)[[view window] platformWindow] drawable], frame.origin.x, frame.origin.y);
}
-(void)makeCurrentWithGLContext:(void *)glContext {
@ -88,6 +91,7 @@ void CGLContextDelete(void *glContext)
}
-(void)swapBuffers {
glXSwapBuffers(_dpy, _window);
}
@end

View File

@ -251,7 +251,6 @@
clickCount:1];
[self postEvent:ev atStart:NO];
[self discardEventsMatchingMask:NSLeftMouseDraggedMask beforeEvent:ev];
NSLog(@"drag");
break;
}
case ClientMessage:
@ -261,6 +260,7 @@
[[window delegate] platformWindowWillClose:window];
break;
}
case KeyRelease:
case KeyPress:
{
char buf[4]={0};
@ -272,13 +272,14 @@
XLookupString(&e, buf, 4, NULL, NULL);
id strIg=[[NSString alloc] initWithCString:buf encoding:NSISOLatin1StringEncoding];
id ev=[NSEvent keyEventWithType:NSKeyDown
id ev=[NSEvent keyEventWithType:e.type == KeyPress ? NSKeyDown : NSKeyUp
location:pos
modifierFlags:0
window:[window delegate]
characters:str
charactersIgnoringModifiers:strIg
isARepeat:NO keyCode:e.xkey.keycode];
[self postEvent:ev atStart:NO];
[str release];
@ -304,6 +305,9 @@
}
-(void)doNothing {
}
-(void)processX11Event {
XEvent e;
@ -317,13 +321,4 @@
}
}
}
-(void)postEvent:(NSEvent *)event atStart:(BOOL)atStart {
[super postEvent:event atStart:atStart];
[[NSPlatform currentPlatform] cancelForRunloopMode:[[NSRunLoop currentRunLoop] currentMode]];
}
@end

View File

@ -34,19 +34,11 @@
}
}
-(void)selectInputSource:(NSSelectInputSource *)inputSource selectEvent:(unsigned)selectEvent; {
if(XEventsQueued([_display display], QueuedAfterReading)) {
[_display processX11Event];
}
}
-(BOOL)processImmediateEvents:(unsigned)selectEvent; {
if(XPending([_display display])) {
if((selectEvent && XEventsQueued([_display display], QueuedAfterReading)) ||
XPending([_display display])) {
[_display processX11Event];
return YES;
}
return [super processImmediateEvents:selectEvent];
}
@end

View File

@ -26,7 +26,7 @@
_frame.origin.x, _frame.origin.y, _frame.size.width, _frame.size.height,
0, 0, 0);
XSelectInput(_dpy, _window, ExposureMask | KeyPressMask | StructureNotifyMask |
XSelectInput(_dpy, _window, ExposureMask | KeyPressMask | KeyReleaseMask | StructureNotifyMask |
ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | VisibilityChangeMask | FocusChangeMask);
XSetWindowAttributes xattr;

View File

@ -7,6 +7,10 @@
objects = {
/* Begin PBXBuildFile section */
C8E0BF9F0F0E6B0E00677729 /* Cocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = FEF3B23A0B35C74700A76FD1 /* Cocoa.h */; settings = {ATTRIBUTES = (Public, ); }; };
C8E0BFA20F0E6B0E00677729 /* Cocoa.m in Sources */ = {isa = PBXBuildFile; fileRef = FEF3B2780B35CB9D00A76FD1 /* Cocoa.m */; };
C8E0BFA40F0E6B0E00677729 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D69BFE84028FC02AAC07 /* Foundation.framework */; };
C8E0BFA50F0E6B0E00677729 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D6A5FE840307C02AAC07 /* AppKit.framework */; };
FE01AB170C5D9C3400AEA51A /* Cocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = FEF3B23A0B35C74700A76FD1 /* Cocoa.h */; settings = {ATTRIBUTES = (Public, ); }; };
FE01AB1A0C5D9C3400AEA51A /* Cocoa.m in Sources */ = {isa = PBXBuildFile; fileRef = FEF3B2780B35CB9D00A76FD1 /* Cocoa.m */; };
FE01AB1C0C5D9C3400AEA51A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D69BFE84028FC02AAC07 /* Foundation.framework */; };
@ -25,6 +29,48 @@
/* End PBXBuildRule section */
/* Begin PBXContainerItemProxy section */
C8724ABF0EC706C200DBDDAD /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FE7135460B36427F006C9493 /* AppKit.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = C889770C0EA0BF3100D0A0A2;
remoteInfo = "AppKit-Linux-i386";
};
C8724AC20EC706C200DBDDAD /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FE3217D10BB41D16004F000A /* ApplicationServices.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = C88977390EA0C0CD00D0A0A2;
remoteInfo = "ApplicationServices-Linux-i386";
};
C8E0BF920F0E6AF300677729 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FE7135460B36427F006C9493 /* AppKit.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = C8A2E5730F07EA1F0054397C /* AppKit.framework */;
remoteInfo = "AppKit-Darwin-i386";
};
C8E0BF960F0E6AF300677729 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FE3217D10BB41D16004F000A /* ApplicationServices.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = C8A2E2900F07E9B70054397C /* ApplicationServices.framework */;
remoteInfo = "ApplicationServices-Darwin-i386";
};
C8E0BFAF0F0E6B6600677729 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FE7135460B36427F006C9493 /* AppKit.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = C8A2E29F0F07EA1F0054397C /* AppKit-Darwin-i386 */;
remoteInfo = "AppKit-Darwin-i386";
};
C8E0BFB10F0E6B6C00677729 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FE3217D10BB41D16004F000A /* ApplicationServices.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = C8A2E2710F07E9B70054397C /* ApplicationServices-Darwin-i386 */;
remoteInfo = "ApplicationServices-Darwin-i386";
};
FE01AB240C5D9C3500AEA51A /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FE7135460B36427F006C9493 /* AppKit.xcodeproj */;
@ -59,6 +105,7 @@
0867D69BFE84028FC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
0867D6A5FE840307C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
8DC2EF5A0486A6940098B216 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
C8E0BFAA0F0E6B0E00677729 /* Cocoa.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Cocoa.framework; sourceTree = BUILT_PRODUCTS_DIR; };
FE01AB210C5D9C3400AEA51A /* Cocoa.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Cocoa.framework; sourceTree = BUILT_PRODUCTS_DIR; };
FE3217D10BB41D16004F000A /* ApplicationServices.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = ApplicationServices.xcodeproj; path = ../ApplicationServices/ApplicationServices.xcodeproj; sourceTree = SOURCE_ROOT; };
FE7135460B36427F006C9493 /* AppKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = AppKit.xcodeproj; path = ../AppKit/AppKit.xcodeproj; sourceTree = SOURCE_ROOT; };
@ -67,6 +114,15 @@
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
C8E0BFA30F0E6B0E00677729 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
C8E0BFA40F0E6B0E00677729 /* Foundation.framework in Frameworks */,
C8E0BFA50F0E6B0E00677729 /* AppKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
FE01AB1B0C5D9C3400AEA51A /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
@ -83,6 +139,7 @@
isa = PBXGroup;
children = (
FE01AB210C5D9C3400AEA51A /* Cocoa.framework */,
C8E0BFAA0F0E6B0E00677729 /* Cocoa.framework */,
);
name = Products;
sourceTree = "<group>";
@ -154,6 +211,8 @@
isa = PBXGroup;
children = (
FE01AB280C5D9C3500AEA51A /* ApplicationServices.framework */,
C8724AC30EC706C200DBDDAD /* ApplicationServices.framework */,
C8E0BF970F0E6AF300677729 /* ApplicationServices.framework */,
);
name = Products;
sourceTree = "<group>";
@ -162,6 +221,8 @@
isa = PBXGroup;
children = (
FE01AB250C5D9C3500AEA51A /* AppKit.framework */,
C8724AC00EC706C200DBDDAD /* AppKit.framework */,
C8E0BF930F0E6AF300677729 /* AppKit.framework */,
);
name = Products;
sourceTree = "<group>";
@ -169,6 +230,14 @@
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
C8E0BF9E0F0E6B0E00677729 /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
C8E0BF9F0F0E6B0E00677729 /* Cocoa.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
FE01AB160C5D9C3400AEA51A /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
@ -180,6 +249,27 @@
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
C8E0BF990F0E6B0E00677729 /* Cocoa-Darwin-i386 */ = {
isa = PBXNativeTarget;
buildConfigurationList = C8E0BFA70F0E6B0E00677729 /* Build configuration list for PBXNativeTarget "Cocoa-Darwin-i386" */;
buildPhases = (
C8E0BF9E0F0E6B0E00677729 /* Headers */,
C8E0BFA00F0E6B0E00677729 /* Resources */,
C8E0BFA10F0E6B0E00677729 /* Sources */,
C8E0BFA30F0E6B0E00677729 /* Frameworks */,
);
buildRules = (
);
dependencies = (
C8E0BFB00F0E6B6600677729 /* PBXTargetDependency */,
C8E0BFB20F0E6B6C00677729 /* PBXTargetDependency */,
);
name = "Cocoa-Darwin-i386";
productInstallPath = "$(HOME)/Library/Frameworks";
productName = Cocoa;
productReference = C8E0BFAA0F0E6B0E00677729 /* Cocoa.framework */;
productType = "com.apple.product-type.framework";
};
FE01AB110C5D9C3400AEA51A /* Cocoa-Windows-i386 */ = {
isa = PBXNativeTarget;
buildConfigurationList = FE01AB1F0C5D9C3400AEA51A /* Build configuration list for PBXNativeTarget "Cocoa-Windows-i386" */;
@ -226,11 +316,40 @@
projectRoot = "";
targets = (
FE01AB110C5D9C3400AEA51A /* Cocoa-Windows-i386 */,
C8E0BF990F0E6B0E00677729 /* Cocoa-Darwin-i386 */,
);
};
/* End PBXProject section */
/* Begin PBXReferenceProxy section */
C8724AC00EC706C200DBDDAD /* AppKit.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = AppKit.framework;
remoteRef = C8724ABF0EC706C200DBDDAD /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
C8724AC30EC706C200DBDDAD /* ApplicationServices.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = ApplicationServices.framework;
remoteRef = C8724AC20EC706C200DBDDAD /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
C8E0BF930F0E6AF300677729 /* AppKit.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = AppKit.framework;
remoteRef = C8E0BF920F0E6AF300677729 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
C8E0BF970F0E6AF300677729 /* ApplicationServices.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = ApplicationServices.framework;
remoteRef = C8E0BF960F0E6AF300677729 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
FE01AB250C5D9C3500AEA51A /* AppKit.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
@ -248,6 +367,13 @@
/* End PBXReferenceProxy section */
/* Begin PBXResourcesBuildPhase section */
C8E0BFA00F0E6B0E00677729 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
FE01AB180C5D9C3400AEA51A /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
@ -258,6 +384,14 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
C8E0BFA10F0E6B0E00677729 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C8E0BFA20F0E6B0E00677729 /* Cocoa.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
FE01AB190C5D9C3400AEA51A /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
@ -269,6 +403,16 @@
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
C8E0BFB00F0E6B6600677729 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = "AppKit-Darwin-i386";
targetProxy = C8E0BFAF0F0E6B6600677729 /* PBXContainerItemProxy */;
};
C8E0BFB20F0E6B6C00677729 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = "ApplicationServices-Darwin-i386";
targetProxy = C8E0BFB10F0E6B6C00677729 /* PBXContainerItemProxy */;
};
FEF80ABE0C5D9F3000FF7CA5 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = "AppKit-Windows-i386";
@ -324,6 +468,52 @@
};
name = Debug;
};
C8E0BFA80F0E6B0E00677729 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = i386;
DEPLOYMENT_LOCATION = YES;
DSTROOT = /;
FRAMEWORK_SEARCH_PATHS = /Developer/Cocotron/1.0/Darwin/i386/Frameworks;
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_PRECOMPILE_PREFIX_HEADER = NO;
GCC_PREFIX_HEADER = "";
INFOPLIST_FILE = Info.plist;
INSTALL_MODE_FLAG = "og-w,a+rX";
INSTALL_PATH = /Developer/Cocotron/1.0/Darwin/i386/Frameworks;
OTHER_CFLAGS = (
"-DCOCOA_INSIDE_BUILD",
"-D__LITTLE_ENDIAN__",
);
PREBINDING = NO;
PRODUCT_NAME = Cocoa;
SYMROOT = /Developer/Cocotron/1.0/build/Cocoa/Darwin;
};
name = Release;
};
C8E0BFA90F0E6B0E00677729 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = i386;
DEPLOYMENT_LOCATION = YES;
DSTROOT = /;
FRAMEWORK_SEARCH_PATHS = /Developer/Cocotron/1.0/Darwin/i386/Frameworks;
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_PRECOMPILE_PREFIX_HEADER = NO;
GCC_PREFIX_HEADER = "";
INFOPLIST_FILE = Info.plist;
INSTALL_MODE_FLAG = "og-w,a+rX";
INSTALL_PATH = /Developer/Cocotron/1.0/Darwin/i386/Frameworks;
OTHER_CFLAGS = (
"-DCOCOA_INSIDE_BUILD",
"-D__LITTLE_ENDIAN__",
);
PREBINDING = NO;
PRODUCT_NAME = Cocoa;
SYMROOT = /Developer/Cocotron/1.0/build/Cocoa/Darwin;
};
name = Debug;
};
FE01AB200C5D9C3400AEA51A /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
@ -366,6 +556,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
C8E0BFA70F0E6B0E00677729 /* Build configuration list for PBXNativeTarget "Cocoa-Darwin-i386" */ = {
isa = XCConfigurationList;
buildConfigurations = (
C8E0BFA80F0E6B0E00677729 /* Release */,
C8E0BFA90F0E6B0E00677729 /* Debug */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
FE01AB1F0C5D9C3400AEA51A /* Build configuration list for PBXNativeTarget "Cocoa-Windows-i386" */ = {
isa = XCConfigurationList;
buildConfigurations = (