简体   繁体   English

如何在XCB中使用关闭按钮退出程序

[英]How to exit program with close button in XCB

Can not find any reference on how to close application by the "X" button. 找不到关于如何通过“X”按钮关闭应用程序的任何参考。 I'm programming using XCB and want to close the program by the "X" button. 我正在使用XCB进行编程,并希望通过“X”按钮关闭程序。 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. 此外,通过按“X”按钮,窗口看起来像是关闭但没有。

I struggled on this topic some time ago as well. 不久前我也在讨论这个话题。

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

The key is to store the cookie for the WM_DELETE_WINDOW in a separate cookie... 关键是将WM_DELETE_WINDOW的cookie存储在一个单独的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 并在事件循环中将client_message与cookie2进行比较

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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