Changeset View
Changeset View
Standalone View
Standalone View
xembed-sni-proxy/fdoselectionmanager.cpp
Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | |||||
61 | } | 61 | } | ||
62 | 62 | | |||
63 | void FdoSelectionManager::init() | 63 | void FdoSelectionManager::init() | ||
64 | { | 64 | { | ||
65 | //load damage extension | 65 | //load damage extension | ||
66 | xcb_connection_t *c = QX11Info::connection(); | 66 | xcb_connection_t *c = QX11Info::connection(); | ||
67 | xcb_prefetch_extension_data(c, &xcb_damage_id); | 67 | xcb_prefetch_extension_data(c, &xcb_damage_id); | ||
68 | const auto *reply = xcb_get_extension_data(c, &xcb_damage_id); | 68 | const auto *reply = xcb_get_extension_data(c, &xcb_damage_id); | ||
69 | if (reply->present) { | 69 | if (reply && reply->present) { | ||
70 | m_damageEventBase = reply->first_event; | 70 | m_damageEventBase = reply->first_event; | ||
71 | xcb_damage_query_version_unchecked(c, XCB_DAMAGE_MAJOR_VERSION, XCB_DAMAGE_MINOR_VERSION); | 71 | xcb_damage_query_version_unchecked(c, XCB_DAMAGE_MAJOR_VERSION, XCB_DAMAGE_MINOR_VERSION); | ||
72 | } else { | 72 | } else { | ||
73 | //no XDamage means | 73 | //no XDamage means | ||
74 | qCCritical(SNIPROXY) << "could not load damage extension. Quitting"; | 74 | qCCritical(SNIPROXY) << "could not load damage extension. Quitting"; | ||
75 | qApp->exit(-1); | 75 | qApp->exit(-1); | ||
76 | } | 76 | } | ||
77 | 77 | | |||
Show All 34 Lines | 87 | { | |||
112 | // if window is gone by this point, it will be caught by eventFilter, so no need to check later errors. | 112 | // if window is gone by this point, it will be caught by eventFilter, so no need to check later errors. | ||
113 | if (changeAttrError && changeAttrError->error_code == XCB_WINDOW) { | 113 | if (changeAttrError && changeAttrError->error_code == XCB_WINDOW) { | ||
114 | return false; | 114 | return false; | ||
115 | } | 115 | } | ||
116 | 116 | | |||
117 | return true; | 117 | return true; | ||
118 | } | 118 | } | ||
119 | 119 | | |||
120 | bool FdoSelectionManager::nativeEventFilter(const QByteArray& eventType, void* message, long int* result) | 120 | bool FdoSelectionManager::nativeEventFilter(const QByteArray &eventType, void *message, long int *result) | ||
121 | { | 121 | { | ||
122 | Q_UNUSED(result); | 122 | Q_UNUSED(result) | ||
123 | 123 | | |||
124 | if (eventType != "xcb_generic_event_t") { | 124 | if (eventType != "xcb_generic_event_t") { | ||
125 | return false; | 125 | return false; | ||
126 | } | 126 | } | ||
127 | 127 | | |||
128 | xcb_generic_event_t* ev = static_cast<xcb_generic_event_t *>(message); | 128 | xcb_generic_event_t *ev = static_cast<xcb_generic_event_t *>(message); | ||
129 | 129 | | |||
130 | const auto responseType = XCB_EVENT_RESPONSE_TYPE(ev); | 130 | const auto responseType = XCB_EVENT_RESPONSE_TYPE(ev); | ||
131 | if (responseType == XCB_CLIENT_MESSAGE) { | 131 | if (responseType == XCB_CLIENT_MESSAGE) { | ||
132 | const auto ce = reinterpret_cast<xcb_client_message_event_t *>(ev); | 132 | const auto ce = reinterpret_cast<xcb_client_message_event_t *>(ev); | ||
133 | if (ce->type == Xcb::atoms->opcodeAtom) { | 133 | if (ce->type == Xcb::atoms->opcodeAtom) { | ||
134 | switch (ce->data.data32[1]) { | 134 | switch (ce->data.data32[1]) { | ||
135 | case SYSTEM_TRAY_REQUEST_DOCK: | 135 | case SYSTEM_TRAY_REQUEST_DOCK: | ||
136 | dock(ce->data.data32[2]); | 136 | dock(ce->data.data32[2]); | ||
137 | return true; | 137 | return true; | ||
138 | } | 138 | } | ||
139 | } | 139 | } | ||
140 | } else if (responseType == XCB_UNMAP_NOTIFY) { | 140 | } else if (responseType == XCB_UNMAP_NOTIFY) { | ||
141 | const auto unmappedWId = reinterpret_cast<xcb_unmap_notify_event_t *>(ev)->window; | 141 | const auto unmappedWId = reinterpret_cast<xcb_unmap_notify_event_t *>(ev)->window; | ||
142 | if (m_proxies.contains(unmappedWId)) { | 142 | if (m_proxies.contains(unmappedWId)) { | ||
143 | undock(unmappedWId); | 143 | undock(unmappedWId); | ||
144 | } | 144 | } | ||
145 | } else if (responseType == XCB_DESTROY_NOTIFY) { | 145 | } else if (responseType == XCB_DESTROY_NOTIFY) { | ||
146 | const auto destroyedWId = reinterpret_cast<xcb_destroy_notify_event_t *>(ev)->window; | 146 | const auto destroyedWId = reinterpret_cast<xcb_destroy_notify_event_t *>(ev)->window; | ||
147 | if (m_proxies.contains(destroyedWId)) { | 147 | if (m_proxies.contains(destroyedWId)) { | ||
148 | undock(destroyedWId); | 148 | undock(destroyedWId); | ||
149 | } | 149 | } | ||
150 | } else if (responseType == m_damageEventBase + XCB_DAMAGE_NOTIFY) { | 150 | } else if (responseType == m_damageEventBase + XCB_DAMAGE_NOTIFY) { | ||
151 | const auto damagedWId = reinterpret_cast<xcb_damage_notify_event_t *>(ev)->drawable; | 151 | const auto damagedWId = reinterpret_cast<xcb_damage_notify_event_t *>(ev)->drawable; | ||
152 | const auto sniProx = m_proxies.value(damagedWId); | 152 | const auto sniProxy = m_proxies.value(damagedWId); | ||
153 | if(sniProx) { | 153 | if (sniProxy) { | ||
154 | sniProx->update(); | 154 | sniProxy->update(); | ||
155 | xcb_damage_subtract(QX11Info::connection(), m_damageWatches[damagedWId], XCB_NONE, XCB_NONE); | 155 | xcb_damage_subtract(QX11Info::connection(), m_damageWatches[damagedWId], XCB_NONE, XCB_NONE); | ||
156 | } | 156 | } | ||
157 | } | 157 | } | ||
158 | 158 | | |||
159 | return false; | 159 | return false; | ||
160 | } | 160 | } | ||
161 | 161 | | |||
162 | void FdoSelectionManager::dock(xcb_window_t winId) | 162 | void FdoSelectionManager::dock(xcb_window_t winId) | ||
Show All 39 Lines | 201 | { | |||
202 | qCWarning(SNIPROXY) << "lost ownership of Systray Manager"; | 202 | qCWarning(SNIPROXY) << "lost ownership of Systray Manager"; | ||
203 | disconnect(KWindowSystem::self(), &KWindowSystem::compositingChanged, this, &FdoSelectionManager::compositingChanged); | 203 | disconnect(KWindowSystem::self(), &KWindowSystem::compositingChanged, this, &FdoSelectionManager::compositingChanged); | ||
204 | qApp->exit(-1); | 204 | qApp->exit(-1); | ||
205 | } | 205 | } | ||
206 | 206 | | |||
207 | void FdoSelectionManager::compositingChanged() | 207 | void FdoSelectionManager::compositingChanged() | ||
208 | { | 208 | { | ||
209 | xcb_connection_t *c = QX11Info::connection(); | 209 | xcb_connection_t *c = QX11Info::connection(); | ||
210 | auto screen = xcb_setup_roots_iterator (xcb_get_setup (c)).data; | 210 | auto screen = xcb_setup_roots_iterator(xcb_get_setup(c)).data; | ||
211 | auto trayVisual = screen->root_visual; | 211 | auto trayVisual = screen->root_visual; | ||
212 | if (KWindowSystem::compositingActive()) { | 212 | if (KWindowSystem::compositingActive()) { | ||
213 | xcb_depth_iterator_t depth_iterator = xcb_screen_allowed_depths_iterator(screen); | 213 | xcb_depth_iterator_t depth_iterator = xcb_screen_allowed_depths_iterator(screen); | ||
214 | xcb_depth_t *depth = nullptr; | 214 | xcb_depth_t *depth = nullptr; | ||
215 | 215 | | |||
216 | while (depth_iterator.rem) { | 216 | while (depth_iterator.rem) { | ||
217 | if (depth_iterator.data->depth == 32) { | 217 | if (depth_iterator.data->depth == 32) { | ||
218 | depth = depth_iterator.data; | 218 | depth = depth_iterator.data; | ||
Show All 27 Lines |