qxcbsystemtraytracker.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7enum {-
8 SystemTrayRequestDock = 0,-
9 SystemTrayBeginMessage = 1,-
10 SystemTrayCancelMessage = 2-
11};-
12-
13-
14-
15-
16-
17QXcbSystemTrayTracker *QXcbSystemTrayTracker::create(QXcbConnection *connection)-
18{-
19-
20 const xcb_atom_t trayAtom = connection->atom(QXcbAtom::_NET_SYSTEM_TRAY_OPCODE);-
21 if (!trayAtom
!trayAtomDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QSystemTrayIcon
)
0-1
22 return
never executed: return 0;
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: return ba;
Executed by:
  • tst_QSystemTrayIcon
ba;
executed 1 time by 1 test: return ba;
Executed by:
  • tst_QSystemTrayIcon
}()) + QByteArray::number(connection->primaryScreenNumber());
1
24 const xcb_atom_t selection = connection->internAtom(netSysTray.constData());-
25 if (!selection
!selectionDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QSystemTrayIcon
)
0-1
26 return
never executed: return 0;
0;
never executed: return 0;
0
27-
28 return
executed 1 time by 1 test: return new QXcbSystemTrayTracker(connection, trayAtom, selection);
Executed by:
  • tst_QSystemTrayIcon
new QXcbSystemTrayTracker(connection, trayAtom, selection);
executed 1 time by 1 test: return new QXcbSystemTrayTracker(connection, trayAtom, selection);
Executed by:
  • tst_QSystemTrayIcon
1
29}-
30-
31QXcbSystemTrayTracker::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 block
Executed by:
  • tst_QSystemTrayIcon
1
41-
42xcb_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
!replyDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QSystemTrayIcon
)
0-1
47 return
never executed: return 0;
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: return result;
Executed by:
  • tst_QSystemTrayIcon
result;
executed 1 time by 1 test: return result;
Executed by:
  • tst_QSystemTrayIcon
1
51}-
52-
53-
54-
55void 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 block
Executed by:
  • tst_QSystemTrayIcon
3
68-
69-
70xcb_window_t QXcbSystemTrayTracker::trayWindow()-
71{-
72 if (!m_trayWindow
!m_trayWindowDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QSystemTrayIcon
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QSystemTrayIcon
) {
1-5
73 m_trayWindow = QXcbSystemTrayTracker::locateTrayWindow(m_connection, m_selection);-
74 if (m_trayWindow
m_trayWindowDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QSystemTrayIcon
FALSEnever evaluated
) {
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 block
Executed by:
  • tst_QSystemTrayIcon
1
80 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QSystemTrayIcon
1
81 return
executed 6 times by 1 test: return m_trayWindow;
Executed by:
  • tst_QSystemTrayIcon
m_trayWindow;
executed 6 times by 1 test: return m_trayWindow;
Executed by:
  • tst_QSystemTrayIcon
6
82}-
83-
84-
85-
86-
87QRect 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
!geomReplyDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QSystemTrayIcon
)
0-4
94 return
never executed: return QRect();
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
!translateReplyDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QSystemTrayIcon
) {
0-4
99 free(geomReply);-
100 return
never executed: return QRect();
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: return result;
Executed by:
  • tst_QSystemTrayIcon
result;
executed 4 times by 1 test: return result;
Executed by:
  • tst_QSystemTrayIcon
4
106}-
107-
108inline void QXcbSystemTrayTracker::emitSystemTrayWindowChanged()-
109{-
110 if (const
const QPlatfor...rimaryScreen()Description
TRUEnever evaluated
FALSEnever evaluated
QPlatformScreen *ps = m_connection->primaryScreen()
const QPlatfor...rimaryScreen()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
111 systemTrayWindowChanged(ps->screen());
never executed: systemTrayWindowChanged(ps->screen());
0
112}
never executed: end of block
0
113-
114-
115void QXcbSystemTrayTracker::notifyManagerClientMessageEvent(const xcb_client_message_event_t *t)-
116{-
117 if (t->data.data32[1] == m_selection
t->data.data32...== m_selectionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
118 emitSystemTrayWindowChanged();
never executed: emitSystemTrayWindowChanged();
0
119}
never executed: end of block
0
120-
121-
122void QXcbSystemTrayTracker::handleDestroyNotifyEvent(const xcb_destroy_notify_event_t *event)-
123{-
124 if (event->window == m_trayWindow
event->window == m_trayWindowDescription
TRUEnever evaluated
FALSEnever evaluated
) {
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-
131bool QXcbSystemTrayTracker::visualHasAlphaChannel()-
132{-
133 if (m_trayWindow == XCB_WINDOW_NONE
m_trayWindow =...CB_WINDOW_NONEDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QSystemTrayIcon
)
0-3
134 return
never executed: return false;
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
!systray_atom_replyDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QSystemTrayIcon
)
0-3
147 return
never executed: return false;
false;
never executed: return false;
0
148-
149 xcb_visualid_t systrayVisualId = 0L;-
150 if (systray_atom_reply->value_len > 0
systray_atom_r...>value_len > 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QSystemTrayIcon
FALSEnever evaluated
&& xcb_get_property_value_length(systray_atom_reply) > 0
xcb_get_proper...tom_reply) > 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QSystemTrayIcon
FALSEnever evaluated
) {
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 block
Executed by:
  • tst_QSystemTrayIcon
3
154-
155 free(systray_atom_reply);-
156-
157 if (systrayVisualId != 0L
systrayVisualId != 0LDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QSystemTrayIcon
FALSEnever evaluated
) {
0-3
158 quint8 depth = m_connection->primaryScreen()->depthOfVisual(systrayVisualId);-
159 return
executed 3 times by 1 test: return depth == 32;
Executed by:
  • tst_QSystemTrayIcon
depth == 32;
executed 3 times by 1 test: return depth == 32;
Executed by:
  • tst_QSystemTrayIcon
3
160 }-
161-
162 return
never executed: return false;
false;
never executed: return false;
0
163}-
164-
165-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9