summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2011-05-26 02:47:32 +0200
committerLars Knoll <lars.knoll@nokia.com>2011-05-30 14:44:12 +0200
commitec23bf0457bbcea2b28feef24047a71c011b2ebc (patch)
tree71cf246099e256a9c4cc771673b882a1323a7bc9 /src/plugins/platforms/xcb
parentbbb2da4a1b49f37e3b009ea81ffcd0cc03e07ef4 (diff)
partially working paste
We now paste something from the clipboard, but the format conversion seems to be still off at times.
Diffstat (limited to 'src/plugins/platforms/xcb')
-rw-r--r--src/plugins/platforms/xcb/qxcbclipboard.cpp24
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp13
2 files changed, 28 insertions, 9 deletions
diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp
index b69642bff1..b138f2a66a 100644
--- a/src/plugins/platforms/xcb/qxcbclipboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbclipboard.cpp
@@ -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;
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index 9fe1730fe1..be341d292e 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -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;
}