Merge branch 'feature-freebsd-posix' into develop
This commit is contained in:
@@ -37,7 +37,7 @@ namespace nana
|
||||
detail::bedrock::instance().wd_manager().internal_lock().unlock();
|
||||
}
|
||||
//end class internal_scope_guard
|
||||
|
||||
|
||||
//class internal_revert_guard
|
||||
internal_revert_guard::internal_revert_guard()
|
||||
{
|
||||
@@ -55,7 +55,7 @@ namespace nana
|
||||
{
|
||||
stop_propagation_ = true;
|
||||
}
|
||||
|
||||
|
||||
bool event_arg::propagation_stopped() const
|
||||
{
|
||||
return stop_propagation_;
|
||||
@@ -111,7 +111,7 @@ namespace nana
|
||||
pi_data_->auto_form_set.insert(wd);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (pi_data_->auto_form_set.erase(wd))
|
||||
{
|
||||
auto p = wd->widget_notifier->widget_ptr();
|
||||
@@ -119,7 +119,7 @@ namespace nana
|
||||
}
|
||||
}
|
||||
|
||||
void bedrock::close_thread_window(unsigned thread_id)
|
||||
void bedrock::close_thread_window(thread_t thread_id)
|
||||
{
|
||||
std::vector<core_window_t*> v;
|
||||
wd_manager().all_handles(v);
|
||||
@@ -321,7 +321,7 @@ namespace nana
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void bedrock::set_menu(native_window_type menu_wd, bool has_keyboard)
|
||||
{
|
||||
if(menu_wd && pi_data_->menu.window != menu_wd)
|
||||
@@ -453,7 +453,7 @@ namespace nana
|
||||
flag_guard fguard(this, wd);
|
||||
(wd->drawer.*drawer_event_fn)(*arg, bForce__EmitInternal);
|
||||
}
|
||||
|
||||
|
||||
if (bProcess__External_event)
|
||||
evt_addr->emit(*arg, reinterpret_cast<window>(wd));
|
||||
break;
|
||||
@@ -610,4 +610,4 @@ namespace nana
|
||||
}
|
||||
}
|
||||
}//end namespace detail
|
||||
}//end namespace nana
|
||||
}//end namespace nana
|
||||
|
||||
@@ -80,26 +80,26 @@ namespace detail
|
||||
cursor.handle = 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct bedrock::private_impl
|
||||
{
|
||||
typedef std::map<unsigned, thread_context> thr_context_container;
|
||||
std::recursive_mutex mutex;
|
||||
thr_context_container thr_contexts;
|
||||
|
||||
|
||||
element_store estore;
|
||||
|
||||
struct cache_type
|
||||
{
|
||||
struct thread_context_cache
|
||||
{
|
||||
unsigned tid{ 0 };
|
||||
thread_t tid{ 0 };
|
||||
thread_context *object{ nullptr };
|
||||
}tcontext;
|
||||
}cache;
|
||||
};
|
||||
|
||||
void timer_proc(unsigned);
|
||||
void timer_proc(thread_t);
|
||||
void window_proc_dispatcher(Display*, nana::detail::msg_packet_tag&);
|
||||
void window_proc_for_packet(Display *, nana::detail::msg_packet_tag&);
|
||||
void window_proc_for_xevent(Display*, XEvent&);
|
||||
@@ -175,7 +175,7 @@ namespace detail
|
||||
|
||||
//inc_window
|
||||
//@biref: increament the number of windows
|
||||
int bedrock::inc_window(unsigned tid)
|
||||
int bedrock::inc_window(thread_t tid)
|
||||
{
|
||||
private_impl * impl = instance().impl_;
|
||||
std::lock_guard<decltype(impl->mutex)> lock(impl->mutex);
|
||||
@@ -184,7 +184,7 @@ namespace detail
|
||||
return (cnt < 0 ? cnt = 1 : ++cnt);
|
||||
}
|
||||
|
||||
bedrock::thread_context* bedrock::open_thread_context(unsigned tid)
|
||||
bedrock::thread_context* bedrock::open_thread_context(thread_t tid)
|
||||
{
|
||||
if(0 == tid) tid = nana::system::this_thread_id();
|
||||
|
||||
@@ -205,7 +205,7 @@ namespace detail
|
||||
return context;
|
||||
}
|
||||
|
||||
bedrock::thread_context* bedrock::get_thread_context(unsigned tid)
|
||||
bedrock::thread_context* bedrock::get_thread_context(thread_t tid)
|
||||
{
|
||||
if(0 == tid) tid = nana::system::this_thread_id();
|
||||
|
||||
@@ -224,7 +224,7 @@ namespace detail
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bedrock::remove_thread_context(unsigned tid)
|
||||
void bedrock::remove_thread_context(thread_t tid)
|
||||
{
|
||||
if(0 == tid) tid = nana::system::this_thread_id();
|
||||
|
||||
@@ -320,7 +320,7 @@ namespace detail
|
||||
|
||||
good_wd = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(thrd) thrd->event_window = prev_wd;
|
||||
return good_wd;
|
||||
@@ -403,10 +403,10 @@ namespace detail
|
||||
arg.distance = 120;
|
||||
arg.which = arg_wheel::wheel::vertical;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void timer_proc(unsigned tid)
|
||||
void timer_proc(thread_t tid)
|
||||
{
|
||||
nana::detail::platform_spec::instance().timer_proc(tid);
|
||||
}
|
||||
@@ -616,7 +616,7 @@ namespace detail
|
||||
|
||||
arg.evt_code = event_code::mouse_move;
|
||||
brock.emit(event_code::mouse_move, msgwnd, arg, true, &context);
|
||||
|
||||
|
||||
if (!wd_manager.available(hovered_wd))
|
||||
hovered_wd = nullptr;
|
||||
}
|
||||
@@ -643,7 +643,7 @@ namespace detail
|
||||
auto & cf = xevent.xconfigure;
|
||||
wd_manager.size(msgwnd, nana::size{static_cast<unsigned>(cf.width), static_cast<unsigned>(cf.height)}, true, true);
|
||||
}
|
||||
|
||||
|
||||
if(msgwnd->pos_native.x != xevent.xconfigure.x || msgwnd->pos_native.y != xevent.xconfigure.y)
|
||||
{
|
||||
msgwnd->pos_native.x = xevent.xconfigure.x;
|
||||
@@ -664,7 +664,7 @@ namespace detail
|
||||
pressed_wd = nullptr;
|
||||
if(nullptr == msgwnd)
|
||||
break;
|
||||
|
||||
|
||||
if ((msgwnd == msgwnd->root_widget->other.attribute.root->menubar) && brock.get_menu(msgwnd->root, true))
|
||||
brock.erase_menu(true);
|
||||
else
|
||||
@@ -752,7 +752,7 @@ namespace detail
|
||||
arg.which = arg_wheel::wheel::vertical;
|
||||
assign_arg(arg, msgwnd, xevent);
|
||||
draw_invoker(&drawer::mouse_wheel, msgwnd, arg, &context);
|
||||
wd_manager.do_lazy_refresh(msgwnd, false);
|
||||
wd_manager.do_lazy_refresh(msgwnd, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -782,13 +782,13 @@ namespace detail
|
||||
draw_invoker(&drawer::click, msgwnd, click_arg, &context);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Do mouse_up, this handle may be closed by click handler.
|
||||
if(wd_manager.available(msgwnd) && msgwnd->flags.enabled)
|
||||
{
|
||||
if(hit)
|
||||
msgwnd->set_action(mouse_action::hovered);
|
||||
|
||||
|
||||
auto retain = msgwnd->annex.events_ptr;
|
||||
auto evt_ptr = retain.get();
|
||||
|
||||
@@ -886,7 +886,7 @@ namespace detail
|
||||
{
|
||||
arg_mouse arg;
|
||||
assign_arg(arg, msgwnd, message, xevent);
|
||||
|
||||
|
||||
if (mouse_action::pressed != msgwnd->flags.action)
|
||||
msgwnd->set_action(mouse_action::hovered);
|
||||
|
||||
@@ -1069,10 +1069,10 @@ namespace detail
|
||||
{
|
||||
const wchar_t* charbuf;
|
||||
|
||||
nana::detail::charset_conv charset("UTF-32", "UTF-8");
|
||||
nana::detail::charset_conv charset(NANA_UNICODE, "UTF-8");
|
||||
const std::string& str = charset.charset(std::string(keybuf, keybuf + len));
|
||||
charbuf = reinterpret_cast<const wchar_t*>(str.c_str()) + 1;
|
||||
len = str.size() / sizeof(wchar_t) - 1;
|
||||
charbuf = reinterpret_cast<const wchar_t*>(str.c_str());
|
||||
len = str.size() / sizeof(wchar_t);
|
||||
|
||||
for(int i = 0; i < len; ++i)
|
||||
{
|
||||
@@ -1080,6 +1080,9 @@ namespace detail
|
||||
arg.ignore = false;
|
||||
arg.key = charbuf[i];
|
||||
|
||||
// ignore Unicode BOM (it may or may not appear)
|
||||
if (arg.key == 0xFEFF) continue;
|
||||
|
||||
//Only accept tab when it is not ignored.
|
||||
if ((keyboard::tab == arg.key) && root_runtime->condition.ignore_tab)
|
||||
continue;
|
||||
@@ -1126,12 +1129,12 @@ namespace detail
|
||||
context.is_ctrl_pressed = false;
|
||||
|
||||
if (('\t' == os_code) && root_runtime->condition.ignore_tab)
|
||||
{
|
||||
{
|
||||
root_runtime->condition.ignore_tab = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
msgwnd = brock.focus();
|
||||
if(msgwnd)
|
||||
{
|
||||
@@ -1165,7 +1168,7 @@ namespace detail
|
||||
else
|
||||
{
|
||||
arg_keyboard arg;
|
||||
|
||||
|
||||
arg.evt_code = event_code::key_release;
|
||||
arg.window_handle = reinterpret_cast<window>(msgwnd);
|
||||
arg.ignore = false;
|
||||
@@ -1264,7 +1267,7 @@ namespace detail
|
||||
|
||||
auto & lock = wd_manager().internal_lock();
|
||||
lock.revert();
|
||||
|
||||
|
||||
native_window_type owner_native{};
|
||||
core_window_t * owner = 0;
|
||||
if(condition_wd && is_modal)
|
||||
@@ -1277,9 +1280,9 @@ namespace detail
|
||||
owner = wd_manager().root(owner_native);
|
||||
if(owner)
|
||||
owner->flags.enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nana::detail::platform_spec::instance().msg_dispatch(condition_wd ? reinterpret_cast<core_window_t*>(condition_wd)->root : 0);
|
||||
|
||||
if(owner_native)
|
||||
@@ -1291,7 +1294,7 @@ namespace detail
|
||||
|
||||
//Before exit of pump_event, it should call the remove_trash_handle.
|
||||
//Under Linux, if the windows are closed in other threads, all the widgets handles
|
||||
//will be marked as deleted after exit of the event loop and in other threads. So the
|
||||
//will be marked as deleted after exit of the event loop and in other threads. So the
|
||||
//handle should be deleted from trash before exit the pump_event.
|
||||
auto thread_id = ::nana::system::this_thread_id();
|
||||
wd_manager().call_safe_place(thread_id);
|
||||
@@ -1376,7 +1379,7 @@ namespace detail
|
||||
{
|
||||
if (!wd_manager().available(wd))
|
||||
return;
|
||||
|
||||
|
||||
wd->root_widget->other.attribute.root->state_cursor = nana::cursor::arrow;
|
||||
wd->root_widget->other.attribute.root->state_cursor_window = nullptr;
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ namespace detail
|
||||
{
|
||||
struct thread_context_cache
|
||||
{
|
||||
unsigned tid{ 0 };
|
||||
thread_t tid{ 0 };
|
||||
thread_context *object{ nullptr };
|
||||
}tcontext;
|
||||
}cache;
|
||||
@@ -251,7 +251,7 @@ namespace detail
|
||||
|
||||
|
||||
/// @brief increament the number of windows in the thread id
|
||||
int bedrock::inc_window(unsigned tid)
|
||||
int bedrock::inc_window(thread_t tid)
|
||||
{
|
||||
//impl refers to the object of private_impl, the object is created when bedrock is creating.
|
||||
private_impl * impl = instance().impl_;
|
||||
@@ -261,7 +261,7 @@ namespace detail
|
||||
return (cnt < 0 ? cnt = 1 : ++cnt);
|
||||
}
|
||||
|
||||
auto bedrock::open_thread_context(unsigned tid) -> thread_context*
|
||||
auto bedrock::open_thread_context(thread_t tid) -> thread_context*
|
||||
{
|
||||
if(0 == tid) tid = nana::system::this_thread_id();
|
||||
std::lock_guard<decltype(impl_->mutex)> lock(impl_->mutex);
|
||||
@@ -275,7 +275,7 @@ namespace detail
|
||||
return context;
|
||||
}
|
||||
|
||||
auto bedrock::get_thread_context(unsigned tid) -> thread_context *
|
||||
auto bedrock::get_thread_context(thread_t tid) -> thread_context *
|
||||
{
|
||||
if(0 == tid) tid = nana::system::this_thread_id();
|
||||
|
||||
@@ -295,7 +295,7 @@ namespace detail
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void bedrock::remove_thread_context(unsigned tid)
|
||||
void bedrock::remove_thread_context(thread_t tid)
|
||||
{
|
||||
if(0 == tid) tid = nana::system::this_thread_id();
|
||||
|
||||
@@ -372,7 +372,7 @@ namespace detail
|
||||
|
||||
void bedrock::pump_event(window condition_wd, bool is_modal)
|
||||
{
|
||||
const unsigned tid = ::GetCurrentThreadId();
|
||||
thread_t tid = ::GetCurrentThreadId();
|
||||
auto context = this->open_thread_context(tid);
|
||||
if(0 == context->window_count)
|
||||
{
|
||||
|
||||
@@ -263,7 +263,7 @@ namespace detail
|
||||
std::vector<key_value_rep> table_;
|
||||
};
|
||||
|
||||
//class window_manager
|
||||
//class window_manager
|
||||
//struct wdm_private_impl
|
||||
struct window_manager::wdm_private_impl
|
||||
{
|
||||
@@ -280,10 +280,10 @@ namespace detail
|
||||
//class revertible_mutex
|
||||
struct thread_refcount
|
||||
{
|
||||
unsigned tid; //Thread ID
|
||||
thread_t tid; //Thread ID
|
||||
std::vector<unsigned> callstack_refs;
|
||||
|
||||
thread_refcount(unsigned thread_id, unsigned refs)
|
||||
thread_refcount(thread_t thread_id, unsigned refs)
|
||||
: tid(thread_id)
|
||||
{
|
||||
callstack_refs.push_back(refs);
|
||||
@@ -294,7 +294,7 @@ namespace detail
|
||||
{
|
||||
std::recursive_mutex mutex;
|
||||
|
||||
unsigned thread_id; //Thread ID
|
||||
thread_t thread_id; //Thread ID
|
||||
unsigned refs; //Ref count
|
||||
|
||||
std::vector<thread_refcount> records;
|
||||
@@ -842,7 +842,7 @@ namespace detail
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
if (!impl_->wd_register.available(wd))
|
||||
return false;
|
||||
|
||||
|
||||
auto & brock = bedrock::instance();
|
||||
bool moved = false;
|
||||
const bool size_changed = (r.width != wd->dimension.width || r.height != wd->dimension.height);
|
||||
@@ -913,12 +913,12 @@ namespace detail
|
||||
// window again, otherwise, it causes an infinite loop, because when a root_widget is resized,
|
||||
// window_manager will call the function.
|
||||
bool window_manager::size(core_window_t* wd, nana::size sz, bool passive, bool ask_update)
|
||||
{
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
if (!impl_->wd_register.available(wd))
|
||||
return false;
|
||||
|
||||
|
||||
auto & brock = bedrock::instance();
|
||||
if (sz != wd->dimension)
|
||||
{
|
||||
@@ -1175,7 +1175,7 @@ namespace detail
|
||||
}
|
||||
|
||||
bool window_manager::set_parent(core_window_t* wd, core_window_t* newpa)
|
||||
{
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
if (!impl_->wd_register.available(wd))
|
||||
@@ -1255,7 +1255,7 @@ namespace detail
|
||||
//The menubar token window will be redirected to the prev focus window when the new
|
||||
//focus window is a menubar.
|
||||
//The focus window will be restored to the prev focus which losts the focus becuase of
|
||||
//memberbar.
|
||||
//memberbar.
|
||||
if (prev_focus && (wd == wd->root_widget->other.attribute.root->menubar))
|
||||
wd = prev_focus;
|
||||
|
||||
@@ -1403,7 +1403,7 @@ namespace detail
|
||||
return tabs.front();
|
||||
}
|
||||
}
|
||||
else if (tabs.size() > 1) //at least 2 elments in tabs are required when moving backward.
|
||||
else if (tabs.size() > 1) //at least 2 elments in tabs are required when moving backward.
|
||||
{
|
||||
auto i = std::find(tabs.begin(), end, wd);
|
||||
if (i != end)
|
||||
@@ -1449,7 +1449,7 @@ namespace detail
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void window_manager::remove_trash_handle(unsigned tid)
|
||||
void window_manager::remove_trash_handle(thread_t tid)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
@@ -1571,7 +1571,7 @@ namespace detail
|
||||
}
|
||||
}
|
||||
|
||||
void window_manager::call_safe_place(unsigned thread_id)
|
||||
void window_manager::call_safe_place(thread_t thread_id)
|
||||
{
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
|
||||
@@ -1608,7 +1608,7 @@ namespace detail
|
||||
|
||||
bool established = (for_new && (wdpa != for_new));
|
||||
decltype(for_new->root_widget->other.attribute.root) pa_root_attr = nullptr;
|
||||
|
||||
|
||||
if (established)
|
||||
pa_root_attr = for_new->root_widget->other.attribute.root;
|
||||
|
||||
@@ -1743,7 +1743,7 @@ namespace detail
|
||||
wd->root = for_new->root;
|
||||
wd->root_graph = for_new->root_graph;
|
||||
wd->root_widget = for_new->root_widget;
|
||||
|
||||
|
||||
wd->pos_owner.x = wd->pos_owner.y = 0;
|
||||
|
||||
auto delta_pos = wd->pos_root - for_new->pos_root;
|
||||
|
||||
@@ -153,7 +153,7 @@ namespace nana
|
||||
}
|
||||
}
|
||||
|
||||
void delete_trash(unsigned thread_id)
|
||||
void delete_trash(thread_t thread_id)
|
||||
{
|
||||
if (0 == thread_id)
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
#include "../detail/platform_spec_selector.hpp"
|
||||
|
||||
#if defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
#if defined(NANA_POSIX)
|
||||
#include <nana/system/platform.hpp>
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
#if defined(NANA_WINDOWS)
|
||||
#include <windows.h>
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
#elif defined(NANA_POSIX)
|
||||
#include "../detail/platform_spec_selector.hpp"
|
||||
#include <nana/system/platform.hpp>
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user