Add ::window() and ::approachWindow as virtual methods to Edge

This allows to no longer needing to dynamic cast the Edge to
WindowBasedEdge for the X11 specific event handling.
icc-effect-5.14.5
Martin Gräßlin 2016-04-15 13:19:22 +02:00
parent 80995fc205
commit 736ad55e37
3 changed files with 33 additions and 13 deletions

View File

@ -445,7 +445,7 @@ void TestScreenEdges::testCallback()
};
event.root = XCB_WINDOW_NONE;
event.child = XCB_WINDOW_NONE;
event.event = static_cast<WindowBasedEdge*>(*it)->window();
event.event = (*it)->window();
event.same_screen_focus = 1;
event.time = QDateTime::currentMSecsSinceEpoch();
setPos(QPoint(0, 50));

View File

@ -487,6 +487,16 @@ void Edge::updateApproaching(const QPoint &point)
}
}
quint32 Edge::window() const
{
return 0;
}
quint32 Edge::approachWindow() const
{
return 0;
}
/**********************************************************
* ScreenEdges
*********************************************************/
@ -1233,8 +1243,8 @@ bool ScreenEdges::handleEnterNotifiy(xcb_window_t window, const QPoint &point, c
bool activated = false;
bool activatedForClient = false;
for (auto it = m_edges.begin(); it != m_edges.end(); ++it) {
WindowBasedEdge *edge = dynamic_cast<WindowBasedEdge*>(*it);
if (!edge) {
Edge *edge = *it;
if (!edge || edge->window() == XCB_WINDOW_NONE) {
continue;
}
if (!edge->isReserved()) {
@ -1268,8 +1278,8 @@ bool ScreenEdges::handleEnterNotifiy(xcb_window_t window, const QPoint &point, c
bool ScreenEdges::handleDndNotify(xcb_window_t window, const QPoint &point)
{
for (auto it = m_edges.begin(); it != m_edges.end(); ++it) {
WindowBasedEdge *edge = dynamic_cast<WindowBasedEdge*>(*it);
if (!edge) {
Edge *edge = *it;
if (!edge || edge->window() == XCB_WINDOW_NONE) {
continue;
}
if (edge->isReserved() && edge->window() == window) {
@ -1292,10 +1302,7 @@ QVector< xcb_window_t > ScreenEdges::windows() const
for (auto it = m_edges.constBegin();
it != m_edges.constEnd();
++it) {
WindowBasedEdge *edge = dynamic_cast<WindowBasedEdge*>(*it);
if (!edge) {
continue;
}
Edge *edge = *it;
xcb_window_t w = edge->window();
if (w != XCB_WINDOW_NONE) {
wins.append(w);

View File

@ -74,6 +74,19 @@ public:
Client *client() const;
const QRect &geometry() const;
/**
* The window id of the native window representing the edge.
* Default implementation returns @c 0, which means no window.
**/
virtual quint32 window() const;
/**
* The approach window is a special window to notice when get close to the screen border but
* not yet triggering the border.
*
* The default implementation returns @c 0, which means no window.
**/
virtual quint32 approachWindow() const;
public Q_SLOTS:
void reserve();
void unreserve();
@ -126,12 +139,12 @@ public:
explicit WindowBasedEdge(ScreenEdges *parent);
virtual ~WindowBasedEdge();
xcb_window_t window() const;
quint32 window() const override;
/**
* The approach window is a special window to notice when get close to the screen border but
* not yet triggering the border.
**/
xcb_window_t approachWindow() const;
quint32 approachWindow() const override;
protected:
virtual void doGeometryUpdate();
@ -487,12 +500,12 @@ inline bool Edge::isApproaching() const
* Inlines WindowBasedEdge
*********************************************************/
inline xcb_window_t WindowBasedEdge::window() const
inline quint32 WindowBasedEdge::window() const
{
return m_window;
}
inline xcb_window_t WindowBasedEdge::approachWindow() const
inline quint32 WindowBasedEdge::approachWindow() const
{
return m_approachWindow;
}