Changeset View
Changeset View
Standalone View
Standalone View
effects.cpp
Show First 20 Lines • Show All 96 Lines • ▼ Show 20 Line(s) | |||||
97 | { | 97 | { | ||
98 | auto c = kwinApp()->x11Connection(); | 98 | auto c = kwinApp()->x11Connection(); | ||
99 | if (!c) { | 99 | if (!c) { | ||
100 | return XCB_ATOM_NONE; | 100 | return XCB_ATOM_NONE; | ||
101 | } | 101 | } | ||
102 | // get the atom for the propertyName | 102 | // get the atom for the propertyName | ||
103 | ScopedCPointer<xcb_intern_atom_reply_t> atomReply(xcb_intern_atom_reply(c, | 103 | ScopedCPointer<xcb_intern_atom_reply_t> atomReply(xcb_intern_atom_reply(c, | ||
104 | xcb_intern_atom_unchecked(c, false, propertyName.size(), propertyName.constData()), | 104 | xcb_intern_atom_unchecked(c, false, propertyName.size(), propertyName.constData()), | ||
105 | NULL)); | 105 | nullptr)); | ||
106 | if (atomReply.isNull()) { | 106 | if (atomReply.isNull()) { | ||
107 | return XCB_ATOM_NONE; | 107 | return XCB_ATOM_NONE; | ||
108 | } | 108 | } | ||
109 | // announce property on root window | 109 | // announce property on root window | ||
110 | unsigned char dummy = 0; | 110 | unsigned char dummy = 0; | ||
111 | xcb_change_property(c, XCB_PROP_MODE_REPLACE, kwinApp()->x11RootWindow(), atomReply->atom, atomReply->atom, 8, 1, &dummy); | 111 | xcb_change_property(c, XCB_PROP_MODE_REPLACE, kwinApp()->x11RootWindow(), atomReply->atom, atomReply->atom, 8, 1, &dummy); | ||
112 | // TODO: add to _NET_SUPPORTED | 112 | // TODO: add to _NET_SUPPORTED | ||
113 | return atomReply->atom; | 113 | return atomReply->atom; | ||
114 | } | 114 | } | ||
115 | 115 | | |||
116 | //--------------------- | 116 | //--------------------- | ||
117 | 117 | | |||
118 | EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, Scene *scene) | 118 | EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, Scene *scene) | ||
119 | : EffectsHandler(scene->compositingType()) | 119 | : EffectsHandler(scene->compositingType()) | ||
120 | , keyboard_grab_effect(NULL) | 120 | , keyboard_grab_effect(nullptr) | ||
121 | , fullscreen_effect(0) | 121 | , fullscreen_effect(nullptr) | ||
122 | , next_window_quad_type(EFFECT_QUAD_TYPE_START) | 122 | , next_window_quad_type(EFFECT_QUAD_TYPE_START) | ||
123 | , m_compositor(compositor) | 123 | , m_compositor(compositor) | ||
124 | , m_scene(scene) | 124 | , m_scene(scene) | ||
125 | , m_desktopRendering(false) | 125 | , m_desktopRendering(false) | ||
126 | , m_currentRenderedDesktop(0) | 126 | , m_currentRenderedDesktop(0) | ||
127 | , m_effectLoader(new EffectLoader(this)) | 127 | , m_effectLoader(new EffectLoader(this)) | ||
128 | , m_trackingCursorChanges(0) | 128 | , m_trackingCursorChanges(0) | ||
129 | { | 129 | { | ||
Show All 15 Lines | |||||
145 | Workspace *ws = Workspace::self(); | 145 | Workspace *ws = Workspace::self(); | ||
146 | VirtualDesktopManager *vds = VirtualDesktopManager::self(); | 146 | VirtualDesktopManager *vds = VirtualDesktopManager::self(); | ||
147 | connect(ws, &Workspace::showingDesktopChanged, | 147 | connect(ws, &Workspace::showingDesktopChanged, | ||
148 | this, &EffectsHandlerImpl::showingDesktopChanged); | 148 | this, &EffectsHandlerImpl::showingDesktopChanged); | ||
149 | connect(ws, &Workspace::currentDesktopChanged, this, | 149 | connect(ws, &Workspace::currentDesktopChanged, this, | ||
150 | [this](int old, AbstractClient *c) { | 150 | [this](int old, AbstractClient *c) { | ||
151 | const int newDesktop = VirtualDesktopManager::self()->current(); | 151 | const int newDesktop = VirtualDesktopManager::self()->current(); | ||
152 | if (old != 0 && newDesktop != old) { | 152 | if (old != 0 && newDesktop != old) { | ||
153 | emit desktopChanged(old, newDesktop, c ? c->effectWindow() : 0); | 153 | emit desktopChanged(old, newDesktop, c ? c->effectWindow() : nullptr); | ||
154 | // TODO: remove in 4.10 | 154 | // TODO: remove in 4.10 | ||
155 | emit desktopChanged(old, newDesktop); | 155 | emit desktopChanged(old, newDesktop); | ||
156 | } | 156 | } | ||
157 | } | 157 | } | ||
158 | ); | 158 | ); | ||
159 | connect(ws, &Workspace::desktopPresenceChanged, this, | 159 | connect(ws, &Workspace::desktopPresenceChanged, this, | ||
160 | [this](AbstractClient *c, int old) { | 160 | [this](AbstractClient *c, int old) { | ||
161 | if (!c->effectWindow()) { | 161 | if (!c->effectWindow()) { | ||
▲ Show 20 Lines • Show All 297 Lines • ▼ Show 20 Line(s) | 454 | { | |||
459 | // no special final code | 459 | // no special final code | ||
460 | } | 460 | } | ||
461 | 461 | | |||
462 | Effect *EffectsHandlerImpl::provides(Effect::Feature ef) | 462 | Effect *EffectsHandlerImpl::provides(Effect::Feature ef) | ||
463 | { | 463 | { | ||
464 | for (int i = 0; i < loaded_effects.size(); ++i) | 464 | for (int i = 0; i < loaded_effects.size(); ++i) | ||
465 | if (loaded_effects.at(i).second->provides(ef)) | 465 | if (loaded_effects.at(i).second->provides(ef)) | ||
466 | return loaded_effects.at(i).second; | 466 | return loaded_effects.at(i).second; | ||
467 | return NULL; | 467 | return nullptr; | ||
468 | } | 468 | } | ||
469 | 469 | | |||
470 | void EffectsHandlerImpl::drawWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) | 470 | void EffectsHandlerImpl::drawWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) | ||
471 | { | 471 | { | ||
472 | if (m_currentDrawWindowIterator != m_activeEffects.constEnd()) { | 472 | if (m_currentDrawWindowIterator != m_activeEffects.constEnd()) { | ||
473 | (*m_currentDrawWindowIterator++)->drawWindow(w, mask, region, data); | 473 | (*m_currentDrawWindowIterator++)->drawWindow(w, mask, region, data); | ||
474 | --m_currentDrawWindowIterator; | 474 | --m_currentDrawWindowIterator; | ||
475 | } else | 475 | } else | ||
▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Line(s) | 611 | { | |||
615 | } | 615 | } | ||
616 | emit windowDamaged(t->effectWindow(), r); | 616 | emit windowDamaged(t->effectWindow(), r); | ||
617 | } | 617 | } | ||
618 | 618 | | |||
619 | void EffectsHandlerImpl::slotGeometryShapeChanged(Toplevel* t, const QRect& old) | 619 | void EffectsHandlerImpl::slotGeometryShapeChanged(Toplevel* t, const QRect& old) | ||
620 | { | 620 | { | ||
621 | // during late cleanup effectWindow() may be already NULL | 621 | // during late cleanup effectWindow() may be already NULL | ||
622 | // in some functions that may still call this | 622 | // in some functions that may still call this | ||
623 | if (t == NULL || t->effectWindow() == NULL) | 623 | if (t == nullptr || t->effectWindow() == nullptr) | ||
624 | return; | 624 | return; | ||
625 | emit windowGeometryShapeChanged(t->effectWindow(), old); | 625 | emit windowGeometryShapeChanged(t->effectWindow(), old); | ||
626 | } | 626 | } | ||
627 | 627 | | |||
628 | void EffectsHandlerImpl::slotPaddingChanged(Toplevel* t, const QRect& old) | 628 | void EffectsHandlerImpl::slotPaddingChanged(Toplevel* t, const QRect& old) | ||
629 | { | 629 | { | ||
630 | // during late cleanup effectWindow() may be already NULL | 630 | // during late cleanup effectWindow() may be already NULL | ||
631 | // in some functions that may still call this | 631 | // in some functions that may still call this | ||
632 | if (t == NULL || t->effectWindow() == NULL) | 632 | if (t == nullptr || t->effectWindow() == nullptr) | ||
633 | return; | 633 | return; | ||
634 | emit windowPaddingChanged(t->effectWindow(), old); | 634 | emit windowPaddingChanged(t->effectWindow(), old); | ||
635 | } | 635 | } | ||
636 | 636 | | |||
637 | void EffectsHandlerImpl::setActiveFullScreenEffect(Effect* e) | 637 | void EffectsHandlerImpl::setActiveFullScreenEffect(Effect* e) | ||
638 | { | 638 | { | ||
639 | if (fullscreen_effect == e) { | 639 | if (fullscreen_effect == e) { | ||
640 | return; | 640 | return; | ||
Show All 13 Lines | |||||
654 | 654 | | |||
655 | bool EffectsHandlerImpl::hasActiveFullScreenEffect() const | 655 | bool EffectsHandlerImpl::hasActiveFullScreenEffect() const | ||
656 | { | 656 | { | ||
657 | return fullscreen_effect; | 657 | return fullscreen_effect; | ||
658 | } | 658 | } | ||
659 | 659 | | |||
660 | bool EffectsHandlerImpl::grabKeyboard(Effect* effect) | 660 | bool EffectsHandlerImpl::grabKeyboard(Effect* effect) | ||
661 | { | 661 | { | ||
662 | if (keyboard_grab_effect != NULL) | 662 | if (keyboard_grab_effect != nullptr) | ||
663 | return false; | 663 | return false; | ||
664 | if (!doGrabKeyboard()) { | 664 | if (!doGrabKeyboard()) { | ||
665 | return false; | 665 | return false; | ||
666 | } | 666 | } | ||
667 | keyboard_grab_effect = effect; | 667 | keyboard_grab_effect = effect; | ||
668 | return true; | 668 | return true; | ||
669 | } | 669 | } | ||
670 | 670 | | |||
671 | bool EffectsHandlerImpl::doGrabKeyboard() | 671 | bool EffectsHandlerImpl::doGrabKeyboard() | ||
672 | { | 672 | { | ||
673 | return true; | 673 | return true; | ||
674 | } | 674 | } | ||
675 | 675 | | |||
676 | void EffectsHandlerImpl::ungrabKeyboard() | 676 | void EffectsHandlerImpl::ungrabKeyboard() | ||
677 | { | 677 | { | ||
678 | Q_ASSERT(keyboard_grab_effect != NULL); | 678 | Q_ASSERT(keyboard_grab_effect != nullptr); | ||
679 | doUngrabKeyboard(); | 679 | doUngrabKeyboard(); | ||
680 | keyboard_grab_effect = NULL; | 680 | keyboard_grab_effect = nullptr; | ||
681 | } | 681 | } | ||
682 | 682 | | |||
683 | void EffectsHandlerImpl::doUngrabKeyboard() | 683 | void EffectsHandlerImpl::doUngrabKeyboard() | ||
684 | { | 684 | { | ||
685 | } | 685 | } | ||
686 | 686 | | |||
687 | void EffectsHandlerImpl::grabbedKeyboardEvent(QKeyEvent* e) | 687 | void EffectsHandlerImpl::grabbedKeyboardEvent(QKeyEvent* e) | ||
688 | { | 688 | { | ||
689 | if (keyboard_grab_effect != NULL) | 689 | if (keyboard_grab_effect != nullptr) | ||
690 | keyboard_grab_effect->grabbedKeyboardEvent(e); | 690 | keyboard_grab_effect->grabbedKeyboardEvent(e); | ||
691 | } | 691 | } | ||
692 | 692 | | |||
693 | void EffectsHandlerImpl::startMouseInterception(Effect *effect, Qt::CursorShape shape) | 693 | void EffectsHandlerImpl::startMouseInterception(Effect *effect, Qt::CursorShape shape) | ||
694 | { | 694 | { | ||
695 | if (m_grabbedMouseEffects.contains(effect)) { | 695 | if (m_grabbedMouseEffects.contains(effect)) { | ||
696 | return; | 696 | return; | ||
697 | } | 697 | } | ||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Line(s) | |||||
783 | } | 783 | } | ||
784 | 784 | | |||
785 | void* EffectsHandlerImpl::getProxy(QString name) | 785 | void* EffectsHandlerImpl::getProxy(QString name) | ||
786 | { | 786 | { | ||
787 | for (QVector< EffectPair >::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) | 787 | for (QVector< EffectPair >::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) | ||
788 | if ((*it).first == name) | 788 | if ((*it).first == name) | ||
789 | return (*it).second->proxy(); | 789 | return (*it).second->proxy(); | ||
790 | 790 | | |||
791 | return NULL; | 791 | return nullptr; | ||
792 | } | 792 | } | ||
793 | 793 | | |||
794 | void EffectsHandlerImpl::startMousePolling() | 794 | void EffectsHandlerImpl::startMousePolling() | ||
795 | { | 795 | { | ||
796 | if (Cursor::self()) | 796 | if (Cursor::self()) | ||
797 | Cursor::self()->startMousePolling(); | 797 | Cursor::self()->startMousePolling(); | ||
798 | } | 798 | } | ||
799 | 799 | | |||
800 | void EffectsHandlerImpl::stopMousePolling() | 800 | void EffectsHandlerImpl::stopMousePolling() | ||
801 | { | 801 | { | ||
802 | if (Cursor::self()) | 802 | if (Cursor::self()) | ||
803 | Cursor::self()->stopMousePolling(); | 803 | Cursor::self()->stopMousePolling(); | ||
804 | } | 804 | } | ||
805 | 805 | | |||
806 | bool EffectsHandlerImpl::hasKeyboardGrab() const | 806 | bool EffectsHandlerImpl::hasKeyboardGrab() const | ||
807 | { | 807 | { | ||
808 | return keyboard_grab_effect != NULL; | 808 | return keyboard_grab_effect != nullptr; | ||
809 | } | 809 | } | ||
810 | 810 | | |||
811 | void EffectsHandlerImpl::desktopResized(const QSize &size) | 811 | void EffectsHandlerImpl::desktopResized(const QSize &size) | ||
812 | { | 812 | { | ||
813 | m_scene->screenGeometryChanged(size); | 813 | m_scene->screenGeometryChanged(size); | ||
814 | emit screenGeometryChanged(size); | 814 | emit screenGeometryChanged(size); | ||
815 | } | 815 | } | ||
816 | 816 | | |||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | |||||
880 | { | 880 | { | ||
881 | if (auto cl = qobject_cast<AbstractClient *>(static_cast<EffectWindowImpl *>(c)->window())) { | 881 | if (auto cl = qobject_cast<AbstractClient *>(static_cast<EffectWindowImpl *>(c)->window())) { | ||
882 | Workspace::self()->activateClient(cl, true); | 882 | Workspace::self()->activateClient(cl, true); | ||
883 | } | 883 | } | ||
884 | } | 884 | } | ||
885 | 885 | | |||
886 | EffectWindow* EffectsHandlerImpl::activeWindow() const | 886 | EffectWindow* EffectsHandlerImpl::activeWindow() const | ||
887 | { | 887 | { | ||
888 | return Workspace::self()->activeClient() ? Workspace::self()->activeClient()->effectWindow() : NULL; | 888 | return Workspace::self()->activeClient() ? Workspace::self()->activeClient()->effectWindow() : nullptr; | ||
889 | } | 889 | } | ||
890 | 890 | | |||
891 | void EffectsHandlerImpl::moveWindow(EffectWindow* w, const QPoint& pos, bool snap, double snapAdjust) | 891 | void EffectsHandlerImpl::moveWindow(EffectWindow* w, const QPoint& pos, bool snap, double snapAdjust) | ||
892 | { | 892 | { | ||
893 | auto cl = qobject_cast<AbstractClient *>(static_cast<EffectWindowImpl *>(w)->window()); | 893 | auto cl = qobject_cast<AbstractClient *>(static_cast<EffectWindowImpl *>(w)->window()); | ||
894 | if (!cl || !cl->isMovable()) | 894 | if (!cl || !cl->isMovable()) | ||
895 | return; | 895 | return; | ||
896 | 896 | | |||
▲ Show 20 Lines • Show All 170 Lines • ▼ Show 20 Line(s) | 1066 | if (Client* w = Workspace::self()->findClient(Predicate::WindowMatch, id)) | |||
1067 | return w->effectWindow(); | 1067 | return w->effectWindow(); | ||
1068 | if (Unmanaged* w = Workspace::self()->findUnmanaged(id)) | 1068 | if (Unmanaged* w = Workspace::self()->findUnmanaged(id)) | ||
1069 | return w->effectWindow(); | 1069 | return w->effectWindow(); | ||
1070 | if (waylandServer()) { | 1070 | if (waylandServer()) { | ||
1071 | if (ShellClient *w = waylandServer()->findClient(id)) { | 1071 | if (ShellClient *w = waylandServer()->findClient(id)) { | ||
1072 | return w->effectWindow(); | 1072 | return w->effectWindow(); | ||
1073 | } | 1073 | } | ||
1074 | } | 1074 | } | ||
1075 | return NULL; | 1075 | return nullptr; | ||
1076 | } | 1076 | } | ||
1077 | 1077 | | |||
1078 | EffectWindow* EffectsHandlerImpl::findWindow(KWayland::Server::SurfaceInterface *surf) const | 1078 | EffectWindow* EffectsHandlerImpl::findWindow(KWayland::Server::SurfaceInterface *surf) const | ||
1079 | { | 1079 | { | ||
1080 | if (waylandServer()) { | 1080 | if (waylandServer()) { | ||
1081 | if (ShellClient *w = waylandServer()->findClient(surf)) { | 1081 | if (ShellClient *w = waylandServer()->findClient(surf)) { | ||
1082 | return w->effectWindow(); | 1082 | return w->effectWindow(); | ||
1083 | } | 1083 | } | ||
▲ Show 20 Lines • Show All 118 Lines • ▼ Show 20 Line(s) | |||||
1202 | } | 1202 | } | ||
1203 | 1203 | | |||
1204 | EffectWindow* EffectsHandlerImpl::currentTabBoxWindow() const | 1204 | EffectWindow* EffectsHandlerImpl::currentTabBoxWindow() const | ||
1205 | { | 1205 | { | ||
1206 | #ifdef KWIN_BUILD_TABBOX | 1206 | #ifdef KWIN_BUILD_TABBOX | ||
1207 | if (auto c = TabBox::TabBox::self()->currentClient()) | 1207 | if (auto c = TabBox::TabBox::self()->currentClient()) | ||
1208 | return c->effectWindow(); | 1208 | return c->effectWindow(); | ||
1209 | #endif | 1209 | #endif | ||
1210 | return NULL; | 1210 | return nullptr; | ||
1211 | } | 1211 | } | ||
1212 | 1212 | | |||
1213 | void EffectsHandlerImpl::addRepaintFull() | 1213 | void EffectsHandlerImpl::addRepaintFull() | ||
1214 | { | 1214 | { | ||
1215 | m_compositor->addRepaintFull(); | 1215 | m_compositor->addRepaintFull(); | ||
1216 | } | 1216 | } | ||
1217 | 1217 | | |||
1218 | void EffectsHandlerImpl::addRepaint(const QRect& r) | 1218 | void EffectsHandlerImpl::addRepaint(const QRect& r) | ||
▲ Show 20 Lines • Show All 925 Lines • ▼ Show 20 Line(s) | 2137 | { | |||
2144 | return ret; | 2144 | return ret; | ||
2145 | } | 2145 | } | ||
2146 | 2146 | | |||
2147 | //**************************************** | 2147 | //**************************************** | ||
2148 | // EffectFrameImpl | 2148 | // EffectFrameImpl | ||
2149 | //**************************************** | 2149 | //**************************************** | ||
2150 | 2150 | | |||
2151 | EffectFrameImpl::EffectFrameImpl(EffectFrameStyle style, bool staticSize, QPoint position, Qt::Alignment alignment) | 2151 | EffectFrameImpl::EffectFrameImpl(EffectFrameStyle style, bool staticSize, QPoint position, Qt::Alignment alignment) | ||
2152 | : QObject(0) | 2152 | : QObject(nullptr) | ||
2153 | , EffectFrame() | 2153 | , EffectFrame() | ||
2154 | , m_style(style) | 2154 | , m_style(style) | ||
2155 | , m_static(staticSize) | 2155 | , m_static(staticSize) | ||
2156 | , m_point(position) | 2156 | , m_point(position) | ||
2157 | , m_alignment(alignment) | 2157 | , m_alignment(alignment) | ||
2158 | , m_shader(NULL) | 2158 | , m_shader(nullptr) | ||
2159 | , m_theme(new Plasma::Theme(this)) | 2159 | , m_theme(new Plasma::Theme(this)) | ||
2160 | { | 2160 | { | ||
2161 | if (m_style == EffectFrameStyled) { | 2161 | if (m_style == EffectFrameStyled) { | ||
2162 | m_frame.setImagePath(QStringLiteral("widgets/background")); | 2162 | m_frame.setImagePath(QStringLiteral("widgets/background")); | ||
2163 | m_frame.setCacheAllRenderedFrames(true); | 2163 | m_frame.setCacheAllRenderedFrames(true); | ||
2164 | connect(m_theme, SIGNAL(themeChanged()), this, SLOT(plasmaThemeChanged())); | 2164 | connect(m_theme, SIGNAL(themeChanged()), this, SLOT(plasmaThemeChanged())); | ||
2165 | } | 2165 | } | ||
2166 | m_selection.setImagePath(QStringLiteral("widgets/viewitem")); | 2166 | m_selection.setImagePath(QStringLiteral("widgets/viewitem")); | ||
▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Line(s) | 2265 | { | |||
2266 | free(); | 2266 | free(); | ||
2267 | } | 2267 | } | ||
2268 | 2268 | | |||
2269 | void EffectFrameImpl::render(QRegion region, double opacity, double frameOpacity) | 2269 | void EffectFrameImpl::render(QRegion region, double opacity, double frameOpacity) | ||
2270 | { | 2270 | { | ||
2271 | if (m_geometry.isEmpty()) { | 2271 | if (m_geometry.isEmpty()) { | ||
2272 | return; // Nothing to display | 2272 | return; // Nothing to display | ||
2273 | } | 2273 | } | ||
2274 | m_shader = NULL; | 2274 | m_shader = nullptr; | ||
2275 | setScreenProjectionMatrix(static_cast<EffectsHandlerImpl*>(effects)->scene()->screenProjectionMatrix()); | 2275 | setScreenProjectionMatrix(static_cast<EffectsHandlerImpl*>(effects)->scene()->screenProjectionMatrix()); | ||
2276 | effects->paintEffectFrame(this, region, opacity, frameOpacity); | 2276 | effects->paintEffectFrame(this, region, opacity, frameOpacity); | ||
2277 | } | 2277 | } | ||
2278 | 2278 | | |||
2279 | void EffectFrameImpl::finalRender(QRegion region, double opacity, double frameOpacity) const | 2279 | void EffectFrameImpl::finalRender(QRegion region, double opacity, double frameOpacity) const | ||
2280 | { | 2280 | { | ||
2281 | region = infiniteRegion(); // TODO: Old region doesn't seem to work with OpenGL | 2281 | region = infiniteRegion(); // TODO: Old region doesn't seem to work with OpenGL | ||
2282 | 2282 | | |||
▲ Show 20 Lines • Show All 104 Lines • Show Last 20 Lines |