From cdee81699a4c2312bcaaddaf194e8d12f2f73c0b Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Sat, 21 Jul 2018 18:36:50 +0900 Subject: [PATCH] Panel should accept close-enough clicks for menus --- apps/panel.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/panel.c b/apps/panel.c index 363b2532..0280b094 100644 --- a/apps/panel.c +++ b/apps/panel.c @@ -118,6 +118,14 @@ struct MenuList * logout_menu; struct MenuList * netstat; static yutani_wid_t _window_menu_wid = 0; +static int _close_enough(struct yutani_msg_window_mouse_event * me) { + if (me->command == YUTANI_MOUSE_EVENT_RAISE && sqrt(pow(me->new_x - me->old_x, 2) + pow(me->new_y - me->old_y, 2)) < 10) { + return 1; + } + return 0; +} + + static int center_x(int x) { return (width - x) / 2; } @@ -371,7 +379,7 @@ static void show_network_status(void) { /* Callback for mouse events */ static void panel_check_click(struct yutani_msg_window_mouse_event * evt) { if (evt->wid == panel->wid) { - if (evt->command == YUTANI_MOUSE_EVENT_CLICK) { + if (evt->command == YUTANI_MOUSE_EVENT_CLICK || _close_enough(evt)) { /* Up-down click */ if (evt->new_x >= width - 24 ) { show_logout_menu();