Jump to content
  • Advertisement
Sign in to follow this  
Techieman

X11 Client Events

This topic is 1154 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

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
Advertisement

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

Sorry, my question was too unprecise. 

I couldn't find any ID for a equivalent of WM_CLOSE/WM_QUIT/WM_DESTROY for "XEvent.type".

Share this post


Link to post
Share on other sites
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)) {
        XNextEvent(display,&ev);

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

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

        XFreeEventData(display, &ev.xcookie);
    }
}

Edited by CaptainMurphy

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!