[wayland] Add support for input shape

Toplevel provides the input shape forwarded from SurfaceInterface. The
shape is evaluated in InputRedirection when finding the Toplevel at a
given position.
icc-effect-5.14.5
Martin Gräßlin 2015-06-18 23:19:13 +02:00
parent 7b842ccc81
commit 97588faea2
3 changed files with 23 additions and 2 deletions

View File

@ -1011,6 +1011,15 @@ bool InputRedirection::areButtonsPressed() const
return false;
}
static bool acceptsInput(Toplevel *t, const QPoint &pos)
{
const QRegion input = t->inputShape();
if (input.isEmpty()) {
return true;
}
return input.translated(t->pos()).contains(pos);
}
Toplevel *InputRedirection::findToplevel(const QPoint &pos)
{
if (!Workspace::self()) {
@ -1019,7 +1028,7 @@ Toplevel *InputRedirection::findToplevel(const QPoint &pos)
// TODO: check whether the unmanaged wants input events at all
const UnmanagedList &unmanaged = Workspace::self()->unmanagedList();
foreach (Unmanaged *u, unmanaged) {
if (u->geometry().contains(pos)) {
if (u->geometry().contains(pos) && acceptsInput(u, pos)) {
return u;
}
}
@ -1044,7 +1053,7 @@ Toplevel *InputRedirection::findToplevel(const QPoint &pos)
if (!t->readyForPainting()) {
continue;
}
if (t->geometry().contains(pos)) {
if (t->geometry().contains(pos) && acceptsInput(t, pos)) {
return t;
}
} while (it != stacking.begin());

View File

@ -493,6 +493,17 @@ void Toplevel::setDepth(int depth)
}
}
QRegion Toplevel::inputShape() const
{
#if HAVE_WAYLAND
if (m_surface) {
return m_surface->input();
} else
#endif
// TODO: maybe also for X11?
return QRegion();
}
} // namespace
#include "toplevel.moc"

View File

@ -268,6 +268,7 @@ public:
bool readyForPainting() const; // true if the window has been already painted its contents
xcb_visualid_t visual() const;
bool shape() const;
QRegion inputShape() const;
virtual void setOpacity(double opacity);
virtual double opacity() const;
int depth() const;