diff --git a/source/detail/posix/shared_icons.cpp b/source/detail/posix/shared_icons.cpp new file mode 100644 index 00000000..c6345db7 --- /dev/null +++ b/source/detail/posix/shared_icons.cpp @@ -0,0 +1,50 @@ +#include "shared_icons.hpp" + +namespace nana +{ + namespace detail + { + shared_icons::shared_icons(): + path_("/usr/share/icons/"), + ifs_("/usr/share/icons/default/index.theme") + { + } + + std::string shared_icons::cursor(const std::string& name) + { + auto theme = _m_read("Icon Theme", "Inherits"); + return path_ + theme + "/cursors/" + name; + } + + std::string shared_icons::_m_read(const std::string& category, const std::string& key) + { + ifs_.seekg(0, std::ios::beg); + + bool found_cat = false; + while(ifs_.good()) + { + std::string text; + std::getline(ifs_, text); + + if(0 == text.find('[')) + { + if(found_cat) + break; + + if(text.find(category + "]") != text.npos) + { + found_cat = true; + } + } + else if(found_cat && (text.find(key + "=") == 0)) + { + return text.substr(key.size() + 1); + } + } + + return {}; + } + + } + +} \ No newline at end of file diff --git a/source/detail/posix/shared_icons.hpp b/source/detail/posix/shared_icons.hpp new file mode 100644 index 00000000..1b225fcf --- /dev/null +++ b/source/detail/posix/shared_icons.hpp @@ -0,0 +1,28 @@ +#ifndef NANA_DETAIL_SHARED_ICONS_INCLUDED +#define NANA_DETAIL_SHARED_ICONS_INCLUDED + +#include +#include + +namespace nana +{ + namespace detail + { + class shared_icons + { + public: + shared_icons(); + + std::string cursor(const std::string& name); + private: + std::string _m_read(const std::string& category, const std::string& key); + private: + std::string path_; + std::ifstream ifs_; + }; + + }//end namespace detail + +}//end namespace nana + +#endif \ No newline at end of file diff --git a/source/detail/posix/xdnd_protocol.hpp b/source/detail/posix/xdnd_protocol.hpp index d902d175..ad101c56 100644 --- a/source/detail/posix/xdnd_protocol.hpp +++ b/source/detail/posix/xdnd_protocol.hpp @@ -18,6 +18,8 @@ #include #include +#include + #include //debug @@ -25,6 +27,56 @@ namespace nana{ namespace detail { + + class shared_icons + { + public: + shared_icons() + { + path_ = "/usr/share/icons/"; + ifs_.open(path_ + "default/index.theme"); + } + + std::string cursor(const std::string& name) + { + auto theme = _m_read("Icon Theme", "Inherits"); + + return path_ + theme + "/cursors/" + name; + } + private: + std::string _m_read(const std::string& category, const std::string& key) + { + ifs_.seekg(0, std::ios::beg); + + bool found_cat = false; + while(ifs_.good()) + { + std::string text; + std::getline(ifs_, text); + + if(0 == text.find('[')) + { + if(found_cat) + break; + + if(text.find(category + "]") != text.npos) + { + found_cat = true; + } + } + else if(found_cat && (text.find(key + "=") == 0)) + { + return text.substr(key.size() + 1); + } + } + + return {}; + } + private: + std::string path_; + std::ifstream ifs_; + }; + struct xdnd_data { std::vector files; @@ -36,7 +88,8 @@ namespace nana{ enum class xdnd_status_state { normal, - position_sent, + position, + drop, //Use the 'accept' flag of XdndStatus when mouse has released(XdndDrop has been sent). status_ignore }; @@ -44,9 +97,21 @@ namespace nana{ spec_(nana::detail::platform_spec::instance()), source_(source) { + auto disp = spec_.open_display(); detail::platform_scope_guard lock; - ::XSetSelectionOwner(spec_.open_display(), spec_.atombase().xdnd_selection, source, CurrentTime); + ::XSetSelectionOwner(disp, spec_.atombase().xdnd_selection, source, CurrentTime); std::cout<<"XSetSelectionOwner "<(xclient.data.l[0]); bool is_accepted_by_target = (xclient.data.l[1] & 1); - std::cout<<"XdndStatus: Accepted="< mvout_table_; + + struct cursor_rep + { + Cursor dnd_move{ 0 }; + Cursor dnd_none{ 0 }; + }cursor_; }; //end class xdnd_protocol } } diff --git a/source/gui/dragdrop.cpp b/source/gui/dragdrop.cpp index baa4b8f3..d04e5a92 100644 --- a/source/gui/dragdrop.cpp +++ b/source/gui/dragdrop.cpp @@ -659,55 +659,6 @@ namespace nana bool const simple_mode_; std::atomic ref_count_{ 1 }; }; - - class shared_icons - { - public: - shared_icons() - { - path_ = "/usr/share/icons/"; - ifs_.open(path_ + "default/index.theme"); - } - - std::string cursor(const std::string& name) - { - auto theme = _m_read("Icon Theme", "Inherits"); - - return path_ + theme + "/cursors/" + name; - } - private: - std::string _m_read(const std::string& category, const std::string& key) - { - ifs_.seekg(0, std::ios::beg); - - bool found_cat = false; - while(ifs_.good()) - { - std::string text; - std::getline(ifs_, text); - - if(0 == text.find('[')) - { - if(found_cat) - break; - - if(text.find(category + "]") != text.npos) - { - found_cat = true; - } - } - else if(found_cat && (text.find(key + "=") == 0)) - { - return text.substr(key.size() + 1); - } - } - - return {}; - } - private: - std::string path_; - std::ifstream ifs_; - }; #endif class dragdrop_service @@ -1022,7 +973,7 @@ namespace nana #ifdef NANA_WINDOWS #elif defined (NANA_X11) - shared_icons icons_; + nana::detail::shared_icons icons_; struct hovered_status { Window native_wd{0}; diff --git a/source/gui/filebox.cpp b/source/gui/filebox.cpp index 3faaf2a1..e89d8af2 100644 --- a/source/gui/filebox.cpp +++ b/source/gui/filebox.cpp @@ -35,6 +35,7 @@ # include # include # include +# include "../detail/posix/shared_icons.hpp" #endif namespace fs = std::filesystem; diff --git a/source/gui/widgets/scroll.cpp b/source/gui/widgets/scroll.cpp index d8e7d64a..b699517a 100644 --- a/source/gui/widgets/scroll.cpp +++ b/source/gui/widgets/scroll.cpp @@ -197,6 +197,7 @@ namespace nana clr.from_rgb(0x86, 0xD5, 0xFD); break; case states::selected: clr.from_rgb(0x3C, 0x7F, 0xB1); break; + default: break; } graph.rectangle(r, false, clr);