support the slide protocol
take and apply thhe informations from the wayland slide protocol in the sliding popups effect REVIEW:125120icc-effect-5.14.5
parent
873b4ed717
commit
5a55727056
|
@ -127,6 +127,9 @@ public:
|
|||
KWin::EffectWindow *findWindow(WId) const override {
|
||||
return nullptr;
|
||||
}
|
||||
KWin::EffectWindow *findWindow(KWayland::Server::SurfaceInterface *) const override {
|
||||
return nullptr;
|
||||
}
|
||||
void *getProxy(QString) override {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
11
effects.cpp
11
effects.cpp
|
@ -1038,6 +1038,17 @@ EffectWindow* EffectsHandlerImpl::findWindow(WId id) const
|
|||
return NULL;
|
||||
}
|
||||
|
||||
EffectWindow* EffectsHandlerImpl::findWindow(KWayland::Server::SurfaceInterface *surf) const
|
||||
{
|
||||
if (waylandServer()) {
|
||||
if (ShellClient *w = waylandServer()->findClient(surf)) {
|
||||
return w->effectWindow();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
EffectWindowList EffectsHandlerImpl::stackingOrder() const
|
||||
{
|
||||
ToplevelList list = Workspace::self()->xStackingOrder();
|
||||
|
|
|
@ -130,6 +130,7 @@ public:
|
|||
void startMousePolling() override;
|
||||
void stopMousePolling() override;
|
||||
EffectWindow* findWindow(WId id) const override;
|
||||
EffectWindow* findWindow(KWayland::Server::SurfaceInterface *surf) const override;
|
||||
EffectWindowList stackingOrder() const override;
|
||||
void setElevatedWindow(KWin::EffectWindow* w, bool set) override;
|
||||
|
||||
|
|
|
@ -24,11 +24,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <QTimeLine>
|
||||
#include <QApplication>
|
||||
|
||||
#include <KWayland/Server/surface_interface.h>
|
||||
#include <KWayland/Server/slide_interface.h>
|
||||
#include <KWayland/Server/display.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
SlidingPopupsEffect::SlidingPopupsEffect()
|
||||
{
|
||||
KWayland::Server::Display *display = effects->waylandDisplay();
|
||||
if (display) {
|
||||
display->createSlideManager(this)->create();
|
||||
}
|
||||
|
||||
mSlideLength = QFontMetrics(qApp->font()).height() * 8;
|
||||
|
||||
mAtom = effects->announceSupportProperty("_KDE_SLIDE", this);
|
||||
|
@ -258,7 +267,17 @@ void SlidingPopupsEffect::postPaintWindow(EffectWindow* w)
|
|||
|
||||
void SlidingPopupsEffect::slotWindowAdded(EffectWindow *w)
|
||||
{
|
||||
//X11
|
||||
slotPropertyNotify(w, mAtom);
|
||||
|
||||
//Wayland
|
||||
if (auto surf = w->surface()) {
|
||||
slotWaylandSlideOnShowChanged(w);
|
||||
connect(surf, &KWayland::Server::SurfaceInterface::slideOnShowHideChanged, this, [this, surf] {
|
||||
slotWaylandSlideOnShowChanged(effects->findWindow(surf));
|
||||
});
|
||||
}
|
||||
|
||||
if (w->isOnCurrentDesktop() && mWindowsData.contains(w)) {
|
||||
if (!w->data(WindowForceBackgroundContrastRole).isValid() && w->hasAlpha()) {
|
||||
w->setData(WindowForceBackgroundContrastRole, QVariant(true));
|
||||
|
@ -342,27 +361,33 @@ void SlidingPopupsEffect::slotPropertyNotify(EffectWindow* w, long a)
|
|||
animData.fadeInDuration = animationTime(mFadeInTime);
|
||||
animData.fadeOutDuration = animationTime(mFadeOutTime);
|
||||
}
|
||||
mWindowsData[ w ] = animData;
|
||||
setupAnimData(w);
|
||||
}
|
||||
|
||||
void SlidingPopupsEffect::setupAnimData(EffectWindow *w)
|
||||
{
|
||||
const QRect screenRect = effects->clientArea(FullScreenArea, w->screen(), effects->currentDesktop());
|
||||
if (animData.start == -1) {
|
||||
switch (animData.from) {
|
||||
if (mWindowsData[w].start == -1) {
|
||||
switch (mWindowsData[w].from) {
|
||||
case West:
|
||||
animData.start = qMax(w->x() - screenRect.x(), 0);
|
||||
mWindowsData[w].start = qMax(w->x() - screenRect.x(), 0);
|
||||
break;
|
||||
case North:
|
||||
animData.start = qMax(w->y() - screenRect.y(), 0);
|
||||
mWindowsData[w].start = qMax(w->y() - screenRect.y(), 0);
|
||||
break;
|
||||
case East:
|
||||
animData.start = qMax(screenRect.x() + screenRect.width() - (w->x() + w->width()), 0);
|
||||
mWindowsData[w].start = qMax(screenRect.x() + screenRect.width() - (w->x() + w->width()), 0);
|
||||
break;
|
||||
case South:
|
||||
default:
|
||||
animData.start = qMax(screenRect.y() + screenRect.height() - (w->y() + w->height()), 0);
|
||||
mWindowsData[w].start = qMax(screenRect.y() + screenRect.height() - (w->y() + w->height()), 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// sanitize
|
||||
int difference = 0;
|
||||
switch (animData.from) {
|
||||
switch (mWindowsData[w].from) {
|
||||
case West:
|
||||
difference = w->x() - screenRect.x();
|
||||
break;
|
||||
|
@ -377,12 +402,50 @@ void SlidingPopupsEffect::slotPropertyNotify(EffectWindow* w, long a)
|
|||
difference = w->y() + w->height() - (screenRect.y() + screenRect.height());
|
||||
break;
|
||||
}
|
||||
animData.start = qMax<int>(animData.start, difference);
|
||||
mWindowsData[ w ] = animData;
|
||||
mWindowsData[w].start = qMax<int>(mWindowsData[w].start, difference);
|
||||
// Grab the window, so other windowClosed effects will ignore it
|
||||
w->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast<void*>(this)));
|
||||
}
|
||||
|
||||
void SlidingPopupsEffect::slotWaylandSlideOnShowChanged(EffectWindow* w)
|
||||
{
|
||||
if (!w) {
|
||||
return;
|
||||
}
|
||||
|
||||
KWayland::Server::SurfaceInterface *surf = w->surface();
|
||||
if (!surf) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (surf->slideOnShowHide()) {
|
||||
Data animData;
|
||||
animData.start = surf->slideOnShowHide()->offset();
|
||||
|
||||
switch (surf->slideOnShowHide()->location()) {
|
||||
case KWayland::Server::SlideInterface::Location::Top:
|
||||
animData.from = North;
|
||||
break;
|
||||
case KWayland::Server::SlideInterface::Location::Left:
|
||||
animData.from = West;
|
||||
break;
|
||||
case KWayland::Server::SlideInterface::Location::Right:
|
||||
animData.from = East;
|
||||
break;
|
||||
case KWayland::Server::SlideInterface::Location::Bottom:
|
||||
default:
|
||||
animData.from = South;
|
||||
break;
|
||||
}
|
||||
animData.slideLength = 0;
|
||||
animData.fadeInDuration = animationTime(mFadeInTime);
|
||||
animData.fadeOutDuration = animationTime(mFadeOutTime);
|
||||
mWindowsData[ w ] = animData;
|
||||
|
||||
setupAnimData(w);
|
||||
}
|
||||
}
|
||||
|
||||
bool SlidingPopupsEffect::isActive() const
|
||||
{
|
||||
return !mAppearingWindows.isEmpty() || !mDisappearingWindows.isEmpty();
|
||||
|
|
|
@ -62,7 +62,10 @@ public Q_SLOTS:
|
|||
void slotWindowClosed(KWin::EffectWindow *c);
|
||||
void slotWindowDeleted(KWin::EffectWindow *w);
|
||||
void slotPropertyNotify(KWin::EffectWindow *w, long a);
|
||||
void slotWaylandSlideOnShowChanged(EffectWindow* w);
|
||||
private:
|
||||
void setupAnimData(EffectWindow *w);
|
||||
|
||||
enum Position {
|
||||
West = 0,
|
||||
North = 1,
|
||||
|
|
|
@ -934,6 +934,7 @@ public:
|
|||
virtual WindowQuadType newWindowQuadType() = 0;
|
||||
|
||||
Q_SCRIPTABLE virtual KWin::EffectWindow* findWindow(WId id) const = 0;
|
||||
Q_SCRIPTABLE virtual KWin::EffectWindow* findWindow(KWayland::Server::SurfaceInterface *surf) const = 0;
|
||||
virtual EffectWindowList stackingOrder() const = 0;
|
||||
// window will be temporarily painted as if being at the top of the stack
|
||||
Q_SCRIPTABLE virtual void setElevatedWindow(KWin::EffectWindow* w, bool set) = 0;
|
||||
|
|
Loading…
Reference in New Issue