summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-06-06 09:07:46 +0200
committerSamuel Rødal <samuel.rodal@nokia.com>2011-06-06 09:08:25 +0200
commit4f1a6ac732f7f879b082b6d413ca4918c6b06dc3 (patch)
tree7db6edfd6f59d212f1a90dfdf5f3d3b4159332e6 /src/plugins
parent36b2c31ba8e15109ef984e18f714814ab5a74ec0 (diff)
Implemented QXcbScreen::topLevelAt(const QPoint &p).
This makes the tst_QWidget::widgetAt() auto-test pass.
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h4
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.cpp3
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.cpp46
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.h2
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;