Changeset View
Changeset View
Standalone View
Standalone View
xwl/drag_x.cpp
Show All 36 Lines | |||||
37 | #include <KWayland/Server/datasource_interface.h> | 37 | #include <KWayland/Server/datasource_interface.h> | ||
38 | 38 | | |||
39 | #include <QMouseEvent> | 39 | #include <QMouseEvent> | ||
40 | #include <QTimer> | 40 | #include <QTimer> | ||
41 | 41 | | |||
42 | namespace KWin { | 42 | namespace KWin { | ||
43 | namespace Xwl { | 43 | namespace Xwl { | ||
44 | 44 | | |||
45 | static QStringList atomToMimeTypes(xcb_atom_t atom) | ||||
46 | { | ||||
47 | QStringList mimeTypes; | ||||
48 | | ||||
49 | if (atom == atoms->utf8_string) { | ||||
50 | mimeTypes << QString::fromLatin1("text/plain;charset=utf-8"); | ||||
51 | } else if (atom == atoms->text) { | ||||
52 | mimeTypes << QString::fromLatin1("text/plain"); | ||||
53 | } else if (atom == atoms->uri_list || atom == atoms->netscape_url || atom == atoms->moz_url) { | ||||
54 | // We identify netscape and moz format as less detailed formats text/uri-list, | ||||
55 | // text/x-uri and accept the information loss. | ||||
56 | mimeTypes << "text/uri-list" << "text/x-uri"; | ||||
zzag: QStringLiteral.
Also, I think it would simpler to just return, e.g.
```lang=cpp
return… | |||||
57 | } else { | ||||
58 | mimeTypes << Selection::atomName(atom); | ||||
59 | } | ||||
60 | return mimeTypes; | ||||
61 | } | ||||
62 | | ||||
45 | XToWlDrag::XToWlDrag(X11Source *source) | 63 | XToWlDrag::XToWlDrag(X11Source *source) | ||
46 | : m_src(source) | 64 | : m_src(source) | ||
47 | { | 65 | { | ||
48 | connect(DataBridge::self()->dnd(), &Dnd::transferFinished, this, [this](xcb_timestamp_t eventTime) { | 66 | connect(DataBridge::self()->dnd(), &Dnd::transferFinished, this, [this](xcb_timestamp_t eventTime) { | ||
49 | // we use this mechanism, because the finished call is not | 67 | // we use this mechanism, because the finished call is not | ||
50 | // reliable done by Wayland clients | 68 | // reliable done by Wayland clients | ||
51 | auto it = std::find_if(m_dataRequests.begin(), m_dataRequests.end(), [this, eventTime](QPair<xcb_timestamp_t, bool> req) { | 69 | auto it = std::find_if(m_dataRequests.begin(), m_dataRequests.end(), [this, eventTime](QPair<xcb_timestamp_t, bool> req) { | ||
52 | return req.first == eventTime; | 70 | return req.first == eventTime; | ||
▲ Show 20 Lines • Show All 309 Lines • ▼ Show 20 Line(s) | 371 | { | |||
362 | m_version = data->data32[1] >> 24; | 380 | m_version = data->data32[1] >> 24; | ||
363 | 381 | | |||
364 | // get types | 382 | // get types | ||
365 | Mimes offers; | 383 | Mimes offers; | ||
366 | if (!(data->data32[1] & 1)) { | 384 | if (!(data->data32[1] & 1)) { | ||
367 | // message has only max 3 types (which are directly in data) | 385 | // message has only max 3 types (which are directly in data) | ||
368 | for (size_t i = 0; i < 3; i++) { | 386 | for (size_t i = 0; i < 3; i++) { | ||
369 | xcb_atom_t mimeAtom = data->data32[2 + i]; | 387 | xcb_atom_t mimeAtom = data->data32[2 + i]; | ||
370 | const auto mimeStrings = Selection::atomToMimeTypes(mimeAtom); | 388 | const auto mimeStrings = atomToMimeTypes(mimeAtom); | ||
371 | for (const auto mime : mimeStrings ) { | 389 | for (const auto mime : mimeStrings ) { | ||
372 | if (!hasMimeName(offers, mime)) { | 390 | if (!hasMimeName(offers, mime)) { | ||
373 | offers << Mime(mime, mimeAtom); | 391 | offers << Mime(mime, mimeAtom); | ||
374 | } | 392 | } | ||
375 | } | 393 | } | ||
376 | } | 394 | } | ||
377 | } else { | 395 | } else { | ||
378 | // more than 3 types -> in window property | 396 | // more than 3 types -> in window property | ||
Show All 21 Lines | 405 | { | |||
400 | if (reply->type != XCB_ATOM_ATOM || reply->value_len == 0) { | 418 | if (reply->type != XCB_ATOM_ATOM || reply->value_len == 0) { | ||
401 | // invalid reply value | 419 | // invalid reply value | ||
402 | free(reply); | 420 | free(reply); | ||
403 | return; | 421 | return; | ||
404 | } | 422 | } | ||
405 | 423 | | |||
406 | xcb_atom_t *mimeAtoms = static_cast<xcb_atom_t*>(xcb_get_property_value(reply)); | 424 | xcb_atom_t *mimeAtoms = static_cast<xcb_atom_t*>(xcb_get_property_value(reply)); | ||
407 | for (size_t i = 0; i < reply->value_len; ++i) { | 425 | for (size_t i = 0; i < reply->value_len; ++i) { | ||
408 | const auto mimeStrings = Selection::atomToMimeTypes(mimeAtoms[i]); | 426 | const auto mimeStrings = atomToMimeTypes(mimeAtoms[i]); | ||
409 | for (const auto mime : mimeStrings ) { | 427 | for (const auto mime : mimeStrings ) { | ||
410 | if (!hasMimeName(offers, mime)) { | 428 | if (!hasMimeName(offers, mime)) { | ||
411 | offers << Mime(mime, mimeAtoms[i]); | 429 | offers << Mime(mime, mimeAtoms[i]); | ||
412 | } | 430 | } | ||
413 | } | 431 | } | ||
414 | } | 432 | } | ||
415 | free(reply); | 433 | free(reply); | ||
416 | } | 434 | } | ||
▲ Show 20 Lines • Show All 117 Lines • Show Last 20 Lines |
QStringLiteral.
Also, I think it would simpler to just return, e.g.