/* * X-Window XDND Protocol Implementation * Nana C++ Library(http://www.nanapro.org) * Copyright(C) 2018 Jinhao(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/detail/posix/xdnd_protocol.hpp * * The XDS is not supported. */ #ifndef NANA_DETAIL_POSIX_XDND_PROTOCOL_INCLUDED #define NANA_DETAIL_POSIX_XDND_PROTOCOL_INCLUDED #include "platform_spec.hpp" #include #include #include #include //debug 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; }; class xdnd_protocol { public: enum class xdnd_status_state { normal, position, drop, //Use the 'accept' flag of XdndStatus when mouse has released(XdndDrop has been sent). status_ignore }; xdnd_protocol(Window source): spec_(nana::detail::platform_spec::instance()), source_(source) { auto disp = spec_.open_display(); detail::platform_scope_guard lock; ::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 } } #endif