[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Draw on Xwindow directly without NSWindow

From: Fred Kiefer
Subject: Re: Draw on Xwindow directly without NSWindow
Date: Wed, 03 May 2006 23:17:12 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.13) Gecko/20060411

I just submitted code for gui and the X backends that should support
most of what you want. Here is how I changed your test code to see if it
is actually working:

- (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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]