From 5207be87f60cd92781cd3ec29641e6447e22a627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Wed, 21 Sep 2011 08:36:49 -0400 Subject: [PATCH] xfreerdp: properly handle local Alt+F4 for RemoteApp windows --- client/X11/xf_event.c | 28 +++++++++++++++++++--------- client/X11/xf_rail.h | 5 ----- client/X11/xf_window.c | 2 ++ client/X11/xfreerdp.c | 9 ++++----- client/X11/xfreerdp.h | 3 +++ 5 files changed, 28 insertions(+), 19 deletions(-) diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c index 2b4e8b6be..8cfc00882 100644 --- a/client/X11/xf_event.c +++ b/client/X11/xf_event.c @@ -378,16 +378,26 @@ boolean xf_event_MappingNotify(xfInfo* xfi, XEvent* event, boolean app) boolean xf_event_ClientMessage(xfInfo* xfi, XEvent* event, boolean app) { - Atom kill_atom; - Atom protocol_atom; - - protocol_atom = XInternAtom(xfi->display, "WM_PROTOCOLS", True); - kill_atom = XInternAtom(xfi->display, "WM_DELETE_WINDOW", True); - - if ((event->xclient.message_type == protocol_atom) - && ((Atom) event->xclient.data.l[0] == kill_atom)) + if ((event->xclient.message_type == xfi->WM_PROTOCOLS) + && ((Atom) event->xclient.data.l[0] == xfi->WM_DELETE_WINDOW)) { - return False; + if (app) + { + rdpWindow* window; + + window = window_list_get_by_extra_id(xfi->rail->list, (void*) event->xclient.window); + + if (window != NULL) + { + xf_rail_send_client_system_command(xfi, window->windowId, SC_CLOSE); + } + + return True; + } + else + { + return False; + } } return True; diff --git a/client/X11/xf_rail.h b/client/X11/xf_rail.h index be5ecee1b..6b5d94663 100644 --- a/client/X11/xf_rail.h +++ b/client/X11/xf_rail.h @@ -23,15 +23,10 @@ #include "xfreerdp.h" void xf_rail_paint(xfInfo* xfi, rdpRail* rail, uint32 ileft, uint32 itop, uint32 iright, uint32 ibottom); - void xf_rail_register_callbacks(xfInfo* xfi, rdpRail* rail); - void xf_rail_send_client_system_command(xfInfo* xfi, uint32 windowId, uint16 command); - void xf_rail_send_activate(xfInfo* xfi, Window xwindow, boolean enabled); - void xf_rail_send_windowmove(xfInfo* xfi, uint32 windowId, uint32 left, uint32 top, uint32 right, uint32 bottom); - void xf_process_rail_event(xfInfo* xfi, rdpChanMan* chanman, RDP_EVENT* event); #endif /* __XF_RAIL_H */ diff --git a/client/X11/xf_window.c b/client/X11/xf_window.c index 634b93cab..20dfcb274 100644 --- a/client/X11/xf_window.c +++ b/client/X11/xf_window.c @@ -333,6 +333,8 @@ xfWindow* xf_CreateWindow(xfInfo* xfi, xfWindow* parent, int x, int y, int width xfree(class); } + XSetWMProtocols(xfi->display, window->handle, &(xfi->WM_DELETE_WINDOW), 1); + input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | VisibilityChangeMask | FocusChangeMask | StructureNotifyMask | diff --git a/client/X11/xfreerdp.c b/client/X11/xfreerdp.c index d69e688f1..8fbad33d9 100644 --- a/client/X11/xfreerdp.c +++ b/client/X11/xfreerdp.c @@ -347,6 +347,9 @@ boolean xf_pre_connect(freerdp* instance) xfi->_NET_WM_MOVERESIZE = XInternAtom(xfi->display, "_NET_WM_MOVERESIZE", False); + xfi->WM_PROTOCOLS = XInternAtom(xfi->display, "WM_PROTOCOLS", False); + xfi->WM_DELETE_WINDOW = XInternAtom(xfi->display, "WM_DELETE_WINDOW", False); + xf_kbd_init(xfi); xfi->clrconv = xnew(CLRCONV); @@ -381,8 +384,6 @@ boolean xf_post_connect(freerdp* instance) xfInfo* xfi; XEvent xevent; XGCValues gcv; - Atom kill_atom; - Atom protocol_atom; xfi = GET_XFI(instance); SET_XFI(instance->update, xfi); @@ -432,9 +433,7 @@ boolean xf_post_connect(freerdp* instance) xfi->unobscured = (xevent.xvisibility.state == VisibilityUnobscured); - protocol_atom = XInternAtom(xfi->display, "WM_PROTOCOLS", True); - kill_atom = XInternAtom(xfi->display, "WM_DELETE_WINDOW", True); - XSetWMProtocols(xfi->display, xfi->window->handle, &kill_atom, 1); + XSetWMProtocols(xfi->display, xfi->window->handle, &(xfi->WM_DELETE_WINDOW), 1); } memset(&gcv, 0, sizeof(gcv)); diff --git a/client/X11/xfreerdp.h b/client/X11/xfreerdp.h index 089404b98..5740f455b 100644 --- a/client/X11/xfreerdp.h +++ b/client/X11/xfreerdp.h @@ -111,6 +111,9 @@ struct xf_info Atom _NET_WM_WINDOW_TYPE_UTILITY; Atom _NET_WM_MOVERESIZE; + + Atom WM_PROTOCOLS; + Atom WM_DELETE_WINDOW; }; void xf_toggle_fullscreen(xfInfo* xfi);