- (void) applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSWindow *win;
/* Setup main window */
int x = 100, y = 10, w = 300, h = 300, border_width = 10;
mainXWindow = XCreateWindow(dpy, root_win, x, y, w, h, border_width,
CopyFromParent, CopyFromParent, CopyFromParent, 0, NULL);
win = [[NSWindow alloc] initWithWindowRef: &mainXWindow];
[win makeKeyAndOrderFront: self];
[[win contentView] lockFocus];
[[NSColor blackColor] set];
NSRectFill(NSMakeRect(0, 0, 300, 300));
[[NSColor whiteColor] set];
NSRectFill(NSMakeRect(10, 10, 280, 280));
[[win contentView] unlockFocus];
}
You shoudl be aware that after wrapping the X window inside of the
NSWindow, the later is responcible of freeing the X window. You should
not be doing this yourself. Also notice that you have to provide a
pointer to the X window not the window itself. I did this to match up
with the existing windowDevice: method.
Cheers
Fred