XLib:'软关闭'一个窗口(XLib: 'Soft

编程入门 行业动态 更新时间:2024-10-22 14:01:27
XLib:'软关闭'一个窗口(XLib: 'Soft-Closing' a window)

我知道,我可以通过调用“关闭”X11窗口:

XDestroyWindow(display, id);

问题是,这会立即破坏窗口。 另一方面,如果我单击关闭按钮(标题栏中的x),应用程序可以显示“你真的要退出吗?”之类的内容。

那么我怎样才能模仿这种类型的窗口关闭?


背景:我正在关闭其他应用程序的窗口,而不是我自己的窗口

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

最满意答案

它可以与stackoverflow.com/questions/1157364/intercept-wm-delete-window-on-x11相同

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/

更多推荐

本文发布于:2023-08-06 21:42:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1456762.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:窗口   XLib   Soft

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!