From f400c14f9b48de7963648df22116973ec83dc82f Mon Sep 17 00:00:00 2001 From: Jinhao Date: Fri, 2 Sep 2016 07:45:47 +0800 Subject: [PATCH] fix mouse_wheel issue on Linux --- source/gui/detail/bedrock_posix.cpp | 30 +++++++++++++++++---------- source/gui/detail/bedrock_windows.cpp | 5 ----- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/source/gui/detail/bedrock_posix.cpp b/source/gui/detail/bedrock_posix.cpp index c959b01c..26de1dbc 100644 --- a/source/gui/detail/bedrock_posix.cpp +++ b/source/gui/detail/bedrock_posix.cpp @@ -626,30 +626,38 @@ namespace detail if(pressed_wd_space) break; + msgwnd = wd_manager.find_window(native_window, xevent.xbutton.x, xevent.xbutton.y); + if(nullptr == msgwnd) + break; + if(xevent.xbutton.button == Button4 || xevent.xbutton.button == Button5) { //The hovered window receives the message, unlike in Windows, no redirection is required. - nana::point mspos{xevent.xbutton.x, xevent.xbutton.y}; - while(msgwnd) + auto evt_wd = msgwnd; + while(evt_wd) { - if(msgwnd->annex.events_ptr->mouse_wheel.length() != 0) + if(evt_wd->annex.events_ptr->mouse_wheel.length() != 0) { - mspos -= msgwnd->pos_root; arg_wheel arg; arg.which = arg_wheel::wheel::vertical; - assign_arg(arg, msgwnd, xevent); - brock.emit(event_code::mouse_wheel, msgwnd, arg, true, &context); + assign_arg(arg, evt_wd, xevent); + brock.emit(event_code::mouse_wheel, evt_wd, arg, true, &context); break; } - msgwnd = msgwnd->parent; + evt_wd = evt_wd->parent; + } + + if(msgwnd && (nullptr == evt_wd)) + { + arg_wheel arg; + arg.which = arg_wheel::wheel::vertical; + assign_arg(arg, msgwnd, xevent); + draw_invoker(&drawer::mouse_wheel, msgwnd, arg, &context); + wd_manager.do_lazy_refresh(msgwnd, false); } } else { - msgwnd = wd_manager.find_window(native_window, xevent.xbutton.x, xevent.xbutton.y); - if(nullptr == msgwnd) - break; - msgwnd->set_action(mouse_action::normal); if(msgwnd->flags.enabled) { diff --git a/source/gui/detail/bedrock_windows.cpp b/source/gui/detail/bedrock_windows.cpp index d6019428..300866f0 100644 --- a/source/gui/detail/bedrock_windows.cpp +++ b/source/gui/detail/bedrock_windows.cpp @@ -1124,8 +1124,6 @@ namespace detail if (evt_wd->annex.events_ptr->mouse_wheel.length() != 0) { def_window_proc = false; - nana::point mspos{ scr_pos.x, scr_pos.y }; - wd_manager.calc_window_point(evt_wd, mspos); arg_wheel arg; arg.which = (WM_MOUSEHWHEEL == message ? arg_wheel::wheel::horizontal : arg_wheel::wheel::vertical); @@ -1138,9 +1136,6 @@ namespace detail if (scrolled_wd && (nullptr == evt_wd)) { - nana::point mspos{ scr_pos.x, scr_pos.y }; - wd_manager.calc_window_point(scrolled_wd, mspos); - arg_wheel arg; arg.which = (WM_MOUSEHWHEEL == message ? arg_wheel::wheel::horizontal : arg_wheel::wheel::vertical); assign_arg(arg, scrolled_wd, pmdec);