implement key_press support for menu in Linux

This commit is contained in:
Jinhao
2017-02-10 08:09:08 +08:00
parent 7a32fa2767
commit 4e42c18815
6 changed files with 42 additions and 35 deletions

View File

@@ -1147,7 +1147,7 @@ namespace detail
}
}
void bedrock::pump_event(window modal_window, bool /*is_modal*/)
void bedrock::pump_event(window condition_wd, bool is_modal)
{
thread_context * context = open_thread_context();
if(0 == context->window_count)
@@ -1162,11 +1162,11 @@ namespace detail
auto & lock = wd_manager().internal_lock();
lock.revert();
native_window_type owner_native = 0;
native_window_type owner_native{};
core_window_t * owner = 0;
if(modal_window)
if(condition_wd && is_modal)
{
native_window_type modal = reinterpret_cast<core_window_t*>(modal_window)->root;
native_window_type modal = reinterpret_cast<core_window_t*>(condition_wd)->root;
owner_native = native_interface::get_owner_window(modal);
if(owner_native)
{
@@ -1177,7 +1177,7 @@ namespace detail
}
}
nana::detail::platform_spec::instance().msg_dispatch(modal_window ? reinterpret_cast<core_window_t*>(modal_window)->root : 0);
nana::detail::platform_spec::instance().msg_dispatch(condition_wd ? reinterpret_cast<core_window_t*>(condition_wd)->root : 0);
if(owner_native)
{
@@ -1190,7 +1190,7 @@ namespace detail
if(0 == --(context->event_pump_ref_count))
{
if(0 == modal_window || 0 == context->window_count)
if(0 == condition_wd || 0 == context->window_count)
remove_thread_context();
}

View File

@@ -345,7 +345,7 @@ namespace detail
}
}
void bedrock::pump_event(window modal_window, bool is_modal)
void bedrock::pump_event(window condition_wd, bool is_modal)
{
const unsigned tid = ::GetCurrentThreadId();
auto context = this->open_thread_context(tid);
@@ -365,9 +365,9 @@ namespace detail
try
{
MSG msg;
if(modal_window)
if (condition_wd)
{
HWND native_handle = reinterpret_cast<HWND>(reinterpret_cast<core_window_t*>(modal_window)->root);
HWND native_handle = reinterpret_cast<HWND>(reinterpret_cast<core_window_t*>(condition_wd)->root);
if (is_modal)
{
HWND owner = ::GetWindow(native_handle, GW_OWNER);
@@ -437,27 +437,27 @@ namespace detail
}
catch(std::exception& e)
{
(msgbox(modal_window, "An uncaptured std::exception during message pumping: ").icon(msgbox::icon_information)
<<"\n in form: "<< API::window_caption(modal_window)
<<"\n exception : "<< e.what()
).show();
(msgbox(condition_wd, "An uncaptured std::exception during message pumping: ").icon(msgbox::icon_information)
<< "\n in form: " << API::window_caption(condition_wd)
<<"\n exception : "<< e.what()
).show();
internal_scope_guard lock;
_m_except_handler();
internal_scope_guard lock;
_m_except_handler();
intr_locker.forward();
if (0 == --(context->event_pump_ref_count))
{
if ((nullptr == modal_window) || (0 == context->window_count))
remove_thread_context();
}
throw;
intr_locker.forward();
if (0 == --(context->event_pump_ref_count))
{
if ((nullptr == condition_wd) || (0 == context->window_count))
remove_thread_context();
}
throw;
}
catch(...)
{
(msgbox(modal_window, "An exception during message pumping!").icon(msgbox::icon_information)
(msgbox(condition_wd, "An exception during message pumping!").icon(msgbox::icon_information)
<<"An uncaptured non-std exception during message pumping!"
<< "\n in form: " << API::window_caption(modal_window)
<< "\n in form: " << API::window_caption(condition_wd)
).show();
internal_scope_guard lock;
_m_except_handler();
@@ -465,7 +465,7 @@ namespace detail
intr_locker.forward();
if(0 == --(context->event_pump_ref_count))
{
if((nullptr == modal_window) || (0 == context->window_count))
if ((nullptr == condition_wd) || (0 == context->window_count))
remove_thread_context();
}
throw;
@@ -474,7 +474,7 @@ namespace detail
intr_locker.forward();
if(0 == --(context->event_pump_ref_count))
{
if((nullptr == modal_window) || (0 == context->window_count))
if ((nullptr == condition_wd) || (0 == context->window_count))
remove_thread_context();
}
}//end pump_event

View File

@@ -747,7 +747,7 @@ namespace nana
//add a is_wd_parent_menu to determine whether the menu wants the focus.
//if a submenu gets the focus, the program may cause a crash error when the submenu is being destroyed
: base_type(wd, false, rectangle(pos, nana::size(2, 2)), appear::bald<appear::floating>()),
want_focus_{ (!wd) || ((!is_wd_parent_menu) && (API::focus_window() != wd)) },
want_focus_{ (!wd) || ((!is_wd_parent_menu) && (API::root(API::focus_window()) != API::root(wd))) },
event_focus_{ nullptr }
{
caption("nana menu window");