From 04294b2bff23656eb3b7468095b90c4401419810 Mon Sep 17 00:00:00 2001
From: Mooffie <mooffie@gmail.com>
Date: Tue, 8 Mar 2016 22:45:17 +0200
Subject: [PATCH] !!experimental!! Fix menu handling.
---
lib/widget/dialog.c | 36 +++++++++++++++++++++---------------
src/filemanager/midnight.c | 28 +---------------------------
2 files changed, 22 insertions(+), 42 deletions(-)
diff --git a/lib/widget/dialog.c b/lib/widget/dialog.c
index ddf78f7..4601bcb 100644
a
|
b
|
dlg_mouse_translator (Gpm_Event * event, Widget * w) |
376 | 376 | /* --------------------------------------------------------------------------------------------- */ |
377 | 377 | |
378 | 378 | static cb_ret_t |
| 379 | try_mouse_event (Widget * w, Gpm_Event * event) |
| 380 | { |
| 381 | if ((w->options & W_DISABLED) == 0 && w->mouse_callback != NULL) |
| 382 | return dlg_mouse_translator (event, w); |
| 383 | return MSG_NOT_HANDLED; |
| 384 | } |
| 385 | |
| 386 | static cb_ret_t |
379 | 387 | dlg_mouse_event (WDialog * h, Gpm_Event * event) |
380 | 388 | { |
381 | 389 | Widget *wh = WIDGET (h); |
382 | | |
383 | | GList *p, *first; |
| 390 | GList *p; |
| 391 | cb_ret_t ret; |
384 | 392 | |
385 | 393 | /* close the dialog by mouse left click out of dialog area */ |
386 | 394 | if (mouse_close_dialog && !h->fullscreen && ((event->buttons & GPM_B_LEFT) != 0) |
… |
… |
dlg_mouse_event (WDialog * h, Gpm_Event * event) |
400 | 408 | return mou; |
401 | 409 | } |
402 | 410 | |
403 | | first = h->current; |
404 | | p = first; |
| 411 | /* First, send the event to the focused widget. */ |
| 412 | /* FIXME: This is just for the case where it's the menu. We can instead make |
| 413 | the menu make itself the topmost, on activation, and then remove this code. */ |
| 414 | if ((ret = try_mouse_event (WIDGET (h->current->data), event)) != MSG_NOT_HANDLED) |
| 415 | return ret; |
405 | 416 | |
| 417 | /* Send the event to widgets in stacking order: from the topmost to the bottomost. */ |
| 418 | p = g_list_last (h->widgets); |
406 | 419 | do |
407 | 420 | { |
408 | 421 | Widget *w = WIDGET (p->data); |
409 | 422 | |
410 | | p = dlg_widget_prev (h, p); |
| 423 | if ((ret = try_mouse_event (w, event)) != MSG_NOT_HANDLED) |
| 424 | return ret; |
411 | 425 | |
412 | | if ((w->options & W_DISABLED) == 0 && w->mouse_callback != NULL) |
413 | | { |
414 | | /* put global cursor position to the widget */ |
415 | | cb_ret_t ret; |
416 | | |
417 | | ret = dlg_mouse_translator (event, w); |
418 | | if (ret != MSG_NOT_HANDLED) |
419 | | return ret; |
420 | | } |
| 426 | p = g_list_previous (p); |
421 | 427 | } |
422 | | while (p != first); |
| 428 | while (p != NULL); |
423 | 429 | |
424 | 430 | return MSG_NOT_HANDLED; |
425 | 431 | } |
diff --git a/src/filemanager/midnight.c b/src/filemanager/midnight.c
index 73dfff5..e0a284d 100644
a
|
b
|
midnight_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void |
1590 | 1590 | } |
1591 | 1591 | |
1592 | 1592 | /* --------------------------------------------------------------------------------------------- */ |
1593 | | |
1594 | | /** |
1595 | | * Handle mouse events of file manager screen. |
1596 | | * |
1597 | | * @param w Widget object (the file manager) |
1598 | | * @param msg mouse event message |
1599 | | * @param event mouse event data |
1600 | | */ |
1601 | | static cb_ret_t |
1602 | | midnight_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event) |
1603 | | { |
1604 | | (void) w; |
1605 | | (void) msg; |
1606 | | |
1607 | | if (msg == MSG_MOUSE_DOWN && event->y == 0) |
1608 | | { |
1609 | | /* menubar */ |
1610 | | if (!the_menubar->is_active) |
1611 | | dlg_select_widget (WIDGET (the_menubar)); |
1612 | | } |
1613 | | |
1614 | | /* allow handle menu events */ |
1615 | | return MSG_NOT_HANDLED; |
1616 | | } |
1617 | | |
1618 | | /* --------------------------------------------------------------------------------------------- */ |
1619 | 1593 | /*** public functions ****************************************************************************/ |
1620 | 1594 | /* --------------------------------------------------------------------------------------------- */ |
1621 | 1595 | |
… |
… |
do_nc (void) |
1798 | 1772 | #endif |
1799 | 1773 | |
1800 | 1774 | midnight_dlg = dlg_create (FALSE, 0, 0, LINES, COLS, dialog_colors, midnight_callback, |
1801 | | midnight_mouse_callback, "[main]", NULL, DLG_NONE); |
| 1775 | NULL, "[main]", NULL, DLG_NONE); |
1802 | 1776 | |
1803 | 1777 | /* Check if we were invoked as an editor or file viewer */ |
1804 | 1778 | if (mc_global.mc_run_mode != MC_RUN_FULL) |