From 92353b384842c4a6ee4044e8b219697fada55f5a Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Fri, 3 Apr 2009 19:29:20 +0400 Subject: [PATCH] Added option to enable/disable close dialog by mouse click outside of it. Disabled by default. This option is available in ini file only. setup.h: declare mouse_close_dialog variable. setup.h: read/write mouse_close_dialog variable from/to ini file. dialog.c: use mouse_close_dialog variable to control the single left click outside of dialog. --- src/dialog.c | 10 +++++++--- src/setup.c | 1 + src/setup.h | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/dialog.c b/src/dialog.c index c46e7de7e..12d5b20a5 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -38,6 +38,7 @@ #include "execute.h" /* suspend_cmd() */ #include "main.h" /* slow_terminal */ #include "strutil.h" +#include "setup.h" /* mouse_close_dialog */ #define waddc(w,y1,x1,c) move (w->y+y1, w->x+x1); addch (c) @@ -48,6 +49,9 @@ Dlg_head *current_dlg = 0; /* A hook list for idle events */ Hook *idle_hook = 0; +/* left click outside of dialog closes it */ +int mouse_close_dialog = 0; + static void dlg_broadcast_msg_to (Dlg_head * h, widget_msg_t message, int reverse, int flags); @@ -686,9 +690,9 @@ dlg_mouse_event (Dlg_head * h, Gpm_Event * event) int y = event->y; /* close the dialog by mouse click out of dialog area */ - if (!h->fullscreen && ((event->type & GPM_DOWN) != 0) - && !((x > h->x) && (x <= h->x + h->cols) - && (y > h->y) && (y <= h->y + h->lines))) { + if (mouse_close_dialog && !h->fullscreen + && ((event->buttons & GPM_B_LEFT) != 0) && ((event->type & GPM_DOWN) != 0) /* left click */ + && !((x > h->x) && (x <= h->x + h->cols) && (y > h->y) && (y <= h->y + h->lines))) { h->ret_value = B_CANCEL; dlg_stop (h); return MOU_NORMAL; diff --git a/src/setup.c b/src/setup.c index 1033e9055..b8523246a 100644 --- a/src/setup.c +++ b/src/setup.c @@ -178,6 +178,7 @@ static const struct { { "confirm_view_dir", &confirm_view_dir }, { "mouse_move_pages", &mouse_move_pages }, { "mouse_move_pages_viewer", &mouse_move_pages_viewer }, + { "mouse_close_dialog", &mouse_close_dialog}, { "fast_refresh", &fast_refresh }, { "navigate_with_arrows", &navigate_with_arrows }, { "drop_menus", &drop_menus }, diff --git a/src/setup.h b/src/setup.h index 855e0ba96..5f6442663 100644 --- a/src/setup.h +++ b/src/setup.h @@ -31,6 +31,8 @@ extern int startup_left_mode; extern int startup_right_mode; extern int verbose; +extern int mouse_close_dialog; + #define PROFILE_NAME ".mc/ini" #define HOTLIST_FILENAME ".mc/hotlist"