Changeset View
Changeset View
Standalone View
Standalone View
effects/kscreen/kscreen.cpp
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | |||||
52 | 52 | | |||
53 | KscreenEffect::KscreenEffect() | 53 | KscreenEffect::KscreenEffect() | ||
54 | : Effect() | 54 | : Effect() | ||
55 | , m_state(StateNormal) | 55 | , m_state(StateNormal) | ||
56 | , m_atom(effects->announceSupportProperty("_KDE_KWIN_KSCREEN_SUPPORT", this)) | 56 | , m_atom(effects->announceSupportProperty("_KDE_KWIN_KSCREEN_SUPPORT", this)) | ||
57 | { | 57 | { | ||
58 | initConfig<KscreenConfig>(); | 58 | initConfig<KscreenConfig>(); | ||
59 | connect(effects, SIGNAL(propertyNotify(KWin::EffectWindow*,long)), SLOT(propertyNotify(KWin::EffectWindow*,long))); | 59 | connect(effects, SIGNAL(propertyNotify(KWin::EffectWindow*,long)), SLOT(propertyNotify(KWin::EffectWindow*,long))); | ||
60 | connect(effects, &EffectsHandler::xcbConnectionChanged, this, | ||||
61 | [this] { | ||||
62 | m_atom = effects->announceSupportProperty(QByteArrayLiteral("_KDE_KWIN_KSCREEN_SUPPORT"), this); | ||||
63 | } | ||||
64 | ); | ||||
60 | reconfigure(ReconfigureAll); | 65 | reconfigure(ReconfigureAll); | ||
61 | } | 66 | } | ||
62 | 67 | | |||
63 | KscreenEffect::~KscreenEffect() | 68 | KscreenEffect::~KscreenEffect() | ||
64 | { | 69 | { | ||
65 | } | 70 | } | ||
66 | 71 | | |||
67 | void KscreenEffect::reconfigure(ReconfigureFlags flags) | 72 | void KscreenEffect::reconfigure(ReconfigureFlags flags) | ||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | 118 | default: | |||
114 | // no adjustment | 119 | // no adjustment | ||
115 | break; | 120 | break; | ||
116 | } | 121 | } | ||
117 | effects->paintWindow(w, mask, region, data); | 122 | effects->paintWindow(w, mask, region, data); | ||
118 | } | 123 | } | ||
119 | 124 | | |||
120 | void KscreenEffect::propertyNotify(EffectWindow *window, long int atom) | 125 | void KscreenEffect::propertyNotify(EffectWindow *window, long int atom) | ||
121 | { | 126 | { | ||
122 | if (window || atom != m_atom) { | 127 | if (window || atom != m_atom || m_atom == XCB_ATOM_NONE) { | ||
123 | return; | 128 | return; | ||
124 | } | 129 | } | ||
125 | QByteArray byteData = effects->readRootProperty(m_atom, XCB_ATOM_CARDINAL, 32); | 130 | QByteArray byteData = effects->readRootProperty(m_atom, XCB_ATOM_CARDINAL, 32); | ||
126 | const uint32_t *data = byteData.isEmpty() ? nullptr : reinterpret_cast<const uint32_t *>(byteData.data()); | 131 | const uint32_t *data = byteData.isEmpty() ? nullptr : reinterpret_cast<const uint32_t *>(byteData.data()); | ||
127 | if (!data // Property was deleted | 132 | if (!data // Property was deleted | ||
128 | || data[0] == 0) { // normal state - KWin should have switched to it | 133 | || data[0] == 0) { // normal state - KWin should have switched to it | ||
129 | if (m_state != StateNormal) { | 134 | if (m_state != StateNormal) { | ||
130 | m_state = StateNormal; | 135 | m_state = StateNormal; | ||
Show All 33 Lines | 168 | { | |||
164 | long value = -1l; | 169 | long value = -1l; | ||
165 | if (m_state == StateFadingOut) { | 170 | if (m_state == StateFadingOut) { | ||
166 | m_state = StateFadedOut; | 171 | m_state = StateFadedOut; | ||
167 | value = 2l; | 172 | value = 2l; | ||
168 | } else if (m_state == StateFadingIn) { | 173 | } else if (m_state == StateFadingIn) { | ||
169 | m_state = StateNormal; | 174 | m_state = StateNormal; | ||
170 | value = 0l; | 175 | value = 0l; | ||
171 | } | 176 | } | ||
172 | if (value != -1l) { | 177 | if (value != -1l && m_atom != XCB_ATOM_NONE) { | ||
173 | xcb_change_property(xcbConnection(), XCB_PROP_MODE_REPLACE, x11RootWindow(), m_atom, XCB_ATOM_CARDINAL, 32, 1, &value); | 178 | xcb_change_property(xcbConnection(), XCB_PROP_MODE_REPLACE, x11RootWindow(), m_atom, XCB_ATOM_CARDINAL, 32, 1, &value); | ||
174 | } | 179 | } | ||
175 | } | 180 | } | ||
176 | 181 | | |||
177 | bool KscreenEffect::isActive() const | 182 | bool KscreenEffect::isActive() const | ||
178 | { | 183 | { | ||
179 | return m_state != StateNormal; | 184 | return m_state != StateNormal; | ||
180 | } | 185 | } | ||
181 | 186 | | |||
182 | } // namespace KWin | 187 | } // namespace KWin |