Changeset View
Changeset View
Standalone View
Standalone View
effects.cpp
Show First 20 Lines • Show All 87 Lines • ▼ Show 20 Line(s) | |||||
88 | static void deleteWindowProperty(Window win, long int atom) | 88 | static void deleteWindowProperty(Window win, long int atom) | ||
89 | { | 89 | { | ||
90 | if (win == XCB_WINDOW_NONE) { | 90 | if (win == XCB_WINDOW_NONE) { | ||
91 | return; | 91 | return; | ||
92 | } | 92 | } | ||
93 | xcb_delete_property(connection(), win, atom); | 93 | xcb_delete_property(connection(), win, atom); | ||
94 | } | 94 | } | ||
95 | 95 | | |||
96 | static xcb_atom_t registerSupportProperty(const QByteArray &propertyName) | ||||
97 | { | ||||
98 | auto c = kwinApp()->x11Connection(); | ||||
99 | if (!c) { | ||||
100 | return XCB_ATOM_NONE; | ||||
101 | } | ||||
102 | // get the atom for the propertyName | ||||
103 | ScopedCPointer<xcb_intern_atom_reply_t> atomReply(xcb_intern_atom_reply(c, | ||||
104 | xcb_intern_atom_unchecked(c, false, propertyName.size(), propertyName.constData()), | ||||
105 | NULL)); | ||||
106 | if (atomReply.isNull()) { | ||||
107 | return XCB_ATOM_NONE; | ||||
108 | } | ||||
109 | // announce property on root window | ||||
110 | unsigned char dummy = 0; | ||||
111 | xcb_change_property(c, XCB_PROP_MODE_REPLACE, kwinApp()->x11RootWindow(), atomReply->atom, atomReply->atom, 8, 1, &dummy); | ||||
112 | // TODO: add to _NET_SUPPORTED | ||||
113 | return atomReply->atom; | ||||
114 | } | ||||
115 | | ||||
96 | //--------------------- | 116 | //--------------------- | ||
97 | 117 | | |||
98 | EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, Scene *scene) | 118 | EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, Scene *scene) | ||
99 | : EffectsHandler(scene->compositingType()) | 119 | : EffectsHandler(scene->compositingType()) | ||
100 | , keyboard_grab_effect(NULL) | 120 | , keyboard_grab_effect(NULL) | ||
101 | , fullscreen_effect(0) | 121 | , fullscreen_effect(0) | ||
102 | , next_window_quad_type(EFFECT_QUAD_TYPE_START) | 122 | , next_window_quad_type(EFFECT_QUAD_TYPE_START) | ||
103 | , m_compositor(compositor) | 123 | , m_compositor(compositor) | ||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | 212 | #ifdef KWIN_BUILD_TABBOX | |||
193 | TabBox::TabBox *tabBox = TabBox::TabBox::self(); | 213 | TabBox::TabBox *tabBox = TabBox::TabBox::self(); | ||
194 | connect(tabBox, &TabBox::TabBox::tabBoxAdded, this, &EffectsHandler::tabBoxAdded); | 214 | connect(tabBox, &TabBox::TabBox::tabBoxAdded, this, &EffectsHandler::tabBoxAdded); | ||
195 | connect(tabBox, &TabBox::TabBox::tabBoxUpdated, this, &EffectsHandler::tabBoxUpdated); | 215 | connect(tabBox, &TabBox::TabBox::tabBoxUpdated, this, &EffectsHandler::tabBoxUpdated); | ||
196 | connect(tabBox, &TabBox::TabBox::tabBoxClosed, this, &EffectsHandler::tabBoxClosed); | 216 | connect(tabBox, &TabBox::TabBox::tabBoxClosed, this, &EffectsHandler::tabBoxClosed); | ||
197 | connect(tabBox, &TabBox::TabBox::tabBoxKeyEvent, this, &EffectsHandler::tabBoxKeyEvent); | 217 | connect(tabBox, &TabBox::TabBox::tabBoxKeyEvent, this, &EffectsHandler::tabBoxKeyEvent); | ||
198 | #endif | 218 | #endif | ||
199 | connect(ScreenEdges::self(), &ScreenEdges::approaching, this, &EffectsHandler::screenEdgeApproaching); | 219 | connect(ScreenEdges::self(), &ScreenEdges::approaching, this, &EffectsHandler::screenEdgeApproaching); | ||
200 | connect(ScreenLockerWatcher::self(), &ScreenLockerWatcher::locked, this, &EffectsHandler::screenLockingChanged); | 220 | connect(ScreenLockerWatcher::self(), &ScreenLockerWatcher::locked, this, &EffectsHandler::screenLockingChanged); | ||
221 | | ||||
222 | connect(kwinApp(), &Application::x11ConnectionChanged, this, | ||||
223 | [this] { | ||||
224 | registered_atoms.clear(); | ||||
225 | for (auto it = m_propertiesForEffects.keyBegin(); it != m_propertiesForEffects.keyEnd(); it++) { | ||||
226 | const auto atom = registerSupportProperty(*it); | ||||
227 | if (atom == XCB_ATOM_NONE) { | ||||
228 | continue; | ||||
229 | } | ||||
230 | m_compositor->keepSupportProperty(atom); | ||||
231 | m_managedProperties.insert(*it, atom); | ||||
232 | registerPropertyType(atom, true); | ||||
233 | } | ||||
234 | } | ||||
235 | ); | ||||
236 | | ||||
201 | // connect all clients | 237 | // connect all clients | ||
202 | for (Client *c : ws->clientList()) { | 238 | for (Client *c : ws->clientList()) { | ||
203 | setupClientConnections(c); | 239 | setupClientConnections(c); | ||
204 | } | 240 | } | ||
205 | for (Unmanaged *u : ws->unmanagedList()) { | 241 | for (Unmanaged *u : ws->unmanagedList()) { | ||
206 | setupUnmanagedConnections(u); | 242 | setupUnmanagedConnections(u); | ||
207 | } | 243 | } | ||
208 | if (auto w = waylandServer()) { | 244 | if (auto w = waylandServer()) { | ||
▲ Show 20 Lines • Show All 580 Lines • ▼ Show 20 Line(s) | |||||
789 | { | 825 | { | ||
790 | PropertyEffectMap::iterator it = m_propertiesForEffects.find(propertyName); | 826 | PropertyEffectMap::iterator it = m_propertiesForEffects.find(propertyName); | ||
791 | if (it != m_propertiesForEffects.end()) { | 827 | if (it != m_propertiesForEffects.end()) { | ||
792 | // property has already been registered for an effect | 828 | // property has already been registered for an effect | ||
793 | // just append Effect and return the atom stored in m_managedProperties | 829 | // just append Effect and return the atom stored in m_managedProperties | ||
794 | if (!it.value().contains(effect)) { | 830 | if (!it.value().contains(effect)) { | ||
795 | it.value().append(effect); | 831 | it.value().append(effect); | ||
796 | } | 832 | } | ||
797 | return m_managedProperties.value(propertyName); | 833 | return m_managedProperties.value(propertyName, XCB_ATOM_NONE); | ||
798 | } | 834 | } | ||
799 | // get the atom for the propertyName | | |||
800 | ScopedCPointer<xcb_intern_atom_reply_t> atomReply(xcb_intern_atom_reply(connection(), | | |||
801 | xcb_intern_atom_unchecked(connection(), false, propertyName.size(), propertyName.constData()), | | |||
802 | NULL)); | | |||
803 | if (atomReply.isNull()) { | | |||
804 | return XCB_ATOM_NONE; | | |||
805 | } | | |||
806 | m_compositor->keepSupportProperty(atomReply->atom); | | |||
807 | // announce property on root window | | |||
808 | unsigned char dummy = 0; | | |||
809 | xcb_change_property(connection(), XCB_PROP_MODE_REPLACE, rootWindow(), atomReply->atom, atomReply->atom, 8, 1, &dummy); | | |||
810 | // TODO: add to _NET_SUPPORTED | | |||
811 | m_managedProperties.insert(propertyName, atomReply->atom); | | |||
812 | m_propertiesForEffects.insert(propertyName, QList<Effect*>() << effect); | 835 | m_propertiesForEffects.insert(propertyName, QList<Effect*>() << effect); | ||
813 | registerPropertyType(atomReply->atom, true); | 836 | const auto atom = registerSupportProperty(propertyName); | ||
814 | return atomReply->atom; | 837 | if (atom == XCB_ATOM_NONE) { | ||
838 | return atom; | ||||
839 | } | ||||
840 | m_compositor->keepSupportProperty(atom); | ||||
841 | m_managedProperties.insert(propertyName, atom); | ||||
842 | registerPropertyType(atom, true); | ||||
843 | return atom; | ||||
815 | } | 844 | } | ||
816 | 845 | | |||
817 | void EffectsHandlerImpl::removeSupportProperty(const QByteArray &propertyName, Effect *effect) | 846 | void EffectsHandlerImpl::removeSupportProperty(const QByteArray &propertyName, Effect *effect) | ||
818 | { | 847 | { | ||
819 | PropertyEffectMap::iterator it = m_propertiesForEffects.find(propertyName); | 848 | PropertyEffectMap::iterator it = m_propertiesForEffects.find(propertyName); | ||
820 | if (it == m_propertiesForEffects.end()) { | 849 | if (it == m_propertiesForEffects.end()) { | ||
821 | // property is not registered - nothing to do | 850 | // property is not registered - nothing to do | ||
822 | return; | 851 | return; | ||
▲ Show 20 Lines • Show All 1272 Lines • Show Last 20 Lines |