Changeset View
Changeset View
Standalone View
Standalone View
effects/mouseclick/mouseclick.cpp
Show First 20 Lines • Show All 158 Lines • ▼ Show 20 Line(s) | |||||
159 | 159 | | |||
160 | void MouseClickEffect::slotMouseChanged(const QPoint& pos, const QPoint&, | 160 | void MouseClickEffect::slotMouseChanged(const QPoint& pos, const QPoint&, | ||
161 | Qt::MouseButtons buttons, Qt::MouseButtons oldButtons, | 161 | Qt::MouseButtons buttons, Qt::MouseButtons oldButtons, | ||
162 | Qt::KeyboardModifiers, Qt::KeyboardModifiers) | 162 | Qt::KeyboardModifiers, Qt::KeyboardModifiers) | ||
163 | { | 163 | { | ||
164 | if (buttons == oldButtons) | 164 | if (buttons == oldButtons) | ||
165 | return; | 165 | return; | ||
166 | 166 | | |||
167 | MouseEvent* m = NULL; | 167 | MouseEvent* m = nullptr; | ||
168 | int i = BUTTON_COUNT; | 168 | int i = BUTTON_COUNT; | ||
169 | while (--i >= 0) { | 169 | while (--i >= 0) { | ||
170 | MouseButton* b = m_buttons[i]; | 170 | MouseButton* b = m_buttons[i]; | ||
171 | if (isPressed(b->m_button, buttons, oldButtons)) { | 171 | if (isPressed(b->m_button, buttons, oldButtons)) { | ||
172 | m = new MouseEvent(i, pos, 0, createEffectFrame(pos, b->m_labelDown), true); | 172 | m = new MouseEvent(i, pos, 0, createEffectFrame(pos, b->m_labelDown), true); | ||
173 | break; | 173 | break; | ||
174 | } else if (isReleased(b->m_button, buttons, oldButtons) && (!b->m_isPressed || b->m_time > m_ringLife)) { | 174 | } else if (isReleased(b->m_button, buttons, oldButtons) && (!b->m_isPressed || b->m_time > m_ringLife)) { | ||
175 | // we might miss a press, thus also check !b->m_isPressed, bug #314762 | 175 | // we might miss a press, thus also check !b->m_isPressed, bug #314762 | ||
176 | m = new MouseEvent(i, pos, 0, createEffectFrame(pos, b->m_labelUp), false); | 176 | m = new MouseEvent(i, pos, 0, createEffectFrame(pos, b->m_labelUp), false); | ||
177 | break; | 177 | break; | ||
178 | } | 178 | } | ||
179 | b->setPressed(b->m_button & buttons); | 179 | b->setPressed(b->m_button & buttons); | ||
180 | } | 180 | } | ||
181 | 181 | | |||
182 | if (m) { | 182 | if (m) { | ||
183 | m_clicks.append(m); | 183 | m_clicks.append(m); | ||
184 | } | 184 | } | ||
185 | repaint(); | 185 | repaint(); | ||
186 | } | 186 | } | ||
187 | 187 | | |||
188 | EffectFrame* MouseClickEffect::createEffectFrame(const QPoint& pos, const QString& text) { | 188 | EffectFrame* MouseClickEffect::createEffectFrame(const QPoint& pos, const QString& text) { | ||
189 | if (!m_showText) { | 189 | if (!m_showText) { | ||
190 | return NULL; | 190 | return nullptr; | ||
191 | } | 191 | } | ||
192 | QPoint point(pos.x() + m_ringMaxSize, pos.y()); | 192 | QPoint point(pos.x() + m_ringMaxSize, pos.y()); | ||
193 | EffectFrame* frame = effects->effectFrame(EffectFrameStyled, false, point, Qt::AlignLeft); | 193 | EffectFrame* frame = effects->effectFrame(EffectFrameStyled, false, point, Qt::AlignLeft); | ||
194 | frame->setFont(m_font); | 194 | frame->setFont(m_font); | ||
195 | frame->setText(text); | 195 | frame->setText(text); | ||
196 | return frame; | 196 | return frame; | ||
197 | } | 197 | } | ||
198 | 198 | | |||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Line(s) | 274 | { | |||
290 | 290 | | |||
291 | for (int ii = 0; ii < num_segments; ++ii) { | 291 | for (int ii = 0; ii < num_segments; ++ii) { | ||
292 | verts << x + cx << y + cy;//output vertex | 292 | verts << x + cx << y + cy;//output vertex | ||
293 | //apply the rotation matrix | 293 | //apply the rotation matrix | ||
294 | t = x; | 294 | t = x; | ||
295 | x = c * x - s * y; | 295 | x = c * x - s * y; | ||
296 | y = s * t + c * y; | 296 | y = s * t + c * y; | ||
297 | } | 297 | } | ||
298 | vbo->setData(verts.size() / 2, 2, verts.data(), NULL); | 298 | vbo->setData(verts.size() / 2, 2, verts.data(), nullptr); | ||
299 | vbo->render(GL_LINE_LOOP); | 299 | vbo->render(GL_LINE_LOOP); | ||
300 | } | 300 | } | ||
301 | 301 | | |||
302 | void MouseClickEffect::drawCircleXr(const QColor& color, float cx, float cy, float r) | 302 | void MouseClickEffect::drawCircleXr(const QColor& color, float cx, float cy, float r) | ||
303 | { | 303 | { | ||
304 | #ifdef KWIN_HAVE_XRENDER_COMPOSITING | 304 | #ifdef KWIN_HAVE_XRENDER_COMPOSITING | ||
305 | if (r <= m_lineWidth) | 305 | if (r <= m_lineWidth) | ||
306 | return; | 306 | return; | ||
▲ Show 20 Lines • Show All 83 Lines • Show Last 20 Lines |