partially working paste
We now paste something from the clipboard, but the format conversion seems to be still off at times.
This commit is contained in:
parent
bbb2da4a1b
commit
ec23bf0457
@ -623,13 +623,16 @@ namespace
|
||||
xcb_window_t window;
|
||||
int type;
|
||||
bool check(xcb_generic_event_t *event) const {
|
||||
if (event->response_type != type)
|
||||
if (!event)
|
||||
return false;
|
||||
if (event->response_type == XCB_PROPERTY_NOTIFY) {
|
||||
int t = event->response_type & 0x7f;
|
||||
if (t != type)
|
||||
return false;
|
||||
if (t == XCB_PROPERTY_NOTIFY) {
|
||||
xcb_property_notify_event_t *pn = (xcb_property_notify_event_t *)event;
|
||||
if (pn->window == window)
|
||||
return true;
|
||||
} else if (event->response_type == XCB_SELECTION_NOTIFY) {
|
||||
} else if (t == XCB_SELECTION_NOTIFY) {
|
||||
xcb_selection_notify_event_t *sn = (xcb_selection_notify_event_t *)event;
|
||||
if (sn->requestor == window)
|
||||
return true;
|
||||
@ -643,10 +646,13 @@ namespace
|
||||
{ clipboard = c->internAtom("CLIPBOARD"); }
|
||||
xcb_atom_t clipboard;
|
||||
bool check(xcb_generic_event_t *e) const {
|
||||
if (e->response_type == XCB_SELECTION_REQUEST) {
|
||||
if (!e)
|
||||
return false;
|
||||
int type = e->response_type & 0x7f;
|
||||
if (type == XCB_SELECTION_REQUEST) {
|
||||
xcb_selection_request_event_t *sr = (xcb_selection_request_event_t *)e;
|
||||
return sr->selection == QXcbAtom::XA_PRIMARY || sr->selection == clipboard;
|
||||
} else if (e->response_type == XCB_SELECTION_CLEAR) {
|
||||
} else if (type == XCB_SELECTION_CLEAR) {
|
||||
xcb_selection_clear_event_t *sc = (xcb_selection_clear_event_t *)e;
|
||||
return sc->selection == QXcbAtom::XA_PRIMARY || sc->selection == clipboard;
|
||||
}
|
||||
@ -734,6 +740,8 @@ QByteArray QXcbClipboard::clipboardReadIncrementalProperty(xcb_window_t win, xcb
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
free(ge);
|
||||
}
|
||||
|
||||
// timed out ... create a new requestor window, otherwise the requestor
|
||||
@ -748,6 +756,7 @@ QByteArray QXcbClipboard::getDataInFormat(xcb_atom_t modeAtom, xcb_atom_t fmtAto
|
||||
QByteArray buf;
|
||||
|
||||
xcb_window_t win = requestor();
|
||||
// qDebug() << "getDataInFormat" << m_connection->atomName(modeAtom) << m_connection->atomName(fmtAtom) << win;
|
||||
|
||||
uint32_t mask = XCB_EVENT_MASK_NO_EVENT;
|
||||
xcb_change_window_attributes(m_connection->xcb_connection(), win, XCB_CW_EVENT_MASK, &mask);
|
||||
@ -759,7 +768,10 @@ QByteArray QXcbClipboard::getDataInFormat(xcb_atom_t modeAtom, xcb_atom_t fmtAto
|
||||
m_connection->sync();
|
||||
|
||||
xcb_generic_event_t *ge = waitForClipboardEvent(m_connection, win, XCB_SELECTION_NOTIFY, clipboard_timeout);
|
||||
if (!ge || ((xcb_selection_notify_event_t *)ge)->property == XCB_NONE)
|
||||
bool no_selection = !ge || ((xcb_selection_notify_event_t *)ge)->property == XCB_NONE;
|
||||
free(ge);
|
||||
|
||||
if (no_selection)
|
||||
return buf;
|
||||
|
||||
mask = XCB_EVENT_MASK_PROPERTY_CHANGE;
|
||||
|
@ -85,11 +85,11 @@ QXcbConnection::QXcbConnection(const char *displayName)
|
||||
, m_has_support_for_dri2(false)
|
||||
#endif
|
||||
{
|
||||
int primaryScreen = 0;
|
||||
m_primaryScreen = 0;
|
||||
|
||||
#ifdef XCB_USE_XLIB
|
||||
Display *dpy = XOpenDisplay(m_displayName.constData());
|
||||
primaryScreen = DefaultScreen(dpy);
|
||||
m_primaryScreen = DefaultScreen(dpy);
|
||||
m_connection = XGetXCBConnection(dpy);
|
||||
XSetEventQueueOwner(dpy, XCBOwnsEventQueue);
|
||||
m_xlib_display = dpy;
|
||||
@ -461,8 +461,15 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
|
||||
break;
|
||||
case XCB_SELECTION_REQUEST:
|
||||
m_clipboard->handleSelectionRequest((xcb_selection_request_event_t *)event);
|
||||
break;
|
||||
case XCB_SELECTION_CLEAR:
|
||||
qDebug() << "XCB_SELECTION_CLEAR";
|
||||
handled = false;
|
||||
break;
|
||||
case XCB_SELECTION_NOTIFY:
|
||||
qDebug() << "XCB_SELECTION_NOTIFY";
|
||||
handled = false;
|
||||
break;
|
||||
default:
|
||||
handled = false;
|
||||
break;
|
||||
@ -724,7 +731,7 @@ QByteArray QXcbConnection::atomName(xcb_atom_t atom)
|
||||
{
|
||||
xcb_get_atom_name_cookie_t cookie = xcb_get_atom_name_unchecked(xcb_connection(), atom);
|
||||
xcb_get_atom_name_reply_t *reply = xcb_get_atom_name_reply(xcb_connection(), cookie, 0);
|
||||
QByteArray result(xcb_get_atom_name_name(reply));
|
||||
QByteArray result(xcb_get_atom_name_name(reply), xcb_get_atom_name_name_length(reply));
|
||||
free(reply);
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user