diff --git a/source/gui/detail/native_window_interface.cpp b/source/gui/detail/native_window_interface.cpp index 0657dd14..bdf75823 100644 --- a/source/gui/detail/native_window_interface.cpp +++ b/source/gui/detail/native_window_interface.cpp @@ -1,7 +1,7 @@ /* * Platform Implementation * Nana C++ Library(http://www.nanapro.org) - * Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com) + * Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at @@ -197,6 +197,13 @@ namespace nana{ return rectangle{ primary_monitor_size() }; } +#ifdef NANA_X11 + //The XMoveWindow and XMoveResizeWindow don't take effect if the specified window is + //unmapped, and the members x and y of XSetSizeHints is obsoluted. So the position that + //set to a unmapped windows should be kept and use the position when the window is mapped. + std::map exposed_positions; //locked by platform_scope_guard +#endif + //platform-dependent native_interface::window_result native_interface::create_window(native_window_type owner, bool nested, const rectangle& r, const appearance& app) { @@ -289,6 +296,7 @@ namespace nana{ { win_attr.save_under = True; attr_mask |= CWSaveUnder; + parent = restrict::spec.root_window(); calc_screen_point(owner, pos); } @@ -303,7 +311,12 @@ namespace nana{ { //make owner if it is a popup window if((!nested) && owner) + { restrict::spec.make_owner(owner, reinterpret_cast(handle)); + exposed_positions[handle] = pos; + } + + XChangeWindowAttributes(disp, handle, attr_mask, &win_attr); XTextProperty name; char text[] = "Nana Window"; @@ -655,6 +668,14 @@ namespace nana{ if(show) { ::XMapWindow(disp, reinterpret_cast(wd)); + + auto i = exposed_positions.find(reinterpret_cast(wd)); + if(i != exposed_positions.end()) + { + ::XMoveWindow(disp, reinterpret_cast(wd), i->second.x, i->second.y); + exposed_positions.erase(i); + } + Window grab = restrict::spec.grab(0); if(grab == reinterpret_cast(wd)) capture_window(wd, true); @@ -882,13 +903,7 @@ namespace nana{ XWindowAttributes attr; ::XGetWindowAttributes(disp, reinterpret_cast(wd), &attr); if(attr.map_state == IsUnmapped) - { - XSizeHints hints; - hints.flags = USPosition; - hints.x = x; - hints.y = y; - ::XSetWMNormalHints(disp, reinterpret_cast(wd), &hints); - } + exposed_positions[reinterpret_cast(wd)] = ::nana::point{x, y}; ::XMoveWindow(disp, reinterpret_cast(wd), x, y); #endif @@ -959,11 +974,11 @@ namespace nana{ ::XGetWindowAttributes(disp, reinterpret_cast(wd), &attr); if(attr.map_state == IsUnmapped) { - hints.flags |= (USPosition | USSize); - hints.x = x; - hints.y = y; + hints.flags |= USSize; hints.width = r.width; hints.height = r.height; + + exposed_positions[reinterpret_cast(wd)] = point{x, y}; } if(hints.flags) diff --git a/source/gui/msgbox.cpp b/source/gui/msgbox.cpp index 6b3b9510..6560fe93 100644 --- a/source/gui/msgbox.cpp +++ b/source/gui/msgbox.cpp @@ -618,7 +618,7 @@ namespace nana place_.field_display(img_fields[i], false); } - size({desc_extent.width, height }); + move(API::make_center(this->owner(), desc_extent.width, height)); caption(title); } diff --git a/source/gui/widgets/menu.cpp b/source/gui/widgets/menu.cpp index 02ba5649..0d8b68f6 100644 --- a/source/gui/widgets/menu.cpp +++ b/source/gui/widgets/menu.cpp @@ -1141,7 +1141,14 @@ namespace nana throw std::out_of_range("menu: a new item inserted to an invalid position"); std::unique_ptr item{ new item_type{ std::move(text_utf8), handler } }; - impl_->mbuilder.data().items.emplace(impl_->mbuilder.data().items.cbegin() + pos, item.get()); + + items.emplace( +#ifdef _MSC_VER + items.cbegin() + pos, +#else + items.begin() + pos, +#endif + item.get()); return item_proxy{ pos, *item.release() }; }