简体   繁体   中英

How to exit program with close button in XCB

Can not find any reference on how to close application by the "X" button. I'm programming using XCB and want to close the program by the "X" button. I looked and can't find anything about it. I know how to close by pressing a button. Also, by pressing the "X" button the window looks like it closes but doesn't.

I struggled on this topic some time ago as well.

Look at http://marc.info/?l=freedesktop-xcb&m=129381953404497 .

The key is to store the cookie for the WM_DELETE_WINDOW in a separate cookie...

xcb_intern_atom_cookie_t cookie2 = xcb_intern_atom(c, 0, 16, "WM_DELETE_WINDOW");
xcb_intern_atom_reply_t* reply2 = xcb_intern_atom_reply(c, cookie2, 0);

and in the event loop compare the client_message with the cookie2

case XCB_CLIENT_MESSAGE:
{
    if((*(xcb_client_message_event_t*)event).data.data32[0] == (*reply2).atom) ...
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM