Xlibe: an Xlib/X11 compatibility layer for Haiku

@zelenoviy had initial wine port running cmd.exe about 10 years ago. Recently @3dEyes compiled wine with a very small patch but it crashes on start. Some kernel changes are needed to support wine. Basically, we need almost the same Serenity needs to get wine going https://github.com/SerenityOS/serenity/issues/6410

7 Likes

This looks like a great project-experiment, congratulations, it’s great that you entered the arena.
Have fun!

I mentioned it briefly in one of my replies above: “Xnest” appears to be the X.org X11 server running atop Xlib. However, based on the documentation and other details I found online, it does not seem to support “rootless” mode (and it seems Xephyr doesn’t either?) making it maybe less useful than it could be. I didn’t try building it myself, yet.

Building a “protocol inverter server” for Xlib, that turns X11 requests into Xlib calls, should be possible (or enhancing Xnest itself to support rootless mode.) I don’t have a lot of interest in that myself however, and while potentially useful it seems like a more niche case, so I don’t think I’ll wind up spending time on that. Or at least not contracted time anyway.

Those already work with the SDL2-based Tk package already available in the repositories, but it doesn’t support “rootless” mode, so it is kind of annoying to use applications that way, yes.

There is a certain tradeoff between stabilizing the system and making sure software is available for it. I spent the last few months on stabilizing in various ways (fixing lots of KDLs, the new NTFS driver, etc.), and things are much better than they were when I started, so now I figured it would be good to spend some time on porting software people have wanted for a long time. Haiku needs both to be generally viable.

Well, Xlib and GTK and related matters are all very complicated things which not a lot of people have the expertise and the time to tackle. At least for Xlibe, I am using quite a lot of knowledge both about Haiku itself, and about X11, and also about UIs and mapping and compatibility layers that I acquired over a period of years. While I’m far from the only person who could tackle this endeavor, I would estimate that there are not a lot of people who could, but whether they have the time (and interest) is another matter. So it seems to make the most sense for me to be the one to work on this, at least in these initial stages, as it will benefit not just a few users or developers but the whole community (and plenty of potential future users too.)

I’ve actually been keeping an eye out for things that use just plain Xlib and not some higher toolkit to use as testcases (Tk was originally good for that), so I might try both of these out and see what they uncover. :slight_smile:

It will probably be useful to get GUIs working with WINE once we do get main WINE working though. I do intend to look at WINE at some point, or rather the changes we have to make in Haiku itself to get it to work. I think we are just missing some fields from the signal context structures…

11 Likes

I’ve actually been keeping an eye out for things that use just plain Xlib and not some higher toolkit to use as testcases (Tk was originally good for that), so I might try both of these out and see what they uncover.

Emacs is a great program to use for that: the native port aside, you can build Emacs with “–with-x-toolkit=none --with-x --without-cairo --without-xft” to get a build of Emacs that only uses Xlib.

1 Like

Yes, I know, but to be honest this is really awkward to use :frowning: The X11 compatibility layer might yield better results once it is working.

2 Likes

I’m sure they’ll be some blasphemy called here, but this is a great stepping stone for an initial WINE port. Whilst many a moon ago, POSIX was a big stumbling block, the work done on POSIX in recent years probably largely makes that point moot. X11 is probably the biggest issue to getting an initial WINE port working now.

1 Like

What is the point of guessing?
Last time I checked the biggest issues were still declared to be adress space layout and some signal stuff, aswell as registers.

Wine world just fine in headless mode, so someone should figure that out first.

1 Like

Good day @waddlesplash ,

Great work you are doing with X. Having inkscape, gimp and Firefox on Haiku would reduce the need of using other oses. I personally use inkscape a lot so right now I switch back and forth quite more than what I would like.

Really appreciate your work on this topic.

Regards,
RR

5 Likes

11 posts were split to a new topic: Porting utility that can map to native APIs?

9 posts were split to a new topic: Native applications and fragmentation

Agree! This would be amazing.

I have fixed the redraw glitches (this was actually partially a problem in Haiku itself; I pushed some patches to Gerrit to resolve it), the hangs on mouse click events (the mouse now mostly works), and crashes on key events (however keyboard input does not work yet.) After a few other compatibility fixes, the “widgets” demo starts and displays largely correctly:

image

34 Likes

Awesome progress! I wonder if it is possible to change the widget look to be more native?

3 Likes

GTK supports theming, yes. @3dEyes took the time to install a Haiku-like theme for his demos; I haven’t bothered with that for the present.

6 Likes
6 Likes

Another update: a number of patches to GTK itself were required in order to avoid having to implement the full XKB structures (which basically nothing else seems to make use of), in addition to a variety of patches to Xlibe, but now keyboard events largely work; only Ctrl/Cmd-based shortcuts do not seem to activate for some reason (however, they also apparently do not work in Tk, so there is likely some common cause.)

10 Likes

Try using DispatchMessage instead of MessageRecieved to handle keyboard messages.
The same way you should handle B_UNMAPPED_KEY_UP/B_UNMAPPED_KEY_DOWN also.

9 Likes

Yes, I’ve just remembered that, and have over half of it written already. :slight_smile:

3 Likes

Done. Now Cmd-key shortcuts work in GTK windows. Next I should probably implement some or part of pointer grabs so it stops crash-asserting on menus, and figure out why windows seem to have no title most of the time.

16 Likes

Can you provide GTK build instructions to be used with Xlibe?

7 Likes