Changeset View
Changeset View
Standalone View
Standalone View
effects/startupfeedback/startupfeedback.cpp
Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | |||||
73 | 73 | | |||
74 | StartupFeedbackEffect::StartupFeedbackEffect() | 74 | StartupFeedbackEffect::StartupFeedbackEffect() | ||
75 | : m_bounceSizesRatio(1.0) | 75 | : m_bounceSizesRatio(1.0) | ||
76 | , m_startupInfo(new KStartupInfo(KStartupInfo::CleanOnCantDetect, this)) | 76 | , m_startupInfo(new KStartupInfo(KStartupInfo::CleanOnCantDetect, this)) | ||
77 | , m_selection(nullptr) | 77 | , m_selection(nullptr) | ||
78 | , m_active(false) | 78 | , m_active(false) | ||
79 | , m_frame(0) | 79 | , m_frame(0) | ||
80 | , m_progress(0) | 80 | , m_progress(0) | ||
81 | , m_texture(0) | 81 | , m_texture(nullptr) | ||
82 | , m_type(BouncingFeedback) | 82 | , m_type(BouncingFeedback) | ||
83 | , m_blinkingShader(0) | 83 | , m_blinkingShader(nullptr) | ||
84 | , m_cursorSize(0) | 84 | , m_cursorSize(0) | ||
85 | { | 85 | { | ||
86 | for (int i = 0; i < 5; ++i) { | 86 | for (int i = 0; i < 5; ++i) { | ||
87 | m_bouncingTextures[i] = 0; | 87 | m_bouncingTextures[i] = nullptr; | ||
88 | } | 88 | } | ||
89 | if (KWindowSystem::isPlatformX11()) { | 89 | if (KWindowSystem::isPlatformX11()) { | ||
90 | m_selection = new KSelectionOwner("_KDE_STARTUP_FEEDBACK", xcbConnection(), x11RootWindow(), this); | 90 | m_selection = new KSelectionOwner("_KDE_STARTUP_FEEDBACK", xcbConnection(), x11RootWindow(), this); | ||
91 | m_selection->claim(true); | 91 | m_selection->claim(true); | ||
92 | } | 92 | } | ||
93 | connect(m_startupInfo, &KStartupInfo::gotNewStartup, this, &StartupFeedbackEffect::gotNewStartup); | 93 | connect(m_startupInfo, &KStartupInfo::gotNewStartup, this, &StartupFeedbackEffect::gotNewStartup); | ||
94 | connect(m_startupInfo, &KStartupInfo::gotRemoveStartup, this, &StartupFeedbackEffect::gotRemoveStartup); | 94 | connect(m_startupInfo, &KStartupInfo::gotRemoveStartup, this, &StartupFeedbackEffect::gotRemoveStartup); | ||
95 | connect(m_startupInfo, &KStartupInfo::gotStartupChange, this, &StartupFeedbackEffect::gotStartupChange); | 95 | connect(m_startupInfo, &KStartupInfo::gotStartupChange, this, &StartupFeedbackEffect::gotStartupChange); | ||
▲ Show 20 Lines • Show All 175 Lines • ▼ Show 20 Line(s) | 270 | if (m_type == NoFeedback) | |||
271 | return; | 271 | return; | ||
272 | if (!m_active) | 272 | if (!m_active) | ||
273 | effects->startMousePolling(); | 273 | effects->startMousePolling(); | ||
274 | m_active = true; | 274 | m_active = true; | ||
275 | // get ratio for bouncing cursor so we don't need to manually calculate the sizes for each icon size | 275 | // get ratio for bouncing cursor so we don't need to manually calculate the sizes for each icon size | ||
276 | if (m_type == BouncingFeedback) | 276 | if (m_type == BouncingFeedback) | ||
277 | m_bounceSizesRatio = IconSize(KIconLoader::Small) / 16.0; | 277 | m_bounceSizesRatio = IconSize(KIconLoader::Small) / 16.0; | ||
278 | QPixmap iconPixmap = KIconLoader::global()->loadIcon(icon, KIconLoader::Small, 0, | 278 | QPixmap iconPixmap = KIconLoader::global()->loadIcon(icon, KIconLoader::Small, 0, | ||
279 | KIconLoader::DefaultState, QStringList(), 0, true); // return null pixmap if not found | 279 | KIconLoader::DefaultState, QStringList(), nullptr, true); // return null pixmap if not found | ||
280 | if (iconPixmap.isNull()) | 280 | if (iconPixmap.isNull()) | ||
281 | iconPixmap = SmallIcon(QStringLiteral("system-run")); | 281 | iconPixmap = SmallIcon(QStringLiteral("system-run")); | ||
282 | prepareTextures(iconPixmap); | 282 | prepareTextures(iconPixmap); | ||
283 | auto readCursorSize = []() -> int { | 283 | auto readCursorSize = []() -> int { | ||
284 | // read details about the mouse-cursor theme define per default | 284 | // read details about the mouse-cursor theme define per default | ||
285 | KConfigGroup mousecfg(effects->inputConfig(), "Mouse"); | 285 | KConfigGroup mousecfg(effects->inputConfig(), "Mouse"); | ||
286 | QString size = mousecfg.readEntry("cursorSize", QString()); | 286 | QString size = mousecfg.readEntry("cursorSize", QString()); | ||
287 | 287 | | |||
Show All 14 Lines | 301 | { | |||
302 | if (m_active) | 302 | if (m_active) | ||
303 | effects->stopMousePolling(); | 303 | effects->stopMousePolling(); | ||
304 | m_active = false; | 304 | m_active = false; | ||
305 | effects->makeOpenGLContextCurrent(); | 305 | effects->makeOpenGLContextCurrent(); | ||
306 | switch(m_type) { | 306 | switch(m_type) { | ||
307 | case BouncingFeedback: | 307 | case BouncingFeedback: | ||
308 | for (int i = 0; i < 5; ++i) { | 308 | for (int i = 0; i < 5; ++i) { | ||
309 | delete m_bouncingTextures[i]; | 309 | delete m_bouncingTextures[i]; | ||
310 | m_bouncingTextures[i] = 0; | 310 | m_bouncingTextures[i] = nullptr; | ||
311 | } | 311 | } | ||
312 | break; | 312 | break; | ||
313 | case BlinkingFeedback: | 313 | case BlinkingFeedback: | ||
314 | case PassiveFeedback: | 314 | case PassiveFeedback: | ||
315 | delete m_texture; | 315 | delete m_texture; | ||
316 | m_texture = 0; | 316 | m_texture = nullptr; | ||
317 | break; | 317 | break; | ||
318 | case NoFeedback: | 318 | case NoFeedback: | ||
319 | return; // don't want the full repaint | 319 | return; // don't want the full repaint | ||
320 | default: | 320 | default: | ||
321 | break; // impossible | 321 | break; // impossible | ||
322 | } | 322 | } | ||
323 | effects->addRepaintFull(); | 323 | effects->addRepaintFull(); | ||
324 | } | 324 | } | ||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | 365 | if (m_cursorSize <= 16) | |||
366 | xDiff = 8 + 7; | 366 | xDiff = 8 + 7; | ||
367 | else if (m_cursorSize <= 32) | 367 | else if (m_cursorSize <= 32) | ||
368 | xDiff = 16 + 7; | 368 | xDiff = 16 + 7; | ||
369 | else if (m_cursorSize <= 48) | 369 | else if (m_cursorSize <= 48) | ||
370 | xDiff = 24 + 7; | 370 | xDiff = 24 + 7; | ||
371 | else | 371 | else | ||
372 | xDiff = 32 + 7; | 372 | xDiff = 32 + 7; | ||
373 | int yDiff = xDiff; | 373 | int yDiff = xDiff; | ||
374 | GLTexture* texture = 0; | 374 | GLTexture* texture = nullptr; | ||
375 | int yOffset = 0; | 375 | int yOffset = 0; | ||
376 | switch(m_type) { | 376 | switch(m_type) { | ||
377 | case BouncingFeedback: | 377 | case BouncingFeedback: | ||
378 | texture = m_bouncingTextures[ FRAME_TO_BOUNCE_TEXTURE[ m_frame ]]; | 378 | texture = m_bouncingTextures[ FRAME_TO_BOUNCE_TEXTURE[ m_frame ]]; | ||
379 | yOffset = FRAME_TO_BOUNCE_YOFFSET[ m_frame ] * m_bounceSizesRatio; | 379 | yOffset = FRAME_TO_BOUNCE_YOFFSET[ m_frame ] * m_bounceSizesRatio; | ||
380 | break; | 380 | break; | ||
381 | case BlinkingFeedback: // fall through | 381 | case BlinkingFeedback: // fall through | ||
382 | case PassiveFeedback: | 382 | case PassiveFeedback: | ||
Show All 19 Lines |