Commit ba4f6b35 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii

Introduce geometry conversion helpers

The new helpers are designed for the purpose of mapping points from the
global screen coordinates to the frame-local and the surface-local coords
parent 7eccfdc5
......@@ -1714,7 +1714,7 @@ public:
switch (event->type()) {
case QEvent::TabletMove: {
const auto pos = event->globalPosF() - toplevel->bufferGeometry().topLeft();
const auto pos = toplevel->mapToLocal(event->globalPosF());
tool->sendMotion(pos);
m_cursorByTool[tool]->setPos(event->globalPos());
break;
......@@ -1725,7 +1725,7 @@ public:
tool->sendProximityOut();
break;
case QEvent::TabletPress: {
const auto pos = event->globalPosF() - toplevel->bufferGeometry().topLeft();
const auto pos = toplevel->mapToLocal(event->globalPosF());
tool->sendMotion(pos);
m_cursorByTool[tool]->setPos(event->globalPos());
tool->sendDown();
......
......@@ -789,6 +789,21 @@ QMatrix4x4 Toplevel::inputTransformation() const
return m;
}
QPoint Toplevel::mapToFrame(const QPoint &point) const
{
return point - frameGeometry().topLeft();
}
QPoint Toplevel::mapToLocal(const QPoint &point) const
{
return point - bufferGeometry().topLeft();
}
QPointF Toplevel::mapToLocal(const QPointF &point) const
{
return point - bufferGeometry().topLeft();
}
quint32 Toplevel::windowId() const
{
return window();
......
......@@ -381,6 +381,18 @@ public:
virtual bool isClient() const;
virtual bool isDeleted() const;
/**
* Maps the specified @a point from the global screen coordinates to the frame coordinates.
*/
QPoint mapToFrame(const QPoint &point) const;
/**
* Maps the specified @a point from the global screen coordinates to the surface-local
* coordinates of the main surface. For X11 clients, this function maps the specified point
* from the global screen coordinates to the buffer-local coordinates.
*/
QPoint mapToLocal(const QPoint &point) const;
QPointF mapToLocal(const QPointF &point) const;
// prefer isXXX() instead
// 0 for supported types means default for managed/unmanaged types
virtual NET::WindowType windowType(bool direct = false, int supported_types = 0) const = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment