{
switch (mode) {
case QClipboard::Selection:
- modeAtom = QXcbAtom::XA_PRIMARY;
+ modeAtom = XCB_ATOM_PRIMARY;
break;
case QClipboard::Clipboard:
- modeAtom = m_clipboard->connection()->atom(QXcbAtom::CLIPBOARD);
+ modeAtom = m_clipboard->atom(QXcbAtom::CLIPBOARD);
break;
default:
// get the list of targets from the current clipboard owner - we do this
// once so that multiple calls to this function don't require multiple
// server round trips...
- that->format_atoms = m_clipboard->getDataInFormat(modeAtom, m_clipboard->connection()->atom(QXcbAtom::TARGETS));
+ that->format_atoms = m_clipboard->getDataInFormat(modeAtom, m_clipboard->atom(QXcbAtom::TARGETS));
if (format_atoms.size() > 0) {
xcb_atom_t *targets = (xcb_atom_t *) format_atoms.data();
const int QXcbClipboard::clipboard_timeout = 5000;
-QXcbClipboard::QXcbClipboard(QXcbConnection *connection)
- : QPlatformClipboard()
- , m_connection(connection)
+QXcbClipboard::QXcbClipboard(QXcbConnection *c)
+ : QXcbObject(c), QPlatformClipboard()
, m_xClipboard(0)
, m_clientClipboard(0)
, m_xSelection(0)
, m_requestor(XCB_NONE)
, m_owner(XCB_NONE)
{
- m_screen = m_connection->screens().at(m_connection->primaryScreen());
+ m_screen = connection()->screens().at(connection()->primaryScreen());
}
xcb_window_t QXcbClipboard::getSelectionOwner(xcb_atom_t atom) const
{
- xcb_connection_t *c = m_connection->xcb_connection();
+ xcb_connection_t *c = xcb_connection();
xcb_get_selection_owner_cookie_t cookie = xcb_get_selection_owner(c, atom);
xcb_get_selection_owner_reply_t *reply;
reply = xcb_get_selection_owner_reply(c, cookie, 0);
if (!m_xClipboard) {
m_xClipboard = new QXcbClipboardMime(mode, this);
}
- xcb_window_t clipboardOwner = getSelectionOwner(m_connection->atom(QXcbAtom::CLIPBOARD));
+ xcb_window_t clipboardOwner = getSelectionOwner(atom(QXcbAtom::CLIPBOARD));
if (clipboardOwner == owner()) {
return m_clientClipboard;
} else {
if (!m_xSelection) {
m_xSelection = new QXcbClipboardMime(mode, this);
}
- xcb_window_t clipboardOwner = getSelectionOwner(QXcbAtom::XA_PRIMARY);
+ xcb_window_t clipboardOwner = getSelectionOwner(XCB_ATOM_PRIMARY);
if (clipboardOwner == owner()) {
return m_clientSelection;
} else {
QMimeData **d;
switch (mode) {
case QClipboard::Selection:
- modeAtom = QXcbAtom::XA_PRIMARY;
+ modeAtom = XCB_ATOM_PRIMARY;
d = &m_clientSelection;
break;
case QClipboard::Clipboard:
- modeAtom = m_connection->atom(QXcbAtom::CLIPBOARD);
+ modeAtom = atom(QXcbAtom::CLIPBOARD);
d = &m_clientClipboard;
break;
*d = data;
}
- xcb_set_selection_owner(m_connection->xcb_connection(), newOwner, modeAtom, m_connection->time());
+ xcb_set_selection_owner(xcb_connection(), newOwner, modeAtom, connection()->time());
if (getSelectionOwner(modeAtom) != newOwner) {
qWarning("QClipboard::setData: Cannot set X11 selection owner");
const int x = 0, y = 0, w = 3, h = 3;
QXcbClipboard *that = const_cast<QXcbClipboard *>(this);
- xcb_window_t window = xcb_generate_id(m_connection->xcb_connection());
- Q_XCB_CALL(xcb_create_window(m_connection->xcb_connection(),
+ xcb_window_t window = xcb_generate_id(xcb_connection());
+ Q_XCB_CALL(xcb_create_window(xcb_connection(),
XCB_COPY_FROM_PARENT, // depth -- same as root
window, // window id
m_screen->screen()->root, // parent window id
0)); // value list
uint32_t mask = XCB_EVENT_MASK_PROPERTY_CHANGE;
- xcb_change_window_attributes(m_connection->xcb_connection(), window, XCB_CW_EVENT_MASK, &mask);
+ xcb_change_window_attributes(xcb_connection(), window, XCB_CW_EVENT_MASK, &mask);
that->setRequestor(window);
}
void QXcbClipboard::setRequestor(xcb_window_t window)
{
if (m_requestor != XCB_NONE) {
- xcb_destroy_window(m_connection->xcb_connection(), m_requestor);
+ xcb_destroy_window(xcb_connection(), m_requestor);
}
m_requestor = window;
}
int x = 0, y = 0, w = 3, h = 3;
QXcbClipboard *that = const_cast<QXcbClipboard *>(this);
- xcb_window_t window = xcb_generate_id(m_connection->xcb_connection());
- Q_XCB_CALL(xcb_create_window(m_connection->xcb_connection(),
+ xcb_window_t window = xcb_generate_id(xcb_connection());
+ Q_XCB_CALL(xcb_create_window(xcb_connection(),
XCB_COPY_FROM_PARENT, // depth -- same as root
window, // window id
m_screen->screen()->root, // parent window id
void QXcbClipboard::setOwner(xcb_window_t window)
{
if (m_owner != XCB_NONE){
- xcb_destroy_window(m_connection->xcb_connection(), m_owner);
+ xcb_destroy_window(xcb_connection(), m_owner);
}
m_owner = window;
}
QVector<xcb_atom_t> types;
QStringList formats = QInternalMimeData::formatsHelper(d);
for (int i = 0; i < formats.size(); ++i) {
- QList<xcb_atom_t> atoms = QXcbMime::mimeAtomsForFormat(m_connection, formats.at(i));
+ QList<xcb_atom_t> atoms = QXcbMime::mimeAtomsForFormat(connection(), formats.at(i));
for (int j = 0; j < atoms.size(); ++j) {
if (!types.contains(atoms.at(j)))
types.append(atoms.at(j));
}
}
- types.append(m_connection->atom(QXcbAtom::TARGETS));
- types.append(m_connection->atom(QXcbAtom::MULTIPLE));
- types.append(m_connection->atom(QXcbAtom::TIMESTAMP));
- types.append(m_connection->atom(QXcbAtom::SAVE_TARGETS));
+ types.append(atom(QXcbAtom::TARGETS));
+ types.append(atom(QXcbAtom::MULTIPLE));
+ types.append(atom(QXcbAtom::TIMESTAMP));
+ types.append(atom(QXcbAtom::SAVE_TARGETS));
- xcb_change_property(m_connection->xcb_connection(), XCB_PROP_MODE_REPLACE, window, property, QXcbAtom::XA_ATOM,
+ xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, window, property, XCB_ATOM_ATOM,
32, types.size(), (const void *)types.constData());
return property;
}
int dataFormat = 0;
QByteArray data;
- QString fmt = QXcbMime::mimeAtomToString(m_connection, target);
+ QString fmt = QXcbMime::mimeAtomToString(connection(), target);
if (fmt.isEmpty()) { // Not a MIME type we have
qDebug() << "QClipboard: send_selection(): converting to type '%s' is not supported" << fmt.data();
return XCB_NONE;
}
qDebug() << "QClipboard: send_selection(): converting to type '%s'" << fmt.data();
- if (QXcbMime::mimeDataForAtom(m_connection, target, d, &data, &atomFormat, &dataFormat)) {
+ if (QXcbMime::mimeDataForAtom(connection(), target, d, &data, &atomFormat, &dataFormat)) {
// don't allow INCR transfers when using MULTIPLE or to
// Motif clients (since Motif doesn't support INCR)
- static xcb_atom_t motif_clip_temporary = m_connection->atom(QXcbAtom::CLIP_TEMPORARY);
+ static xcb_atom_t motif_clip_temporary = atom(QXcbAtom::CLIP_TEMPORARY);
bool allow_incr = property != motif_clip_temporary;
// X_ChangeProperty protocol request is 24 bytes
- const int increment = (xcb_get_maximum_request_length(m_connection->xcb_connection()) * 4) - 24;
+ const int increment = (xcb_get_maximum_request_length(xcb_connection()) * 4) - 24;
if (data.size() > increment && allow_incr) {
long bytes = data.size();
- xcb_change_property(m_connection->xcb_connection(), XCB_PROP_MODE_REPLACE, window, property,
- m_connection->atom(QXcbAtom::INCR), 32, 1, (const void *)&bytes);
+ xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, window, property,
+ atom(QXcbAtom::INCR), 32, 1, (const void *)&bytes);
// (void)new QClipboardINCRTransaction(window, property, atomFormat, dataFormat, data, increment);
qDebug() << "not implemented INCRT just YET!";
return XCB_NONE; // ### perhaps use several XChangeProperty calls w/ PropModeAppend?
int dataSize = data.size() / (dataFormat / 8);
// use a single request to transfer data
- xcb_change_property(m_connection->xcb_connection(), XCB_PROP_MODE_REPLACE, window, property, atomFormat,
+ xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, window, property, atomFormat,
dataFormat, dataSize, (const void *)data.constData());
}
return property;
event.time = req->time;
QMimeData *d;
- if (req->selection == QXcbAtom::XA_PRIMARY) {
+ if (req->selection == XCB_ATOM_PRIMARY) {
d = m_clientSelection;
- } else if (req->selection == m_connection->atom(QXcbAtom::CLIPBOARD)) {
+ } else if (req->selection == atom(QXcbAtom::CLIPBOARD)) {
d = m_clientClipboard;
} else {
- qWarning() << "QClipboard: Unknown selection" << m_connection->atomName(req->selection);
- xcb_send_event(m_connection->xcb_connection(), false, req->requestor, XCB_EVENT_MASK_NO_EVENT, (const char *)&event);
+ qWarning() << "QClipboard: Unknown selection" << connection()->atomName(req->selection);
+ xcb_send_event(xcb_connection(), false, req->requestor, XCB_EVENT_MASK_NO_EVENT, (const char *)&event);
return;
}
if (!d) {
qWarning("QClipboard: Cannot transfer data, no data available");
- xcb_send_event(m_connection->xcb_connection(), false, req->requestor, XCB_EVENT_MASK_NO_EVENT, (const char *)&event);
+ xcb_send_event(xcb_connection(), false, req->requestor, XCB_EVENT_MASK_NO_EVENT, (const char *)&event);
return;
}
- xcb_atom_t xa_targets = m_connection->atom(QXcbAtom::TARGETS);
- xcb_atom_t xa_multiple = m_connection->atom(QXcbAtom::MULTIPLE);
- xcb_atom_t xa_timestamp = m_connection->atom(QXcbAtom::TIMESTAMP);
+ xcb_atom_t xa_targets = atom(QXcbAtom::TARGETS);
+ xcb_atom_t xa_multiple = atom(QXcbAtom::MULTIPLE);
+ xcb_atom_t xa_timestamp = atom(QXcbAtom::TIMESTAMP);
struct AtomPair { xcb_atom_t target; xcb_atom_t property; } *multi = 0;
xcb_atom_t multi_type = XCB_NONE;
0, &multi_type, &multi_format)
|| multi_format != 32) {
// MULTIPLE property not formatted correctly
- xcb_send_event(m_connection->xcb_connection(), false, req->requestor, XCB_EVENT_MASK_NO_EVENT, (const char *)&event);
+ xcb_send_event(xcb_connection(), false, req->requestor, XCB_EVENT_MASK_NO_EVENT, (const char *)&event);
return;
}
nmulti = multi_data.size()/sizeof(*multi);
;
} else if (target == xa_timestamp) {
// if (d->timestamp != CurrentTime) {
-// XChangeProperty(DISPLAY_FROM_XCB(m_connection), req->requestor, property, QXcbAtom::XA_INTEGER, 32,
+// XChangeProperty(DISPLAY_FROM_XCB(connection()), req->requestor, property, QXcbAtom::XA_INTEGER, 32,
// PropModeReplace, CurrentTime, 1);
// ret = property;
// } else {
if (multi_writeback) {
// according to ICCCM 2.6.2 says to put None back
// into the original property on the requestor window
- xcb_change_property(m_connection->xcb_connection(), XCB_PROP_MODE_REPLACE, req->requestor, req->property,
+ xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, req->requestor, req->property,
multi_type, 32, nmulti*2, (const void *)multi);
}
}
// send selection notify to requestor
- xcb_send_event(m_connection->xcb_connection(), false, req->requestor, XCB_EVENT_MASK_NO_EVENT, (const char *)&event);
+ xcb_send_event(xcb_connection(), false, req->requestor, XCB_EVENT_MASK_NO_EVENT, (const char *)&event);
}
static inline int maxSelectionIncr(xcb_connection_t *c)
bool QXcbClipboard::clipboardReadProperty(xcb_window_t win, xcb_atom_t property, bool deleteProperty, QByteArray *buffer, int *size, xcb_atom_t *type, int *format) const
{
- int maxsize = maxSelectionIncr(m_connection->xcb_connection());
+ int maxsize = maxSelectionIncr(xcb_connection());
ulong bytes_left; // bytes_after
xcb_atom_t dummy_type;
int dummy_format;
format = &dummy_format;
// Don't read anything, just get the size of the property data
- xcb_get_property_cookie_t cookie = Q_XCB_CALL(xcb_get_property(m_connection->xcb_connection(), false, win, property, XCB_GET_PROPERTY_TYPE_ANY, 0, 0));
- xcb_get_property_reply_t *reply = xcb_get_property_reply(m_connection->xcb_connection(), cookie, 0);
+ xcb_get_property_cookie_t cookie = Q_XCB_CALL(xcb_get_property(xcb_connection(), false, win, property, XCB_GET_PROPERTY_TYPE_ANY, 0, 0));
+ xcb_get_property_reply_t *reply = xcb_get_property_reply(xcb_connection(), cookie, 0);
if (!reply || reply->type == XCB_NONE) {
buffer->resize(0);
return false;
while (bytes_left) {
// more to read...
- xcb_get_property_cookie_t cookie = Q_XCB_CALL(xcb_get_property(m_connection->xcb_connection(), false, win, property, XCB_GET_PROPERTY_TYPE_ANY, offset, maxsize/4));
- reply = xcb_get_property_reply(m_connection->xcb_connection(), cookie, 0);
+ xcb_get_property_cookie_t cookie = Q_XCB_CALL(xcb_get_property(xcb_connection(), false, win, property, XCB_GET_PROPERTY_TYPE_ANY, offset, maxsize/4));
+ reply = xcb_get_property_reply(xcb_connection(), cookie, 0);
if (!reply || reply->type == XCB_NONE) {
free(reply);
break;
*size = buffer_offset;
if (deleteProperty)
- xcb_delete_property(m_connection->xcb_connection(), win, property);
+ xcb_delete_property(xcb_connection(), win, property);
- m_connection->flush();
+ connection()->flush();
return ok;
}
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;
+ return sr->selection == XCB_ATOM_PRIMARY || sr->selection == clipboard;
} 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;
+ return sc->selection == XCB_ATOM_PRIMARY || sc->selection == clipboard;
}
return false;
}
timer.start();
do {
Notify notify(win, type);
- xcb_generic_event_t *e = m_connection->checkEvent(notify);
+ xcb_generic_event_t *e = connection()->checkEvent(notify);
if (e)
return e;
// process other clipboard events, since someone is probably requesting data from us
- ClipboardEvent clipboard(m_connection);
- e = m_connection->checkEvent(clipboard);
+ ClipboardEvent clipboard(connection());
+ e = connection()->checkEvent(clipboard);
if (e) {
- m_connection->handleXcbEvent(e);
+ connection()->handleXcbEvent(e);
free(e);
}
- m_connection->flush();
+ connection()->flush();
// sleep 50 ms, so we don't use up CPU cycles all the time.
struct timeval usleep_tv;
}
for (;;) {
- m_connection->flush();
+ connection()->flush();
xcb_generic_event_t *ge = waitForClipboardEvent(win, XCB_PROPERTY_NOTIFY, clipboard_timeout);
if (!ge)
break;
QByteArray QXcbClipboard::getDataInFormat(xcb_atom_t modeAtom, xcb_atom_t fmtAtom)
{
- return getSelection(modeAtom, fmtAtom, m_connection->atom(QXcbAtom::_QT_SELECTION));
+ return getSelection(modeAtom, fmtAtom, atom(QXcbAtom::_QT_SELECTION));
}
QByteArray QXcbClipboard::getSelection(xcb_atom_t selection, xcb_atom_t target, xcb_atom_t property)
QByteArray buf;
xcb_window_t win = requestor();
- xcb_delete_property(m_connection->xcb_connection(), win, property);
- xcb_convert_selection(m_connection->xcb_connection(), win, selection, target, property, m_connection->time());
+ xcb_delete_property(xcb_connection(), win, property);
+ xcb_convert_selection(xcb_connection(), win, selection, target, property, connection()->time());
- m_connection->sync();
+ connection()->sync();
xcb_generic_event_t *ge = waitForClipboardEvent(win, XCB_SELECTION_NOTIFY, clipboard_timeout);
bool no_selection = !ge || ((xcb_selection_notify_event_t *)ge)->property == XCB_NONE;
xcb_atom_t type;
if (clipboardReadProperty(win, property, true, &buf, 0, &type, 0)) {
- if (type == m_connection->atom(QXcbAtom::INCR)) {
+ if (type == atom(QXcbAtom::INCR)) {
int nbytes = buf.size() >= 4 ? *((int*)buf.data()) : 0;
buf = clipboardReadIncrementalProperty(win, property, nbytes, false);
}
#define QXCBCLIPBOARD_H
#include <QPlatformClipboard>
-
+#include <qxcbobject.h>
#include <xcb/xcb.h>
class QXcbConnection;
class QXcbScreen;
-class QXcbClipboard : public QPlatformClipboard
+class QXcbClipboard : public QXcbObject, public QPlatformClipboard
{
public:
QXcbClipboard(QXcbConnection *connection);
bool supportsMode(QClipboard::Mode mode) const;
- QXcbConnection *connection() const { return m_connection; }
QXcbScreen *screen() const { return m_screen; }
xcb_window_t requestor() const;
xcb_atom_t sendTargetsSelection(QMimeData *d, xcb_window_t window, xcb_atom_t property);
xcb_atom_t sendSelection(QMimeData *d, xcb_atom_t target, xcb_window_t window, xcb_atom_t property);
- QXcbConnection *m_connection;
QXcbScreen *m_screen;
QMimeData *m_xClipboard;
typedef QHash<xcb_window_t, QXcbWindow *> WindowMapper;
namespace QXcbAtom {
- static const xcb_atom_t XA_PRIMARY = 1;
- static const xcb_atom_t XA_SECONDARY = 2;
- static const xcb_atom_t XA_ATOM = 4;
- static const xcb_atom_t XA_PIXMAP = 20;
- static const xcb_atom_t XA_BITMAP = 5;
- static const xcb_atom_t XA_STRING = 32;
- static const xcb_atom_t XA_WINDOW = 33;
- static const xcb_atom_t XA_CARDINAL = 6;
-
enum Atom {
// window-manager <-> client protocols
WM_PROTOCOLS,
xcb_window_t proxy = XCB_NONE;
xcb_get_property_cookie_t cookie = Q_XCB_CALL2(xcb_get_property(c->xcb_connection(), false, w, c->atom(QXcbAtom::XdndProxy),
- QXcbAtom::XA_WINDOW, 0, 1), c);
+ XCB_ATOM_WINDOW, 0, 1), c);
xcb_get_property_reply_t *reply = xcb_get_property_reply(c->xcb_connection(), cookie, 0);
- if (reply && reply->type == QXcbAtom::XA_WINDOW)
+ if (reply && reply->type == XCB_ATOM_WINDOW)
proxy = *((xcb_window_t *)xcb_get_property_value(reply));
free(reply);
// exists and is real?
cookie = Q_XCB_CALL2(xcb_get_property(c->xcb_connection(), false, proxy, c->atom(QXcbAtom::XdndProxy),
- QXcbAtom::XA_WINDOW, 0, 1), c);
+ XCB_ATOM_WINDOW, 0, 1), c);
reply = xcb_get_property_reply(c->xcb_connection(), cookie, 0);
- if (reply && reply->type == QXcbAtom::XA_WINDOW) {
+ if (reply && reply->type == XCB_ATOM_WINDOW) {
xcb_window_t p = *((xcb_window_t *)xcb_get_property_value(reply));
if (proxy != p)
proxy = 0;
QXcbDrag::QXcbDrag(QXcbConnection *c)
+ : QXcbObject(c)
{
- m_connection = c;
dropData = new QDropData(this);
init();
heartbeat = startTimer(200);
xdnd_dragging = true;
- xcb_set_selection_owner(connection()->xcb_connection(), connection()->clipboard()->owner(),
- connection()->atom(QXcbAtom::XdndSelection), connection()->time());
+ xcb_set_selection_owner(xcb_connection(), connection()->clipboard()->owner(),
+ atom(QXcbAtom::XdndSelection), connection()->time());
QDragManager *manager = QDragManager::self();
QStringList fmts = QXcbMime::formatsHelper(manager->dropData());
}
}
if (drag_types.size() > 3)
- xcb_change_property(connection()->xcb_connection(), XCB_PROP_MODE_REPLACE, connection()->clipboard()->owner(),
- connection()->atom(QXcbAtom::XdndTypelist),
- QXcbAtom::XA_ATOM, 32, drag_types.size(), (const void *)drag_types.constData());
+ xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, connection()->clipboard()->owner(),
+ atom(QXcbAtom::XdndTypelist),
+ XCB_ATOM_ATOM, 32, drag_types.size(), (const void *)drag_types.constData());
QMouseEvent me(QEvent::MouseMove, QCursor::pos(), QCursor::pos(), Qt::LeftButton,
QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers());
free(translate);
// check if it has XdndAware
- xcb_get_property_cookie_t cookie = Q_XCB_CALL(xcb_get_property(connection()->xcb_connection(), false, target,
- connection()->atom(QXcbAtom::XdndAware), XCB_GET_PROPERTY_TYPE_ANY, 0, 0));
- xcb_get_property_reply_t *reply = xcb_get_property_reply(m_connection->xcb_connection(), cookie, 0);
+ xcb_get_property_cookie_t cookie = Q_XCB_CALL(xcb_get_property(xcb_connection(), false, target,
+ atom(QXcbAtom::XdndAware), XCB_GET_PROPERTY_TYPE_ANY, 0, 0));
+ xcb_get_property_reply_t *reply = xcb_get_property_reply(xcb_connection(), cookie, 0);
bool aware = reply && reply->type != XCB_NONE;
free(reply);
if (aware) {
int target_version = 1;
if (proxy_target) {
- xcb_get_property_cookie_t cookie = xcb_get_property(connection()->xcb_connection(), false, target,
- connection()->atom(QXcbAtom::XdndAware), XCB_GET_PROPERTY_TYPE_ANY, 0, 1);
- xcb_get_property_reply_t *reply = xcb_get_property_reply(m_connection->xcb_connection(), cookie, 0);
+ xcb_get_property_cookie_t cookie = xcb_get_property(xcb_connection(), false, target,
+ atom(QXcbAtom::XdndAware), XCB_GET_PROPERTY_TYPE_ANY, 0, 1);
+ xcb_get_property_reply_t *reply = xcb_get_property_reply(xcb_connection(), cookie, 0);
if (!reply || reply->type == XCB_NONE)
target = 0;
target_version = xcb_get_property_value_length(reply) == 1 ? *(uint32_t *)xcb_get_property_value(reply) : 1;
enter.response_type = XCB_CLIENT_MESSAGE;
enter.window = target;
enter.format = 32;
- enter.type = connection()->atom(QXcbAtom::XdndEnter);
+ enter.type = atom(QXcbAtom::XdndEnter);
enter.data.data32[0] = connection()->clipboard()->owner();
enter.data.data32[1] = flags;
enter.data.data32[2] = drag_types.size()>0 ? drag_types.at(0) : 0;
if (w)
handleEnter(w->window(), &enter);
else if (target)
- xcb_send_event(connection()->xcb_connection(), false, proxy_target, XCB_EVENT_MASK_NO_EVENT, (const char *)&enter);
+ xcb_send_event(xcb_connection(), false, proxy_target, XCB_EVENT_MASK_NO_EVENT, (const char *)&enter);
waiting_for_status = false;
}
}
move.response_type = XCB_CLIENT_MESSAGE;
move.window = target;
move.format = 32;
- move.type = connection()->atom(QXcbAtom::XdndPosition);
+ move.type = atom(QXcbAtom::XdndPosition);
move.window = target;
move.data.data32[0] = connection()->clipboard()->owner();
move.data.data32[1] = 0; // flags
if (w)
handle_xdnd_position(w->window(), &move, false);
else
- xcb_send_event(connection()->xcb_connection(), false, proxy_target, XCB_EVENT_MASK_NO_EVENT, (const char *)&move);
+ xcb_send_event(xcb_connection(), false, proxy_target, XCB_EVENT_MASK_NO_EVENT, (const char *)&move);
} else {
if (m->willDrop) {
m->willDrop = false;
drop.response_type = XCB_CLIENT_MESSAGE;
drop.window = current_target;
drop.format = 32;
- drop.type = connection()->atom(QXcbAtom::XdndDrop);
+ drop.type = atom(QXcbAtom::XdndDrop);
drop.data.data32[0] = connection()->clipboard()->owner();
drop.data.data32[1] = 0; // flags
drop.data.data32[2] = connection()->time();
if (w)
handleDrop(w->window(), &drop, false);
else
- xcb_send_event(connection()->xcb_connection(), false, current_proxy_target, XCB_EVENT_MASK_NO_EVENT, (const char *)&drop);
+ xcb_send_event(xcb_connection(), false, current_proxy_target, XCB_EVENT_MASK_NO_EVENT, (const char *)&drop);
current_target = 0;
current_proxy_target = 0;
manager->object = 0;
}
-#define ATOM(x) connection()->atom(QXcbAtom::x)
-
-Qt::DropAction QXcbDrag::toDropAction(xcb_atom_t atom) const
+Qt::DropAction QXcbDrag::toDropAction(xcb_atom_t a) const
{
- if (atom == ATOM(XdndActionCopy) || atom == 0)
+ if (a == atom(QXcbAtom::XdndActionCopy) || a == 0)
return Qt::CopyAction;
- if (atom == ATOM(XdndActionLink))
+ if (a == atom(QXcbAtom::XdndActionLink))
return Qt::LinkAction;
- if (atom == ATOM(XdndActionMove))
+ if (a == atom(QXcbAtom::XdndActionMove))
return Qt::MoveAction;
return Qt::CopyAction;
}
{
switch (a) {
case Qt::CopyAction:
- return ATOM(XdndActionCopy);
+ return atom(QXcbAtom::XdndActionCopy);
case Qt::LinkAction:
- return ATOM(XdndActionLink);
+ return atom(QXcbAtom::XdndActionLink);
case Qt::MoveAction:
case Qt::TargetMoveAction:
- return ATOM(XdndActionMove);
+ return atom(QXcbAtom::XdndActionMove);
case Qt::IgnoreAction:
return XCB_NONE;
default:
- return ATOM(XdndActionCopy);
+ return atom(QXcbAtom::XdndActionCopy);
}
}
-#undef ATOM
-
// timer used to discard old XdndDrop transactions
enum { XdndDropTransactionTimeout = 5000 }; // 5 seconds
if (event->data.data32[1] & 1) {
// get the types from XdndTypeList
- xcb_get_property_cookie_t cookie = xcb_get_property(connection()->xcb_connection(), false, xdnd_dragsource,
- connection()->atom(QXcbAtom::XdndTypelist), QXcbAtom::XA_ATOM,
+ xcb_get_property_cookie_t cookie = xcb_get_property(xcb_connection(), false, xdnd_dragsource,
+ atom(QXcbAtom::XdndTypelist), XCB_ATOM_ATOM,
0, xdnd_max_type);
- xcb_get_property_reply_t *reply = xcb_get_property_reply(connection()->xcb_connection(), cookie, 0);
+ xcb_get_property_reply_t *reply = xcb_get_property_reply(xcb_connection(), cookie, 0);
if (reply && reply->type != XCB_NONE && reply->format == 32) {
int length = xcb_get_property_value_length(reply) / 4;
if (length > xdnd_max_type)
response.response_type = XCB_CLIENT_MESSAGE;
response.window = xdnd_dragsource;
response.format = 32;
- response.type = connection()->atom(QXcbAtom::XdndStatus);
+ response.type = atom(QXcbAtom::XdndStatus);
response.data.data32[0] = xcb_window(w);
response.data.data32[1] = 0; // flags
response.data.data32[2] = 0; // x, y
if (xdnd_dragsource == connection()->clipboard()->owner())
handle_xdnd_status(&response, passive);
else
- Q_XCB_CALL(xcb_send_event(connection()->xcb_connection(), false, xdnd_dragsource,
+ Q_XCB_CALL(xcb_send_event(xcb_connection(), false, xdnd_dragsource,
XCB_EVENT_MASK_NO_EVENT, (const char *)&response));
}
{
xcb_client_message_event_t *lastEvent = const_cast<xcb_client_message_event_t *>(event);
xcb_generic_event_t *nextEvent;
- ClientMessageScanner scanner(connection()->atom(QXcbAtom::XdndPosition));
+ ClientMessageScanner scanner(atom(QXcbAtom::XdndPosition));
while ((nextEvent = connection()->checkEvent(scanner))) {
if (lastEvent != event)
free(lastEvent);
xcb_client_message_event_t *lastEvent = const_cast<xcb_client_message_event_t *>(event);
qDebug() << "handleStatus" << lastEvent->window << lastEvent->data.data32[0];
xcb_generic_event_t *nextEvent;
- ClientMessageScanner scanner(connection()->atom(QXcbAtom::XdndStatus));
+ ClientMessageScanner scanner(atom(QXcbAtom::XdndStatus));
while ((nextEvent = connection()->checkEvent(scanner))) {
if (lastEvent != event)
free(lastEvent);
leave.response_type = XCB_CLIENT_MESSAGE;
leave.window = current_target;
leave.format = 32;
- leave.type = connection()->atom(QXcbAtom::XdndLeave);
+ leave.type = atom(QXcbAtom::XdndLeave);
leave.data.data32[0] = connection()->clipboard()->owner();
leave.data.data32[1] = 0; // flags
leave.data.data32[2] = 0; // x, y
if (w)
handleLeave(w->window(), (const xcb_client_message_event_t *)&leave, false);
else
- xcb_send_event(connection()->xcb_connection(), false,current_proxy_target,
+ xcb_send_event(xcb_connection(), false,current_proxy_target,
XCB_EVENT_MASK_NO_EVENT, (const char *)&leave);
// reset the drag manager state
finished.response_type = XCB_CLIENT_MESSAGE;
finished.window = xdnd_dragsource;
finished.format = 32;
- finished.type = connection()->atom(QXcbAtom::XdndFinished);
+ finished.type = atom(QXcbAtom::XdndFinished);
DNDDEBUG << "xdndHandleDrop"
<< "currentWindow" << currentWindow.data()
<< (currentWindow ? xcb_window(currentWindow.data()) : 0);
finished.data.data32[0] = currentWindow ? xcb_window(currentWindow.data()) : XCB_NONE;
finished.data.data32[1] = de.isAccepted() ? 1 : 0; // flags
finished.data.data32[2] = toXdndAction(manager->global_accepted_action);
- Q_XCB_CALL(xcb_send_event(connection()->xcb_connection(), false, xdnd_dragsource,
+ Q_XCB_CALL(xcb_send_event(xcb_connection(), false, xdnd_dragsource,
XCB_EVENT_MASK_NO_EVENT, (char *)&finished));
} else {
QDragLeaveEvent e;
if (QXcbMime::mimeDataForAtom(connection(), event->target, manager->dragPrivate()->data,
&data, &atomFormat, &dataFormat)) {
int dataSize = data.size() / (dataFormat / 8);
- xcb_change_property(connection()->xcb_connection(), XCB_PROP_MODE_REPLACE, event->requestor, event->property,
+ xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, event->requestor, event->property,
atomFormat, dataFormat, dataSize, (const void *)data.constData());
notify.property = event->property;
notify.target = atomFormat;
// ### this can die if event->requestor crashes at the wrong
// ### moment
- xcb_send_event(connection()->xcb_connection(), false, event->requestor, XCB_EVENT_MASK_NO_EVENT, (const char *)¬ify);
+ xcb_send_event(xcb_connection(), false, event->requestor, XCB_EVENT_MASK_NO_EVENT, (const char *)¬ify);
}
if (desktop_proxy) // *WE* already have one.
return false;
- xcb_grab_server(connection()->xcb_connection());
+ xcb_grab_server(xcb_connection());
// As per Xdnd4, use XdndProxy
xcb_window_t proxy_id = xdndProxy(connection(), w->xcb_window());
desktop_proxy = new QWindow;
xdnd_widget = static_cast<QXcbWindow *>(desktop_proxy->handle());
proxy_id = xdnd_widget->xcb_window();
- xcb_atom_t xdnd_proxy = connection()->atom(QXcbAtom::XdndProxy);
- xcb_change_property(connection()->xcb_connection(), XCB_PROP_MODE_REPLACE, w->xcb_window(), xdnd_proxy,
- QXcbAtom::XA_WINDOW, 32, 1, &proxy_id);
- xcb_change_property(connection()->xcb_connection(), XCB_PROP_MODE_REPLACE, proxy_id, xdnd_proxy,
- QXcbAtom::XA_WINDOW, 32, 1, &proxy_id);
+ xcb_atom_t xdnd_proxy = atom(QXcbAtom::XdndProxy);
+ xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, w->xcb_window(), xdnd_proxy,
+ XCB_ATOM_WINDOW, 32, 1, &proxy_id);
+ xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, proxy_id, xdnd_proxy,
+ XCB_ATOM_WINDOW, 32, 1, &proxy_id);
}
- xcb_ungrab_server(connection()->xcb_connection());
+ xcb_ungrab_server(xcb_connection());
} else {
xdnd_widget = w;
}
if (xdnd_widget) {
DNDDEBUG << "setting XdndAware for" << xdnd_widget << xdnd_widget->xcb_window();
xcb_atom_t atm = xdnd_version;
- xcb_change_property(connection()->xcb_connection(), XCB_PROP_MODE_REPLACE, xdnd_widget->xcb_window(),
- connection()->atom(QXcbAtom::XdndAware), QXcbAtom::XA_ATOM, 32, 1, &atm);
+ xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, xdnd_widget->xcb_window(),
+ atom(QXcbAtom::XdndAware), XCB_ATOM_ATOM, 32, 1, &atm);
return true;
} else {
return false;
}
} else {
if ((w->window()->windowType() == Qt::Desktop)) {
- xcb_delete_property(connection()->xcb_connection(), w->xcb_window(), connection()->atom(QXcbAtom::XdndProxy));
+ xcb_delete_property(xcb_connection(), w->xcb_window(), atom(QXcbAtom::XdndProxy));
delete desktop_proxy;
desktop_proxy = 0;
} else {
if (a == XCB_NONE)
return result;
- if (c->clipboard()->getSelectionOwner(drag->connection()->atom(QXcbAtom::XdndSelection)) == XCB_NONE)
+ if (c->clipboard()->getSelectionOwner(drag->atom(QXcbAtom::XdndSelection)) == XCB_NONE)
return result; // should never happen?
xcb_atom_t xdnd_selection = c->atom(QXcbAtom::XdndSelection);
#ifndef QXCBDRAG_H
#define QXCBDRAG_H
-#include <qlist.h>
#include <qplatformdrag_qpa.h>
-#include <qnamespace.h>
+#include <qxcbobject.h>
#include <xcb/xcb.h>
+#include <qlist.h>
#include <qpoint.h>
#include <qrect.h>
#include <qsharedpointer.h>
class QXcbScreen;
class QDrag;
-class QXcbDrag : public QObject, public QPlatformDrag
+class QXcbDrag : public QObject, public QXcbObject, public QPlatformDrag
{
public:
QXcbDrag(QXcbConnection *c);
bool dndEnable(QXcbWindow *win, bool on);
- QXcbConnection *connection() const { return m_connection; }
-
protected:
void timerEvent(QTimerEvent* e);
QWeakPointer<QWindow> currentWindow;
QPoint currentPosition;
- QXcbConnection *m_connection;
QDropData *dropData;
QWindow *desktop_proxy;
#include <X11/Xutil.h>
-#undef XA_STRING
-#undef XA_PIXMAP
-#undef XA_BITMAP
+#undef XCB_ATOM_STRING
+#undef XCB_ATOM_PIXMAP
+#undef XCB_ATOM_BITMAP
QXcbMime::QXcbMime()
: QInternalMimeData()
return 0;
// special cases for string type
- if (a == QXcbAtom::XA_STRING
+ if (a == XCB_ATOM_STRING
|| a == connection->atom(QXcbAtom::UTF8_STRING)
|| a == connection->atom(QXcbAtom::TEXT))
return QLatin1String("text/plain");
// special case for images
- if (a == QXcbAtom::XA_PIXMAP)
+ if (a == XCB_ATOM_PIXMAP)
return QLatin1String("image/ppm");
QByteArray atomName = connection->atomName(a);
*dataFormat = 8;
if ((a == connection->atom(QXcbAtom::UTF8_STRING)
- || a == QXcbAtom::XA_STRING
+ || a == XCB_ATOM_STRING
|| a == connection->atom(QXcbAtom::TEXT))
&& QInternalMimeData::hasFormatHelper(QLatin1String("text/plain"), mimeData)) {
if (a == connection->atom(QXcbAtom::UTF8_STRING)) {
*data = QInternalMimeData::renderDataHelper(QLatin1String("text/plain"), mimeData);
ret = true;
- } else if (a == QXcbAtom::XA_STRING ||
+ } else if (a == XCB_ATOM_STRING ||
a == connection->atom(QXcbAtom::TEXT)) {
// ICCCM says STRING is latin1
*data = QString::fromUtf8(QInternalMimeData::renderDataHelper(
mozUri += QLatin1Char('\n');
*data = QByteArray(reinterpret_cast<const char *>(mozUri.utf16()), mozUri.length() * 2);
ret = true;
- } else if ((a == QXcbAtom::XA_PIXMAP || a == QXcbAtom::XA_BITMAP) && mimeData->hasImage()) {
+ } else if ((a == XCB_ATOM_PIXMAP || a == XCB_ATOM_BITMAP) && mimeData->hasImage()) {
ret = true;
}
return ret;
// special cases for strings
if (format == QLatin1String("text/plain")) {
atoms.append(connection->atom(QXcbAtom::UTF8_STRING));
- atoms.append(QXcbAtom::XA_STRING);
+ atoms.append(XCB_ATOM_STRING);
atoms.append(connection->atom(QXcbAtom::TEXT));
}
//special cases for images
if (format == QLatin1String("image/ppm"))
- atoms.append(QXcbAtom::XA_PIXMAP);
+ atoms.append(XCB_ATOM_PIXMAP);
if (format == QLatin1String("image/pbm"))
- atoms.append(QXcbAtom::XA_BITMAP);
+ atoms.append(XCB_ATOM_BITMAP);
return atoms;
}
if (format == QLatin1String("text/plain")) {
if (a == connection->atom(QXcbAtom::UTF8_STRING))
return QString::fromUtf8(data);
- if (a == QXcbAtom::XA_STRING ||
+ if (a == XCB_ATOM_STRING ||
a == connection->atom(QXcbAtom::TEXT))
return QString::fromLatin1(data);
}
#if 0 // ###
// special case for images
if (format == QLatin1String("image/ppm")) {
- if (a == XA_PIXMAP && data.size() == sizeof(Pixmap)) {
+ if (a == XCB_ATOM_PIXMAP && data.size() == sizeof(Pixmap)) {
Pixmap xpm = *((Pixmap*)data.data());
if (!xpm)
return QByteArray();
if (format == QLatin1String("text/plain")) {
if (atoms.contains(connection->atom(QXcbAtom::UTF8_STRING)))
return connection->atom(QXcbAtom::UTF8_STRING);
- if (atoms.contains(QXcbAtom::XA_STRING))
- return QXcbAtom::XA_STRING;
+ if (atoms.contains(XCB_ATOM_STRING))
+ return XCB_ATOM_STRING;
if (atoms.contains(connection->atom(QXcbAtom::TEXT)))
return connection->atom(QXcbAtom::TEXT);
}
// find match for image
if (format == QLatin1String("image/ppm")) {
- if (atoms.contains(QXcbAtom::XA_PIXMAP))
- return QXcbAtom::XA_PIXMAP;
+ if (atoms.contains(XCB_ATOM_PIXMAP))
+ return XCB_ATOM_PIXMAP;
}
// for string/text requests try to use a format with a well-defined charset
0)); // value list
wid = m_netWmUserTimeWindow;
xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::_NET_WM_USER_TIME_WINDOW),
- QXcbAtom::XA_WINDOW, 32, 1, &m_netWmUserTimeWindow);
+ XCB_ATOM_WINDOW, 32, 1, &m_netWmUserTimeWindow);
xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::_NET_WM_USER_TIME));
} else if (!isSupportedByWM) {
// WM no longer supports it, then we should remove the
}
}
xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, wid, atom(QXcbAtom::_NET_WM_USER_TIME),
- QXcbAtom::XA_CARDINAL, 32, 1, ×tamp);
+ XCB_ATOM_CARDINAL, 32, 1, ×tamp);
}
int remaining = 0;
do {
xcb_generic_error_t *error = 0;
- xcb_get_property_cookie_t cookie = xcb_get_property(xcb_connection(), false, root, atom(QXcbAtom::_NET_SUPPORTED), QXcbAtom::XA_ATOM, offset, 1024);
+ xcb_get_property_cookie_t cookie = xcb_get_property(xcb_connection(), false, root, atom(QXcbAtom::_NET_SUPPORTED), XCB_ATOM_ATOM, offset, 1024);
xcb_get_property_reply_t *reply = xcb_get_property_reply(xcb_connection(), cookie, &error);
if (!reply || error)
break;
remaining = 0;
- if (reply->type == QXcbAtom::XA_ATOM && reply->format == 32) {
+ if (reply->type == XCB_ATOM_ATOM && reply->format == 32) {
int len = xcb_get_property_value_length(reply)/4;
xcb_atom_t *atoms = (xcb_atom_t *)xcb_get_property_value(reply);
int s = net_wm_atoms.size();
int remaining = 0;
do {
xcb_generic_error_t *error = 0;
- xcb_get_property_cookie_t cookie = xcb_get_property(xcb_connection(), false, root, atom(QXcbAtom::_NET_VIRTUAL_ROOTS), QXcbAtom::XA_ATOM, offset, 1024);
+ xcb_get_property_cookie_t cookie = xcb_get_property(xcb_connection(), false, root, atom(QXcbAtom::_NET_VIRTUAL_ROOTS), XCB_ATOM_ATOM, offset, 1024);
xcb_get_property_reply_t *reply = xcb_get_property_reply(xcb_connection(), cookie, &error);
if (!reply || error)
break;
remaining = 0;
- if (reply->type == QXcbAtom::XA_ATOM && reply->format == 32) {
+ if (reply->type == XCB_ATOM_ATOM && reply->format == 32) {
int len = xcb_get_property_value_length(reply)/4;
xcb_atom_t *atoms = (xcb_atom_t *)xcb_get_property_value(reply);
int s = net_wm_atoms.size();
LIBS += -lxcb -lxcb-image -lxcb-keysyms -lxcb-icccm -lxcb-sync
-DEFINES += $$QMAKE_DEFINES_XCB
+DEFINES += $$QMAKE_DEFINES_XCB QT_NO_XCB_XKB
LIBS += $$QMAKE_LIBS_XCB
QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_XCB