From 8490ca7be4b19e2d3f26d431e9f14638d790a57e Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Sun, 6 Mar 2016 09:44:16 +0300 Subject: [PATCH] Drop old mouse API and use the new one. Signed-off-by: Andrew Borodin --- lib/tty/mouse.h | 3 -- lib/widget/button.c | 3 +- lib/widget/buttonbar.c | 3 +- lib/widget/check.c | 3 +- lib/widget/dialog.c | 37 +++++++++++++++------- lib/widget/dialog.h | 3 +- lib/widget/input.c | 3 +- lib/widget/listbox.c | 3 +- lib/widget/menu.c | 5 ++- lib/widget/mouse.c | 77 ++++++++++++---------------------------------- lib/widget/mouse.h | 6 ---- lib/widget/quick.c | 8 ++--- lib/widget/quick.h | 2 +- lib/widget/radio.c | 3 +- lib/widget/widget-common.c | 11 ++++--- lib/widget/widget-common.h | 15 ++++----- src/diffviewer/ydiff.c | 3 +- src/editor/editwidget.c | 13 ++++---- src/filemanager/panel.c | 3 +- src/filemanager/tree.c | 3 +- src/help.c | 3 +- src/viewer/mcviewer.c | 3 +- 22 files changed, 84 insertions(+), 129 deletions(-) diff --git a/lib/tty/mouse.h b/lib/tty/mouse.h index 5f82da795..99d0a69a2 100644 --- a/lib/tty/mouse.h +++ b/lib/tty/mouse.h @@ -89,9 +89,6 @@ typedef struct Gpm_Event } Gpm_Event; #endif /* !HAVE_LIBGPM */ -/* Mouse callback */ -typedef int (*mouse_h) (Gpm_Event *, void *); - /*** global variables defined in .c file *********************************************************/ /* Type of the currently used mouse */ diff --git a/lib/widget/button.c b/lib/widget/button.c index f660bac01..97c2bf144 100644 --- a/lib/widget/button.c +++ b/lib/widget/button.c @@ -210,8 +210,7 @@ button_new (int y, int x, int action, button_flags_t flags, const char *text, bc b->action = action; b->flags = flags; b->text = parse_hotkey (text); - widget_init (w, y, x, 1, button_get_len (b), button_callback, NULL); - set_easy_mouse_callback (w, button_mouse_callback); + widget_init (w, y, x, 1, button_get_len (b), button_callback, button_mouse_callback); b->selected = FALSE; b->callback = callback; widget_want_hotkey (w, TRUE); diff --git a/lib/widget/buttonbar.c b/lib/widget/buttonbar.c index c9be271d3..d15b9fc47 100644 --- a/lib/widget/buttonbar.c +++ b/lib/widget/buttonbar.c @@ -248,8 +248,7 @@ buttonbar_new (gboolean visible) bb = g_new0 (WButtonBar, 1); w = WIDGET (bb); - widget_init (w, LINES - 1, 0, 1, COLS, buttonbar_callback, NULL); - set_easy_mouse_callback (w, buttonbar_mouse_callback); + widget_init (w, LINES - 1, 0, 1, COLS, buttonbar_callback, buttonbar_mouse_callback); w->pos_flags = WPOS_KEEP_HORZ | WPOS_KEEP_BOTTOM; bb->visible = visible; diff --git a/lib/widget/check.c b/lib/widget/check.c index 98cb69748..fc3b69e67 100644 --- a/lib/widget/check.c +++ b/lib/widget/check.c @@ -138,8 +138,7 @@ check_new (int y, int x, int state, const char *text) w = WIDGET (c); c->text = parse_hotkey (text); /* 4 is width of "[X] " */ - widget_init (w, y, x, 1, 4 + hotkey_width (c->text), check_callback, NULL); - set_easy_mouse_callback (w, check_mouse_callback); + widget_init (w, y, x, 1, 4 + hotkey_width (c->text), check_callback, check_mouse_callback); c->state = state ? C_BOOL : 0; widget_want_hotkey (w, TRUE); diff --git a/lib/widget/dialog.c b/lib/widget/dialog.c index 1677a7047..8fa00fc10 100644 --- a/lib/widget/dialog.c +++ b/lib/widget/dialog.c @@ -40,10 +40,12 @@ #include "lib/skin.h" #include "lib/tty/key.h" #include "lib/strutil.h" -#include "lib/widget.h" #include "lib/fileloc.h" /* MC_HISTORY_FILE */ #include "lib/event.h" /* mc_event_raise() */ +#include "lib/widget.h" +#include "lib/widget/mouse.h" + /*** global variables ****************************************************************************/ /* Color styles for normal and error dialogs */ @@ -356,6 +358,22 @@ dlg_handle_key (WDialog * h, int d_key) } /* --------------------------------------------------------------------------------------------- */ +/** + * This is the low-level mouse handler. + * It receives a Gpm_Event event and translates it into a higher level protocol. + */ +static int +dlg_mouse_translator (Gpm_Event * event, Widget * w) +{ + gboolean run_click; + mouse_event_t me; + + me = mouse_translate_event (w, event, &run_click); + + return mouse_process_event (w, &me, run_click); +} + +/* --------------------------------------------------------------------------------------------- */ static int dlg_mouse_event (WDialog * h, Gpm_Event * event) @@ -373,11 +391,11 @@ dlg_mouse_event (WDialog * h, Gpm_Event * event) return MOU_NORMAL; } - if (wh->mouse != NULL) + if (wh->mouse_callback != NULL) { int mou; - mou = wh->mouse (event, wh); + mou = dlg_mouse_translator (event, wh); if (mou != MOU_UNHANDLED) return mou; } @@ -388,12 +406,12 @@ dlg_mouse_event (WDialog * h, Gpm_Event * event) { Widget *w = WIDGET (p->data); - if ((w->options & W_DISABLED) == 0 && w->mouse != NULL) + if ((w->options & W_DISABLED) == 0 && w->mouse_callback != NULL) { /* put global cursor position to the widget */ int ret; - ret = w->mouse (event, w); + ret = dlg_mouse_translator (event, w); if (ret != MOU_UNHANDLED) return ret; } @@ -771,7 +789,7 @@ dlg_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, v WDialog * dlg_create (gboolean modal, int y1, int x1, int lines, int cols, - const int *colors, widget_cb_fn callback, mouse_h mouse_handler, + const int *colors, widget_cb_fn callback, widget_mouse_cb_fn mouse_callback, const char *help_ctx, const char *title, dlg_flags_t flags) { WDialog *new_d; @@ -780,7 +798,7 @@ dlg_create (gboolean modal, int y1, int x1, int lines, int cols, new_d = g_new0 (WDialog, 1); w = WIDGET (new_d); widget_init (w, y1, x1, lines, cols, (callback != NULL) ? callback : dlg_default_callback, - mouse_handler); + mouse_callback); widget_want_cursor (w, FALSE); new_d->state = DLG_CONSTRUCT; @@ -1245,11 +1263,8 @@ dlg_process_event (WDialog * h, int key, Gpm_Event * event) if (tty_got_interrupt ()) if (send_message (h, NULL, MSG_ACTION, CK_Cancel, NULL) != MSG_HANDLED) dlg_execute_cmd (h, CK_Cancel); - - return; } - - if (key == EV_MOUSE) + else if (key == EV_MOUSE) h->mouse_status = dlg_mouse_event (h, event); else dlg_key_event (h, key); diff --git a/lib/widget/dialog.h b/lib/widget/dialog.h index 25b672db7..6ff23d809 100644 --- a/lib/widget/dialog.h +++ b/lib/widget/dialog.h @@ -14,7 +14,6 @@ #include "lib/global.h" #include "lib/hook.h" /* hook_t */ #include "lib/keybind.h" /* global_keymap_t */ -#include "lib/tty/mouse.h" /* mouse_h */ /*** typedefs(not structures) and defined constants **********************************************/ @@ -128,7 +127,7 @@ extern const global_keymap_t *dialog_map; /* Creates a dialog head */ WDialog *dlg_create (gboolean modal, int y1, int x1, int lines, int cols, - const int *colors, widget_cb_fn callback, mouse_h mouse_handler, + const int *colors, widget_cb_fn callback, widget_mouse_cb_fn mouse_callback, const char *help_ctx, const char *title, dlg_flags_t flags); void dlg_set_default_colors (void); diff --git a/lib/widget/input.c b/lib/widget/input.c index d6280dd66..2b2cdc37f 100644 --- a/lib/widget/input.c +++ b/lib/widget/input.c @@ -1009,8 +1009,7 @@ input_new (int y, int x, const int *colors, int width, const char *def_text, in = g_new (WInput, 1); w = WIDGET (in); - widget_init (w, y, x, 1, width, input_callback, NULL); - set_easy_mouse_callback (w, input_mouse_callback); + widget_init (w, y, x, 1, width, input_callback, input_mouse_callback); w->options |= W_IS_INPUT; w->set_options = input_set_options_callback; diff --git a/lib/widget/listbox.c b/lib/widget/listbox.c index c68fd1d2f..95e2b8f27 100644 --- a/lib/widget/listbox.c +++ b/lib/widget/listbox.c @@ -551,8 +551,7 @@ listbox_new (int y, int x, int height, int width, gboolean deletable, lcback_fn l = g_new (WListbox, 1); w = WIDGET (l); - widget_init (w, y, x, height, width, listbox_callback, NULL); - set_easy_mouse_callback (w, listbox_mouse_callback); + widget_init (w, y, x, height, width, listbox_callback, listbox_mouse_callback); l->list = NULL; l->top = l->pos = 0; diff --git a/lib/widget/menu.c b/lib/widget/menu.c index 2cbe96a16..d5d609a0f 100644 --- a/lib/widget/menu.c +++ b/lib/widget/menu.c @@ -743,7 +743,7 @@ menubar_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event) * touched by us. We should think of some other way of communicating * this to the system. */ - w->Mouse.capture = FALSE; + w->mouse.capture = FALSE; } break; @@ -891,8 +891,7 @@ menubar_new (int y, int x, int cols, GList * menu, gboolean visible) menubar = g_new0 (WMenuBar, 1); w = WIDGET (menubar); - widget_init (w, y, x, 1, cols, menubar_callback, NULL); - set_easy_mouse_callback (w, menubar_mouse_callback); + widget_init (w, y, x, 1, cols, menubar_callback, menubar_mouse_callback); menubar->is_visible = visible; widget_want_cursor (w, FALSE); diff --git a/lib/widget/mouse.c b/lib/widget/mouse.c index 76f10db7c..6e63a8767 100644 --- a/lib/widget/mouse.c +++ b/lib/widget/mouse.c @@ -42,16 +42,19 @@ /*** file scope variables ************************************************************************/ -static int last_buttons_down; -static gboolean was_drag = FALSE; - /* --------------------------------------------------------------------------------------------- */ /*** file scope functions ************************************************************************/ /* --------------------------------------------------------------------------------------------- */ /** - * Constructs a mouse event structure. The is the high-level type used - * with "easy callbacks". + * Constructs a mouse event structure. + * + * It receives a Gpm_Event event and translates it into a higher level protocol. + * + * Tip: for details on the C mouse API, see MC's lib/tty/mouse.h, + * or GPM's excellent 'info' manual: + * + * http://www.fifi.org/cgi-bin/info2www?(gpm)Event+Types */ static void init_mouse_event (mouse_event_t * event, mouse_msg_t msg, const Gpm_Event * global_gpm, @@ -67,52 +70,10 @@ init_mouse_event (mouse_event_t * event, mouse_msg_t msg, const Gpm_Event * glob } /* --------------------------------------------------------------------------------------------- */ - -/** - * This is the low-level mouse handler that's in use when you install - * an "easy callback". - * - * It receives a Gpm_Event event and translates it into a higher level - * protocol with which it feeds your "easy callback". - * - * Tip: for details on the C mouse API, see MC's lib/tty/mouse.h, - * or GPM's excellent 'info' manual: - * - * http://www.fifi.org/cgi-bin/info2www?(gpm)Event+Types - */ -static int -easy_mouse_translator (Gpm_Event * event, void *data) -{ - Widget *w = WIDGET (data); - gboolean run_click; - mouse_event_t me; - - me = mouse_translate_event (w, event, &run_click); - - return mouse_process_event (w, &me, run_click); -} - -/* --------------------------------------------------------------------------------------------- */ /*** public functions ****************************************************************************/ /* --------------------------------------------------------------------------------------------- */ /** - * Use this to install an "easy mouse callback". - * - * (The mouse callback widget_init() accepts is a low-level one; you can - * pass NULL to it. In the future we'll probably do the opposite: have - * widget_init() accept the "easy" callback.) - */ -void -set_easy_mouse_callback (Widget * w, easy_mouse_callback cb) -{ - w->mouse = easy_mouse_translator; - w->Mouse.callback = cb; -} - -/* --------------------------------------------------------------------------------------------- */ - -/** * Translate GPM event to high-level event, * * @param w Widget object @@ -134,7 +95,7 @@ mouse_translate_event (Widget * w, Gpm_Event * event, gboolean * click) * You'll also need, in your mouse handler, to inform the system of * events you want to pass on by setting 'event->result.abort' to TRUE. */ - in_widget = w->Mouse.forced_capture || mouse_global_in_widget (event, w); + in_widget = w->mouse.forced_capture || mouse_global_in_widget (event, w); *click = FALSE; @@ -154,10 +115,10 @@ mouse_translate_event (Widget * w, Gpm_Event * event, gboolean * click) * buttons doesn't make sense as they don't generate a * mouse_up event, which means we'd never get uncaptured.) */ - w->Mouse.capture = TRUE; + w->mouse.capture = TRUE; msg = MSG_MOUSE_DOWN; - last_buttons_down = event->buttons; + w->mouse.last_buttons_down = event->buttons; } } } @@ -166,13 +127,13 @@ mouse_translate_event (Widget * w, Gpm_Event * event, gboolean * click) /* We trigger the mouse_up event even when !in_widget. That's * because, for example, a paint application should stop drawing * lines when the button is released even outside the canvas. */ - if (w->Mouse.capture) + if (w->mouse.capture) { - w->Mouse.capture = FALSE; + w->mouse.capture = FALSE; msg = MSG_MOUSE_UP; if (in_widget) - *click = !was_drag; + *click = !w->mouse.was_drag; /* * When using xterm, event->buttons reports the buttons' state @@ -183,12 +144,12 @@ mouse_translate_event (Widget * w, Gpm_Event * event, gboolean * click) * The following makes xterm behave effectively like GPM: */ if (event->buttons == 0) - event->buttons = last_buttons_down; + event->buttons = w->mouse.last_buttons_down; } } else if ((event->type & GPM_DRAG) != 0) { - if (w->Mouse.capture) + if (w->mouse.capture) msg = MSG_MOUSE_DRAG; } else if ((event->type & GPM_MOVE) != 0) @@ -199,7 +160,7 @@ mouse_translate_event (Widget * w, Gpm_Event * event, gboolean * click) if (msg != MSG_MOUSE_NONE) /* Remember the current state for next event. */ - was_drag = ((event->type & GPM_DRAG) != 0); + w->mouse.was_drag = ((event->type & GPM_DRAG) != 0); init_mouse_event (&local, msg, event, w); @@ -224,9 +185,9 @@ mouse_process_event (Widget * w, mouse_event_t * event, gboolean click) if (event->msg != MSG_MOUSE_NONE) { - w->Mouse.callback (w, event->msg, event); + w->mouse_callback (w, event->msg, event); if (click) - w->Mouse.callback (w, MSG_MOUSE_CLICK, event); + w->mouse_callback (w, MSG_MOUSE_CLICK, event); if (!event->result.abort) ret = event->result.repeat ? MOU_REPEAT : MOU_NORMAL; diff --git a/lib/widget/mouse.h b/lib/widget/mouse.h index f2a4e2a1e..8cdd0e9fd 100644 --- a/lib/widget/mouse.h +++ b/lib/widget/mouse.h @@ -53,16 +53,10 @@ typedef struct /*** typedefs(not structures) and defined constants **********************************************/ -/* A callback to respond to mouse events. - * Note: We embed "easy" in it to distinguish it from the old-style callbacks we still use. */ -typedef void (*easy_mouse_callback) (Widget * w, mouse_msg_t msg, mouse_event_t * event); - /*** global variables defined in .c file *********************************************************/ /*** declarations of public functions ************************************************************/ -/* Installs an easy callback on a widget. */ -void set_easy_mouse_callback (Widget * w, easy_mouse_callback cb); /* Translate GPM event to high-level event */ mouse_event_t mouse_translate_event (Widget * w, Gpm_Event * event, gboolean * click); /* Process high-level mouse event */ diff --git a/lib/widget/quick.c b/lib/widget/quick.c index 09172ac5b..780aed87e 100644 --- a/lib/widget/quick.c +++ b/lib/widget/quick.c @@ -406,12 +406,12 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip) if (quick_dlg->x == -1 || quick_dlg->y == -1) dd = dlg_create (TRUE, 0, 0, y + 3, quick_dlg->cols, - dialog_colors, quick_dlg->callback, quick_dlg->mouse, quick_dlg->help, - quick_dlg->title, DLG_CENTER | DLG_TRYUP); + dialog_colors, quick_dlg->callback, quick_dlg->mouse_callback, + quick_dlg->help, quick_dlg->title, DLG_CENTER | DLG_TRYUP); else dd = dlg_create (TRUE, quick_dlg->y, quick_dlg->x, y + 3, quick_dlg->cols, - dialog_colors, quick_dlg->callback, quick_dlg->mouse, quick_dlg->help, - quick_dlg->title, DLG_NONE); + dialog_colors, quick_dlg->callback, quick_dlg->mouse_callback, + quick_dlg->help, quick_dlg->title, DLG_NONE); /* add widgets into the dialog */ x2 = x1 + width2 + 1; diff --git a/lib/widget/quick.h b/lib/widget/quick.h index 7c3d3362d..b588828fd 100644 --- a/lib/widget/quick.h +++ b/lib/widget/quick.h @@ -335,7 +335,7 @@ typedef struct const char *help; quick_widget_t *widgets; widget_cb_fn callback; - mouse_h mouse; + widget_mouse_cb_fn mouse_callback; } quick_dialog_t; /*** global variables defined in .c file *********************************************************/ diff --git a/lib/widget/radio.c b/lib/widget/radio.c index 2cff88e7f..7198b7e08 100644 --- a/lib/widget/radio.c +++ b/lib/widget/radio.c @@ -190,8 +190,7 @@ radio_new (int y, int x, int count, const char **texts) } /* 4 is width of "(*) " */ - widget_init (w, y, x, count, 4 + wmax, radio_callback, NULL); - set_easy_mouse_callback (w, radio_mouse_callback); + widget_init (w, y, x, count, 4 + wmax, radio_callback, radio_mouse_callback); r->state = 1; r->pos = 0; r->sel = 0; diff --git a/lib/widget/widget-common.c b/lib/widget/widget-common.c index ee8a208f6..a29181aa5 100644 --- a/lib/widget/widget-common.c +++ b/lib/widget/widget-common.c @@ -138,7 +138,7 @@ hotkey_draw (Widget * w, const hotkey_t hotkey, gboolean focused) void widget_init (Widget * w, int y, int x, int lines, int cols, - widget_cb_fn callback, mouse_h mouse_handler) + widget_cb_fn callback, widget_mouse_cb_fn mouse_callback) { w->x = x; w->y = y; @@ -146,12 +146,13 @@ widget_init (Widget * w, int y, int x, int lines, int cols, w->lines = lines; w->pos_flags = WPOS_KEEP_DEFAULT; w->callback = callback; - w->mouse = mouse_handler; + w->mouse_callback = mouse_callback; w->set_options = widget_default_set_options_callback; w->owner = NULL; - w->Mouse.callback = NULL; /* it will be overriden in set_easy_mouse_callback() */ - w->Mouse.capture = FALSE; - w->Mouse.forced_capture = FALSE; + w->mouse.capture = FALSE; + w->mouse.forced_capture = FALSE; + w->mouse.last_buttons_down = 0; + w->mouse.was_drag = FALSE; /* Almost all widgets want to put the cursor in a suitable place */ w->options = W_WANT_CURSOR; diff --git a/lib/widget/widget-common.h b/lib/widget/widget-common.h index 9419d5911..be524d1ff 100644 --- a/lib/widget/widget-common.h +++ b/lib/widget/widget-common.h @@ -7,7 +7,7 @@ #define MC__WIDGET_INTERNAL_H #include "lib/tty/mouse.h" -#include "lib/widget/mouse.h" /* typedef easy_mouse_callback */ +#include "lib/widget/mouse.h" /* mouse_msg_t, mouse_event_t */ /*** typedefs(not structures) and defined constants **********************************************/ @@ -94,6 +94,8 @@ typedef enum /* Widget callback */ typedef cb_ret_t (*widget_cb_fn) (Widget * widget, Widget * sender, widget_msg_t msg, int parm, void *data); +/* Widget mouse callback */ +typedef void (*widget_mouse_cb_fn) (Widget * w, mouse_msg_t msg, mouse_event_t * event); /* Every Widget must have this as its first element */ struct Widget @@ -104,18 +106,17 @@ struct Widget widget_pos_flags_t pos_flags; /* repositioning flags */ unsigned int id; /* Number of the widget, starting with 0 */ widget_cb_fn callback; - mouse_h mouse; + widget_mouse_cb_fn mouse_callback; void (*set_options) (Widget * w, widget_options_t options, gboolean enable); WDialog *owner; /* Mouse-related fields. */ struct { - easy_mouse_callback callback; gboolean capture; /* Whether the widget "owns" the mouse. */ gboolean forced_capture; /* Overrides the above. Set explicitly by the programmer. */ - } Mouse; - /* "Mouse" capitalized -- as we already have a lowercase "mouse" here. - * @FIXME: rename "mouse" to something else. */ + int last_buttons_down; + gboolean was_drag; + } mouse; }; /* structure for label (caption) with hotkey, if original text does not contain @@ -144,7 +145,7 @@ void hotkey_draw (Widget * w, const hotkey_t hotkey, gboolean focused); /* widget initialization */ void widget_init (Widget * w, int y, int x, int lines, int cols, - widget_cb_fn callback, mouse_h mouse_handler); + widget_cb_fn callback, widget_mouse_cb_fn mouse_callback); /* Default callback for widgets */ cb_ret_t widget_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data); diff --git a/src/diffviewer/ydiff.c b/src/diffviewer/ydiff.c index 79a86c45e..8d8bfa5a1 100644 --- a/src/diffviewer/ydiff.c +++ b/src/diffviewer/ydiff.c @@ -3462,8 +3462,7 @@ diff_view (const char *file1, const char *file2, const char *label1, const char dview = g_new0 (WDiff, 1); w = WIDGET (dview); - widget_init (w, 0, 0, LINES - 1, COLS, dview_callback, NULL); - set_easy_mouse_callback (w, dview_mouse_callback); + widget_init (w, 0, 0, LINES - 1, COLS, dview_callback, dview_mouse_callback); widget_want_cursor (w, FALSE); add_widget (dview_dlg, dview); diff --git a/src/editor/editwidget.c b/src/editor/editwidget.c index 5facbeb5b..d60f03eca 100644 --- a/src/editor/editwidget.c +++ b/src/editor/editwidget.c @@ -214,7 +214,7 @@ edit_restore_size (WEdit * edit) Widget *w = WIDGET (edit); edit->drag_state = MCEDIT_DRAG_NONE; - w->Mouse.forced_capture = FALSE; + w->mouse.forced_capture = FALSE; widget_set_size (w, edit->y_prev, edit->x_prev, edit->lines_prev, edit->cols_prev); dlg_redraw (w->owner); } @@ -1220,9 +1220,8 @@ edit_files (const GList * files) /* Create a new dialog and add it widgets to it */ edit_dlg = - dlg_create (FALSE, 0, 0, LINES, COLS, NULL, edit_dialog_callback, NULL, - "[Internal File Editor]", NULL, DLG_WANT_TAB); - set_easy_mouse_callback (WIDGET (edit_dlg), edit_dialog_mouse_callback); + dlg_create (FALSE, 0, 0, LINES, COLS, NULL, edit_dialog_callback, + edit_dialog_mouse_callback, "[Internal File Editor]", NULL, DLG_WANT_TAB); edit_dlg->get_shortcut = edit_get_shortcut; edit_dlg->get_title = edit_get_title; @@ -1355,7 +1354,7 @@ edit_add_window (WDialog * h, int y, int x, int lines, int cols, const vfs_path_ w = WIDGET (edit); w->callback = edit_callback; - set_easy_mouse_callback (w, edit_mouse_callback); + w->mouse_callback = edit_mouse_callback; add_widget (h, w); dlg_redraw (h); @@ -1381,7 +1380,7 @@ edit_handle_move_resize (WEdit * edit, long command) if (edit->fullscreen) { edit->drag_state = MCEDIT_DRAG_NONE; - w->Mouse.forced_capture = FALSE; + w->mouse.forced_capture = FALSE; return ret; } @@ -1475,7 +1474,7 @@ edit_handle_move_resize (WEdit * edit, long command) * "Anywhere" means: inside or outside the window. We make this happen * with the 'forced_capture' flag. */ - w->Mouse.forced_capture = (edit->drag_state != MCEDIT_DRAG_NONE); + w->mouse.forced_capture = (edit->drag_state != MCEDIT_DRAG_NONE); return ret; } diff --git a/src/filemanager/panel.c b/src/filemanager/panel.c index f22d56290..a598a3f59 100644 --- a/src/filemanager/panel.c +++ b/src/filemanager/panel.c @@ -4257,8 +4257,7 @@ panel_new_with_dir (const char *panel_name, const vfs_path_t * vpath) panel = g_new0 (WPanel, 1); w = WIDGET (panel); /* No know sizes of the panel at startup */ - widget_init (w, 0, 0, 0, 0, panel_callback, NULL); - set_easy_mouse_callback (w, panel_mouse_callback); + widget_init (w, 0, 0, 0, 0, panel_callback, panel_mouse_callback); /* We do not want the cursor */ widget_want_cursor (w, FALSE); diff --git a/src/filemanager/tree.c b/src/filemanager/tree.c index eaf2b7b08..44b96447b 100644 --- a/src/filemanager/tree.c +++ b/src/filemanager/tree.c @@ -1279,8 +1279,7 @@ tree_new (int y, int x, int lines, int cols, gboolean is_panel) tree = g_new (WTree, 1); w = WIDGET (tree); - widget_init (w, y, x, lines, cols, tree_callback, NULL); - set_easy_mouse_callback (w, tree_mouse_callback); + widget_init (w, y, x, lines, cols, tree_callback, tree_mouse_callback); tree->is_panel = is_panel; tree->selected_ptr = 0; diff --git a/src/help.c b/src/help.c index fcb5d3dae..e29d619b8 100644 --- a/src/help.c +++ b/src/help.c @@ -1022,8 +1022,7 @@ mousedispatch_new (int y, int x, int yl, int xl) Widget *w; w = g_new0 (Widget, 1); - widget_init (w, y, x, yl, xl, md_callback, NULL); - set_easy_mouse_callback (w, help_mouse_callback); + widget_init (w, y, x, yl, xl, md_callback, help_mouse_callback); return w; } diff --git a/src/viewer/mcviewer.c b/src/viewer/mcviewer.c index f5c08304b..b327dcaec 100644 --- a/src/viewer/mcviewer.c +++ b/src/viewer/mcviewer.c @@ -192,8 +192,7 @@ mcview_new (int y, int x, int lines, int cols, gboolean is_panel) WView *view; view = g_new0 (WView, 1); - widget_init (WIDGET (view), y, x, lines, cols, mcview_callback, NULL); - set_easy_mouse_callback (WIDGET (view), mcview_mouse_callback); + widget_init (WIDGET (view), y, x, lines, cols, mcview_callback, mcview_mouse_callback); view->hex_mode = FALSE; view->hexedit_mode = FALSE; -- 2.11.4.GIT