| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | - | |||||||||||||
| 5 | - | |||||||||||||
| 6 | - | |||||||||||||
| 7 | enum { | - | ||||||||||||
| 8 | SystemTrayRequestDock = 0, | - | ||||||||||||
| 9 | SystemTrayBeginMessage = 1, | - | ||||||||||||
| 10 | SystemTrayCancelMessage = 2 | - | ||||||||||||
| 11 | }; | - | ||||||||||||
| 12 | - | |||||||||||||
| 13 | - | |||||||||||||
| 14 | - | |||||||||||||
| 15 | - | |||||||||||||
| 16 | - | |||||||||||||
| 17 | QXcbSystemTrayTracker *QXcbSystemTrayTracker::create(QXcbConnection *connection) | - | ||||||||||||
| 18 | { | - | ||||||||||||
| 19 | - | |||||||||||||
| 20 | const xcb_atom_t trayAtom = connection->atom(QXcbAtom::_NET_SYSTEM_TRAY_OPCODE); | - | ||||||||||||
| 21 | if (!trayAtom
| 0-1 | ||||||||||||
| 22 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 23 | const QByteArray netSysTray = ([]() -> QByteArray { enum { Size = sizeof("_NET_SYSTEM_TRAY_S") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "_NET_SYSTEM_TRAY_S" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return executed 1 time by 1 test: ba;return ba;Executed by:
executed 1 time by 1 test: }()) + QByteArray::number(connection->primaryScreenNumber());return ba;Executed by:
| 1 | ||||||||||||
| 24 | const xcb_atom_t selection = connection->internAtom(netSysTray.constData()); | - | ||||||||||||
| 25 | if (!selection
| 0-1 | ||||||||||||
| 26 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 27 | - | |||||||||||||
| 28 | return executed 1 time by 1 test: new QXcbSystemTrayTracker(connection, trayAtom, selection);return new QXcbSystemTrayTracker(connection, trayAtom, selection);Executed by:
executed 1 time by 1 test: return new QXcbSystemTrayTracker(connection, trayAtom, selection);Executed by:
| 1 | ||||||||||||
| 29 | } | - | ||||||||||||
| 30 | - | |||||||||||||
| 31 | QXcbSystemTrayTracker::QXcbSystemTrayTracker(QXcbConnection *connection, | - | ||||||||||||
| 32 | xcb_atom_t trayAtom, | - | ||||||||||||
| 33 | xcb_atom_t selection) | - | ||||||||||||
| 34 | : QObject(connection) | - | ||||||||||||
| 35 | , m_selection(selection) | - | ||||||||||||
| 36 | , m_trayAtom(trayAtom) | - | ||||||||||||
| 37 | , m_connection(connection) | - | ||||||||||||
| 38 | , m_trayWindow(0) | - | ||||||||||||
| 39 | { | - | ||||||||||||
| 40 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||
| 41 | - | |||||||||||||
| 42 | xcb_window_t QXcbSystemTrayTracker::locateTrayWindow(const QXcbConnection *connection, xcb_atom_t selection) | - | ||||||||||||
| 43 | { | - | ||||||||||||
| 44 | xcb_get_selection_owner_cookie_t cookie = xcb_get_selection_owner(connection->xcb_connection(), selection); | - | ||||||||||||
| 45 | xcb_get_selection_owner_reply_t *reply = xcb_get_selection_owner_reply(connection->xcb_connection(), cookie, 0); | - | ||||||||||||
| 46 | if (!reply
| 0-1 | ||||||||||||
| 47 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 48 | const xcb_window_t result = reply->owner; | - | ||||||||||||
| 49 | free(reply); | - | ||||||||||||
| 50 | return executed 1 time by 1 test: result;return result;Executed by:
executed 1 time by 1 test: return result;Executed by:
| 1 | ||||||||||||
| 51 | } | - | ||||||||||||
| 52 | - | |||||||||||||
| 53 | - | |||||||||||||
| 54 | - | |||||||||||||
| 55 | void QXcbSystemTrayTracker::requestSystemTrayWindowDock(xcb_window_t window) const | - | ||||||||||||
| 56 | { | - | ||||||||||||
| 57 | xcb_client_message_event_t trayRequest; | - | ||||||||||||
| 58 | trayRequest.response_type = 33; | - | ||||||||||||
| 59 | trayRequest.format = 32; | - | ||||||||||||
| 60 | trayRequest.sequence = 0; | - | ||||||||||||
| 61 | trayRequest.window = m_trayWindow; | - | ||||||||||||
| 62 | trayRequest.type = m_trayAtom; | - | ||||||||||||
| 63 | trayRequest.data.data32[0] = 0L; | - | ||||||||||||
| 64 | trayRequest.data.data32[1] = SystemTrayRequestDock; | - | ||||||||||||
| 65 | trayRequest.data.data32[2] = window; | - | ||||||||||||
| 66 | xcb_send_event(m_connection->xcb_connection(), 0, m_trayWindow, XCB_EVENT_MASK_NO_EVENT, (const char *)&trayRequest); | - | ||||||||||||
| 67 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||
| 68 | - | |||||||||||||
| 69 | - | |||||||||||||
| 70 | xcb_window_t QXcbSystemTrayTracker::trayWindow() | - | ||||||||||||
| 71 | { | - | ||||||||||||
| 72 | if (!m_trayWindow
| 1-5 | ||||||||||||
| 73 | m_trayWindow = QXcbSystemTrayTracker::locateTrayWindow(m_connection, m_selection); | - | ||||||||||||
| 74 | if (m_trayWindow
| 0-1 | ||||||||||||
| 75 | m_connection->addWindowEventListener(m_trayWindow, this); | - | ||||||||||||
| 76 | const quint32 mask = XCB_CW_EVENT_MASK; | - | ||||||||||||
| 77 | const quint32 value = XCB_EVENT_MASK_STRUCTURE_NOTIFY; | - | ||||||||||||
| 78 | xcb_change_window_attributes(m_connection->xcb_connection(), m_trayWindow, mask, &value); | - | ||||||||||||
| 79 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||
| 80 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||
| 81 | return executed 6 times by 1 test: m_trayWindow;return m_trayWindow;Executed by:
executed 6 times by 1 test: return m_trayWindow;Executed by:
| 6 | ||||||||||||
| 82 | } | - | ||||||||||||
| 83 | - | |||||||||||||
| 84 | - | |||||||||||||
| 85 | - | |||||||||||||
| 86 | - | |||||||||||||
| 87 | QRect QXcbSystemTrayTracker::systemTrayWindowGlobalGeometry(xcb_window_t window) const | - | ||||||||||||
| 88 | { | - | ||||||||||||
| 89 | - | |||||||||||||
| 90 | xcb_connection_t *conn = m_connection->xcb_connection(); | - | ||||||||||||
| 91 | xcb_get_geometry_reply_t *geomReply = | - | ||||||||||||
| 92 | xcb_get_geometry_reply(conn, xcb_get_geometry(conn, window), 0); | - | ||||||||||||
| 93 | if (!geomReply
| 0-4 | ||||||||||||
| 94 | return never executed: QRect();return QRect();never executed: return QRect(); | 0 | ||||||||||||
| 95 | - | |||||||||||||
| 96 | xcb_translate_coordinates_reply_t *translateReply = | - | ||||||||||||
| 97 | xcb_translate_coordinates_reply(conn, xcb_translate_coordinates(conn, window, m_connection->rootWindow(), 0, 0), 0); | - | ||||||||||||
| 98 | if (!translateReply
| 0-4 | ||||||||||||
| 99 | free(geomReply); | - | ||||||||||||
| 100 | return never executed: QRect();return QRect();never executed: return QRect(); | 0 | ||||||||||||
| 101 | } | - | ||||||||||||
| 102 | - | |||||||||||||
| 103 | const QRect result(QPoint(translateReply->dst_x, translateReply->dst_y), QSize(geomReply->width, geomReply->height)); | - | ||||||||||||
| 104 | free(translateReply); | - | ||||||||||||
| 105 | return executed 4 times by 1 test: result;return result;Executed by:
executed 4 times by 1 test: return result;Executed by:
| 4 | ||||||||||||
| 106 | } | - | ||||||||||||
| 107 | - | |||||||||||||
| 108 | inline void QXcbSystemTrayTracker::emitSystemTrayWindowChanged() | - | ||||||||||||
| 109 | { | - | ||||||||||||
| 110 | if (const
| 0 | ||||||||||||
| 111 | systemTrayWindowChanged(ps->screen()); never executed: systemTrayWindowChanged(ps->screen()); | 0 | ||||||||||||
| 112 | } never executed: end of block | 0 | ||||||||||||
| 113 | - | |||||||||||||
| 114 | - | |||||||||||||
| 115 | void QXcbSystemTrayTracker::notifyManagerClientMessageEvent(const xcb_client_message_event_t *t) | - | ||||||||||||
| 116 | { | - | ||||||||||||
| 117 | if (t->data.data32[1] == m_selection
| 0 | ||||||||||||
| 118 | emitSystemTrayWindowChanged(); never executed: emitSystemTrayWindowChanged(); | 0 | ||||||||||||
| 119 | } never executed: end of block | 0 | ||||||||||||
| 120 | - | |||||||||||||
| 121 | - | |||||||||||||
| 122 | void QXcbSystemTrayTracker::handleDestroyNotifyEvent(const xcb_destroy_notify_event_t *event) | - | ||||||||||||
| 123 | { | - | ||||||||||||
| 124 | if (event->window == m_trayWindow
| 0 | ||||||||||||
| 125 | m_connection->removeWindowEventListener(m_trayWindow); | - | ||||||||||||
| 126 | m_trayWindow = XCB_WINDOW_NONE; | - | ||||||||||||
| 127 | emitSystemTrayWindowChanged(); | - | ||||||||||||
| 128 | } never executed: end of block | 0 | ||||||||||||
| 129 | } never executed: end of block | 0 | ||||||||||||
| 130 | - | |||||||||||||
| 131 | bool QXcbSystemTrayTracker::visualHasAlphaChannel() | - | ||||||||||||
| 132 | { | - | ||||||||||||
| 133 | if (m_trayWindow == XCB_WINDOW_NONE
| 0-3 | ||||||||||||
| 134 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||
| 135 | - | |||||||||||||
| 136 | xcb_atom_t tray_atom = m_connection->atom(QXcbAtom::_NET_SYSTEM_TRAY_VISUAL); | - | ||||||||||||
| 137 | - | |||||||||||||
| 138 | - | |||||||||||||
| 139 | xcb_get_property_cookie_t systray_atom_cookie; | - | ||||||||||||
| 140 | xcb_get_property_reply_t *systray_atom_reply; | - | ||||||||||||
| 141 | - | |||||||||||||
| 142 | systray_atom_cookie = xcb_get_property_unchecked(m_connection->xcb_connection(), false, m_trayWindow, | - | ||||||||||||
| 143 | tray_atom, XCB_ATOM_VISUALID, 0, 1); | - | ||||||||||||
| 144 | systray_atom_reply = xcb_get_property_reply(m_connection->xcb_connection(), systray_atom_cookie, 0); | - | ||||||||||||
| 145 | - | |||||||||||||
| 146 | if (!systray_atom_reply
| 0-3 | ||||||||||||
| 147 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||
| 148 | - | |||||||||||||
| 149 | xcb_visualid_t systrayVisualId = 0L; | - | ||||||||||||
| 150 | if (systray_atom_reply->value_len > 0
| 0-3 | ||||||||||||
| 151 | xcb_visualid_t * vids = (uint32_t *)xcb_get_property_value(systray_atom_reply); | - | ||||||||||||
| 152 | systrayVisualId = vids[0]; | - | ||||||||||||
| 153 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||
| 154 | - | |||||||||||||
| 155 | free(systray_atom_reply); | - | ||||||||||||
| 156 | - | |||||||||||||
| 157 | if (systrayVisualId != 0L
| 0-3 | ||||||||||||
| 158 | quint8 depth = m_connection->primaryScreen()->depthOfVisual(systrayVisualId); | - | ||||||||||||
| 159 | return executed 3 times by 1 test: depth == 32;return depth == 32;Executed by:
executed 3 times by 1 test: return depth == 32;Executed by:
| 3 | ||||||||||||
| 160 | } | - | ||||||||||||
| 161 | - | |||||||||||||
| 162 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||
| 163 | } | - | ||||||||||||
| 164 | - | |||||||||||||
| 165 | - | |||||||||||||
| Switch to Source code | Preprocessed file |