fix bug that wd.find_window unexpectedly returns
wd.find_window unexpectedly returns a wrong handle if captured window ignores children windows.
This commit is contained in:
parent
6b8a898239
commit
a4c3784efe
@ -99,7 +99,11 @@ namespace detail
|
||||
|
||||
bool show(core_window_t* wd, bool visible);
|
||||
|
||||
core_window_t* find_window(native_window_type root, const point& pos);
|
||||
//find a widget window at specified position
|
||||
//@param root A root window
|
||||
//@param pos Position
|
||||
//@param ignore_captured A flag indicates whether to ignore redirecting the result to its captured window. If this paramter is true, it returns the window at the position, if the parameter is false, it returns the captured window if the captured window don't ignore children.
|
||||
core_window_t* find_window(native_window_type root, const point& pos, bool ignore_captured = false);
|
||||
|
||||
//move the wnd and its all children window, x and y is a relatively coordinate for wnd's parent window
|
||||
bool move(core_window_t*, int x, int y, bool passive);
|
||||
|
@ -701,19 +701,40 @@ namespace detail
|
||||
return true;
|
||||
}
|
||||
|
||||
window_manager::core_window_t* window_manager::find_window(native_window_type root, const point& pos)
|
||||
window_manager::core_window_t* window_manager::find_window(native_window_type root, const point& pos, bool ignore_captured)
|
||||
{
|
||||
if (nullptr == root)
|
||||
return nullptr;
|
||||
|
||||
if((false == attr_.capture.ignore_children) || (nullptr == attr_.capture.window) || (attr_.capture.window->root != root))
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
|
||||
if (ignore_captured || (nullptr == attr_.capture.window))
|
||||
{
|
||||
auto rrt = root_runtime(root);
|
||||
if (rrt && _m_effective(rrt->window, pos))
|
||||
return _m_find(rrt->window, pos);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (attr_.capture.ignore_children)
|
||||
return attr_.capture.window;
|
||||
|
||||
auto rrt = root_runtime(root);
|
||||
if (rrt && _m_effective(rrt->window, pos))
|
||||
{
|
||||
auto target = _m_find(rrt->window, pos);
|
||||
|
||||
auto p = target;
|
||||
while (p)
|
||||
{
|
||||
if (p == attr_.capture.window)
|
||||
return target;
|
||||
p = p->parent;
|
||||
}
|
||||
}
|
||||
|
||||
return attr_.capture.window;
|
||||
}
|
||||
|
||||
|
@ -1403,7 +1403,7 @@ namespace API
|
||||
::nana::point clipos{pos};
|
||||
interface_type::calc_window_point(wd, clipos);
|
||||
return reinterpret_cast<window>(
|
||||
restrict::wd_manager().find_window(wd, clipos));
|
||||
restrict::wd_manager().find_window(wd, clipos, true));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user