From 970cfd881ae901db977f145dd1bfb530765be088 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Sun, 23 Jun 2013 17:30:03 +0400 Subject: [PATCH] (dlg_mouse_event): minor refactoring. Signed-off-by: Andrew Borodin --- lib/widget/dialog.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/lib/widget/dialog.c b/lib/widget/dialog.c index 615e048e3..69fca0720 100644 --- a/lib/widget/dialog.c +++ b/lib/widget/dialog.c @@ -361,14 +361,11 @@ dlg_mouse_event (WDialog * h, Gpm_Event * event) { Widget *wh = WIDGET (h); - GList *item; - GList *starting_widget = h->current; - int x = event->x; - int y = event->y; - - /* close the dialog by mouse click out of dialog area */ - if (mouse_close_dialog && !h->fullscreen && ((event->buttons & GPM_B_LEFT) != 0) && ((event->type & GPM_DOWN) != 0) /* left click */ - && !((x > wh->x) && (x <= wh->x + wh->cols) && (y > wh->y) && (y <= wh->y + wh->lines))) + GList *p, *first; + + /* close the dialog by mouse left click out of dialog area */ + if (mouse_close_dialog && !h->fullscreen && ((event->buttons & GPM_B_LEFT) != 0) + && ((event->type & GPM_DOWN) != 0) && !mouse_global_in_widget (event, wh)) { h->ret_value = B_CANCEL; dlg_stop (h); @@ -384,24 +381,26 @@ dlg_mouse_event (WDialog * h, Gpm_Event * event) return mou; } - item = starting_widget; + first = h->current; + p = first; + do { - Widget *widget = WIDGET (item->data); + Widget *w = WIDGET (p->data); - item = dlg_widget_prev (h, item); + p = dlg_widget_prev (h, p); - if ((widget->options & W_DISABLED) == 0 && widget->mouse != NULL) + if ((w->options & W_DISABLED) == 0 && w->mouse != NULL) { /* put global cursor position to the widget */ int ret; - ret = widget->mouse (event, widget); + ret = w->mouse (event, w); if (ret != MOU_UNHANDLED) return ret; } } - while (item != starting_widget); + while (p != first); return MOU_UNHANDLED; } -- 2.11.4.GIT