0

I know, that I can 'close' an X11 Window by calling:

XDestroyWindow(display, id);

The problem is, this destroyes the window immediately. On the other hand, if i click the close button (x in the title bar) the app can show something like "Do you really want to exit?".

So how can I emulate this type of window closing?


Background: I am closing windows from other applications, not my own

mame98
  • 1,271
  • 12
  • 26

2 Answers2

6

I found a solution:

XEvent event;
event.xclient.type = ClientMessage;
event.xclient.window = id;
event.xclient.message_type = XInternAtom(d, "WM_PROTOCOLS", TRUE);
event.xclient.format = 32;
event.xclient.data.l[0] = XInternAtom(d, "WM_DELETE_WINDOW", FALSE);
event.xclient.data.l[1] = CurrentTime;
XSendEvent(d, id, False, NoEventMask, &event);

Where d is the display handle and id is the window ID.

CREDIT: https://john.nachtimwald.com/2009/11/08/sending-wm_delete_window-client-messages/

mame98
  • 1,271
  • 12
  • 26
1

It can be the same as stackoverflow.com/questions/1157364/intercept-wm-delete-window-on-x11

Community
  • 1
  • 1
ulix
  • 274
  • 1
  • 2
  • 13
  • that is not directly what I need, but maybe the first answer is quite helpfull, thanks anyways! – mame98 Dec 17 '16 at 20:34