remove deprecated code and debug code
This commit is contained in:
@@ -36,8 +36,6 @@
|
||||
|
||||
#include "posix/msg_dispatcher.hpp"
|
||||
|
||||
#include <iostream> //debug
|
||||
|
||||
namespace nana
|
||||
{
|
||||
namespace detail
|
||||
@@ -1121,12 +1119,7 @@ namespace detail
|
||||
platform_scope_guard lock;
|
||||
if(0 != xdnd_.dragdrop.count(wd))
|
||||
return false;
|
||||
#if 0 //deprecated
|
||||
std::cout<<"ChangeProperty XdndAware"<<std::endl;
|
||||
int dndver = 4;
|
||||
::XChangeProperty(display_, reinterpret_cast<Window>(wd), atombase_.xdnd_aware, XA_ATOM, sizeof(int) * 8,
|
||||
PropModeReplace, reinterpret_cast<unsigned char*>(&dndver), 1);
|
||||
#endif
|
||||
|
||||
xdnd_.dragdrop[wd] = ddrop;
|
||||
return true;
|
||||
}
|
||||
@@ -1140,7 +1133,6 @@ namespace detail
|
||||
new_val = (xdnd_.targets[wd] += count);
|
||||
if(1 == new_val)
|
||||
{
|
||||
std::cout<<"ChangeProperty XdndAware"<<std::endl;
|
||||
int dndver = 5;
|
||||
::XChangeProperty(display_, reinterpret_cast<Window>(wd), atombase_.xdnd_aware, XA_ATOM, sizeof(int) * 8,
|
||||
PropModeReplace, reinterpret_cast<unsigned char*>(&dndver), 1);
|
||||
@@ -1235,7 +1227,6 @@ namespace detail
|
||||
}
|
||||
else if(evt.xselection.property == self.atombase_.xdnd_selection)
|
||||
{
|
||||
std::cout<<"Platform SelectionNotfy by XdndSelection, type="<<type<<", good_type="<<self.xdnd_.good_type<<", bytes_left="<<bytes_left<<std::endl;
|
||||
bool accepted = false;
|
||||
msg.kind = msg_packet_tag::pkt_family::mouse_drop;
|
||||
msg.u.mouse_drop.window = 0;
|
||||
@@ -1250,7 +1241,6 @@ namespace detail
|
||||
auto files = new std::vector<std::string>;
|
||||
std::stringstream ss(reinterpret_cast<char*>(data));
|
||||
|
||||
std::cout<<" data:["<<ss.str()<<"]"<<std::endl;
|
||||
while(true)
|
||||
{
|
||||
std::string file;
|
||||
@@ -1271,7 +1261,6 @@ namespace detail
|
||||
files->push_back(file);
|
||||
}
|
||||
|
||||
std::cout<<" file size:"<<files->size()<<std::endl;
|
||||
if(files->size())
|
||||
{
|
||||
msg.u.mouse_drop.window = evt.xselection.requestor;
|
||||
@@ -1285,8 +1274,6 @@ namespace detail
|
||||
accepted = true;
|
||||
::XFree(data);
|
||||
}
|
||||
else
|
||||
std::cout<<" invalid property"<<std::endl;
|
||||
}
|
||||
::XEvent respond;
|
||||
::memset(respond.xclient.data.l, 0, sizeof(respond.xclient.data.l));
|
||||
@@ -1313,15 +1300,9 @@ namespace detail
|
||||
}
|
||||
else if(SelectionRequest == evt.type)
|
||||
{
|
||||
std::cout<<"Event SelectionRequest in platform spec";
|
||||
//Skip if it is requested by XDND, it will be processed by dragdrop's xdnd_protocol
|
||||
if(self.atombase_.xdnd_selection == evt.xselectionrequest.selection)
|
||||
{
|
||||
std::cout<<", xdnd_selection"<<std::endl;
|
||||
return 0; //
|
||||
}
|
||||
|
||||
std::cout<<std::endl;
|
||||
return 0;
|
||||
|
||||
auto disp = evt.xselectionrequest.display;
|
||||
XEvent respond;
|
||||
@@ -1368,7 +1349,6 @@ namespace detail
|
||||
{
|
||||
if(self.atombase_.xdnd_enter == evt.xclient.message_type)
|
||||
{
|
||||
std::cout<<"Platform: XdndEnter";
|
||||
const Atom * atoms = reinterpret_cast<const Atom*>(&(evt.xclient.data.l[2]));
|
||||
unsigned long len = 3;
|
||||
unsigned char * data = 0;
|
||||
@@ -1380,32 +1360,19 @@ namespace detail
|
||||
Atom type;
|
||||
int format;
|
||||
unsigned long bytes_left;
|
||||
auto status = ::XGetWindowProperty(self.display_, self.xdnd_.wd_src, self.atombase_.xdnd_typelist, 0, 0, False,
|
||||
::XGetWindowProperty(self.display_, self.xdnd_.wd_src, self.atombase_.xdnd_typelist, 0, 0, False,
|
||||
XA_ATOM, &type, &format, &len, &bytes_left, &data);
|
||||
|
||||
std::cout<<", XGetWindowProperty xdnd_typelist = "<<status<<" bytes_left="<<bytes_left<<std::endl;
|
||||
|
||||
if(bytes_left > 0)
|
||||
{
|
||||
::XGetWindowProperty(self.display_, self.xdnd_.wd_src, self.atombase_.xdnd_typelist,
|
||||
0, bytes_left, False, XA_ATOM,
|
||||
&type, &format, &len, &bytes_left, &data);
|
||||
|
||||
std::cout<<" format="<<format<<" len="<<len<<" bytes_left="<<bytes_left;
|
||||
auto type_name = ::XGetAtomName(self.display_, type);
|
||||
if(type_name)
|
||||
{
|
||||
std::cout<<" type="<<type_name;
|
||||
::XFree(type_name);
|
||||
}
|
||||
std::cout<<std::endl;
|
||||
|
||||
if(XA_ATOM == type && len > 0)
|
||||
atoms = reinterpret_cast<const Atom*>(data);
|
||||
}
|
||||
}
|
||||
else
|
||||
std::cout<<", less than 3 types"<<std::endl;
|
||||
|
||||
#define DEBUG_XdndDirectSave
|
||||
#ifdef DEBUG_XdndDirectSave
|
||||
@@ -1417,15 +1384,12 @@ namespace detail
|
||||
auto name = XGetAtomName(self.display_, atoms[i]); //debug
|
||||
if(name)
|
||||
{
|
||||
std::cout<<" Supported type: "<<name<<std::endl;
|
||||
#ifdef DEBUG_XdndDirectSave
|
||||
if(strstr(name, "XdndDirectSave"))
|
||||
XdndDirectSave = atoms[i];
|
||||
#endif
|
||||
::XFree(name);
|
||||
}
|
||||
else
|
||||
std::cout<<" Supported type: no name("<<atoms[i]<<")"<<std::endl;
|
||||
|
||||
if(atoms[i] == self.atombase_.text_uri_list)
|
||||
{
|
||||
@@ -1444,24 +1408,13 @@ namespace detail
|
||||
int format;
|
||||
unsigned long bytes_left;
|
||||
|
||||
auto status = ::XGetWindowProperty(self.display_, self.xdnd_.wd_src, XdndDirectSave, 0, 0, False, XA_ATOM, &type, &format, &len, &bytes_left, &data);
|
||||
auto name = XGetAtomName(self.display_, type); //debug
|
||||
if(name)
|
||||
{
|
||||
std::cout<<" XdndDirectSave text/plain Atom: "<<name<<std::endl;
|
||||
::XFree(name);
|
||||
}
|
||||
|
||||
std::cout<<", XGetWindowProperty XdndDirectSave = "<<status<<" bytes_left="<<bytes_left<<std::endl;
|
||||
::XGetWindowProperty(self.display_, self.xdnd_.wd_src, XdndDirectSave, 0, 0, False, XA_ATOM, &type, &format, &len, &bytes_left, &data);
|
||||
|
||||
if(bytes_left > 0)
|
||||
{
|
||||
::XGetWindowProperty(self.display_, self.xdnd_.wd_src, XdndDirectSave,
|
||||
0, bytes_left, False, type,
|
||||
&type, &format, &len, &bytes_left, &data);
|
||||
|
||||
std::cout<<" XdndDirectSave Data:["<<(char*)data<<"]"<<std::endl;
|
||||
std::system("cp xds.txt /home/jinhao/xds.txt");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1469,8 +1422,6 @@ namespace detail
|
||||
}
|
||||
else if(self.atombase_.xdnd_position == evt.xclient.message_type)
|
||||
{
|
||||
std::cout<<"Platform: XdndPosition"<<std::endl;
|
||||
|
||||
Window wd_src = evt.xclient.data.l[0];
|
||||
int x = (evt.xclient.data.l[2] >> 16);
|
||||
int y = (evt.xclient.data.l[2] & 0xFFFF);
|
||||
@@ -1482,7 +1433,6 @@ namespace detail
|
||||
Window child;
|
||||
::XTranslateCoordinates(self.display_, self.root_window(), evt.xclient.window, x, y, &self.xdnd_.pos.x, &self.xdnd_.pos.y, &child);
|
||||
|
||||
std::cout<<" find_window"<<std::endl;
|
||||
auto wd = bedrock.wd_manager().find_window(reinterpret_cast<native_window_type>(evt.xclient.window), self.xdnd_.pos);
|
||||
if(wd && wd->flags.dropable)
|
||||
{
|
||||
@@ -1491,8 +1441,6 @@ namespace detail
|
||||
self.xdnd_.pos = wd->pos_root;
|
||||
accepted = 1;
|
||||
}
|
||||
|
||||
std::cout<<" return,"<<wd<<std::endl;
|
||||
}
|
||||
|
||||
XEvent respond;
|
||||
@@ -1511,25 +1459,18 @@ namespace detail
|
||||
respond.xclient.data.l[3] = 0;
|
||||
respond.xclient.data.l[4] = self.atombase_.xdnd_action_copy;
|
||||
|
||||
std::cout<<" Target XdndStatus begin to send. Accepted"<<accepted<<std::endl;
|
||||
::XSendEvent(self.display_, wd_src, True, NoEventMask, &respond);
|
||||
std::cout<<" Target XdndStatus ed"<<std::endl;
|
||||
return 2;
|
||||
}
|
||||
else if(self.atombase_.xdnd_status == evt.xclient.message_type)
|
||||
{
|
||||
std::cout<<"Platform Recv XdndStatus"<<std::endl;
|
||||
//Platform Recv XdndStatus
|
||||
}
|
||||
else if(self.atombase_.xdnd_drop == evt.xclient.message_type)
|
||||
{
|
||||
Window owner = ::XGetSelectionOwner(self.display_, self.atombase_.xdnd_selection);
|
||||
std::cout<<"Platform XdndDrop: XdndSelectionOwner = "<<owner<<std::endl;
|
||||
|
||||
::XConvertSelection(self.display_, self.atombase_.xdnd_selection, self.xdnd_.good_type, self.atombase_.xdnd_selection,
|
||||
evt.xclient.window, self.xdnd_.timestamp);
|
||||
|
||||
std::cout<<" XConvertSelection ed"<<std::endl;
|
||||
|
||||
//The XdndDrop should send a XdndFinished to source window.
|
||||
//This operation is implemented in SelectionNotify, because
|
||||
//XdndFinished should be sent after retrieving data.
|
||||
|
||||
@@ -28,8 +28,6 @@
|
||||
#include <thread>
|
||||
#include <atomic>
|
||||
|
||||
#include <iostream> //debug
|
||||
|
||||
namespace nana
|
||||
{
|
||||
namespace detail
|
||||
@@ -231,10 +229,6 @@ namespace detail
|
||||
if(keymap[event.xkey.keycode / 8] & (1 << (event.xkey.keycode % 8)))
|
||||
continue;
|
||||
}
|
||||
else if(SelectionRequest == event.type)
|
||||
{
|
||||
std::cout<<"Dispatcher SelectionRequest"<<std::endl; //debug
|
||||
}
|
||||
|
||||
if(::XFilterEvent(&event, None))
|
||||
continue;
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
#include <iostream> //debug
|
||||
namespace nana
|
||||
{
|
||||
namespace detail
|
||||
@@ -179,13 +178,7 @@ namespace nana
|
||||
auto name = find_kde_theme_name();
|
||||
|
||||
if(name.empty())
|
||||
{
|
||||
name = find_gnome_theme_name();
|
||||
std::cout<<"GNOME:"<<name<<std::endl;
|
||||
return find_gnome_theme_name();
|
||||
}
|
||||
|
||||
std::cout<<"KDE:"<<name<<std::endl;
|
||||
|
||||
return name;
|
||||
}
|
||||
@@ -294,13 +287,6 @@ namespace nana
|
||||
std::vector<std::string> directories_;
|
||||
};
|
||||
|
||||
void test()
|
||||
{
|
||||
theme thm;
|
||||
auto png = thm.icon("folder", 30);
|
||||
std::cout<<"Icon Theme="<<png<<std::endl;
|
||||
}
|
||||
|
||||
theme::theme():
|
||||
path_("/usr/share/icons/"),
|
||||
ifs_("/usr/share/icons/default/index.theme")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* X-Window XDND Protocol Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2018 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2018-2019 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -23,12 +23,6 @@
|
||||
#include <vector>
|
||||
|
||||
|
||||
#define DEBUG_XDND_PROTOCOL
|
||||
|
||||
#ifdef DEBUG_XDND_PROTOCOL
|
||||
#include <iostream> //debug
|
||||
#endif
|
||||
|
||||
namespace nana{
|
||||
namespace detail
|
||||
{
|
||||
@@ -58,15 +52,6 @@ namespace nana{
|
||||
detail::platform_scope_guard lock;
|
||||
::XSetSelectionOwner(disp, spec_.atombase().xdnd_selection, source, CurrentTime);
|
||||
|
||||
#ifdef DEBUG_XDND_PROTOCOL
|
||||
std::cout<<"XSetSelectionOwner "<<source<<std::endl;
|
||||
#endif
|
||||
/* //deprecated
|
||||
theme icons;
|
||||
cursor_.dnd_copy = ::XcursorFilenameLoadCursor(disp, icons.cursor("dnd-copy").c_str());
|
||||
cursor_.dnd_move = ::XcursorFilenameLoadCursor(disp, icons.cursor("dnd-move").c_str());
|
||||
cursor_.dnd_none = ::XcursorFilenameLoadCursor(disp, icons.cursor("dnd-none").c_str());
|
||||
*/
|
||||
cursor_.dnd_copy = ::XcursorLibraryLoadCursor(disp, "dnd-copy");
|
||||
cursor_.dnd_move = ::XcursorLibraryLoadCursor(disp, "dnd-move");
|
||||
cursor_.dnd_none = ::XcursorLibraryLoadCursor(disp, "dnd-none");
|
||||
@@ -115,18 +100,12 @@ namespace nana{
|
||||
|
||||
if(atombase.xdnd_status == xclient.message_type)
|
||||
{
|
||||
#ifdef DEBUG_XDND_PROTOCOL
|
||||
std::cout<<"Event: XdndStatus"<<std::endl;
|
||||
#endif
|
||||
if(xdnd_status_state::position != xstate_ && xdnd_status_state::drop != xstate_)
|
||||
return false;
|
||||
|
||||
Window target_wd = static_cast<Window>(xclient.data.l[0]);
|
||||
bool is_accepted_by_target = (xclient.data.l[1] & 1);
|
||||
|
||||
#ifdef DEBUG_XDND_PROTOCOL
|
||||
std::cout<<"XdndStatus: Accepted="<<is_accepted_by_target<<", target="<<target_wd<<std::endl;
|
||||
#endif
|
||||
if(xclient.data.l[1] & 0x2)
|
||||
{
|
||||
rectangle rct{
|
||||
@@ -137,16 +116,8 @@ namespace nana{
|
||||
};
|
||||
|
||||
if(!rct.empty())
|
||||
{
|
||||
mvout_table_[target_wd] = rct;
|
||||
#ifdef DEBUG_XDND_PROTOCOL
|
||||
std::cout<<". rct=("<<rct.x<<","<<rct.y<<","<<rct.width<<","<<rct.height<<")";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG_XDND_PROTOCOL
|
||||
std::cout<<std::endl;
|
||||
#endif
|
||||
_m_cursor(is_accepted_by_target);
|
||||
|
||||
if((!is_accepted_by_target) && (xdnd_status_state::drop == xstate_))
|
||||
@@ -156,11 +127,6 @@ namespace nana{
|
||||
}
|
||||
|
||||
executed_action_ = xclient.data.l[4];
|
||||
|
||||
#ifdef DEBUG_XDND_PROTOCOL
|
||||
std::cout<<" Assign ExecutedAction = "<<static_cast<int>(executed_action_)<<std::endl;
|
||||
#endif
|
||||
|
||||
xstate_ = xdnd_status_state::normal;
|
||||
}
|
||||
else if(atombase.xdnd_finished == xclient.message_type)
|
||||
@@ -173,9 +139,6 @@ namespace nana{
|
||||
{
|
||||
if(spec_.atombase().xdnd_selection == xselectionrequest.selection)
|
||||
{
|
||||
#ifdef DEBUG_XDND_PROTOCOL
|
||||
std::cout<<"Event SelectionRequest: XdndSelection"<<std::endl;
|
||||
#endif
|
||||
::XEvent evt;
|
||||
evt.xselection.type = SelectionNotify;
|
||||
evt.xselection.display = xselectionrequest.display;
|
||||
@@ -185,23 +148,8 @@ namespace nana{
|
||||
evt.xselection.property = 0;
|
||||
evt.xselection.time = xselectionrequest.time;
|
||||
|
||||
#ifdef DEBUG_XDND_PROTOCOL
|
||||
auto property_name = ::XGetAtomName(spec_.open_display(), xselectionrequest.property); //debug
|
||||
|
||||
std::cout<<"SelectionRequest"<<std::endl;
|
||||
std::cout<<" xdnd_selection:"<<spec_.atombase().xdnd_selection<<std::endl;
|
||||
std::cout<<" text_uri_list :"<<spec_.atombase().text_uri_list<<std::endl;
|
||||
std::cout<<" selection="<<xselectionrequest.selection<<std::endl;
|
||||
std::cout<<" property ="<<xselectionrequest.property<<", name="<<property_name<<std::endl;
|
||||
std::cout<<" target ="<<xselectionrequest.target<<std::endl;
|
||||
::XFree(property_name);
|
||||
#endif
|
||||
|
||||
if(xselectionrequest.target == spec_.atombase().text_uri_list)
|
||||
{
|
||||
#ifdef DEBUG_XDND_PROTOCOL
|
||||
std::cout<<"SelectionRequest target = text_uri_list";
|
||||
#endif
|
||||
if(data.files.size())
|
||||
{
|
||||
std::string uri_list;
|
||||
@@ -211,9 +159,7 @@ namespace nana{
|
||||
uri_list += file.u8string();
|
||||
uri_list += "\r\n";
|
||||
}
|
||||
#ifdef DEBUG_XDND_PROTOCOL
|
||||
std::cout<<". URIs="<<uri_list<<std::endl;
|
||||
#endif
|
||||
|
||||
::XChangeProperty (spec_.open_display(),
|
||||
xselectionrequest.requestor,
|
||||
xselectionrequest.property,
|
||||
@@ -226,10 +172,7 @@ namespace nana{
|
||||
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG_XDND_PROTOCOL
|
||||
else
|
||||
std::cout<<"SelectionRequest target = "<<xselectionrequest.target<<std::endl;
|
||||
#endif
|
||||
|
||||
platform_scope_guard lock;
|
||||
::XSendEvent(spec_.open_display(), xselectionrequest.requestor, False, 0, &evt);
|
||||
::XFlush(spec_.open_display());
|
||||
@@ -247,9 +190,6 @@ namespace nana{
|
||||
return false;
|
||||
|
||||
target_ = wd;
|
||||
#ifdef DEBUG_XDND_PROTOCOL
|
||||
std::cout<<"Send XdndEnter, text/uri-list="<<spec_.atombase().text_uri_list<<std::endl;
|
||||
#endif
|
||||
_m_client_msg(spec_.atombase().xdnd_enter, (xdnd_ver << 24), spec_.atombase().text_uri_list, XA_STRING);
|
||||
|
||||
return true;
|
||||
@@ -264,9 +204,6 @@ namespace nana{
|
||||
if(i != mvout_table_.end() && i->second.is_hit(pos))
|
||||
return;
|
||||
|
||||
#ifdef DEBUG_XDND_PROTOCOL
|
||||
std::cout<<"Send: XdndPosition, RequestedAction="<<requested_action<<", XdndActionCopy="<<spec_.atombase().xdnd_action_copy<<std::endl;
|
||||
#endif
|
||||
xstate_ = xdnd_status_state::position;
|
||||
//Send XdndPosition
|
||||
long position = (pos.x << 16 | pos.y);
|
||||
@@ -279,9 +216,6 @@ namespace nana{
|
||||
|
||||
if(target_)
|
||||
{
|
||||
#ifdef DEBUG_XDND_PROTOCOL
|
||||
std::cout<<"Send: XdndLeave, reset ExecutedAction"<<std::endl;
|
||||
#endif
|
||||
_m_client_msg(spec_.atombase().xdnd_leave, 0, 0, 0);
|
||||
target_ = 0;
|
||||
executed_action_ = 0;
|
||||
@@ -294,12 +228,8 @@ namespace nana{
|
||||
xstate_ = xdnd_status_state::drop;
|
||||
|
||||
if(executed_action_)
|
||||
{
|
||||
#ifdef DEBUG_XDND_PROTOCOL
|
||||
std::cout<<"Send: XdndDrop"<<std::endl;
|
||||
#endif
|
||||
_m_client_msg(spec_.atombase().xdnd_drop, 0, CurrentTime, 0);
|
||||
}
|
||||
|
||||
target_ = 0;
|
||||
|
||||
return (executed_action_ != 0);
|
||||
@@ -338,16 +268,13 @@ namespace nana{
|
||||
0, 4, False, XA_ATOM, &actual, &format, &count, &remaining, &data);
|
||||
|
||||
int version = 0;
|
||||
if ((actual == XA_ATOM) && (format==32) && count && data)
|
||||
{
|
||||
version = int(*(Atom*)data);
|
||||
#ifdef DEBUG_XDND_PROTOCOL
|
||||
std::cout<<"Get:XdndAware version:"<<version<<std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (data)
|
||||
{
|
||||
if ((actual == XA_ATOM) && (format==32) && count)
|
||||
version = int(*(Atom*)data);
|
||||
|
||||
::XFree(data);
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user