From 6a96c25be2a60c713cddcd26bd2228b9774d5d5c Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Sun, 15 Jun 2008 17:30:21 +0200 Subject: [PATCH] mouse: add mouse_get_client_under_pointer Signed-off-by: Julien Danjou --- mouse.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/mouse.c b/mouse.c index 9e72243f..4737719c 100644 --- a/mouse.c +++ b/mouse.c @@ -337,6 +337,32 @@ mouse_track_mouse_drag(int *x, int *y) } } +/** Get the client that contains the Pointer. + * + * \return The client that contains the Pointer or NULL. + */ +static client_t * +mouse_get_client_under_pointer() +{ + xcb_window_t root; + xcb_query_pointer_cookie_t query_ptr_c; + xcb_query_pointer_reply_t *query_ptr_r; + client_t *c = NULL; + + root = xcb_aux_get_screen(globalconf.connection, globalconf.default_screen)->root; + + query_ptr_c = xcb_query_pointer_unchecked(globalconf.connection, root); + query_ptr_r = xcb_query_pointer_reply(globalconf.connection, query_ptr_c, NULL); + + if(query_ptr_r) + { + c = client_getbywin(query_ptr_r->child); + p_delete(&query_ptr_r); + } + + return c; +} + /** Move the focused window with the mouse. */ static void