effect_builtins.cpp 23.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/********************************************************************
 KWin - the KDE window manager
 This file is part of the KDE project.

Copyright (C) 2014 Martin Gräßlin <mgraesslin@kde.org>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "effect_builtins.h"
21
#ifdef EFFECT_BUILTINS
22 23 24
// common effects
#include "backgroundcontrast/contrast.h"
#include "blur/blur.h"
25
#include "colorpicker/colorpicker.h"
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
#include "kscreen/kscreen.h"
#include "presentwindows/presentwindows.h"
#include "screenedge/screenedgeeffect.h"
#include "screenshot/screenshot.h"
#include "slidingpopups/slidingpopups.h"
// Common effects only relevant to desktop
#include "desktopgrid/desktopgrid.h"
#include "diminactive/diminactive.h"
#include "fallapart/fallapart.h"
#include "highlightwindow/highlightwindow.h"
#include "magiclamp/magiclamp.h"
#include "resize/resize.h"
#include "showfps/showfps.h"
#include "showpaint/showpaint.h"
#include "slide/slide.h"
#include "slideback/slideback.h"
#include "thumbnailaside/thumbnailaside.h"
43
#include "touchpoints/touchpoints.h"
44 45 46 47 48
#include "windowgeometry/windowgeometry.h"
#include "zoom/zoom.h"
// OpenGL-specific effects for desktop
#include "coverswitch/coverswitch.h"
#include "cube/cube.h"
49
#include "cubeslide/cubeslide.h"
50 51 52 53 54 55 56 57 58 59 60 61
#include "flipswitch/flipswitch.h"
#include "glide/glide.h"
#include "invert/invert.h"
#include "lookingglass/lookingglass.h"
#include "magnifier/magnifier.h"
#include "mouseclick/mouseclick.h"
#include "mousemark/mousemark.h"
#include "sheet/sheet.h"
#include "snaphelper/snaphelper.h"
#include "startupfeedback/startupfeedback.h"
#include "trackmouse/trackmouse.h"
#include "wobblywindows/wobblywindows.h"
62 63 64 65 66 67 68 69 70 71
#endif

#include <KLocalizedString>
#include <kwineffects.h>

#ifndef EFFECT_BUILTINS
#define EFFECT_FALLBACK nullptr, nullptr, nullptr
#else
#define EFFECT_FALLBACK
#endif
72 73 74 75

namespace KWin
{

76 77 78
namespace BuiltInEffects
{

79 80 81 82 83 84
template <class T>
inline Effect *createHelper()
{
    return new T();
}

85 86 87
static const QVector<EffectData> &effectData()
{
    static const QVector<EffectData> s_effectData = {
88 89
    {
        QString(),
90 91 92 93 94 95
        QString(),
        QString(),
        QString(),
        QString(),
        QUrl(),
        false,
96 97 98 99 100 101
        false,
        nullptr,
        nullptr,
        nullptr
    }, {
        QStringLiteral("blur"),
102 103
        i18ndc("kwin_effects", "Name of a KWin Effect", "Blur"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Blurs the background behind semi-transparent windows"),
104 105 106
        QStringLiteral("Appearance"),
        QString(),
        QUrl(),
107
        true,
108
        false,
109
#ifdef EFFECT_BUILTINS
110 111 112
        &createHelper<BlurEffect>,
        &BlurEffect::supported,
        &BlurEffect::enabledByDefault
113
#endif
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
EFFECT_FALLBACK
    }, {
        QStringLiteral("colorpicker"),
        i18ndc("kwin_effects", "Name of a KWin Effect", "Color Picker"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Supports picking a color"),
        QStringLiteral("Accessibility"),
        QString(),
        QUrl(),
        true,
        true,
#ifdef EFFECT_BUILTINS
        &createHelper<ColorPickerEffect>,
        &ColorPickerEffect::supported,
        nullptr
#endif
129
EFFECT_FALLBACK
130 131
    }, {
        QStringLiteral("contrast"),
132 133
        i18ndc("kwin_effects", "Name of a KWin Effect", "Background contrast"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Improve contrast and readability behind semi-transparent windows"),
134 135 136
        QStringLiteral("Appearance"),
        QString(),
        QUrl(),
137
        true,
138
        false,
139
#ifdef EFFECT_BUILTINS
140 141 142
        &createHelper<ContrastEffect>,
        &ContrastEffect::supported,
        &ContrastEffect::enabledByDefault
143 144
#endif
EFFECT_FALLBACK
145 146
    }, {
        QStringLiteral("coverswitch"),
147 148
        i18ndc("kwin_effects", "Name of a KWin Effect", "Cover Switch"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Display a Cover Flow effect for the alt+tab window switcher"),
149 150
        QStringLiteral("Window Management"),
        QString(),
Volker Krause's avatar
Volker Krause committed
151
        QUrl(QStringLiteral("https://files.kde.org/plasma/kwin/effect-videos/cover_switch.mp4")),
152
        false,
153
        true,
154
#ifdef EFFECT_BUILTINS
155 156 157
        &createHelper<CoverSwitchEffect>,
        &CoverSwitchEffect::supported,
        nullptr
158 159
#endif
EFFECT_FALLBACK
160 161
    }, {
        QStringLiteral("cube"),
162 163
        i18ndc("kwin_effects", "Name of a KWin Effect", "Desktop Cube"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Display each virtual desktop on a side of a cube"),
164 165
        QStringLiteral("Window Management"),
        QString(),
Volker Krause's avatar
Volker Krause committed
166
        QUrl(QStringLiteral("https://files.kde.org/plasma/kwin/effect-videos/desktop_cube.ogv")),
167
        false,
168
        false,
169
#ifdef EFFECT_BUILTINS
170 171 172
        &createHelper<CubeEffect>,
        &CubeEffect::supported,
        nullptr
173 174
#endif
EFFECT_FALLBACK
175 176
    }, {
        QStringLiteral("cubeslide"),
177 178
        i18ndc("kwin_effects", "Name of a KWin Effect", "Desktop Cube Animation"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Animate desktop switching with a cube"),
179 180
        QStringLiteral("Virtual Desktop Switching Animation"),
        QStringLiteral("desktop-animations"),
Volker Krause's avatar
Volker Krause committed
181
        QUrl(QStringLiteral("https://files.kde.org/plasma/kwin/effect-videos/desktop_cube_animation.ogv")),
182
        false,
183
        false,
184
#ifdef EFFECT_BUILTINS
185 186 187
        &createHelper<CubeSlideEffect>,
        &CubeSlideEffect::supported,
        nullptr
188 189
#endif
EFFECT_FALLBACK
190 191
    }, {
        QStringLiteral("desktopgrid"),
192 193
        i18ndc("kwin_effects", "Name of a KWin Effect", "Desktop Grid"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Zoom out so all desktops are displayed side-by-side in a grid"),
194 195
        QStringLiteral("Window Management"),
        QString(),
Volker Krause's avatar
Volker Krause committed
196
        QUrl(QStringLiteral("https://files.kde.org/plasma/kwin/effect-videos/desktop_grid.mp4")),
197
        true,
198
        false,
199
#ifdef EFFECT_BUILTINS
200 201 202
        &createHelper<DesktopGridEffect>,
        nullptr,
        nullptr
203 204
#endif
EFFECT_FALLBACK
205 206
    }, {
        QStringLiteral("diminactive"),
207 208
        i18ndc("kwin_effects", "Name of a KWin Effect", "Dim Inactive"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Darken inactive windows"),
209 210
        QStringLiteral("Focus"),
        QString(),
Volker Krause's avatar
Volker Krause committed
211
        QUrl(QStringLiteral("https://files.kde.org/plasma/kwin/effect-videos/dim_inactive.mp4")),
212
        false,
213
        false,
214
#ifdef EFFECT_BUILTINS
215 216 217
        &createHelper<DimInactiveEffect>,
        nullptr,
        nullptr
218 219
#endif
EFFECT_FALLBACK
220 221
    }, {
        QStringLiteral("fallapart"),
222 223
        i18ndc("kwin_effects", "Name of a KWin Effect", "Fall Apart"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Closed windows fall into pieces"),
224
        QStringLiteral("Appearance"),
225 226 227
        QString(),
        QUrl(),
        false,
228
        false,
229
#ifdef EFFECT_BUILTINS
230 231 232
        &createHelper<FallApartEffect>,
        &FallApartEffect::supported,
        nullptr
233 234
#endif
EFFECT_FALLBACK
235 236
    }, {
        QStringLiteral("flipswitch"),
237 238
        i18ndc("kwin_effects", "Name of a KWin Effect", "Flip Switch"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Flip through windows that are in a stack for the alt+tab window switcher"),
239 240
        QStringLiteral("Window Management"),
        QString(),
Volker Krause's avatar
Volker Krause committed
241
        QUrl(QStringLiteral("https://files.kde.org/plasma/kwin/effect-videos/flip_switch.mp4")),
242
        false,
243
        false,
244
#ifdef EFFECT_BUILTINS
245 246 247
        &createHelper<FlipSwitchEffect>,
        &FlipSwitchEffect::supported,
        nullptr
248 249
#endif
EFFECT_FALLBACK
250 251
    }, {
        QStringLiteral("glide"),
252
        i18ndc("kwin_effects", "Name of a KWin Effect", "Glide"),
253
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Glide windows as they appear or disappear"),
254 255
        QStringLiteral("Window Open/Close Animation"),
        QStringLiteral("toplevel-open-close-animation"),
256 257
        QUrl(),
        false,
258
        false,
259
#ifdef EFFECT_BUILTINS
260 261 262
        &createHelper<GlideEffect>,
        &GlideEffect::supported,
        nullptr
263 264
#endif
EFFECT_FALLBACK
265 266
    }, {
        QStringLiteral("highlightwindow"),
267 268
        i18ndc("kwin_effects", "Name of a KWin Effect", "Highlight Window"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Highlight the appropriate window when hovering over taskbar entries"),
269 270 271 272
        QStringLiteral("Appearance"),
        QString(),
        QUrl(),
        true,
273
        true,
274
#ifdef EFFECT_BUILTINS
275 276 277
        &createHelper<HighlightWindowEffect>,
        nullptr,
        nullptr
278 279
#endif
EFFECT_FALLBACK
280 281
    }, {
        QStringLiteral("invert"),
282 283
        i18ndc("kwin_effects", "Name of a KWin Effect", "Invert"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Inverts the color of the desktop and windows"),
284 285
        QStringLiteral("Accessibility"),
        QString(),
Volker Krause's avatar
Volker Krause committed
286
        QUrl(QStringLiteral("https://files.kde.org/plasma/kwin/effect-videos/invert.mp4")),
287
        false,
288
        false,
289
#ifdef EFFECT_BUILTINS
290 291 292
        &createHelper<InvertEffect>,
        &InvertEffect::supported,
        nullptr
293 294
#endif
EFFECT_FALLBACK
295 296
    }, {
        QStringLiteral("kscreen"),
297 298
        i18ndc("kwin_effects", "Name of a KWin Effect", "Kscreen"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Helper Effect for KScreen"),
299 300 301 302
        QStringLiteral("Appearance"),
        QString(),
        QUrl(),
        true,
303
        true,
304
#ifdef EFFECT_BUILTINS
305 306 307
        &createHelper<KscreenEffect>,
        nullptr,
        nullptr
308 309
#endif
EFFECT_FALLBACK
310 311
    }, {
        QStringLiteral("lookingglass"),
312 313
        i18ndc("kwin_effects", "Name of a KWin Effect", "Looking Glass"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "A screen magnifier that looks like a fisheye lens"),
314 315
        QStringLiteral("Accessibility"),
        QStringLiteral("magnifiers"),
Volker Krause's avatar
Volker Krause committed
316
        QUrl(QStringLiteral("https://files.kde.org/plasma/kwin/effect-videos/looking_glass.ogv")),
317
        false,
318
        false,
319
#ifdef EFFECT_BUILTINS
320 321 322
        &createHelper<LookingGlassEffect>,
        &LookingGlassEffect::supported,
        nullptr
323 324
#endif
EFFECT_FALLBACK
325 326
    }, {
        QStringLiteral("magiclamp"),
327 328
        i18ndc("kwin_effects", "Name of a KWin Effect", "Magic Lamp"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Simulate a magic lamp when minimizing windows"),
329 330
        QStringLiteral("Appearance"),
        QStringLiteral("minimize"),
Volker Krause's avatar
Volker Krause committed
331
        QUrl(QStringLiteral("https://files.kde.org/plasma/kwin/effect-videos/magic_lamp.ogv")),
332
        false,
333
        false,
334
#ifdef EFFECT_BUILTINS
335 336 337
        &createHelper<MagicLampEffect>,
        &MagicLampEffect::supported,
        nullptr
338 339
#endif
EFFECT_FALLBACK
340 341
    }, {
        QStringLiteral("magnifier"),
342 343
        i18ndc("kwin_effects", "Name of a KWin Effect", "Magnifier"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Magnify the section of the screen that is near the mouse cursor"),
344 345
        QStringLiteral("Accessibility"),
        QStringLiteral("magnifiers"),
Volker Krause's avatar
Volker Krause committed
346
        QUrl(QStringLiteral("https://files.kde.org/plasma/kwin/effect-videos/magnifier.ogv")),
347
        false,
348
        false,
349
#ifdef EFFECT_BUILTINS
350 351 352
        &createHelper<MagnifierEffect>,
        &MagnifierEffect::supported,
        nullptr
353 354
#endif
EFFECT_FALLBACK
355 356
    }, {
        QStringLiteral("mouseclick"),
357 358
        i18ndc("kwin_effects", "Name of a KWin Effect", "Mouse Click Animation"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Creates an animation whenever a mouse button is clicked. This is useful for screenrecordings/presentations"),
359 360
        QStringLiteral("Accessibility"),
        QString(),
Volker Krause's avatar
Volker Krause committed
361
        QUrl(QStringLiteral("https://files.kde.org/plasma/kwin/effect-videos/mouse_click.mp4")),
362
        false,
363
        false,
364
#ifdef EFFECT_BUILTINS
365 366 367
        &createHelper<MouseClickEffect>,
        nullptr,
        nullptr
368 369
#endif
EFFECT_FALLBACK
370 371
    }, {
        QStringLiteral("mousemark"),
372 373
        i18ndc("kwin_effects", "Name of a KWin Effect", "Mouse Mark"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Allows you to draw lines on the desktop"),
374 375 376 377
        QStringLiteral("Appearance"),
        QString(),
        QUrl(),
        false,
378
        false,
379
#ifdef EFFECT_BUILTINS
380 381 382
        &createHelper<MouseMarkEffect>,
        nullptr,
        nullptr
383 384
#endif
EFFECT_FALLBACK
385 386
    }, {
        QStringLiteral("presentwindows"),
387 388
        i18ndc("kwin_effects", "Name of a KWin Effect", "Present Windows"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Zoom out until all opened windows can be displayed side-by-side"),
389 390
        QStringLiteral("Window Management"),
        QString(),
Volker Krause's avatar
Volker Krause committed
391
        QUrl(QStringLiteral("https://files.kde.org/plasma/kwin/effect-videos/present_windows.mp4")),
392
        true,
393
        false,
394
#ifdef EFFECT_BUILTINS
395 396 397
        &createHelper<PresentWindowsEffect>,
        nullptr,
        nullptr
398 399
#endif
EFFECT_FALLBACK
400 401
    }, {
        QStringLiteral("resize"),
402 403
        i18ndc("kwin_effects", "Name of a KWin Effect", "Resize Window"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Resizes windows with a fast texture scale instead of updating contents"),
404 405 406 407
        QStringLiteral("Window Management"),
        QString(),
        QUrl(),
        false,
408
        false,
409
#ifdef EFFECT_BUILTINS
410 411 412
        &createHelper<ResizeEffect>,
        nullptr,
        nullptr
413 414
#endif
EFFECT_FALLBACK
415 416
    }, {
        QStringLiteral("screenedge"),
417 418
        i18ndc("kwin_effects", "Name of a KWin Effect", "Screen Edge"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Highlights a screen edge when approaching"),
419 420 421
        QStringLiteral("Appearance"),
        QString(),
        QUrl(),
422
        true,
423
        false,
424
#ifdef EFFECT_BUILTINS
425 426 427
        &createHelper<ScreenEdgeEffect>,
        nullptr,
        nullptr
428 429
#endif
EFFECT_FALLBACK
430 431
    }, {
        QStringLiteral("screenshot"),
432
        i18ndc("kwin_effects", "Name of a KWin Effect", "Screenshot"),
433
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Helper effect for screenshot tools"),
434 435 436 437
        QStringLiteral("Appearance"),
        QString(),
        QUrl(),
        true,
438
        true,
439
#ifdef EFFECT_BUILTINS
440 441 442
        &createHelper<ScreenShotEffect>,
        &ScreenShotEffect::supported,
        nullptr
443 444
#endif
EFFECT_FALLBACK
445 446
    }, {
        QStringLiteral("sheet"),
447 448
        i18ndc("kwin_effects", "Name of a KWin Effect", "Sheet"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Make modal dialogs smoothly fly in and out when they are shown or hidden"),
449
        QStringLiteral("Appearance"),
450 451 452
        QString(),
        QUrl(),
        false,
453
        false,
454
#ifdef EFFECT_BUILTINS
455 456 457
        &createHelper<SheetEffect>,
        &SheetEffect::supported,
        nullptr
458 459
#endif
EFFECT_FALLBACK
460 461
    }, {
        QStringLiteral("showfps"),
462 463
        i18ndc("kwin_effects", "Name of a KWin Effect", "Show FPS"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Display KWin's performance in the corner of the screen"),
464 465 466 467
        QStringLiteral("Tools"),
        QString(),
        QUrl(),
        false,
468
        false,
469
#ifdef EFFECT_BUILTINS
470 471 472
        &createHelper<ShowFpsEffect>,
        nullptr,
        nullptr
473 474
#endif
EFFECT_FALLBACK
475 476
    }, {
        QStringLiteral("showpaint"),
477 478
        i18ndc("kwin_effects", "Name of a KWin Effect", "Show Paint"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Highlight areas of the desktop that have been recently updated"),
479 480 481 482
        QStringLiteral("Tools"),
        QString(),
        QUrl(),
        false,
483
        false,
484
#ifdef EFFECT_BUILTINS
485 486 487
        &createHelper<ShowPaintEffect>,
        nullptr,
        nullptr
488 489
#endif
EFFECT_FALLBACK
490 491
    }, {
        QStringLiteral("slide"),
492
        i18ndc("kwin_effects", "Name of a KWin Effect", "Slide"),
493
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Slide desktops when switching virtual desktops"),
494 495
        QStringLiteral("Virtual Desktop Switching Animation"),
        QStringLiteral("desktop-animations"),
Volker Krause's avatar
Volker Krause committed
496
        QUrl(QStringLiteral("https://files.kde.org/plasma/kwin/effect-videos/slide.ogv")),
497
        true,
498
        false,
499
#ifdef EFFECT_BUILTINS
500
        &createHelper<SlideEffect>,
501
        &SlideEffect::supported,
502
        nullptr
503 504
#endif
EFFECT_FALLBACK
505 506
    }, {
        QStringLiteral("slideback"),
507 508
        i18ndc("kwin_effects", "Name of a KWin Effect", "Slide Back"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Slide back windows when another window is raised"),
509 510 511 512
        QStringLiteral("Focus"),
        QString(),
        QUrl(),
        false,
513
        false,
514
#ifdef EFFECT_BUILTINS
515 516 517
        &createHelper<SlideBackEffect>,
        nullptr,
        nullptr
518 519
#endif
EFFECT_FALLBACK
520 521
    }, {
        QStringLiteral("slidingpopups"),
522 523
        i18ndc("kwin_effects", "Name of a KWin Effect", "Sliding popups"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Sliding animation for Plasma popups"),
524 525
        QStringLiteral("Appearance"),
        QString(),
Volker Krause's avatar
Volker Krause committed
526
        QUrl(QStringLiteral("https://files.kde.org/plasma/kwin/effect-videos/sliding_popups.mp4")),
527
        true,
528
        false,
529
#ifdef EFFECT_BUILTINS
530
        &createHelper<SlidingPopupsEffect>,
531
        &SlidingPopupsEffect::supported,
532
        nullptr
533 534
#endif
EFFECT_FALLBACK
535 536
    }, {
        QStringLiteral("snaphelper"),
537 538
        i18ndc("kwin_effects", "Name of a KWin Effect", "Snap Helper"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Help you locate the center of the screen when moving a window"),
539 540
        QStringLiteral("Accessibility"),
        QString(),
Volker Krause's avatar
Volker Krause committed
541
        QUrl(QStringLiteral("https://files.kde.org/plasma/kwin/effect-videos/snap_helper.mp4")),
542
        false,
543
        false,
544
#ifdef EFFECT_BUILTINS
545 546 547
        &createHelper<SnapHelperEffect>,
        nullptr,
        nullptr
548 549
#endif
EFFECT_FALLBACK
550 551
    }, {
        QStringLiteral("startupfeedback"),
552 553
        i18ndc("kwin_effects", "Name of a KWin Effect", "Startup Feedback"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Helper effect for startup feedback"),
554
        QStringLiteral("Appearance"),
555 556 557
        QString(),
        QUrl(),
        true,
558
        true,
559
#ifdef EFFECT_BUILTINS
560 561 562
        &createHelper<StartupFeedbackEffect>,
        &StartupFeedbackEffect::supported,
        nullptr
563 564
#endif
EFFECT_FALLBACK
565 566
    }, {
        QStringLiteral("thumbnailaside"),
567 568
        i18ndc("kwin_effects", "Name of a KWin Effect", "Thumbnail Aside"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Display window thumbnails on the edge of the screen"),
569 570 571 572
        QStringLiteral("Appearance"),
        QString(),
        QUrl(),
        false,
573
        false,
574
#ifdef EFFECT_BUILTINS
575 576 577
        &createHelper<ThumbnailAsideEffect>,
        nullptr,
        nullptr
578
#endif
579 580 581 582 583 584 585 586 587 588 589 590 591 592 593
EFFECT_FALLBACK
    }, {
        QStringLiteral("touchpoints"),
        i18ndc("kwin_effects", "Name of a KWin Effect", "Touch Points"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Visualize touch points"),
        QStringLiteral("Appearance"),
        QString(),
        QUrl(),
        false,
        false,
#ifdef EFFECT_BUILTINS
        &createHelper<TouchPointsEffect>,
        nullptr,
        nullptr
#endif
594
EFFECT_FALLBACK
595 596
    }, {
        QStringLiteral("trackmouse"),
597 598
        i18ndc("kwin_effects", "Name of a KWin Effect", "Track Mouse"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Display a mouse cursor locating effect when activated"),
599 600
        QStringLiteral("Accessibility"),
        QString(),
Volker Krause's avatar
Volker Krause committed
601
        QUrl(QStringLiteral("https://files.kde.org/plasma/kwin/effect-videos/track_mouse.mp4")),
602
        false,
603
        false,
604
#ifdef EFFECT_BUILTINS
605 606 607
        &createHelper<TrackMouseEffect>,
        nullptr,
        nullptr
608 609
#endif
EFFECT_FALLBACK
610 611
    }, {
        QStringLiteral("windowgeometry"),
612 613
        i18ndc("kwin_effects", "Name of a KWin Effect", "Window Geometry"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Display window geometries on move/resize"),
614 615 616
        QStringLiteral("Appearance"),
        QString(),
        QUrl(),
617
        false,
618
        true,
619
#ifdef EFFECT_BUILTINS
620 621 622
        &createHelper<WindowGeometry>,
        nullptr,
        nullptr
623 624
#endif
EFFECT_FALLBACK
625 626
    }, {
        QStringLiteral("wobblywindows"),
627 628
        i18ndc("kwin_effects", "Name of a KWin Effect", "Wobbly Windows"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Deform windows while they are moving"),
629
        QStringLiteral("Appearance"),
630
        QString(),
Volker Krause's avatar
Volker Krause committed
631
        QUrl(QStringLiteral("https://files.kde.org/plasma/kwin/effect-videos/wobbly_windows.ogv")),
632
        false,
633
        false,
634
#ifdef EFFECT_BUILTINS
635 636 637
        &createHelper<WobblyWindowsEffect>,
        &WobblyWindowsEffect::supported,
        nullptr
638 639
#endif
EFFECT_FALLBACK
640 641
    }, {
        QStringLiteral("zoom"),
642 643
        i18ndc("kwin_effects", "Name of a KWin Effect", "Zoom"),
        i18ndc("kwin_effects", "Comment describing the KWin Effect", "Magnify the entire desktop"),
644 645
        QStringLiteral("Accessibility"),
        QStringLiteral("magnifiers"),
Volker Krause's avatar
Volker Krause committed
646
        QUrl(QStringLiteral("https://files.kde.org/plasma/kwin/effect-videos/zoom.ogv")),
647
        true,
648
        false,
649
#ifdef EFFECT_BUILTINS
650 651 652
        &createHelper<ZoomEffect>,
        nullptr,
        nullptr
653 654
#endif
EFFECT_FALLBACK
655
    }
656 657 658
    };
    return s_effectData;
}
659

660
static inline int index(BuiltInEffect effect)
661
{
662
    return static_cast<int>(effect);
663 664
}

665
Effect *create(BuiltInEffect effect)
666
{
667 668
    const EffectData &data = effectData(effect);
    if (data.createFunction == nullptr) {
669 670
        return nullptr;
    }
671
    return data.createFunction();
672 673
}

674
bool available(const QString &name)
675
{
676
    auto it = std::find_if(effectData().begin(), effectData().end(),
677 678 679 680
        [name](const EffectData &data) {
            return data.name == name;
        }
    );
681
    return it != effectData().end();
682 683
}

684
bool supported(BuiltInEffect effect)
685 686 687 688
{
    if (effect == BuiltInEffect::Invalid) {
        return false;
    }
689 690
    const EffectData &data = effectData(effect);
    if (data.supportedFunction == nullptr) {
691
        return true;
692
    }
693
    return data.supportedFunction();
694 695
}

696
bool checkEnabledByDefault(BuiltInEffect effect)
697
{
698 699
    if (effect == BuiltInEffect::Invalid) {
        return false;
700
    }
701 702
    const EffectData &data = effectData(effect);
    if (data.enabledFunction == nullptr) {
703
        return true;
704
    }
705
    return data.enabledFunction();
706 707
}

708 709
bool enabledByDefault(BuiltInEffect effect)
{
710
    return effectData(effect).enabled;
711 712
}

713
QStringList availableEffectNames()
714
{
715
    QStringList result;
716
    for (const EffectData &data : effectData()) {
717 718 719 720 721 722
        if (data.name.isEmpty()) {
            continue;
        }
        result << data.name;
    }
    return result;
723 724 725 726
}

QList< BuiltInEffect > availableEffects()
{
727 728 729 730 731
    QList<BuiltInEffect> result;
    for (int i = index(BuiltInEffect::Invalid) + 1; i <= index(BuiltInEffect::Zoom); ++i) {
        result << BuiltInEffect(i);
    }
    return result;
732 733
}

734
BuiltInEffect builtInForName(const QString &name)
735
{
736
    auto it = std::find_if(effectData().begin(), effectData().end(),
737 738 739 740
        [name](const EffectData &data) {
            return data.name == name;
        }
    );
741
    if (it == effectData().end()) {
742 743
        return BuiltInEffect::Invalid;
    }
744
    return BuiltInEffect(std::distance(effectData().begin(), it));
745 746
}

747
QString nameForEffect(BuiltInEffect effect)
748
{
749
    return effectData(effect).name;
750 751
}

752 753
const EffectData &effectData(BuiltInEffect effect)
{
754
    return effectData().at(index(effect));
755 756
}

757 758 759
} // BuiltInEffects

} // namespace