#include #include #include #include #include static Ecore_X_Window input_win = 0; static Ecore_Event_Handler *_mouse_up_handler = NULL; static Ecore_Event_Handler *_key_up_handler = NULL; static int _window_key_up_cb(void *data, int type, void *event); static int _window_mouse_up_cb(void *data, int type, void *event); static void _input_window_remove(); static void _cursor_set(int cursor_type); int main(int argc, char **argv) { Ecore_X_Window root, parent; int root_x, root_y, root_w, root_h; ecore_init(); ecore_x_init(NULL); root = ecore_x_window_root_first_get(); while ((parent = ecore_x_window_parent_get(root)) != 0) root = parent; ecore_x_window_geometry_get(root, &root_x, &root_y, &root_w, &root_h); input_win = ecore_x_window_input_new(root, root_x, root_y, root_w, root_h); ecore_x_window_show(input_win); ecore_x_keyboard_grab(input_win); _cursor_set(ECORE_X_CURSOR_PLUS); _key_up_handler = ecore_event_handler_add(ECORE_X_EVENT_KEY_UP, _window_key_up_cb, NULL); _mouse_up_handler = ecore_event_handler_add(ECORE_X_EVENT_MOUSE_BUTTON_UP, _window_mouse_up_cb, NULL); ecore_main_loop_begin(); ecore_x_shutdown(); ecore_shutdown(); return 0; } static int _window_key_up_cb(void *data, int type, void *event) { Ecore_X_Event_Key_Up *key_event; _input_window_remove(); printf("key up!\n"); return 1; } static int _window_mouse_up_cb(void *data, int type, void *event) { Ecore_X_Event_Mouse_Button_Up *mouse_event; Ecore_X_Window win; int w, h; char buf[4096]; char *name; mouse_event = event; _input_window_remove(); win = ecore_x_window_at_xy_get(mouse_event->x, mouse_event->y); if(!win) return 1; while((win = ecore_x_window_parent_get(win))) { unsigned char *data = NULL; int count; ecore_x_window_prop_property_get(win, ECORE_X_ATOM_WM_STATE, ECORE_X_ATOM_WM_STATE, 32, &data, &count); if(data) { free(data); break; } } ecore_x_window_geometry_get(win, NULL, NULL, &w, &h); snprintf(buf, sizeof(buf), "0x%lx", win); ecore_x_netwm_name_get(win, &name); printf("got: %s %s [%dx%d]\n", name, buf, w, h); free(name); return 1; } static void _input_window_remove() { _cursor_set(ECORE_X_CURSOR_LEFT_PTR); ecore_x_keyboard_ungrab(); ecore_x_window_del(input_win); ecore_event_handler_del(_mouse_up_handler); ecore_event_handler_del(_key_up_handler); } static void _cursor_set(int cursor_type) { Ecore_X_Cursor cursor; cursor = ecore_x_cursor_shape_get(ECORE_X_CURSOR_PLUS); if(!cursor) return; ecore_x_window_cursor_set(input_win, cursor); }