update experimental::filesystem and remove file_iterator

This commit is contained in:
Jinhao
2016-01-19 01:34:07 +08:00
parent 13669f7591
commit 8d2ec2fbd1
22 changed files with 1255 additions and 788 deletions

View File

@@ -1,41 +0,0 @@
/*
* A File Iterator Implementation
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* @file: nana/filesystem/file_iterator.cpp
* @description:
* file_iterator is a toolkit for applying each file and directory in a
* specified path.
*/
#include <nana/filesystem/file_iterator.hpp>
namespace nana
{
namespace filesystem
{
//struct fileinfo
fileinfo::fileinfo()
:size(0), directory(false)
{}
#if defined(NANA_WINDOWS)
fileinfo::fileinfo(const WIN32_FIND_DATA& wfd)
: name(utf8_cast(wfd.cFileName)), size(wfd.nFileSizeLow),
directory((FILE_ATTRIBUTE_DIRECTORY & wfd.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY)
{
}
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
fileinfo::fileinfo(const ::std::string& name, const struct stat& fst)
:name(name), size(fst.st_size), directory(0 != S_ISDIR(fst.st_mode))
{
}
#endif
//end struct fileinfo
}//end namespace filesystem
}//end namespace nana

View File

@@ -24,7 +24,7 @@
#include <shlobj.h>
#include <nana/datetime.hpp>
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
#elif defined(NANA_POSIX)
#include <nana/charset.hpp>
#include <sys/stat.h>
#include <sys/types.h>
@@ -36,9 +36,38 @@
#include <stdlib.h>
#endif
namespace nana { namespace experimental {
namespace filesystem
{
//class filesystem_error
filesystem_error::filesystem_error(const std::string& msg, std::error_code err)
: std::system_error(err, msg)
{}
filesystem_error::filesystem_error(const std::string& msg, const path& path1, std::error_code err)
: std::system_error(err, msg),
path1_(path1)
{}
filesystem_error::filesystem_error(const std::string& msg, const path& path1, const path& path2, std::error_code err)
: std::system_error(err, msg),
path1_(path1),
path2_(path2)
{}
const path& filesystem_error::path1() const
{
return path1_;
}
const path&filesystem_error::path2() const
{
return path2_;
}
//end class filesystem_error
//Because of No wide character version of POSIX
#if defined(NANA_LINUX) || defined(NANA_MACOS)
const char* splstr = "/";
@@ -72,9 +101,7 @@ namespace nana { namespace experimental {
}
//end filestatus
//class path
path::path() {}
//class path
int path::compare(const path& p) const
{
return pathstr_.compare(p.pathstr_);
@@ -158,6 +185,41 @@ namespace nana { namespace experimental {
return{ pathstr_ };
}
path& path::remove_filename()
{
#ifdef NANA_WINDOWS
wchar_t seps[] = L"/\\";
#else
char seps[] = "/\\";
#endif
auto pos = pathstr_.find_last_of(seps);
if (pos != pathstr_.npos)
{
pos = pathstr_.find_last_not_of(seps, pos);
if (pos != pathstr_.npos)
{
#ifdef NANA_WINDOWS
if (pathstr_[pos] == L':')
{
pathstr_.erase(pos + 1);
pathstr_ += L'\\';
return *this;
}
#endif
++pos;
}
else
pos = 0;
}
else
pos = 0;
pathstr_.erase(pos);
return *this;
}
const path::value_type* path::c_str() const
{
return native().c_str();
@@ -188,6 +250,36 @@ namespace nana { namespace experimental {
return to_utf8(pathstr_);
}
path & path::operator/=(const path& p)
{
if (p.empty())
return *this;
if (this == &p)
{
auto other = p.pathstr_;
if ((other.front() != '/') && (other.front() == path::preferred_separator))
{
if (!this->pathstr_.empty() && (pathstr_.back() != '/' && pathstr_.back() == path::preferred_separator))
pathstr_.append(path::preferred_separator, 1);
}
pathstr_ += other;
}
else
{
auto & other = p.pathstr_;
if ((other.front() != '/') && (other.front() == path::preferred_separator))
{
if (!this->pathstr_.empty() && (pathstr_.back() != '/' && pathstr_.back() == path::preferred_separator))
pathstr_.append(path::preferred_separator, 1);
}
pathstr_ += p.pathstr_;
}
return *this;
}
void path::_m_assign(const std::string& source_utf8)
{
#if defined(NANA_WINDOWS)
@@ -227,52 +319,251 @@ namespace nana { namespace experimental {
return (rhs.compare(lhs) < 0);
}
path operator/(const path& lhs, const path& rhs)
{
auto path = lhs;
return (path /= rhs);
}
//class directory_entry
directory_entry::directory_entry(const filesystem::path& p)
:path_{ p }
{}
//modifiers
void directory_entry::assign(const filesystem::path& p)
{
path_ = p;
}
void directory_entry::replace_filename(const filesystem::path& p)
{
path_ = path_.parent_path() / p;
}
//observers
file_status directory_entry::status() const
{
return filesystem::status(path_);
}
directory_entry::operator const filesystem::path&() const
{
return path_;
}
const path& directory_entry::path() const
{
return path_;
}
//end class directory_entry
//class directory_iterator
struct inner_handle_deleter
{
void operator()(void** handle)
{
#if defined(NANA_WINDOWS)
::FindClose(*handle);
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
::closedir(*reinterpret_cast<DIR**>(handle));
#endif
}
};
directory_iterator::directory_iterator()
: end_(true),
handle_(nullptr)
{}
directory_iterator::directory_iterator(const path& file_path)
{
_m_prepare(file_path);
}
const directory_iterator::value_type& directory_iterator::operator*() const { return value_; }
const directory_iterator::value_type*
directory_iterator::operator->() const { return &(operator*()); }
directory_iterator& directory_iterator::operator++()
{
_m_read(); return *this;
}
directory_iterator directory_iterator::operator++(int)
{
directory_iterator tmp = *this;
_m_read();
return tmp;
}
bool directory_iterator::equal(const directory_iterator& x) const
{
if (end_ && (end_ == x.end_)) return true;
return (value_.path().filename() == x.value_.path().filename());
}
// enable directory_iterator range-based for statements
directory_iterator directory_iterator::begin() { return *this; }
directory_iterator directory_iterator::end() { return{}; }
void directory_iterator::_m_prepare(const path& file_path)
{
path_ = file_path.native();
#if defined(NANA_WINDOWS)
if (!path_.empty() && (path_.back() != L'/' && path_.back() != L'\\'))
path_ += L'\\';
auto pat = path_;
DWORD attr = ::GetFileAttributes(pat.data());
if ((attr != INVALID_FILE_ATTRIBUTES) && (attr & FILE_ATTRIBUTE_DIRECTORY))
pat += L"*";
WIN32_FIND_DATAW wfd;
::HANDLE handle = ::FindFirstFile(pat.data(), &wfd);
if (handle == INVALID_HANDLE_VALUE)
{
end_ = true;
return;
}
while (_m_ignore(wfd.cFileName))
{
if (::FindNextFile(handle, &wfd) == 0)
{
end_ = true;
::FindClose(handle);
return;
}
}
value_ = value_type(path(path_ + wfd.cFileName));
#elif defined(NANA_POSIX)
if (path_.size() && (path_.back() != '/'))
path_ += '/';
auto handle = opendir(path_.c_str());
end_ = true;
if (handle)
{
struct dirent * dnt = readdir(handle);
if (dnt)
{
while (_m_ignore(dnt->d_name))
{
dnt = readdir(handle);
if (dnt == 0)
{
closedir(handle);
return;
}
}
value_ = value_type(path_ + dnt->d_name);
end_ = false;
}
}
#endif
if (false == end_)
{
find_ptr_ = std::shared_ptr<find_handle>(new find_handle(handle), inner_handle_deleter());
handle_ = handle;
}
}
void directory_iterator::_m_read()
{
if (handle_)
{
#if defined(NANA_WINDOWS)
WIN32_FIND_DATAW wfd;
if (::FindNextFile(handle_, &wfd) != 0)
{
while (_m_ignore(wfd.cFileName))
{
if (::FindNextFile(handle_, &wfd) == 0)
{
end_ = true;
return;
}
}
value_ = value_type(path(path_ + wfd.cFileName));
}
else
end_ = true;
#elif defined(NANA_POSIX)
struct dirent * dnt = readdir(reinterpret_cast<DIR*>(handle_));
if (dnt)
{
while (_m_ignore(dnt->d_name))
{
dnt = readdir(reinterpret_cast<DIR*>(handle_));
if (!dnt)
{
end_ = true;
return;
}
}
value_ = value_type(path(path_ + dnt->d_name));
}
else
end_ = true;
#endif
}
}
//end class directory_iterator
namespace detail
{
//rm_dir_recursive
//@brief: remove a directory, if it is not empty, recursively remove it's subfiles and sub directories
template<typename CharT>
bool rm_dir_recursive(const CharT* dir)
//rm_dir_recursive
//@brief: remove a directory, if it is not empty, recursively remove it's subfiles and sub directories
template<typename CharT>
bool rm_dir_recursive(const CharT* dir)
{
std::vector<directory_iterator::value_type> files;
std::basic_string<CharT> path = dir;
path += '\\';
std::copy(directory_iterator(dir), directory_iterator(), std::back_inserter(files));
for (auto & f : files)
{
std::vector<directory_iterator::value_type> files;
std::basic_string<CharT> path = dir;
path += '\\';
auto subpath = path + f.path().filename().native();
std::copy(directory_iterator(dir), directory_iterator(), std::back_inserter(files));
for (auto & f : files)
{
auto subpath = path + f.path().filename().native();
if (f.attr.directory)
rm_dir_recursive(subpath.c_str());
else
rmfile(subpath.c_str());
}
return rmdir(dir, true);
if (is_directory(f))
rm_dir_recursive(subpath.c_str());
else
rmfile(subpath.c_str());
}
return rmdir(dir, true);
}
#if defined(NANA_WINDOWS)
void filetime_to_c_tm(FILETIME& ft, struct tm& t)
void filetime_to_c_tm(FILETIME& ft, struct tm& t)
{
FILETIME local_file_time;
if (::FileTimeToLocalFileTime(&ft, &local_file_time))
{
FILETIME local_file_time;
if (::FileTimeToLocalFileTime(&ft, &local_file_time))
{
SYSTEMTIME st;
::FileTimeToSystemTime(&local_file_time, &st);
t.tm_year = st.wYear - 1900;
t.tm_mon = st.wMonth - 1;
t.tm_mday = st.wDay;
t.tm_wday = st.wDayOfWeek - 1;
t.tm_yday = nana::date::day_in_year(st.wYear, st.wMonth, st.wDay);
SYSTEMTIME st;
::FileTimeToSystemTime(&local_file_time, &st);
t.tm_year = st.wYear - 1900;
t.tm_mon = st.wMonth - 1;
t.tm_mday = st.wDay;
t.tm_wday = st.wDayOfWeek - 1;
t.tm_yday = nana::date::day_in_year(st.wYear, st.wMonth, st.wDay);
t.tm_hour = st.wHour;
t.tm_min = st.wMinute;
t.tm_sec = st.wSecond;
}
t.tm_hour = st.wHour;
t.tm_min = st.wMinute;
t.tm_sec = st.wSecond;
}
}
#endif
}//end namespace detail
}//end namespace detail
bool not_found_error(int errval)
{

View File

@@ -1,6 +1,6 @@
/*
* A FileSystem Utility Implementation
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@@ -12,7 +12,6 @@
*/
#include <nana/filesystem/fs_utility.hpp>
#include <nana/filesystem/file_iterator.hpp>
#include <nana/deploy.hpp>
#include <vector>
#if defined(NANA_WINDOWS)
@@ -53,27 +52,6 @@ namespace filesystem
namespace detail
{
//rm_dir_recursive
//@brief: remove a directory, if it is not empty, recursively remove it's subfiles and sub directories
bool rm_dir_recursive(std::string&& dir)
{
std::vector<file_iterator::value_type> files;
auto path = dir;
path += '\\';
std::copy(file_iterator(dir), file_iterator(), std::back_inserter(files));
for(auto & f : files)
{
if(f.directory)
rm_dir_recursive(path + f.name);
else
rmfile((path + f.name).c_str());
}
return rmdir(dir.c_str(), true);
}
#if defined(NANA_WINDOWS)
void filetime_to_c_tm(FILETIME& ft, struct tm& t)
{
@@ -150,41 +128,18 @@ namespace filesystem
#endif
}
bool rmdir(const char* dir, bool fails_if_not_empty)
{
bool ret = false;
if(dir)
{
#if defined(NANA_WINDOWS)
ret = (::RemoveDirectory(utf8_cast(dir).c_str()) == TRUE);
if(!fails_if_not_empty && (::GetLastError() == ERROR_DIR_NOT_EMPTY))
ret = detail::rm_dir_recursive(dir);
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
std::string mbstr = nana::charset(dir);
if(::rmdir(mbstr.c_str()))
{
if(!fails_if_not_empty && (errno == EEXIST || errno == ENOTEMPTY))
ret = detail::rm_dir_recursive(dir);
}
else
ret = true;
#endif
}
return ret;
}
std::wstring path_user()
std::string path_user()
{
#if defined(NANA_WINDOWS)
wchar_t path[MAX_PATH];
if(SUCCEEDED(SHGetFolderPath(0, CSIDL_PROFILE, 0, SHGFP_TYPE_CURRENT, path)))
return path;
return to_utf8(path);
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
const char * s = ::getenv("HOME");
if(s)
return nana::charset(std::string(s, std::strlen(s)), nana::unicode::utf8);
return s;
#endif
return std::wstring();
return std::string();
}
}//end namespace filesystem
}//end namespace nana

View File

@@ -158,7 +158,7 @@ namespace nana{
{
#if defined(NANA_WINDOWS)
typedef HMONITOR (__stdcall * MonitorFromPointT)(POINT,DWORD);
MonitorFromPointT mfp = reinterpret_cast<MonitorFromPointT>(::GetProcAddress(::GetModuleHandleA("User32.DLL"), "MonitorFromPoint"));
if(mfp)
{
@@ -473,13 +473,13 @@ namespace nana{
auto & atombase = restrict::spec.atombase();
::XSetTransientForHint(disp, reinterpret_cast<Window>(wd), owner);
::XChangeProperty(disp, reinterpret_cast<Window>(wd),
atombase.net_wm_state, XA_ATOM, sizeof(int) * 8,
atombase.net_wm_state, XA_ATOM, sizeof(int) * 8,
PropModeReplace,
reinterpret_cast<const unsigned char*>(&atombase.net_wm_state_modal), 1);
}
}
#endif
void native_interface::enable_dropfiles(native_window_type wd, bool enb)
{
#if defined(NANA_WINDOWS)
@@ -505,7 +505,7 @@ namespace nana{
}
::XSelectInput(restrict::spec.open_display(), reinterpret_cast<Window>(wd), mask);
#endif
#endif
}
bool native_interface::window_icon(native_window_type wd, const nana::paint::image& sml_icon, const ::nana::paint::image& big_icon)
@@ -1117,9 +1117,9 @@ namespace nana{
native_string_type str;
//One for NULL terminator which GetWindowText will write.
str.resize(length+1);
::GetWindowText(reinterpret_cast<HWND>(wd), &(str[0]), static_cast<int>(str.size()));
//Remove the null terminator writtien by GetWindowText
str.resize(length);
@@ -1207,9 +1207,9 @@ namespace nana{
Window parent;
Window * children;
unsigned size;
platform_scope_guard lock;
if(0 != ::XQueryTree(restrict::spec.open_display(), reinterpret_cast<Window>(wd),
&root, &parent, &children, &size))
{
@@ -1226,7 +1226,7 @@ namespace nana{
auto prev = ::SetParent(reinterpret_cast<HWND>(child), reinterpret_cast<HWND>(new_parent));
if (prev)
::PostMessage(prev, WM_CHANGEUISTATE, UIS_INITIALIZE, NULL);
::PostMessage(prev, /*WM_CHANGEUISTATE*/0x0127, /*UIS_INITIALIZE*/ 3, 0);
::SetWindowPos(reinterpret_cast<HWND>(child), NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED);
@@ -1239,7 +1239,7 @@ namespace nana{
if(returns_previous)
prev = parent_window(child);
::XReparentWindow(restrict::spec.open_display(),
::XReparentWindow(restrict::spec.open_display(),
reinterpret_cast<Window>(child), reinterpret_cast<Window>(new_parent),
0, 0);
return prev;

View File

@@ -1,7 +1,7 @@
/*
* Filebox
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@@ -17,7 +17,7 @@
#if defined(NANA_WINDOWS)
#include <windows.h>
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
#elif defined(NANA_POSIX)
#include <nana/gui/widgets/label.hpp>
#include <nana/gui/widgets/button.hpp>
#include <nana/gui/widgets/listbox.hpp>
@@ -25,7 +25,7 @@
#include <nana/gui/widgets/textbox.hpp>
#include <nana/gui/widgets/treebox.hpp>
#include <nana/gui/widgets/combox.hpp>
#include <nana/filesystem/file_iterator.hpp>
#include <nana/filesystem/filesystem.hpp>
#include <nana/gui/place.hpp>
#include <stdexcept>
#include <algorithm>
@@ -33,7 +33,7 @@
namespace nana
{
#if defined(NANA_LINUX) || defined(NANA_MACOS)
#if defined(NANA_POSIX)
class filebox_implement
: public form
{
@@ -421,8 +421,6 @@ namespace nana
void _m_init_tree()
{
using namespace nana::filesystem;
//The path in linux is starting with the character '/', the name of root key should be
//"FS.HOME", "FS.ROOT". Because a key of the tree widget should not be '/'
nodes_.home = tree_.insert("FS.HOME", "Home");
@@ -430,28 +428,27 @@ namespace nana
nodes_.filesystem = tree_.insert("FS.ROOT", "Filesystem");
nodes_.filesystem.value(kind::filesystem);
file_iterator end;
for(file_iterator i(to_nstring(path_user())); i != end; ++i)
namespace fs = ::nana::experimental::filesystem;
std::vector<std::string> paths;
paths.emplace_back(nana::filesystem::path_user());
paths.emplace_back("/");
fs::directory_iterator end;
for (auto & p : paths)
{
if((false == i->directory) || (i->name.size() && i->name[0] == '.')) continue;
item_proxy node = tree_.insert(nodes_.home, i->name, i->name);
if(false == node.empty())
for (fs::directory_iterator i(p); i != end; ++i)
{
node.value(kind::filesystem);
break;
}
}
auto name = i->path().filename().native();
if (!is_directory(i->status()) || (name.size() && name[0] == '.'))
continue;
for(file_iterator i("/"); i != end; ++i)
{
if((false == i->directory) || (i->name.size() && i->name[0] == '.')) continue;
item_proxy node = tree_.insert(nodes_.filesystem, i->name, i->name);
if(false == node.empty())
{
node.value(kind::filesystem);
break;
item_proxy node = tree_.insert(nodes_.filesystem, name, name);
if (false == node.empty())
{
node.value(kind::filesystem);
break;
}
}
}
@@ -494,29 +491,31 @@ namespace nana
file_container_.clear();
using namespace nana::filesystem;
file_iterator end;
for(file_iterator i(path); i != end; ++i)
{
if((i->name.size() == 0) || (i->name[0] == '.'))
continue;
item_fs m;
m.name = i->name;
namespace fs = ::nana::experimental::filesystem;
fs::directory_iterator end;
for(fs::directory_iterator i(path); i != end; ++i)
{
auto name = i->path().filename().native();
if(name.empty() || (name.front() == '.'))
continue;
item_fs m;
m.name = name;
namespace fs = ::nana::experimental::filesystem;
auto fattr = fs::status(path + m.name);
if(fattr.type() != fs::file_type::not_found && fattr.type() != fs::file_type::unknown)
{
m.bytes = fs::file_size(path + m.name);
m.directory = fs::is_directory(fattr);
modified_file_time(path + m.name, m.modified_time);
::nana::filesystem::modified_file_time(path + m.name, m.modified_time);
}
else
{
m.bytes = 0;
m.directory = i->directory;
modified_file_time(path + i->name, m.modified_time);
m.directory = fs::is_directory(*i);
::nana::filesystem::modified_file_time(path + i->path().filename().native(), m.modified_time);
}
file_container_.push_back(m);
@@ -554,11 +553,13 @@ namespace nana
if(head.size() == 0 || head[head.size() - 1] != '/')
head += '/';
nana::filesystem::file_iterator end;
for(nana::filesystem::file_iterator i(head); i != end; ++i)
namespace fs = ::nana::experimental::filesystem;
fs::directory_iterator end;
for(fs::directory_iterator i(head); i != end; ++i)
{
if(i->directory)
path_.childset(i->name, 0);
if(is_directory(*i))
path_.childset(i->path().filename().native(), 0);
}
auto cat_path = path_.caption();
if(cat_path.size() && cat_path[cat_path.size() - 1] != '/')
@@ -574,10 +575,10 @@ namespace nana
(head += folder) += '/';
path_.caption(cat_path);
for(nana::filesystem::file_iterator i(head); i != end; ++i)
for(fs::directory_iterator i(head); i != end; ++i)
{
if(i->directory)
path_.childset(i->name, 0);
if (is_directory(*i))
path_.childset(i->path().filename().native(), 0);
}
if(pos == path.npos)
@@ -809,18 +810,25 @@ namespace nana
auto path = tree_.make_key_path(node, "/") + "/";
_m_resolute_path(path);
nana::filesystem::file_iterator end;
for(nana::filesystem::file_iterator i(path); i != end; ++i)
namespace fs = ::nana::experimental::filesystem;
fs::directory_iterator end;
for (fs::directory_iterator i{path}; i != end; ++i)
{
if((false == i->directory) || (i->name.size() && i->name[0] == '.')) continue;
auto child = node.append(i->name, i->name, kind::filesystem);
auto name = i->path().filename().native();
if((!is_directory(*i)) || (name.size() && name[0] == '.'))
continue;
auto child = node.append(name, name, kind::filesystem);
if(!child.empty())
{
for(nana::filesystem::file_iterator u(path + i->name); u != end; ++u)
for(fs::directory_iterator u(i->path()); u != end; ++u)
{
if(false == u->directory || (u->name.size() && u->name[0] == '.')) continue;
auto uname = i->path().filename().native();
if ((!is_directory(*i)) || (uname.size() && uname[0] == '.'))
continue;
child.append(u->name, u->name, kind::filesystem);
child.append(uname, uname, kind::filesystem);
break;
}
}
@@ -1047,7 +1055,7 @@ namespace nana
wfile.resize(std::wcslen(wfile.data()));
impl_->file = utf8_cast(wfile);
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
#elif defined(NANA_POSIX)
filebox_implement fb(impl_->owner, impl_->open_or_save, impl_->title);
if(impl_->filters.size())

View File

@@ -1168,24 +1168,6 @@ namespace API
return reinterpret_cast<window>(ts_wd);
}
/*
//glass_window deprecated
//@brief: Test a window whether it is a glass attribute.
bool glass_window(window wd)
{
return (bground_mode::basic == effects_bground_mode(wd));
}
bool glass_window(window wd, bool isglass) //deprecated
{
if(isglass)
effects_bground(wd, effects::bground_transparent(0), 0);
else
effects_bground_remove(wd);
return true;
}
*/
void take_active(window wd, bool active, window take_if_active_false)
{
auto const iwd = reinterpret_cast<basic_window*>(wd);