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 {
|
KWin::EffectWindow *findWindow(WId) const override {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
KWin::EffectWindow *findWindow(KWayland::Server::SurfaceInterface *) const override {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
void *getProxy(QString) override {
|
void *getProxy(QString) override {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
11
effects.cpp
11
effects.cpp
|
@ -1038,6 +1038,17 @@ EffectWindow* EffectsHandlerImpl::findWindow(WId id) const
|
||||||
return NULL;
|
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
|
EffectWindowList EffectsHandlerImpl::stackingOrder() const
|
||||||
{
|
{
|
||||||
ToplevelList list = Workspace::self()->xStackingOrder();
|
ToplevelList list = Workspace::self()->xStackingOrder();
|
||||||
|
|
|
@ -130,6 +130,7 @@ public:
|
||||||
void startMousePolling() override;
|
void startMousePolling() override;
|
||||||
void stopMousePolling() override;
|
void stopMousePolling() override;
|
||||||
EffectWindow* findWindow(WId id) const override;
|
EffectWindow* findWindow(WId id) const override;
|
||||||
|
EffectWindow* findWindow(KWayland::Server::SurfaceInterface *surf) const override;
|
||||||
EffectWindowList stackingOrder() const override;
|
EffectWindowList stackingOrder() const override;
|
||||||
void setElevatedWindow(KWin::EffectWindow* w, bool set) 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 <QTimeLine>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
|
#include <KWayland/Server/surface_interface.h>
|
||||||
|
#include <KWayland/Server/slide_interface.h>
|
||||||
|
#include <KWayland/Server/display.h>
|
||||||
|
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
|
||||||
SlidingPopupsEffect::SlidingPopupsEffect()
|
SlidingPopupsEffect::SlidingPopupsEffect()
|
||||||
{
|
{
|
||||||
|
KWayland::Server::Display *display = effects->waylandDisplay();
|
||||||
|
if (display) {
|
||||||
|
display->createSlideManager(this)->create();
|
||||||
|
}
|
||||||
|
|
||||||
mSlideLength = QFontMetrics(qApp->font()).height() * 8;
|
mSlideLength = QFontMetrics(qApp->font()).height() * 8;
|
||||||
|
|
||||||
mAtom = effects->announceSupportProperty("_KDE_SLIDE", this);
|
mAtom = effects->announceSupportProperty("_KDE_SLIDE", this);
|
||||||
|
@ -258,7 +267,17 @@ void SlidingPopupsEffect::postPaintWindow(EffectWindow* w)
|
||||||
|
|
||||||
void SlidingPopupsEffect::slotWindowAdded(EffectWindow *w)
|
void SlidingPopupsEffect::slotWindowAdded(EffectWindow *w)
|
||||||
{
|
{
|
||||||
|
//X11
|
||||||
slotPropertyNotify(w, mAtom);
|
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->isOnCurrentDesktop() && mWindowsData.contains(w)) {
|
||||||
if (!w->data(WindowForceBackgroundContrastRole).isValid() && w->hasAlpha()) {
|
if (!w->data(WindowForceBackgroundContrastRole).isValid() && w->hasAlpha()) {
|
||||||
w->setData(WindowForceBackgroundContrastRole, QVariant(true));
|
w->setData(WindowForceBackgroundContrastRole, QVariant(true));
|
||||||
|
@ -342,27 +361,33 @@ void SlidingPopupsEffect::slotPropertyNotify(EffectWindow* w, long a)
|
||||||
animData.fadeInDuration = animationTime(mFadeInTime);
|
animData.fadeInDuration = animationTime(mFadeInTime);
|
||||||
animData.fadeOutDuration = animationTime(mFadeOutTime);
|
animData.fadeOutDuration = animationTime(mFadeOutTime);
|
||||||
}
|
}
|
||||||
|
mWindowsData[ w ] = animData;
|
||||||
|
setupAnimData(w);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SlidingPopupsEffect::setupAnimData(EffectWindow *w)
|
||||||
|
{
|
||||||
const QRect screenRect = effects->clientArea(FullScreenArea, w->screen(), effects->currentDesktop());
|
const QRect screenRect = effects->clientArea(FullScreenArea, w->screen(), effects->currentDesktop());
|
||||||
if (animData.start == -1) {
|
if (mWindowsData[w].start == -1) {
|
||||||
switch (animData.from) {
|
switch (mWindowsData[w].from) {
|
||||||
case West:
|
case West:
|
||||||
animData.start = qMax(w->x() - screenRect.x(), 0);
|
mWindowsData[w].start = qMax(w->x() - screenRect.x(), 0);
|
||||||
break;
|
break;
|
||||||
case North:
|
case North:
|
||||||
animData.start = qMax(w->y() - screenRect.y(), 0);
|
mWindowsData[w].start = qMax(w->y() - screenRect.y(), 0);
|
||||||
break;
|
break;
|
||||||
case East:
|
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;
|
break;
|
||||||
case South:
|
case South:
|
||||||
default:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// sanitize
|
// sanitize
|
||||||
int difference = 0;
|
int difference = 0;
|
||||||
switch (animData.from) {
|
switch (mWindowsData[w].from) {
|
||||||
case West:
|
case West:
|
||||||
difference = w->x() - screenRect.x();
|
difference = w->x() - screenRect.x();
|
||||||
break;
|
break;
|
||||||
|
@ -377,12 +402,50 @@ void SlidingPopupsEffect::slotPropertyNotify(EffectWindow* w, long a)
|
||||||
difference = w->y() + w->height() - (screenRect.y() + screenRect.height());
|
difference = w->y() + w->height() - (screenRect.y() + screenRect.height());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
animData.start = qMax<int>(animData.start, difference);
|
mWindowsData[w].start = qMax<int>(mWindowsData[w].start, difference);
|
||||||
mWindowsData[ w ] = animData;
|
|
||||||
// Grab the window, so other windowClosed effects will ignore it
|
// Grab the window, so other windowClosed effects will ignore it
|
||||||
w->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast<void*>(this)));
|
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
|
bool SlidingPopupsEffect::isActive() const
|
||||||
{
|
{
|
||||||
return !mAppearingWindows.isEmpty() || !mDisappearingWindows.isEmpty();
|
return !mAppearingWindows.isEmpty() || !mDisappearingWindows.isEmpty();
|
||||||
|
|
|
@ -62,7 +62,10 @@ public Q_SLOTS:
|
||||||
void slotWindowClosed(KWin::EffectWindow *c);
|
void slotWindowClosed(KWin::EffectWindow *c);
|
||||||
void slotWindowDeleted(KWin::EffectWindow *w);
|
void slotWindowDeleted(KWin::EffectWindow *w);
|
||||||
void slotPropertyNotify(KWin::EffectWindow *w, long a);
|
void slotPropertyNotify(KWin::EffectWindow *w, long a);
|
||||||
|
void slotWaylandSlideOnShowChanged(EffectWindow* w);
|
||||||
private:
|
private:
|
||||||
|
void setupAnimData(EffectWindow *w);
|
||||||
|
|
||||||
enum Position {
|
enum Position {
|
||||||
West = 0,
|
West = 0,
|
||||||
North = 1,
|
North = 1,
|
||||||
|
|
|
@ -934,6 +934,7 @@ public:
|
||||||
virtual WindowQuadType newWindowQuadType() = 0;
|
virtual WindowQuadType newWindowQuadType() = 0;
|
||||||
|
|
||||||
Q_SCRIPTABLE virtual KWin::EffectWindow* findWindow(WId id) const = 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;
|
virtual EffectWindowList stackingOrder() const = 0;
|
||||||
// window will be temporarily painted as if being at the top of the stack
|
// 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;
|
Q_SCRIPTABLE virtual void setElevatedWindow(KWin::EffectWindow* w, bool set) = 0;
|
||||||
|
|
Loading…
Reference in New Issue