[kwin_wayland] Hold the currently entered Surface in Pointer
This commit is contained in:
parent
94654a12dd
commit
9bde3bf0ce
2 changed files with 29 additions and 4 deletions
|
@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
#include "pointer.h"
|
#include "pointer.h"
|
||||||
|
#include "surface.h"
|
||||||
|
|
||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
|
|
||||||
|
@ -37,6 +38,7 @@ const wl_pointer_listener Pointer::s_listener = {
|
||||||
Pointer::Pointer(QObject *parent)
|
Pointer::Pointer(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_pointer(nullptr)
|
, m_pointer(nullptr)
|
||||||
|
, m_enteredSurface(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,18 +67,29 @@ void Pointer::setup(wl_pointer *pointer)
|
||||||
void Pointer::enterCallback(void *data, wl_pointer *pointer, uint32_t serial, wl_surface *surface,
|
void Pointer::enterCallback(void *data, wl_pointer *pointer, uint32_t serial, wl_surface *surface,
|
||||||
wl_fixed_t sx, wl_fixed_t sy)
|
wl_fixed_t sx, wl_fixed_t sy)
|
||||||
{
|
{
|
||||||
Q_UNUSED(surface)
|
|
||||||
Pointer *p = reinterpret_cast<Pointer*>(data);
|
Pointer *p = reinterpret_cast<Pointer*>(data);
|
||||||
Q_ASSERT(p->m_pointer == pointer);
|
Q_ASSERT(p->m_pointer == pointer);
|
||||||
emit p->entered(serial, QPointF(wl_fixed_to_double(sx), wl_fixed_to_double(sy)));
|
p->enter(serial, surface, QPointF(wl_fixed_to_double(sx), wl_fixed_to_double(sy)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Pointer::enter(uint32_t serial, wl_surface *surface, const QPointF &relativeToSurface)
|
||||||
|
{
|
||||||
|
m_enteredSurface = Surface::get(surface);
|
||||||
|
emit entered(serial, relativeToSurface);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Pointer::leaveCallback(void *data, wl_pointer *pointer, uint32_t serial, wl_surface *surface)
|
void Pointer::leaveCallback(void *data, wl_pointer *pointer, uint32_t serial, wl_surface *surface)
|
||||||
{
|
{
|
||||||
Q_UNUSED(surface)
|
|
||||||
Pointer *p = reinterpret_cast<Pointer*>(data);
|
Pointer *p = reinterpret_cast<Pointer*>(data);
|
||||||
Q_ASSERT(p->m_pointer == pointer);
|
Q_ASSERT(p->m_pointer == pointer);
|
||||||
emit p->left(serial);
|
Q_ASSERT(*(p->m_enteredSurface) == surface);
|
||||||
|
p->leave(serial);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Pointer::leave(uint32_t serial)
|
||||||
|
{
|
||||||
|
m_enteredSurface = nullptr;
|
||||||
|
emit left(serial);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Pointer::motionCallback(void *data, wl_pointer *pointer, uint32_t time, wl_fixed_t sx, wl_fixed_t sy)
|
void Pointer::motionCallback(void *data, wl_pointer *pointer, uint32_t time, wl_fixed_t sx, wl_fixed_t sy)
|
||||||
|
|
|
@ -28,6 +28,8 @@ namespace KWin
|
||||||
namespace Wayland
|
namespace Wayland
|
||||||
{
|
{
|
||||||
|
|
||||||
|
class Surface;
|
||||||
|
|
||||||
class Pointer : public QObject
|
class Pointer : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -49,6 +51,13 @@ public:
|
||||||
void setup(wl_pointer *pointer);
|
void setup(wl_pointer *pointer);
|
||||||
void release();
|
void release();
|
||||||
|
|
||||||
|
Surface *enteredSurface() const {
|
||||||
|
return m_enteredSurface;
|
||||||
|
}
|
||||||
|
Surface *enteredSurface(){
|
||||||
|
return m_enteredSurface;
|
||||||
|
}
|
||||||
|
|
||||||
operator wl_pointer*() {
|
operator wl_pointer*() {
|
||||||
return m_pointer;
|
return m_pointer;
|
||||||
}
|
}
|
||||||
|
@ -72,7 +81,10 @@ Q_SIGNALS:
|
||||||
void axisChanged(quint32 time, Axis axis, qreal delta);
|
void axisChanged(quint32 time, Axis axis, qreal delta);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void enter(uint32_t serial, wl_surface *surface, const QPointF &relativeToSurface);
|
||||||
|
void leave(uint32_t serial);
|
||||||
wl_pointer *m_pointer;
|
wl_pointer *m_pointer;
|
||||||
|
Surface *m_enteredSurface;
|
||||||
static const wl_pointer_listener s_listener;
|
static const wl_pointer_listener s_listener;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue