diff --git a/tabbox/declarative.cpp b/tabbox/declarative.cpp
index 3828f1a3f0..81103cc687 100644
--- a/tabbox/declarative.cpp
+++ b/tabbox/declarative.cpp
@@ -27,6 +27,8 @@ along with this program. If not, see .
#include
#include
#include
+#include
+
// include KDE
#include
#include
@@ -186,6 +188,28 @@ void DeclarativeView::hideEvent(QHideEvent *event)
}
}
+bool DeclarativeView::x11Event(XEvent *e)
+{
+ if (tabBox->embedded() &&
+ (e->type == ButtonPress || e->type == ButtonRelease || e->type == MotionNotify)) {
+ XEvent ev;
+
+ memcpy(&ev, e, sizeof(ev));
+ if (e->type == ButtonPress || e->type == ButtonRelease) {
+ ev.xbutton.x += m_relativePos.x();
+ ev.xbutton.y += m_relativePos.y();
+ ev.xbutton.window = tabBox->embedded();
+ } else if (e->type == MotionNotify) {
+ ev.xmotion.x += m_relativePos.x();
+ ev.xmotion.y += m_relativePos.y();
+ ev.xmotion.window = tabBox->embedded();
+ }
+
+ XSendEvent( QX11Info::display(), tabBox->embedded(), False, NoEventMask, &ev );
+ }
+ return QDeclarativeView::x11Event(e);
+}
+
void DeclarativeView::slotUpdateGeometry()
{
const WId embeddedId = tabBox->embedded();
@@ -216,12 +240,15 @@ void DeclarativeView::slotUpdateGeometry()
height = info.geometry().height() - 2 * offset.y();
}
setGeometry(QRect(x, y, width, height));
+
+ m_relativePos = QPoint(info.geometry().x(), info.geometry().x());
} else {
const int width = rootObject()->property("width").toInt();
const int height = rootObject()->property("height").toInt();
setGeometry(m_currentScreenGeometry.x() + static_cast(m_currentScreenGeometry.width()) * 0.5 - static_cast(width) * 0.5,
m_currentScreenGeometry.y() + static_cast(m_currentScreenGeometry.height()) * 0.5 - static_cast(height) * 0.5,
width, height);
+ m_relativePos = pos();
}
}
diff --git a/tabbox/declarative.h b/tabbox/declarative.h
index 341ecb6595..104e6cf79d 100644
--- a/tabbox/declarative.h
+++ b/tabbox/declarative.h
@@ -60,6 +60,7 @@ public:
protected:
virtual void hideEvent(QHideEvent *event);
+ virtual bool x11Event(XEvent *e);
public Q_SLOTS:
void slotUpdateGeometry();
@@ -78,6 +79,8 @@ private:
QString m_currentLayout;
int m_cachedWidth;
int m_cachedHeight;
+ //relative position to the embedding window
+ QPoint m_relativePos;
};
} // namespace TabBox