🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

The MAC OS and Linux/Unix window message pump

Started by
9 comments, last by Katie 14 years, 5 months ago
Dear all, I'm busy writing a window manager for my engine. Right now I can create Win32 windows in an abstract manner, it's a bit rough around the edges still, but it works. Now I want to abstract the windows events that come in, so I have this central point to process window messages from Windows, Mac and Linux/Unix. However, I don't know how the message pump in those latter operating systems work. Windows works with an unsigned int as the message and then a long and unsigned int (both 32-bit mind you!) as parameters. I'm sure Mac and Linux work with something different. Can anyone tell me how? I was thinking of creating a translation table that translates the messages of said operating systems to something my engine can understand. Is this a good approach? Thanks!
Advertisement
Moved to the Unix forum.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

For X Window (the common windowing system used in Linux), you use Xlib to program an X client. In Xlib, an event has type XEvent, which is a union that includes an int called `type'. You can find more information here.

Unfortunately, MacOS X doesn't use X Window, so you'll have to find somewhere else how its windowing system works.

Quote: Original post by ApochPiQ
Moved to the Unix forum.


Sorry thought it was considered general programming :)

Thanks for the link. This event manager is going to be quit a piece of work I think. I'm completely unknown with Linux programming :(
Quote: Original post by alvaro
Unfortunately, MacOS X doesn't use X Window, so you'll have to find somewhere else how its windowing system works.


Actually it can use X11 and since 10.5 IIRC it has been installed by default.

Quote: Original post by dmail
Quote: Original post by alvaro
Unfortunately, MacOS X doesn't use X Window, so you'll have to find somewhere else how its windowing system works.


Actually it can use X11 and since 10.5 IIRC it has been installed by default.


Well, yes, there are X servers for most platforms, including Windows. But I would imagine the OP was talking about using the natural windowing system in each system. Not too long ago I had to run Open Office using the X server on my Mac and it was a pain.

Maybe the best place to start is by examining how existing software that already does what you're trying to do works. For example, the SDL library works on not only WIN32, MacOS, and X11 but also on several other GUI layers you may not have heard of but are in widespread use. You don;t have to copy it, but it's Free so it doesn't hurt to study it.

Stephen M. Webb
Professional Free Software Developer

For Mac OS, go to Developer Center to get access to Mac OS documentation. Although available source like SDL is actually good for investigation, especially Mac OS isn't easy to understand without some background. Not only that one can find several APIs like Carbon and Cocoa (for windowing), and CoreGraphics (for full-screen OpenGL), also e.g. running the Carbon event system is something uncommon. That said, almost all examples of games and abstractions I know deep enough use Carbon and CoreGraphics.

Another thing is X11 on Mac OS. Yes, it is available, but Mac OS users are not necessarily happy to run it (I personally know 4 Mac users, and I can say you they weren't happy). Especially games should IMHO run natively.
Quote: Original post by alvaro
For X Window (the common windowing system used in Linux), you use Xlib to program an X client. In Xlib, an event has type XEvent, which is a union that includes an int called `type'. You can find more information here.


In my experience, xlib is unnecessarily arcane and does not work reliably in multithreaded applications. I'd recommend using XCB instead: it is very simple, stable and well-engineered.

My 2cc.

[OpenTK: C# OpenGL 4.4, OpenGL ES 3.0 and OpenAL 1.1. Now with Linux/KMS support!]

Thanks for all the advice and tips!

I'll be sure to look into it. I'm not even sure yet if my current approach is good enough :D

This topic is closed to new replies.

Advertisement