implememting KWindowSystem on Mac OSX
l.lunak at suse.cz
Mon Feb 11 15:04:59 GMT 2008
On Monday 11 of February 2008, Marijn Kruisselbrink wrote:
> I've been working on implementing most of the KWindowSystem/KWindowInfo
> methods on OSX, but while doing so I encountered one annoying thing. The
> entire KWindowSystem API uses Qt's WId type to pass windows around.
Which it, more or less, has to - the ID is the only way to refer to windows
outside of the application.
> However this has one major problem on OSX: a WId can only refer to a
> window in the same application.
I see. So much for not using X11's Window directly in favour of
Qt's "portable" WId :(.
> Now I'm not sure what would be the
> cleanest/best way to work arround this issue:
> a. Keep the current API, but use some convention like when the highest
> bit in a WId is set, it isn't really a WId, but another kind of id,
> hoping real WId will never have that bit set. Given that a WId on OSX
> really is a pointer, this might be a valid assumption, but of course it
> could also break very easily.
Haaaacks!!! I smell fresh hacks! Erm, I mean, if WId is just a pointer, then
you don't need to set any bits.
You make your special WId's by simply allocating them and keeping them in
some list. Since these "other" WId's should come either from KWindowSystem or
from platform-specific calls (meaning nobody on X11/Win can break it for
you), you should be able to easily keep track of them.
Also, IIRC Qt mostly uses WId's only in the Qt->window system direction, not
the other way around, it should be also very unlikely this special WId gets
passed to Qt and causes trouble. I think the only relevant call is
QWidget::create() and that's basically used in platform-specific code too.
Which means that your specific WId's should be only created in KWindowSystem
and should be mostly confined to it. The other place where you could have
trouble is passing WId over DBUS, where it's typed to various "random"
integer types if I'm not mistaken, but there it can't get better anyway I'm
afraid - it could at most get a bit better by using WId more consistently in
> Any comments, or have I missed something obvious that would make this
> easier/nicer to implement?
SUSE LINUX, s.r.o. e-mail: l.lunak at suse.cz , l.lunak at kde.org
Lihovarska 1060/12 tel: +420 284 028 972
190 00 Prague 9 fax: +420 284 028 951
Czech Republic http//www.suse.cz
More information about the kde-core-devel