diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbconnection.h | 4 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbintegration.cpp | 3 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbscreen.cpp | 46 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbscreen.h | 2 |
4 files changed, 52 insertions, 3 deletions
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 01014775b9..e0cb1d954e 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -282,6 +282,8 @@ public: template<typename T> inline xcb_generic_event_t *checkEvent(const T &checker); + QXcbWindow *platformWindowFromId(xcb_window_t id); + private slots: void processXcbEvents(); @@ -291,8 +293,6 @@ private: #ifdef XCB_USE_DRI2 void initializeDri2(); #endif - QXcbWindow *platformWindowFromId(xcb_window_t id); - xcb_connection_t *m_connection; const xcb_setup_t *m_setup; diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index 0f0b25f5b2..c63a29b675 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -215,6 +215,8 @@ QPixmap QXcbIntegration::grabWindow(WId window, int x, int y, int width, int hei y = translate_reply->dst_y; window = root; + + free(translate_reply); free(reply); reply = root_reply; } else { @@ -338,7 +340,6 @@ QPixmap QXcbIntegration::grabWindow(WId window, int x, int y, int width, int hei return result; } - bool QXcbIntegration::hasOpenGL() const { #if defined(XCB_USE_GLX) diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 1b6bf30294..0d0c4a5138 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qxcbscreen.h" +#include "qxcbwindow.h" #include <stdio.h> @@ -145,6 +146,51 @@ QXcbScreen::~QXcbScreen() { } +QWindow *QXcbScreen::topLevelAt(const QPoint &p) const +{ + xcb_window_t root = m_screen->root; + + int x = p.x(); + int y = p.y(); + + xcb_generic_error_t *error; + + xcb_window_t parent = root; + xcb_window_t child = root; + + do { + xcb_translate_coordinates_cookie_t translate_cookie = + xcb_translate_coordinates(xcb_connection(), parent, child, x, y); + + xcb_translate_coordinates_reply_t *translate_reply = + xcb_translate_coordinates_reply(xcb_connection(), translate_cookie, &error); + + if (!translate_reply) { + if (error) { + connection()->handleXcbError(error); + free(error); + } + return 0; + } + + parent = child; + child = translate_reply->child; + x = translate_reply->dst_x; + y = translate_reply->dst_y; + + free(translate_reply); + + if (!child || child == root) + return 0; + + QPlatformWindow *platformWindow = connection()->platformWindowFromId(child); + if (platformWindow) + return platformWindow->window(); + } while (parent != child); + + return 0; +} + const xcb_visualtype_t *QXcbScreen::visualForId(xcb_visualid_t visualid) const { QMap<xcb_visualid_t, xcb_visualtype_t>::const_iterator it = m_visuals.find(visualid); diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h index d2a38b0791..cb84e55ccc 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.h +++ b/src/plugins/platforms/xcb/qxcbscreen.h @@ -57,6 +57,8 @@ public: QXcbScreen(QXcbConnection *connection, xcb_screen_t *screen, int number); ~QXcbScreen(); + QWindow *topLevelAt(const QPoint &point) const; + QRect geometry() const; int depth() const; QImage::Format format() const; |