Changeset View
Changeset View
Standalone View
Standalone View
effects/slidingpopups/slidingpopups.cpp
Show All 18 Lines | |||||
19 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
20 | *********************************************************************/ | 20 | *********************************************************************/ | ||
21 | 21 | | |||
22 | #include "slidingpopups.h" | 22 | #include "slidingpopups.h" | ||
23 | #include "slidingpopupsconfig.h" | 23 | #include "slidingpopupsconfig.h" | ||
24 | 24 | | |||
25 | #include <QApplication> | 25 | #include <QApplication> | ||
26 | #include <QFontMetrics> | 26 | #include <QFontMetrics> | ||
27 | #include <QWindow> | ||||
27 | 28 | | |||
28 | #include <KWayland/Server/surface_interface.h> | 29 | #include <KWayland/Server/surface_interface.h> | ||
29 | #include <KWayland/Server/slide_interface.h> | 30 | #include <KWayland/Server/slide_interface.h> | ||
30 | #include <KWayland/Server/display.h> | 31 | #include <KWayland/Server/display.h> | ||
31 | 32 | | |||
33 | #include <KWindowEffects> | ||||
34 | | ||||
35 | Q_DECLARE_METATYPE(KWindowEffects::SlideFromLocation) | ||||
36 | | ||||
32 | namespace KWin | 37 | namespace KWin | ||
33 | { | 38 | { | ||
34 | 39 | | |||
35 | SlidingPopupsEffect::SlidingPopupsEffect() | 40 | SlidingPopupsEffect::SlidingPopupsEffect() | ||
36 | { | 41 | { | ||
37 | initConfig<SlidingPopupsConfig>(); | 42 | initConfig<SlidingPopupsConfig>(); | ||
38 | KWayland::Server::Display *display = effects->waylandDisplay(); | 43 | KWayland::Server::Display *display = effects->waylandDisplay(); | ||
39 | if (display) { | 44 | if (display) { | ||
▲ Show 20 Lines • Show All 155 Lines • ▼ Show 20 Line(s) | 194 | { | |||
195 | //Wayland | 200 | //Wayland | ||
196 | if (auto surf = w->surface()) { | 201 | if (auto surf = w->surface()) { | ||
197 | slotWaylandSlideOnShowChanged(w); | 202 | slotWaylandSlideOnShowChanged(w); | ||
198 | connect(surf, &KWayland::Server::SurfaceInterface::slideOnShowHideChanged, this, [this, surf] { | 203 | connect(surf, &KWayland::Server::SurfaceInterface::slideOnShowHideChanged, this, [this, surf] { | ||
199 | slotWaylandSlideOnShowChanged(effects->findWindow(surf)); | 204 | slotWaylandSlideOnShowChanged(effects->findWindow(surf)); | ||
200 | }); | 205 | }); | ||
201 | } | 206 | } | ||
202 | 207 | | |||
208 | if (auto internal = w->internalWindow()) { | ||||
209 | internal->installEventFilter(this); | ||||
210 | setupInternalWindowSlide(w); | ||||
211 | } | ||||
212 | | ||||
203 | slideIn(w); | 213 | slideIn(w); | ||
204 | } | 214 | } | ||
205 | 215 | | |||
206 | void SlidingPopupsEffect::slotWindowDeleted(EffectWindow *w) | 216 | void SlidingPopupsEffect::slotWindowDeleted(EffectWindow *w) | ||
207 | { | 217 | { | ||
208 | m_animations.remove(w); | 218 | m_animations.remove(w); | ||
209 | m_animationsData.remove(w); | 219 | m_animationsData.remove(w); | ||
210 | } | 220 | } | ||
▲ Show 20 Lines • Show All 161 Lines • ▼ Show 20 Line(s) | 362 | if (surf->slideOnShowHide()) { | |||
372 | animData.slideLength = 0; | 382 | animData.slideLength = 0; | ||
373 | animData.slideInDuration = m_slideInDuration; | 383 | animData.slideInDuration = m_slideInDuration; | ||
374 | animData.slideOutDuration = m_slideOutDuration; | 384 | animData.slideOutDuration = m_slideOutDuration; | ||
375 | 385 | | |||
376 | setupAnimData(w); | 386 | setupAnimData(w); | ||
377 | } | 387 | } | ||
378 | } | 388 | } | ||
379 | 389 | | |||
390 | void SlidingPopupsEffect::setupInternalWindowSlide(EffectWindow *w) | ||||
391 | { | ||||
392 | if (!w) { | ||||
393 | return; | ||||
394 | } | ||||
395 | auto internal = w->internalWindow(); | ||||
396 | if (!internal) { | ||||
397 | return; | ||||
398 | } | ||||
399 | const QVariant slideProperty = internal->property("kwin_slide"); | ||||
400 | if (!slideProperty.isValid()) { | ||||
401 | return; | ||||
402 | } | ||||
403 | AnimationData &animData = m_animationsData[w]; | ||||
404 | switch (slideProperty.value<KWindowEffects::SlideFromLocation>()) { | ||||
405 | case KWindowEffects::BottomEdge: | ||||
406 | animData.location = Location::Bottom; | ||||
407 | break; | ||||
408 | case KWindowEffects::TopEdge: | ||||
409 | animData.location = Location::Top; | ||||
410 | break; | ||||
411 | case KWindowEffects::RightEdge: | ||||
412 | animData.location = Location::Right; | ||||
413 | break; | ||||
414 | case KWindowEffects::LeftEdge: | ||||
415 | animData.location = Location::Left; | ||||
416 | break; | ||||
417 | default: | ||||
418 | return; | ||||
419 | } | ||||
420 | bool intOk = false; | ||||
421 | animData.offset = internal->property("kwin_slide_offset").toInt(&intOk); | ||||
422 | if (!intOk) { | ||||
423 | animData.offset = -1; | ||||
424 | } | ||||
425 | animData.slideLength = 0; | ||||
426 | animData.slideInDuration = m_slideInDuration; | ||||
427 | animData.slideOutDuration = m_slideOutDuration; | ||||
428 | | ||||
429 | setupAnimData(w); | ||||
430 | } | ||||
431 | | ||||
432 | bool SlidingPopupsEffect::eventFilter(QObject *watched, QEvent *event) | ||||
433 | { | ||||
434 | auto internal = qobject_cast<QWindow*>(watched); | ||||
435 | if (internal && event->type() == QEvent::DynamicPropertyChange) { | ||||
436 | QDynamicPropertyChangeEvent *pe = static_cast<QDynamicPropertyChangeEvent*>(event); | ||||
437 | if (pe->propertyName() == "kwin_slide" || pe->propertyName() == "kwin_slide_offset") { | ||||
438 | if (auto w = effects->findWindow(internal)) { | ||||
439 | setupInternalWindowSlide(w); | ||||
440 | } | ||||
441 | } | ||||
442 | } | ||||
443 | return false; | ||||
444 | } | ||||
445 | | ||||
380 | void SlidingPopupsEffect::slideIn(EffectWindow *w) | 446 | void SlidingPopupsEffect::slideIn(EffectWindow *w) | ||
381 | { | 447 | { | ||
382 | if (effects->activeFullScreenEffect()) { | 448 | if (effects->activeFullScreenEffect()) { | ||
383 | return; | 449 | return; | ||
384 | } | 450 | } | ||
385 | 451 | | |||
386 | if (!w->isVisible()) { | 452 | if (!w->isVisible()) { | ||
387 | return; | 453 | return; | ||
▲ Show 20 Lines • Show All 88 Lines • Show Last 20 Lines |