Changeset View
Changeset View
Standalone View
Standalone View
xembed-sni-proxy/sniproxy.cpp
Show All 14 Lines | |||||
15 | * You should have received a copy of the GNU Lesser General Public | 15 | * You should have received a copy of the GNU Lesser General Public | ||
16 | * License along with this library; if not, write to the Free Software | 16 | * License along with this library; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | * | 18 | * | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include "sniproxy.h" | 21 | #include "sniproxy.h" | ||
22 | 22 | | |||
23 | #include <algorithm> | ||||
23 | #include <xcb/xcb.h> | 24 | #include <xcb/xcb.h> | ||
24 | #include <xcb/xcb_atom.h> | 25 | #include <xcb/xcb_atom.h> | ||
25 | #include <xcb/xcb_event.h> | 26 | #include <xcb/xcb_event.h> | ||
26 | #include <xcb/xcb_image.h> | 27 | #include <xcb/xcb_image.h> | ||
27 | 28 | | |||
28 | #include "xcbutils.h" | 29 | #include "xcbutils.h" | ||
29 | #include "debug.h" | 30 | #include "debug.h" | ||
30 | 31 | | |||
▲ Show 20 Lines • Show All 187 Lines • ▼ Show 20 Line(s) | |||||
218 | 219 | | |||
219 | void SNIProxy::stackContainerWindow(const uint32_t stackMode) const | 220 | void SNIProxy::stackContainerWindow(const uint32_t stackMode) const | ||
220 | { | 221 | { | ||
221 | auto c = QX11Info::connection(); | 222 | auto c = QX11Info::connection(); | ||
222 | const uint32_t stackData[] = {stackMode}; | 223 | const uint32_t stackData[] = {stackMode}; | ||
223 | xcb_configure_window(c, m_containerWid, XCB_CONFIG_WINDOW_STACK_MODE, stackData); | 224 | xcb_configure_window(c, m_containerWid, XCB_CONFIG_WINDOW_STACK_MODE, stackData); | ||
224 | } | 225 | } | ||
225 | 226 | | |||
226 | void SNIProxy::sendConfigureNotification() const | 227 | void SNIProxy::resizeWindow(const uint16_t width, const uint16_t height) const | ||
227 | { | 228 | { | ||
228 | xcb_configure_notify_event_t event; | | |||
kmaterka: xcb_configure_notify_event_t
@davidedmundson In [[ https://github.com/KDE/plasma… | |||||
No idea. It was before a lot of other refractors. Things could well have changed since. Let's go with this and monitor feedback. davidedmundson: No idea. It was before a lot of other refractors.
Things could well have changed since. | |||||
229 | memset(&event, 0x00, sizeof(xcb_configure_notify_event_t)); | | |||
230 | event.response_type = XCB_CONFIGURE_NOTIFY; | | |||
231 | event.event = m_windowId; | | |||
232 | event.window = m_windowId; | | |||
233 | event.x = 0; | | |||
234 | event.y = 0; | | |||
235 | event.width = s_embedSize; | | |||
236 | event.height = s_embedSize; | | |||
237 | | ||||
238 | auto connection = QX11Info::connection(); | 229 | auto connection = QX11Info::connection(); | ||
239 | xcb_send_event(connection, false, m_windowId, XCB_EVENT_MASK_STRUCTURE_NOTIFY, reinterpret_cast<char *>(&event)); | 230 | | ||
231 | uint16_t widthNormalized = std::min(width, s_embedSize); | ||||
232 | uint16_t heighNormalized = std::min(height, s_embedSize); | ||||
233 | | ||||
234 | const uint32_t windowSizeConfigVals[2] = { widthNormalized, heighNormalized }; | ||||
235 | xcb_configure_window(connection, m_windowId, | ||||
236 | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, | ||||
237 | windowSizeConfigVals); | ||||
238 | | ||||
239 | xcb_flush(connection); | ||||
xcb_flush is probably not needed, but better make sure is is handled before we capture image. kmaterka: xcb_flush is probably not needed, but better make sure is is handled before we capture image. | |||||
240 | } | 240 | } | ||
241 | 241 | | |||
242 | QSize SNIProxy::calculateClientWindowSize() const | 242 | QSize SNIProxy::calculateClientWindowSize() const | ||
243 | { | 243 | { | ||
244 | auto c = QX11Info::connection(); | 244 | auto c = QX11Info::connection(); | ||
245 | 245 | | |||
246 | auto cookie = xcb_get_geometry(c, m_windowId); | 246 | auto cookie = xcb_get_geometry(c, m_windowId); | ||
247 | QScopedPointer<xcb_get_geometry_reply_t, QScopedPointerPodDeleter> | 247 | QScopedPointer<xcb_get_geometry_reply_t, QScopedPointerPodDeleter> | ||
248 | clientGeom(xcb_get_geometry_reply(c, cookie, nullptr)); | 248 | clientGeom(xcb_get_geometry_reply(c, cookie, nullptr)); | ||
249 | 249 | | |||
250 | QSize clientWindowSize; | 250 | QSize clientWindowSize; | ||
251 | if (clientGeom) { | 251 | if (clientGeom) { | ||
252 | clientWindowSize = QSize(clientGeom->width, clientGeom->height); | 252 | clientWindowSize = QSize(clientGeom->width, clientGeom->height); | ||
253 | } | 253 | } | ||
254 | //if the window is a clearly stupid size resize to be something sensible | 254 | //if the window is a clearly stupid size resize to be something sensible | ||
255 | //this is needed as chromium and such when resized just fill the icon with transparent space and only draw in the middle | 255 | //this is needed as chromium and such when resized just fill the icon with transparent space and only draw in the middle | ||
256 | //however KeePass2 does need this as by default the window size is 273px wide and is not transparent | 256 | //however KeePass2 does need this as by default the window size is 273px wide and is not transparent | ||
257 | //use an artbitrary heuristic to make sure icons are always sensible | 257 | //use an artbitrary heuristic to make sure icons are always sensible | ||
258 | if (clientWindowSize.isEmpty() || clientWindowSize.width() > s_embedSize || clientWindowSize.height() > s_embedSize) { | 258 | if (clientWindowSize.isEmpty() || clientWindowSize.width() > s_embedSize || clientWindowSize.height() > s_embedSize) { | ||
259 | qCDebug(SNIPROXY) << "Resizing window" << m_windowId << Title() << "from w*h" << clientWindowSize; | 259 | qCDebug(SNIPROXY) << "Resizing window" << m_windowId << Title() << "from w*h" << clientWindowSize; | ||
260 | 260 | | |||
261 | sendConfigureNotification(); | 261 | resizeWindow(s_embedSize, s_embedSize); | ||
262 | | ||||
263 | const uint32_t windowSizeConfigVals[2] = { s_embedSize, s_embedSize }; | | |||
264 | xcb_configure_window(c, m_windowId, | | |||
265 | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, | | |||
266 | windowSizeConfigVals); | | |||
267 | 262 | | |||
268 | clientWindowSize = QSize(s_embedSize, s_embedSize); | 263 | clientWindowSize = QSize(s_embedSize, s_embedSize); | ||
269 | } | 264 | } | ||
270 | 265 | | |||
271 | return clientWindowSize; | 266 | return clientWindowSize; | ||
272 | } | 267 | } | ||
273 | 268 | | |||
274 | void sni_cleanup_xcb_image(void *data) { | 269 | void sni_cleanup_xcb_image(void *data) { | ||
▲ Show 20 Lines • Show All 337 Lines • Show Last 20 Lines |
xcb_configure_notify_event_t
@davidedmundson In this commit you added xcb_configure_notify_event_t to resize window. Do you remember why and which application were not working correctly? Seems that old review board os down.