Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exit program with close button in XCB

Tags:

linux

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.

like image 650
Matthew Hooker Avatar asked Jan 08 '12 08:01

Matthew Hooker


People also ask

How do I enable/disable the close button of selected Windows?

Disable the Close button (X) of selected windows. - Press Ctrl+1 to Enable or Disable the Close button of the active window. - Press Ctrl+2 to Add a rule. - Automatic enabling and disabling of close buttons on program start and stop, and on window creation. - Change hotkeys and automation options.

How does XCB_disconnect work?

Instead, it calls xcb_disconnect to terminate the connection to the X server. If XCB is installed on the development system, the source file can be compiled with the following command: Unless the user clicks the window's close button, the window will stay open for five seconds because of the sleep function.

How do I use XCB_connect?

In XCB, the function to use is xcb_connect: The first argument identifies the X server's display name. If this is set to NULL, the function will use the value of the DISPLAY environment variable. The second argument points to a number for the screen that should be connected.

How do I use XCB-Proto to compile X programs?

Note that xcb-proto exists only to install header files, so typing 'make' or 'make all' will produce the message "Nothing to be done for 'all'". That's normal. Compiling XCB-based programs requires linking them with the XCB library. This is easily done thanks to pkgconfig: An X program first needs to open the connection to the X server.


Video Answer


1 Answers

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) ...
}
like image 154
max.haredoom Avatar answered Sep 23 '22 22:09

max.haredoom