Sign in to follow this  

X11 Client Events

Recommended Posts

Techieman    276


my next milestone is to port the Window class (or better the Window_Impl class) to X11 but

I am uncertain how to catch and process events like "WM_CLOSE" known from WinAPI.


Are there even events like this in Linux/X11?



Sincerely Julien


P.S.: My team has a reason NOT to use GLFW etc. even if it's just personal preference.

Edited by MyNameIsJulien

Share this post

Link to post
Share on other sites
RamonG    106

Yes there are equivalent messages in X11. Take a look at the XNextEvent function. This function will be run in a loop like the WndProc function. It accepts an XEvent structure in which you can query the type field to determine which event (Expose (a.k.a Paint), Click, ect.) occurred.

Share this post

Link to post
Share on other sites
andrew111    310
Try this:
Display *display;
Window win;
Atom wmDelete;

void onInit() {
    wmDelete=XInternAtom(display, "WM_DELETE_WINDOW", True);
    XSetWMProtocols(display, win, &wmDelete, 1);

void onUpdate() {
    XEvent ev;

    while(XPending(display)) {

        if(ev.type==DestroyNotify) {
            //on exit

        if(ev.type==ClientMessage && (Atom)[0] == wmDelete) {
            //on close window

        XFreeEventData(display, &ev.xcookie);

Edited by CaptainMurphy

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this