(menubar_callback): refactoring of menu draw after get focus and resize.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2016-06-11 17:01:13 +03:00
parent 41144d619c
commit 3debdac657

View File

@ -573,6 +573,25 @@ menubar_handle_key (WMenuBar * menubar, int key)
/* --------------------------------------------------------------------------------------------- */
static cb_ret_t
menubar_refresh (WMenuBar * menubar)
{
Widget *w = WIDGET (menubar);
if (!menubar->is_active)
return MSG_NOT_HANDLED;
/* Trick to get all the mouse events */
w->lines = LINES;
/* Trick to get all of the hotkeys */
widget_want_hotkey (w, TRUE);
menubar_draw (menubar);
return MSG_HANDLED;
}
/* --------------------------------------------------------------------------------------------- */
static cb_ret_t
menubar_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
{
@ -582,16 +601,10 @@ menubar_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void
{
/* We do not want the focus unless we have been activated */
case MSG_FOCUS:
if (!menubar->is_active)
return MSG_NOT_HANDLED;
return menubar_refresh (menubar);
/* Trick to get all the mouse events */
w->lines = LINES;
/* Trick to get all of the hotkeys */
widget_want_hotkey (w, TRUE);
menubar_draw (menubar);
return MSG_HANDLED;
case MSG_UNFOCUS:
return menubar->is_active ? MSG_NOT_HANDLED : MSG_HANDLED;
/* We don't want the buttonbar to activate while using the menubar */
case MSG_HOTKEY:
@ -607,23 +620,18 @@ menubar_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void
/* Put the cursor in a suitable place */
return MSG_NOT_HANDLED;
case MSG_UNFOCUS:
return menubar->is_active ? MSG_NOT_HANDLED : MSG_HANDLED;
case MSG_DRAW:
if (menubar->is_visible)
{
menubar_draw (menubar);
return MSG_HANDLED;
}
/* fall through */
else
menubar_refresh (menubar);
return MSG_HANDLED;
case MSG_RESIZE:
/* try show menu after screen resize */
send_message (w, sender, MSG_FOCUS, 0, data);
menubar_refresh (menubar);
return MSG_HANDLED;
case MSG_DESTROY:
menubar_set_menu (menubar, NULL);
return MSG_HANDLED;