fix bug that window has wrong position if it has an ancestor

This commit is contained in:
Jinhao 2019-01-21 22:35:44 +08:00
parent 5935ce2036
commit 8ecae7402c

View File

@ -1,7 +1,7 @@
/*
* Platform Implementation
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com)
* Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@ -29,6 +29,7 @@
#include "../../paint/image_accessor.hpp"
namespace nana{
namespace detail{
@ -1019,15 +1020,11 @@ namespace nana{
auto const owner = restrict::spec.get_owner(wd);
if(owner && (owner != reinterpret_cast<native_window_type>(restrict::spec.root_window())))
{
auto origin = window_position(owner);
#if 0
x += origin.x;
y += origin.y;
#else
auto owner_extents = window_frame_extents(owner);
x += origin.x + owner_extents.left;
y += origin.y + owner_extents.top;
#endif
int origin_x, origin_y;
Window child_useless_for_API;
::XTranslateCoordinates(disp, reinterpret_cast<Window>(owner), restrict::spec.root_window(), 0, 0, &origin_x, &origin_y, &child_useless_for_API);
x += origin_x;
y += origin_y;
}
::XMoveWindow(disp, reinterpret_cast<Window>(wd), x, y);
@ -1074,7 +1071,6 @@ namespace nana{
XSizeHints hints;
nana::detail::platform_scope_guard psg;
//Returns if the requested rectangle is same with the current rectangle.
//In some X-Server versions/implementations, XMapWindow() doesn't generate
//a ConfigureNotify if the requested rectangle is same with the current rectangle.
@ -1114,11 +1110,11 @@ namespace nana{
auto const owner = restrict::spec.get_owner(wd);
if(owner && (owner != reinterpret_cast<native_window_type>(restrict::spec.root_window())))
{
auto origin = window_position(owner);
auto owner_extents = window_frame_extents(owner);
x += origin.x + owner_extents.left;
y += origin.y + owner_extents.top;
int origin_x, origin_y;
Window child_useless_for_API;
::XTranslateCoordinates(disp, reinterpret_cast<Window>(owner), restrict::spec.root_window(), 0, 0, &origin_x, &origin_y, &child_useless_for_API);
x += origin_x;
y += origin_y;
}
::XMoveResizeWindow(disp, reinterpret_cast<Window>(wd), x, y, r.width, r.height);