Changeset View
Changeset View
Standalone View
Standalone View
xwl/drag_x.cpp
Show All 36 Lines | |||||
37 | #include <KWayland/Server/surface_interface.h> | 37 | #include <KWayland/Server/surface_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 << QString::fromLatin1("text/uri-list") << QString::fromLatin1("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 307 Lines • ▼ Show 20 Line(s) | 369 | { | |||
360 | m_version = data->data32[1] >> 24; | 378 | m_version = data->data32[1] >> 24; | ||
361 | 379 | | |||
362 | // get types | 380 | // get types | ||
363 | Mimes offers; | 381 | Mimes offers; | ||
364 | if (!(data->data32[1] & 1)) { | 382 | if (!(data->data32[1] & 1)) { | ||
365 | // message has only max 3 types (which are directly in data) | 383 | // message has only max 3 types (which are directly in data) | ||
366 | for (size_t i = 0; i < 3; i++) { | 384 | for (size_t i = 0; i < 3; i++) { | ||
367 | xcb_atom_t mimeAtom = data->data32[2 + i]; | 385 | xcb_atom_t mimeAtom = data->data32[2 + i]; | ||
368 | const auto mimeStrings = Selection::atomToMimeTypes(mimeAtom); | 386 | const auto mimeStrings = atomToMimeTypes(mimeAtom); | ||
369 | for (const auto mime : mimeStrings ) { | 387 | for (const auto mime : mimeStrings ) { | ||
370 | if (!hasMimeName(offers, mime)) { | 388 | if (!hasMimeName(offers, mime)) { | ||
371 | offers << Mime(mime, mimeAtom); | 389 | offers << Mime(mime, mimeAtom); | ||
372 | } | 390 | } | ||
373 | } | 391 | } | ||
374 | } | 392 | } | ||
375 | } else { | 393 | } else { | ||
376 | // more than 3 types -> in window property | 394 | // more than 3 types -> in window property | ||
Show All 21 Lines | 403 | { | |||
398 | if (reply->type != XCB_ATOM_ATOM || reply->value_len == 0) { | 416 | if (reply->type != XCB_ATOM_ATOM || reply->value_len == 0) { | ||
399 | // invalid reply value | 417 | // invalid reply value | ||
400 | free(reply); | 418 | free(reply); | ||
401 | return; | 419 | return; | ||
402 | } | 420 | } | ||
403 | 421 | | |||
404 | xcb_atom_t *mimeAtoms = static_cast<xcb_atom_t*>(xcb_get_property_value(reply)); | 422 | xcb_atom_t *mimeAtoms = static_cast<xcb_atom_t*>(xcb_get_property_value(reply)); | ||
405 | for (size_t i = 0; i < reply->value_len; ++i) { | 423 | for (size_t i = 0; i < reply->value_len; ++i) { | ||
406 | const auto mimeStrings = Selection::atomToMimeTypes(mimeAtoms[i]); | 424 | const auto mimeStrings = atomToMimeTypes(mimeAtoms[i]); | ||
407 | for (const auto mime : mimeStrings ) { | 425 | for (const auto mime : mimeStrings ) { | ||
408 | if (!hasMimeName(offers, mime)) { | 426 | if (!hasMimeName(offers, mime)) { | ||
409 | offers << Mime(mime, mimeAtoms[i]); | 427 | offers << Mime(mime, mimeAtoms[i]); | ||
410 | } | 428 | } | ||
411 | } | 429 | } | ||
412 | } | 430 | } | ||
413 | free(reply); | 431 | free(reply); | ||
414 | } | 432 | } | ||
▲ Show 20 Lines • Show All 117 Lines • Show Last 20 Lines |
QStringLiteral.
Also, I think it would simpler to just return, e.g.