Commit be3a0cf4 authored by Martin Flöser's avatar Martin Flöser

Fix reading of window properties from effects

That's what you get for changing code you cannot properly test. The
calculation was completely messed up. Now reads the correct byte size
for the byte array. In addition the usages in the effects are improved
to cast the data into the proper uint32_t values instead of the more
generic long. After all if the format is 32, the length is 32 and not
a long.
parent feafbca9
......@@ -185,9 +185,8 @@ static QByteArray readWindowProperty(xcb_window_t win, xcb_atom_t atom, xcb_atom
continue;
}
if (prop->type == type && prop->format == format) {
const int nitems = xcb_get_property_value_length(prop.data());
int bytelen = format == 8 ? nitems : format == 16 ? nitems * sizeof(short) : nitems * sizeof(long);
return QByteArray(reinterpret_cast< const char* >(xcb_get_property_value(prop.data())), bytelen);
return QByteArray(reinterpret_cast< const char* >(xcb_get_property_value(prop.data())),
xcb_get_property_value_length(prop.data()));
} else {
return QByteArray();
}
......
......@@ -145,7 +145,7 @@ void HighlightWindowEffect::slotPropertyNotify(EffectWindow* w, long a, EffectWi
finishHighlighting();
return;
}
long* data = reinterpret_cast<long*>(byteData.data());
auto* data = reinterpret_cast<uint32_t*>(byteData.data());
if (!data[0]) {
// Purposely clearing highlight by issuing a NULL target
......
......@@ -126,7 +126,7 @@ void KscreenEffect::propertyNotify(EffectWindow *window, long int atom)
return;
}
QByteArray byteData = effects->readRootProperty(m_atom, XCB_ATOM_CARDINAL, 32);
long *data = reinterpret_cast<long *>(byteData.data());
auto *data = reinterpret_cast<uint32_t *>(byteData.data());
if (!data[0]) {
// Property was deleted
if (m_state != StateNormal) {
......
......@@ -810,7 +810,7 @@ void PresentWindowsEffect::slotPropertyNotify(EffectWindow* w, long a)
setActive(false);
return;
}
long* data = reinterpret_cast<long*>(byteData.data());
auto* data = reinterpret_cast<uint32_t*>(byteData.data());
if (!data[0]) {
// Purposely ending present windows by issuing a NULL target
......@@ -839,7 +839,7 @@ void PresentWindowsEffect::slotPropertyNotify(EffectWindow* w, long a)
setActive(false);
return;
}
long* data = reinterpret_cast<long*>(byteData.data());
auto* data = reinterpret_cast<uint32_t*>(byteData.data());
if (!data[0]) {
// Purposely ending present windows by issuing a NULL target
......
......@@ -280,13 +280,13 @@ void SlidingPopupsEffect::slotPropertyNotify(EffectWindow* w, long a)
return;
}
long* d = reinterpret_cast< long* >(data.data());
auto* d = reinterpret_cast< uint32_t* >(data.data());
Data animData;
animData.start = d[ 0 ];
animData.from = (Position)d[ 1 ];
if (data.length() >= (int)(sizeof(long) * 3)) {
if (data.length() >= (int)(sizeof(uint32_t) * 3)) {
animData.fadeInDuration = d[2];
if (data.length() >= (int)(sizeof(long) * 4))
if (data.length() >= (int)(sizeof(uint32_t) * 4))
animData.fadeOutDuration = d[3];
else
animData.fadeOutDuration = d[2];
......
......@@ -127,7 +127,7 @@ void TaskbarThumbnailEffect::slotPropertyNotify(EffectWindow* w, long a)
QByteArray data = w->readProperty(atom, atom, 32);
if (data.length() < 1)
return;
long* d = reinterpret_cast< long* >(data.data());
auto* d = reinterpret_cast< uint32_t* >(data.data());
int len = data.length() / sizeof(d[ 0 ]);
int pos = 0;
int cnt = d[ 0 ];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment