improve window manager refresh process
This commit is contained in:
@@ -346,6 +346,12 @@ namespace nana
|
||||
return anc;
|
||||
}
|
||||
|
||||
void basic_window::set_action(mouse_action act)
|
||||
{
|
||||
flags.action_before = flags.action;
|
||||
flags.action = act;
|
||||
}
|
||||
|
||||
void basic_window::_m_init_pos_and_size(basic_window* parent, const rectangle& r)
|
||||
{
|
||||
pos_owner = pos_root = r;
|
||||
@@ -390,6 +396,8 @@ namespace nana
|
||||
flags.fullscreen = false;
|
||||
flags.tab = nana::detail::tab_type::none;
|
||||
flags.action = mouse_action::normal;
|
||||
flags.action_before = mouse_action::normal;
|
||||
|
||||
flags.refreshing = false;
|
||||
flags.destroying = false;
|
||||
flags.borderless = false;
|
||||
|
||||
@@ -165,8 +165,7 @@ namespace nana
|
||||
arg.window_handle = reinterpret_cast<window>(wd);
|
||||
arg.x = x;
|
||||
arg.y = y;
|
||||
if (emit(event_code::move, wd, arg, false, get_thread_context()))
|
||||
wd_manager().update(wd, false, true);
|
||||
emit(event_code::move, wd, arg, true, get_thread_context());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +173,7 @@ namespace nana
|
||||
{
|
||||
if (wd_manager().available(hovered) && hovered->flags.enabled)
|
||||
{
|
||||
hovered->flags.action = mouse_action::normal;
|
||||
hovered->set_action(mouse_action::normal);
|
||||
|
||||
arg_mouse arg;
|
||||
arg.evt_code = event_code::mouse_leave;
|
||||
@@ -203,7 +202,7 @@ namespace nana
|
||||
if (root_wd->flags.enabled && root_wd->flags.take_active)
|
||||
{
|
||||
if (focused && focused->together.caret)
|
||||
focused->together.caret->set_active(false);
|
||||
focused->together.caret->set_active(true);
|
||||
|
||||
if (!emit(event_code::focus, focused, arg, true, get_thread_context()))
|
||||
this->wd_manager().set_focus(root_wd, true, arg_focus::reason::general);
|
||||
|
||||
@@ -515,7 +515,8 @@ namespace detail
|
||||
if(msgwnd)
|
||||
{
|
||||
if (mouse_action::pressed != msgwnd->flags.action)
|
||||
msgwnd->flags.action = mouse_action::over;
|
||||
msgwnd->set_action(mouse_action::over);
|
||||
|
||||
hovered_wd = msgwnd;
|
||||
|
||||
arg_mouse arg;
|
||||
@@ -597,7 +598,8 @@ namespace detail
|
||||
context.event_window = msgwnd;
|
||||
|
||||
pressed_wd = nullptr;
|
||||
msgwnd->flags.action = mouse_action::pressed;
|
||||
|
||||
msgwnd->set_action(mouse_action::pressed);
|
||||
arg_mouse arg;
|
||||
assign_arg(arg, msgwnd, ButtonPress, xevent);
|
||||
arg.evt_code = dbl_click ? event_code::dbl_click : event_code::mouse_down;
|
||||
@@ -610,7 +612,7 @@ namespace detail
|
||||
if (msgwnd->root != native_interface::get_focus_window())
|
||||
{
|
||||
//call the drawer mouse up event for restoring the surface graphics
|
||||
msgwnd->flags.action = mouse_action::normal;
|
||||
msgwnd->set_action(mouse_action::normal);
|
||||
|
||||
draw_invoker(&drawer::mouse_up, msgwnd, arg, &context);
|
||||
wd_manager.do_lazy_refresh(msgwnd, false);
|
||||
@@ -648,7 +650,7 @@ namespace detail
|
||||
if(nullptr == msgwnd)
|
||||
break;
|
||||
|
||||
msgwnd->flags.action = mouse_action::normal;
|
||||
msgwnd->set_action(mouse_action::normal);
|
||||
if(msgwnd->flags.enabled)
|
||||
{
|
||||
auto retain = msgwnd->together.events_ptr;
|
||||
@@ -667,7 +669,7 @@ namespace detail
|
||||
{
|
||||
if((arg.button == ::nana::mouse::left_button) && hit)
|
||||
{
|
||||
msgwnd->flags.action = mouse_action::over;
|
||||
msgwnd->set_action(mouse_action::over);
|
||||
|
||||
click_arg.window_handle = reinterpret_cast<window>(msgwnd);
|
||||
draw_invoker(&drawer::click, msgwnd, click_arg, &context);
|
||||
@@ -678,7 +680,7 @@ namespace detail
|
||||
if(wd_manager.available(msgwnd) && msgwnd->flags.enabled)
|
||||
{
|
||||
if(hit)
|
||||
msgwnd->flags.action = mouse_action::over;
|
||||
msgwnd->set_action(mouse_action::over);
|
||||
|
||||
auto retain = msgwnd->together.events_ptr;
|
||||
auto evt_ptr = retain.get();
|
||||
@@ -740,7 +742,7 @@ namespace detail
|
||||
if (wd_manager.available(hovered_wd) && (msgwnd != hovered_wd))
|
||||
{
|
||||
brock.event_msleave(hovered_wd);
|
||||
hovered_wd->flags.action = mouse_action::normal;
|
||||
hovered_wd->set_action(mouse_action::normal);
|
||||
hovered_wd = nullptr;
|
||||
|
||||
//if msgwnd is neither a captured window nor a child of captured window,
|
||||
@@ -758,13 +760,13 @@ namespace detail
|
||||
if(prev_captured_inside)
|
||||
{
|
||||
evt_code = event_code::mouse_leave;
|
||||
msgwnd->flags.action = mouse_action::normal;
|
||||
msgwnd->set_action(mouse_action::normal);
|
||||
}
|
||||
else
|
||||
{
|
||||
evt_code = event_code::mouse_enter;
|
||||
if (mouse_action::pressed != msgwnd->flags.action)
|
||||
msgwnd->flags.action = mouse_action::over;
|
||||
msgwnd->set_action(mouse_action::over);
|
||||
}
|
||||
arg_mouse arg;
|
||||
assign_arg(arg, msgwnd, message, xevent);
|
||||
@@ -779,7 +781,7 @@ namespace detail
|
||||
assign_arg(arg, msgwnd, message, xevent);
|
||||
|
||||
if (mouse_action::pressed != msgwnd->flags.action)
|
||||
msgwnd->flags.action = mouse_action::over;
|
||||
msgwnd->set_action(mouse_action::over);
|
||||
|
||||
if (hovered_wd != msgwnd)
|
||||
{
|
||||
@@ -890,7 +892,7 @@ namespace detail
|
||||
arg.pos.y = 0;
|
||||
arg.window_handle = reinterpret_cast<window>(msgwnd);
|
||||
|
||||
msgwnd->flags.action = mouse_action::pressed;
|
||||
msgwnd->set_action(mouse_action::pressed);
|
||||
|
||||
pressed_wd_space = msgwnd;
|
||||
auto retain = msgwnd->together.events_ptr;
|
||||
@@ -1023,7 +1025,7 @@ namespace detail
|
||||
{
|
||||
if(msgwnd == pressed_wd_space)
|
||||
{
|
||||
msgwnd->flags.action = mouse_action::normal;
|
||||
msgwnd->set_action(mouse_action::normal);
|
||||
|
||||
arg_click click_arg;
|
||||
click_arg.mouse_args = nullptr;
|
||||
|
||||
@@ -945,7 +945,7 @@ namespace detail
|
||||
|
||||
arg_mouse arg;
|
||||
assign_arg(arg, msgwnd, message, pmdec);
|
||||
msgwnd->flags.action = mouse_action::pressed;
|
||||
msgwnd->set_action(mouse_action::pressed);
|
||||
|
||||
auto retain = msgwnd->together.events_ptr;
|
||||
if (brock.emit(event_code::mouse_down, msgwnd, arg, true, &context))
|
||||
@@ -959,7 +959,7 @@ namespace detail
|
||||
if(msgwnd != wd_manager.find_window(rootwd, pos.x, pos.y))
|
||||
{
|
||||
//call the drawer mouse up event for restoring the surface graphics
|
||||
msgwnd->flags.action = mouse_action::normal;
|
||||
msgwnd->set_action(mouse_action::normal);
|
||||
|
||||
arg.evt_code = event_code::mouse_up;
|
||||
draw_invoker(&drawer::mouse_up, msgwnd, arg, &context);
|
||||
@@ -983,7 +983,7 @@ namespace detail
|
||||
if(nullptr == msgwnd)
|
||||
break;
|
||||
|
||||
msgwnd->flags.action = mouse_action::normal;
|
||||
msgwnd->set_action(mouse_action::normal);
|
||||
if(msgwnd->flags.enabled)
|
||||
{
|
||||
auto retain = msgwnd->together.events_ptr;
|
||||
@@ -999,7 +999,7 @@ namespace detail
|
||||
|
||||
if (msgwnd->dimension.is_hit(arg.pos))
|
||||
{
|
||||
msgwnd->flags.action = mouse_action::over;
|
||||
msgwnd->set_action(mouse_action::over);
|
||||
if ((::nana::mouse::left_button == arg.button) && (pressed_wd == msgwnd))
|
||||
{
|
||||
click_arg.window_handle = reinterpret_cast<window>(msgwnd);
|
||||
@@ -1038,7 +1038,7 @@ namespace detail
|
||||
if (wd_manager.available(hovered_wd) && (msgwnd != hovered_wd))
|
||||
{
|
||||
brock.event_msleave(hovered_wd);
|
||||
hovered_wd->flags.action = mouse_action::normal;
|
||||
hovered_wd->set_action(mouse_action::normal);
|
||||
hovered_wd = nullptr;
|
||||
|
||||
//if msgwnd is neither captured window nor the child of captured window,
|
||||
@@ -1057,15 +1057,15 @@ namespace detail
|
||||
if(prev_captured_inside)
|
||||
{
|
||||
evt_code = event_code::mouse_leave;
|
||||
msgwnd->flags.action = mouse_action::normal;
|
||||
msgwnd->set_action(mouse_action::normal);
|
||||
}
|
||||
else
|
||||
{
|
||||
evt_code = event_code::mouse_enter;
|
||||
if (pressed_wd == msgwnd)
|
||||
msgwnd->flags.action = mouse_action::pressed;
|
||||
msgwnd->set_action(mouse_action::pressed);
|
||||
else if (mouse_action::pressed != msgwnd->flags.action)
|
||||
msgwnd->flags.action = mouse_action::over;
|
||||
msgwnd->set_action(mouse_action::over);
|
||||
}
|
||||
arg_mouse arg;
|
||||
assign_arg(arg, msgwnd, message, pmdec);
|
||||
@@ -1082,9 +1082,9 @@ namespace detail
|
||||
if (hovered_wd != msgwnd)
|
||||
{
|
||||
if (pressed_wd == msgwnd)
|
||||
msgwnd->flags.action = mouse_action::pressed;
|
||||
msgwnd->set_action(mouse_action::pressed);
|
||||
else if (mouse_action::pressed != msgwnd->flags.action)
|
||||
msgwnd->flags.action = mouse_action::over;
|
||||
msgwnd->set_action(mouse_action::over);
|
||||
|
||||
hovered_wd = msgwnd;
|
||||
arg.evt_code = event_code::mouse_enter;
|
||||
@@ -1419,7 +1419,7 @@ namespace detail
|
||||
arg.pos.y = 0;
|
||||
arg.window_handle = reinterpret_cast<window>(msgwnd);
|
||||
|
||||
msgwnd->flags.action = mouse_action::pressed;
|
||||
msgwnd->set_action(mouse_action::pressed);
|
||||
|
||||
pressed_wd_space = msgwnd;
|
||||
auto retain = msgwnd->together.events_ptr;
|
||||
@@ -1490,7 +1490,7 @@ namespace detail
|
||||
{
|
||||
if (msgwnd == pressed_wd_space)
|
||||
{
|
||||
msgwnd->flags.action = mouse_action::normal;
|
||||
msgwnd->set_action(mouse_action::normal);
|
||||
|
||||
arg_click click_arg;
|
||||
click_arg.mouse_args = nullptr;
|
||||
|
||||
@@ -245,9 +245,7 @@ namespace nana
|
||||
if(wd)
|
||||
{
|
||||
auto iwd = reinterpret_cast<bedrock_type::core_window_t*>(wd);
|
||||
auto caret_wd = iwd->root_widget->other.attribute.root->focus;
|
||||
|
||||
bool owns_caret = (caret_wd && (caret_wd->together.caret) && (caret_wd->together.caret->visible()));
|
||||
bool owns_caret = (iwd->together.caret) && (iwd->together.caret->visible());
|
||||
|
||||
//The caret in X11 is implemented by Nana, it is different from Windows'
|
||||
//the caret in X11 is asynchronous, it is hard to hide and show the caret
|
||||
@@ -256,7 +254,7 @@ namespace nana
|
||||
if(owns_caret)
|
||||
{
|
||||
#ifndef NANA_X11
|
||||
caret_wd->together.caret->visible(false);
|
||||
iwd->together.caret->visible(false);
|
||||
#else
|
||||
owns_caret = nana::detail::platform_spec::instance().caret_update(iwd->root, *iwd->root_graph, false);
|
||||
#endif
|
||||
@@ -267,7 +265,7 @@ namespace nana
|
||||
if(owns_caret)
|
||||
{
|
||||
#ifndef NANA_X11
|
||||
caret_wd->together.caret->visible(true);
|
||||
iwd->together.caret->visible(true);
|
||||
#else
|
||||
nana::detail::platform_spec::instance().caret_update(iwd->root, *iwd->root_graph, true);
|
||||
#endif
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace nana
|
||||
{
|
||||
//Test if the root widget is overlapped the specified widget
|
||||
//the pos of root widget is (0, 0)
|
||||
if (overlap(visual, rectangle{ wd->root_widget->pos_owner, wd->root_widget->dimension }) == false)
|
||||
if (overlapped(visual, rectangle{ wd->root_widget->pos_owner, wd->root_widget->dimension }) == false)
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -365,7 +365,7 @@ namespace nana
|
||||
for (auto wd : data_sect.effects_bground_windows)
|
||||
{
|
||||
if (wd == sigwd || !wd->displayed() ||
|
||||
(false == overlap(nana::rectangle{ wd->pos_root, wd->dimension }, r_of_sigwd)))
|
||||
(false == overlapped(nana::rectangle{ wd->pos_root, wd->dimension }, r_of_sigwd)))
|
||||
continue;
|
||||
|
||||
if (sigwd->parent == wd->parent)
|
||||
|
||||
@@ -845,13 +845,13 @@ namespace detail
|
||||
{
|
||||
window_layer::paint(wd, false, refresh_tree);
|
||||
this->map(wd, force_copy_to_screen);
|
||||
|
||||
wd->drawer.graphics.save_as_file("d:\\button.bmp");
|
||||
wd->root_graph->save_as_file("d:\\button_root.bmp");
|
||||
}
|
||||
else if (effects::edge_nimbus::none != wd->effect.edge_nimbus)
|
||||
{
|
||||
this->map(wd, true);
|
||||
//The window is still mapped because of edge nimbus effect.
|
||||
//Avoid duplicate copy if action state is not changed and the window is not focused.
|
||||
if ((wd->flags.action != wd->flags.action_before) || (bedrock::instance().focus() == wd))
|
||||
this->map(wd, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1398,9 +1398,10 @@ namespace detail
|
||||
|
||||
if (!established)
|
||||
{
|
||||
using effect_renderer = detail::edge_nimbus_renderer<basic_window>;
|
||||
|
||||
//remove the window from edge nimbus effect when it is destroying
|
||||
using edge_nimbus = detail::edge_nimbus_renderer<core_window_t>;
|
||||
edge_nimbus::instance().erase(wd);
|
||||
effect_renderer::instance().erase(wd);
|
||||
}
|
||||
else if (pa_root_attr != root_attr)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user