From f9672ff39472d92be20fe7f262d54718f4220a63 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Sat, 31 Oct 2009 10:58:06 +0000 Subject: [PATCH] new effect: highlightWindows, uses _KDE_WINDOW_HIGHLIGHT atom svn path=/trunk/KDE/kdelibs/; revision=1042972 --- windoweffects.cpp | 35 +++++++++++++++++++++++++++++++++++ windoweffects.h | 24 ++++++++++++++++++------ 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/windoweffects.cpp b/windoweffects.cpp index aac872313..29009757a 100644 --- a/windoweffects.cpp +++ b/windoweffects.cpp @@ -56,6 +56,9 @@ bool isEffectAvailable(Effect effect) case PresentWindowsGroup: effectName = "_KDE_PRESENT_WINDOWS_GROUP"; break; + case HighlightWindows: + effectName = "_KDE_WINDOW_HIGHLIGHT"; + break; default: return false; } @@ -242,6 +245,38 @@ void presentWindows(WId controler, int desktop) #endif } +void highlightWindows(WId controller, const QList &ids) +{ +#ifdef Q_WS_X11 + const int numWindows = ids.count(); + Display *dpy = QX11Info::display(); + Atom atom = XInternAtom(dpy, "_KDE_WINDOW_HIGHLIGHT", False); + + if (numWindows == 0) { + Atom atom = XInternAtom(dpy, "_KDE_WINDOW_HIGHLIGHT", False); + XDeleteProperty(dpy, controller, atom); + } + + QVarLengthArray data(numWindows); + int actualCount = 0; + + for (int i = 0; i < numWindows; ++i) { + data[i] = ids.at(i); + ++actualCount; + + } + + if (actualCount != numWindows) { + data.resize(actualCount); + } + + if (!data.isEmpty()) { + XChangeProperty(dpy, controller, atom, atom, 32, PropModeReplace, + reinterpret_cast(data.data()), data.size()); + } +#endif +} + } } diff --git a/windoweffects.h b/windoweffects.h index 43c4ea23d..fcb381cab 100644 --- a/windoweffects.h +++ b/windoweffects.h @@ -39,7 +39,8 @@ namespace WindowEffects Slide = 1, WindowPreview = 2, PresentWindows = 3, - PresentWindowsGroup = 4 + PresentWindowsGroup = 4, + HighlightWindows = 5 }; /** @@ -96,21 +97,32 @@ namespace WindowEffects /** * Activate the Present Windows effect for the given groups of windows. * - * @param controler The window which is the controler of this effect. The property + * @param controller The window which is the controller of this effect. The property * will be set on this window. It will be removed by the effect * @param ids all the windows which should be presented. * @since 4.4 */ - PLASMA_EXPORT void presentWindows(WId controler, const QList &ids); - /** + PLASMA_EXPORT void presentWindows(WId controller, const QList &ids); + + /** * Activate the Present Windows effect for the windows of the given desktop. * - * @param controler The window which is the controler of this effect. The property + * @param controller The window which is the controller of this effect. The property * will be set on this window. It will be removed by the effect * @param desktop The desktop whose windows should be presented. -1 for all desktops * @since 4.4 */ - PLASMA_EXPORT void presentWindows(WId controler, int desktop = -1); + PLASMA_EXPORT void presentWindows(WId controller, int desktop = -1); + + /** + * Highlight the selected windos, making all the others translucent + * + * @param controller The window which is the controller of this effect. The property + * will be set on this window. It will be removed by the effect + * @param ids all the windows which should be highlighted. + * @since 4.4 + */ + PLASMA_EXPORT void highlightWindows(WId controller, const QList &ids); } } // namespace Plasma