From bae773e4561d9fa4c2b9b64d04ae92dcfd1143f8 Mon Sep 17 00:00:00 2001 From: raster Date: Fri, 29 Jan 2010 10:28:54 +0000 Subject: [PATCH] say we do pings - and respond within the event handler. git-svn-id: http://svn.enlightenment.org/svn/e/trunk/ecore@45699 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/ecore_evas/ecore_evas_x.c | 31 ++++++++++++++++++------------- src/lib/ecore_x/xlib/ecore_x_events.c | 10 ++++++++++ src/lib/ecore_x/xlib/ecore_x_icccm.c | 15 +++++++++++++++ 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/src/lib/ecore_evas/ecore_evas_x.c b/src/lib/ecore_evas/ecore_evas_x.c index d640d9f..a83765d 100644 --- a/src/lib/ecore_evas/ecore_evas_x.c +++ b/src/lib/ecore_evas/ecore_evas_x.c @@ -24,6 +24,18 @@ static int _ecore_evas_init_count = 0; static Ecore_Event_Handler *ecore_evas_event_handlers[12]; +static void +_ecore_evas_x_protocols_set(Ecore_Evas *ee) +{ + Ecore_X_Atom protos[10]; + int num = 0; + + protos[num++] = ECORE_X_ATOM_NET_WM_PING; + if (ee->func.fn_delete_request) + protos[num++] = ECORE_X_ATOM_WM_DELETE_WINDOW; + ecore_x_icccom_protocol_atoms_set(ee->prop.window, protos, num); +} + #ifdef HAVE_ECORE_X_XCB static xcb_visualtype_t * xcb_visualtype_get(xcb_screen_t *screen, xcb_visualid_t visual) @@ -127,7 +139,8 @@ _ecore_evas_x_gl_window_new(Ecore_Evas *ee, Ecore_X_Window parent, int x, int y, evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); ecore_x_window_defaults_set(win); - } + _ecore_evas_x_protocols_set(ee); + } else { win = 0; @@ -1043,22 +1056,11 @@ _ecore_evas_x_free(Ecore_Evas *ee) ecore_x_shutdown(); } -/* FIXME: round trip */ static void _ecore_evas_x_callback_delete_request_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee)) { -#ifdef HAVE_ECORE_X_XCB - ecore_x_icccm_protocol_get_prefetch(ee->prop.window); - ecore_x_icccm_protocol_get_fetch(); -#endif /* HAVE_ECORE_X_XCB */ - if (func) - ecore_x_icccm_protocol_set(ee->prop.window, ECORE_X_WM_PROTOCOL_DELETE_REQUEST, 1); - else - ecore_x_icccm_protocol_set(ee->prop.window, ECORE_X_WM_PROTOCOL_DELETE_REQUEST, 0); ee->func.fn_delete_request = func; -#ifdef HAVE_ECORE_X_XCB - ecore_xcb_reply_free(); -#endif /* HAVE_ECORE_X_XCB */ + _ecore_evas_x_protocols_set(ee); } static void @@ -1529,6 +1531,7 @@ _ecore_evas_x_alpha_set(Ecore_Evas *ee, int alpha) 0 /* icon_window */, 0 /* window_group */, 0 /* is_urgent */); + _ecore_evas_x_protocols_set(ee); #endif /* BUILD_ECORE_EVAS_SOFTWARE_X11 */ } else if (!strcmp(ee->driver, "xrender_x11")) @@ -1603,6 +1606,7 @@ _ecore_evas_x_alpha_set(Ecore_Evas *ee, int alpha) 0 /* icon_window */, 0 /* window_group */, 0 /* is_urgent */); + _ecore_evas_x_protocols_set(ee); #endif /* BUILD_ECORE_EVAS_XRENDER_X11 || BUILD_ECORE_EVAS_XRENDER_XCB */ } else if (!strcmp(ee->driver, "software_16_x11")) @@ -1670,6 +1674,7 @@ _ecore_evas_x_alpha_set(Ecore_Evas *ee, int alpha) 0 /* icon_window */, 0 /* window_group */, 0 /* is_urgent */); + _ecore_evas_x_protocols_set(ee); #endif /* BUILD_ECORE_EVAS_SOFTWARE_16_X11 */ } } diff --git a/src/lib/ecore_x/xlib/ecore_x_events.c b/src/lib/ecore_x/xlib/ecore_x_events.c index a421e36..5a34ef5 100644 --- a/src/lib/ecore_x/xlib/ecore_x_events.c +++ b/src/lib/ecore_x/xlib/ecore_x_events.c @@ -1776,6 +1776,7 @@ _ecore_x_event_handle_client_message(XEvent *xevent) && (xevent->xclient.format == 32)) { Ecore_X_Event_Ping *e; + Ecore_X_Window root; e = calloc(1, sizeof(Ecore_X_Event_Ping)); if (!e) return; @@ -1784,6 +1785,15 @@ _ecore_x_event_handle_client_message(XEvent *xevent) e->event_win = xevent->xclient.data.l[2]; ecore_event_add(ECORE_X_EVENT_PING, e, NULL, NULL); + /* send a reply anyway - we are alive... eventloop at least */ + root = ecore_x_window_root_get(e->win); + if (xevent->xclient.window != root) + { + xevent->xclient.window = root; + XSendEvent(_ecore_x_disp, root, False, + SubstructureRedirectMask | SubstructureNotifyMask, + xevent); + } } else if ((xevent->xclient.message_type == ECORE_X_ATOM_NET_STARTUP_INFO_BEGIN) && (xevent->xclient.format == 8)) diff --git a/src/lib/ecore_x/xlib/ecore_x_icccm.c b/src/lib/ecore_x/xlib/ecore_x_icccm.c index c03dd52..7905941 100644 --- a/src/lib/ecore_x/xlib/ecore_x_icccm.c +++ b/src/lib/ecore_x/xlib/ecore_x_icccm.c @@ -495,6 +495,21 @@ ecore_x_icccm_title_get(Ecore_X_Window win) } /** + * Set protocol atoms explicitly + * @param win The Window + * @param protos An array of protocol atoms + * @param num the number of members of the array + */ +EAPI void +ecore_x_icccom_protocol_atoms_set(Ecore_X_Window win, Ecore_X_Atom *protos, int num) +{ + if (num > 0) + XSetWMProtocols(_ecore_x_disp, win, (Atom *)(protos), num); + else + XDeleteProperty(_ecore_x_disp, win, ECORE_X_ATOM_WM_PROTOCOLS); +} + +/** * Set or unset a wm protocol property. * @param win The Window * @param protocol The protocol to enable/disable -- 2.7.4