Changeset View
Changeset View
Standalone View
Standalone View
touch_input.cpp
Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | 67 | { | |||
---|---|---|---|---|---|
68 | if (!m_inited) { | 68 | if (!m_inited) { | ||
69 | return; | 69 | return; | ||
70 | } | 70 | } | ||
71 | if (m_windowUpdatedInCycle) { | 71 | if (m_windowUpdatedInCycle) { | ||
72 | return; | 72 | return; | ||
73 | } | 73 | } | ||
74 | m_windowUpdatedInCycle = true; | 74 | m_windowUpdatedInCycle = true; | ||
75 | // TODO: handle pointer grab aka popups | 75 | // TODO: handle pointer grab aka popups | ||
76 | Toplevel *t = m_input->findToplevel(pos.toPoint()); | 76 | Toplevel *t = input()->findToplevel(pos.toPoint()); | ||
77 | auto oldWindow = m_window; | 77 | auto oldWindow = window(); | ||
78 | updateInternalWindow(pos); | 78 | updateInternalWindow(pos); | ||
79 | if (!m_internalWindow) { | 79 | if (!internalWindow()) { | ||
80 | updateDecoration(t, pos); | 80 | updateDecoration(t, pos); | ||
81 | } else { | 81 | } else { | ||
82 | // TODO: send hover leave to decoration | 82 | // TODO: send hover leave to decoration | ||
83 | if (m_decoration) { | 83 | if (decoration()) { | ||
84 | m_decoration->client()->leaveEvent(); | 84 | decoration()->client()->leaveEvent(); | ||
85 | } | 85 | } | ||
86 | m_decoration.clear(); | 86 | clearDecoration(); | ||
87 | } | 87 | } | ||
88 | if (m_decoration || m_internalWindow) { | 88 | if (decoration() || internalWindow()) { | ||
89 | t = nullptr; | 89 | t = nullptr; | ||
90 | } else if (!m_decoration) { | 90 | } else if (!decoration()) { | ||
91 | m_decorationId = -1; | 91 | m_decorationId = -1; | ||
92 | } else if (!m_internalWindow) { | 92 | } else if (!internalWindow()) { | ||
93 | m_internalId = -1; | 93 | m_internalId = -1; | ||
94 | } | 94 | } | ||
95 | if (!oldWindow.isNull() && t == oldWindow.data()) { | 95 | if (!oldWindow.isNull() && t == oldWindow.data()) { | ||
96 | return; | 96 | return; | ||
97 | } | 97 | } | ||
98 | auto seat = waylandServer()->seat(); | 98 | auto seat = waylandServer()->seat(); | ||
99 | // disconnect old surface | 99 | // disconnect old surface | ||
100 | if (oldWindow) { | 100 | if (oldWindow) { | ||
101 | disconnect(m_windowGeometryConnection); | 101 | disconnect(m_windowGeometryConnection); | ||
102 | m_windowGeometryConnection = QMetaObject::Connection(); | 102 | m_windowGeometryConnection = QMetaObject::Connection(); | ||
103 | } | 103 | } | ||
104 | if (t && t->surface()) { | 104 | if (t && t->surface()) { | ||
105 | // FIXME: add input transformation API to KWayland::Server::SeatInterface for touch input | 105 | // FIXME: add input transformation API to KWayland::Server::SeatInterface for touch input | ||
106 | seat->setFocusedTouchSurface(t->surface(), -1 * t->inputTransformation().map(t->pos()) + t->pos()); | 106 | seat->setFocusedTouchSurface(t->surface(), -1 * t->inputTransformation().map(t->pos()) + t->pos()); | ||
107 | m_windowGeometryConnection = connect(t, &Toplevel::geometryChanged, this, | 107 | m_windowGeometryConnection = connect(t, &Toplevel::geometryChanged, this, | ||
108 | [this] { | 108 | [this] { | ||
109 | if (m_window.isNull()) { | 109 | if (window().isNull()) { | ||
110 | return; | 110 | return; | ||
111 | } | 111 | } | ||
112 | auto seat = waylandServer()->seat(); | 112 | auto seat = waylandServer()->seat(); | ||
113 | if (m_window.data()->surface() != seat->focusedTouchSurface()) { | 113 | if (window().data()->surface() != seat->focusedTouchSurface()) { | ||
114 | return; | 114 | return; | ||
115 | } | 115 | } | ||
116 | auto t = m_window.data(); | 116 | auto t = window().data(); | ||
117 | seat->setFocusedTouchSurfacePosition(-1 * t->inputTransformation().map(t->pos()) + t->pos()); | 117 | seat->setFocusedTouchSurfacePosition(-1 * t->inputTransformation().map(t->pos()) + t->pos()); | ||
118 | } | 118 | } | ||
119 | ); | 119 | ); | ||
120 | } else { | 120 | } else { | ||
121 | seat->setFocusedTouchSurface(nullptr); | 121 | seat->setFocusedTouchSurface(nullptr); | ||
122 | t = nullptr; | 122 | t = nullptr; | ||
123 | } | 123 | } | ||
124 | if (!t) { | 124 | if (!t) { | ||
125 | m_window.clear(); | 125 | setWindow(); | ||
126 | return; | 126 | return; | ||
127 | } | 127 | } | ||
128 | m_window = QPointer<Toplevel>(t); | 128 | setWindow(t); | ||
129 | } | 129 | } | ||
130 | 130 | | |||
131 | void TouchInputRedirection::insertId(quint32 internalId, qint32 kwaylandId) | 131 | void TouchInputRedirection::insertId(quint32 internalId, qint32 kwaylandId) | ||
132 | { | 132 | { | ||
133 | m_idMapper.insert(internalId, kwaylandId); | 133 | m_idMapper.insert(internalId, kwaylandId); | ||
134 | } | 134 | } | ||
135 | 135 | | |||
136 | qint32 TouchInputRedirection::mappedId(quint32 internalId) | 136 | qint32 TouchInputRedirection::mappedId(quint32 internalId) | ||
Show All 12 Lines | |||||
149 | 149 | | |||
150 | void TouchInputRedirection::processDown(qint32 id, const QPointF &pos, quint32 time, LibInput::Device *device) | 150 | void TouchInputRedirection::processDown(qint32 id, const QPointF &pos, quint32 time, LibInput::Device *device) | ||
151 | { | 151 | { | ||
152 | Q_UNUSED(device) | 152 | Q_UNUSED(device) | ||
153 | if (!m_inited) { | 153 | if (!m_inited) { | ||
154 | return; | 154 | return; | ||
155 | } | 155 | } | ||
156 | m_windowUpdatedInCycle = false; | 156 | m_windowUpdatedInCycle = false; | ||
157 | m_input->processSpies(std::bind(&InputEventSpy::touchDown, std::placeholders::_1, id, pos, time)); | 157 | input()->processSpies(std::bind(&InputEventSpy::touchDown, std::placeholders::_1, id, pos, time)); | ||
158 | m_input->processFilters(std::bind(&InputEventFilter::touchDown, std::placeholders::_1, id, pos, time)); | 158 | input()->processFilters(std::bind(&InputEventFilter::touchDown, std::placeholders::_1, id, pos, time)); | ||
159 | m_windowUpdatedInCycle = false; | 159 | m_windowUpdatedInCycle = false; | ||
160 | } | 160 | } | ||
161 | 161 | | |||
162 | void TouchInputRedirection::processUp(qint32 id, quint32 time, LibInput::Device *device) | 162 | void TouchInputRedirection::processUp(qint32 id, quint32 time, LibInput::Device *device) | ||
163 | { | 163 | { | ||
164 | Q_UNUSED(device) | 164 | Q_UNUSED(device) | ||
165 | if (!m_inited) { | 165 | if (!m_inited) { | ||
166 | return; | 166 | return; | ||
167 | } | 167 | } | ||
168 | m_windowUpdatedInCycle = false; | 168 | m_windowUpdatedInCycle = false; | ||
169 | m_input->processSpies(std::bind(&InputEventSpy::touchUp, std::placeholders::_1, id, time)); | 169 | input()->processSpies(std::bind(&InputEventSpy::touchUp, std::placeholders::_1, id, time)); | ||
170 | m_input->processFilters(std::bind(&InputEventFilter::touchUp, std::placeholders::_1, id, time)); | 170 | input()->processFilters(std::bind(&InputEventFilter::touchUp, std::placeholders::_1, id, time)); | ||
171 | m_windowUpdatedInCycle = false; | 171 | m_windowUpdatedInCycle = false; | ||
172 | } | 172 | } | ||
173 | 173 | | |||
174 | void TouchInputRedirection::processMotion(qint32 id, const QPointF &pos, quint32 time, LibInput::Device *device) | 174 | void TouchInputRedirection::processMotion(qint32 id, const QPointF &pos, quint32 time, LibInput::Device *device) | ||
175 | { | 175 | { | ||
176 | Q_UNUSED(device) | 176 | Q_UNUSED(device) | ||
177 | if (!m_inited) { | 177 | if (!m_inited) { | ||
178 | return; | 178 | return; | ||
179 | } | 179 | } | ||
180 | m_windowUpdatedInCycle = false; | 180 | m_windowUpdatedInCycle = false; | ||
181 | m_input->processSpies(std::bind(&InputEventSpy::touchMotion, std::placeholders::_1, id, pos, time)); | 181 | input()->processSpies(std::bind(&InputEventSpy::touchMotion, std::placeholders::_1, id, pos, time)); | ||
182 | m_input->processFilters(std::bind(&InputEventFilter::touchMotion, std::placeholders::_1, id, pos, time)); | 182 | input()->processFilters(std::bind(&InputEventFilter::touchMotion, std::placeholders::_1, id, pos, time)); | ||
183 | m_windowUpdatedInCycle = false; | 183 | m_windowUpdatedInCycle = false; | ||
184 | } | 184 | } | ||
185 | 185 | | |||
186 | void TouchInputRedirection::cancel() | 186 | void TouchInputRedirection::cancel() | ||
187 | { | 187 | { | ||
188 | if (!m_inited) { | 188 | if (!m_inited) { | ||
189 | return; | 189 | return; | ||
190 | } | 190 | } | ||
Show All 13 Lines |