[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: |
Sat, 29 Apr 2006 18:52:15 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.13) Gecko/20060411 |
Yen-Ju Chen wrote:
> I am looking a way to use GNUstep AppKit to draw on Xwindow, not NSWindow.
> I guess basically it depends on how NSBezierPath and drawing of
> NSAttributesString is implemented.
> I did some research on backend.
> But I think it would be faster to get some answers
> since many people here have more knowledge about backend. :)
>
> In [XGServerWindow windowdevice:],
> there is a piece of code:
>
> gswindow_device_t *window;
> NSGraphicsContext *ctxt;
> ctxt = GSCurrentContext();
> GSSetDevice(ctxt, window, 0, NSHeight(window->xframe));
> DPSinitmatrix(ctxt);
> DPSinitclip(ctxt);
>
> If I can fake a gswindow_device_t and hook up to NSGraphicsContext as
> above,
> will it redirect all the drawing into the fake gswindow_device_t ?
> There are some codes in NSWindow related to GraphicState.
> Are they critical for this purpose ?
>
> Thanx a lot.
>
> Here is the explanation why I need to do that if you are interesting:
>
> I am trying to find a way to draw the window decorations in Azalea.
> Reparenting NSWindow into XWindow does not seem to work in an easy way.
> It's partially because how Azalea works.
> NSWindow is always mapped as a regular client, not just a normal XWindow.
> This introduces a lot of complication.
> So the other easy way around is to draw directly on Xwindow.
> The shortcoming of this approach is that NSWindow and NSView cannot be
> used,
> Therefore, most GUI in AppKit is useless.
> But if NSBezierPath and string drawing are still working, it is worth to
> try
> because I can take the advantage of whatever backend GNUstep can offer.
>
> If you are interesting in the code,
> they are in http://svn.gna.org/viewcvs/etoile/branches/AzaleaAppKit/.
> The window decorationi part is in AZFrame.
>
I have been giving this some thought. Wouldn't it resolve your problem,
if we add to GNUstep an implementation of the method [NSWindow
initWithWindowRef:], where the window ref would be the X window?
This should give about the same results as your code, but in a well
defined way. The code inside of initWithWindowRef: would be a mixture of
the code from _initBackendWindow and
initWithContentRect:styleMask:backing:defer:screen:, where the size,
style, level, screen and backingstore information would be extracted
from the underlying X window by a new backend method, that would also
return a GNUstep window number.
For your special environment we need to ensure that the window
decoration handling is set correctly. Somehow we need to trick the x
backend as well as the gui code into thinking that the window
decoratione should not be handled at their level :-)
I am willing to write this code, if you can provide a test application
for it, that is point me to the part of teh Azalea code that would use this.
Cheers
Fred