Attached is the required code to trigger KWin's new highlight window effect. This effect highlights the requested window by fading out all others allowing the user to see the window even if it's covered.
This patch is purely proof-of-concept as it adds code to an suboptimal location in the Plasma codebase and requires taskbar thumbnails to be enabled for the code to be executed. I'll leave it up to the Plasma team as to how they want to correctly implement this feature; I am not familiar with the Plasma code at all so I cannot do it myself. It works by attaching an X property atom called "_KDE_WINDOW_HIGHLIGHT" to a window that Plasma controls and contains the X window ID of the window to highlight. If the property is deleted or if the managing window is destroyed the effect terminates. Keen eyes will notice that ToolTip::hide() is actually redundant in this particular patch. It is only possible to highlight a single window at a time as I cannot think of any scenario where highlighting multiple windows would be useful over not highlighting any at all. If anyone can think of one feel free to mention it. I have also yet to determine what the effect should do if the requested window to highlight isn't on the current desktop. There is no need to display a thumbnail as that's what taskbar thumbnails does but what happens when the user has disabled that effect? Should it show a thumbnail with an arrow pointing in the direction of the desktop that the window is on? Should it display the window in the same position as it is on the other desktop? Should it display a pager-like thing in the center of the screen with the desktop that the window is on highlighted? Should it even show anything at all?
Index: private/tooltip_p.h =================================================================== --- private/tooltip_p.h (revision 920969) +++ private/tooltip_p.h (working copy) @@ -43,6 +43,8 @@ public: bool autohide() const; void setDirection(Plasma::Direction); + void hide(); + protected: void checkSize(); void showEvent(QShowEvent *); Index: private/tooltip.cpp =================================================================== --- private/tooltip.cpp (revision 920969) +++ private/tooltip.cpp (working copy) @@ -42,6 +42,13 @@ #include <plasma/theme.h> #include <plasma/framesvg.h> +#ifdef Q_WS_X11 +#include <QX11Info> + +#include <X11/Xlib.h> +#include <fixx11h.h> +#endif + namespace Plasma { class TipTextWidget : public QWidget @@ -121,6 +128,20 @@ void ToolTip::showEvent(QShowEvent *e) checkSize(); QWidget::showEvent(e); d->preview->setInfo(); + + //----------------------- + // KWin highlight window + +#ifdef Q_WS_X11 + Display *dpy = QX11Info::display(); + Atom atom = XInternAtom(dpy, "_KDE_WINDOW_HIGHLIGHT", False); + Q_ASSERT(isWindow()); // parent must be toplevel + long data[] = { d->preview->windowId() }; + XChangeProperty(dpy, winId(), atom, atom, 32, PropModeReplace, + reinterpret_cast<unsigned char *>(data), sizeof(data) / sizeof(data[ 0 ])); +#endif + + //----------------------- } void ToolTip::hideEvent(QHideEvent *e) @@ -131,6 +152,23 @@ void ToolTip::hideEvent(QHideEvent *e) } } +void ToolTip::hide() +{ + //----------------------- + // KWin highlight window + +#ifdef Q_WS_X11 + Display *dpy = QX11Info::display(); + Atom atom = XInternAtom(dpy, "_KDE_WINDOW_HIGHLIGHT", False); + Q_ASSERT(isWindow()); // parent must be toplevel + XDeleteProperty(dpy, winId(), atom); +#endif + + //----------------------- + + QWidget::hide(); +} + void ToolTip::mouseReleaseEvent(QMouseEvent *event) { if (rect().contains(event->pos())) { @@ -230,6 +268,20 @@ void ToolTip::setContent(QObject *tipper d->source = tipper; if (isVisible()) { + //----------------------- + // KWin highlight window + +#ifdef Q_WS_X11 + Display *dpy = QX11Info::display(); + Atom atom = XInternAtom(dpy, "_KDE_WINDOW_HIGHLIGHT", False); + Q_ASSERT(isWindow()); // parent must be toplevel + long data[] = { d->preview->windowId() }; + XChangeProperty(dpy, winId(), atom, atom, 32, PropModeReplace, + reinterpret_cast<unsigned char *>(data), sizeof(data) / sizeof(data[ 0 ])); +#endif + + //----------------------- + d->preview->setInfo(); //kDebug() << "about to check size"; checkSize();
_______________________________________________ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel