aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Gräßlin <mgraesslin@kde.org>2013-11-11 10:30:59 (GMT)
committerMartin Gräßlin <mgraesslin@kde.org>2013-11-11 10:36:26 (GMT)
commit008ac5efabfb99f04813e5dad29c2d0a92d13fc5 (patch)
tree9ddb4a436f4bf38d559060efb74503429b4f0de1
parente511c8eb5594151e02b2b5e0030dec7317f549a0 (diff)
[kwin] Work around broken xcb_sync_create_alarm
The xcb sync protocol is incorrectly defined (see [1]) which results in xcb_sync_create_alarm not creating a valid alarm. To work around this issue we only create the alarm without setting the int64 values. For those we use the XLib XSyncChangeAlarm call after we verified that the alarm got created. This unfortunately reintroduces linking against libxext. But at least resizing works again. [1] http://lists.freedesktop.org/archives/xcb/2013-June/008375.html
-rw-r--r--kwin/CMakeLists.txt1
-rw-r--r--kwin/client.cpp25
2 files changed, 16 insertions, 10 deletions
diff --git a/kwin/CMakeLists.txt b/kwin/CMakeLists.txt
index 6153075..d4960a5 100644
--- a/kwin/CMakeLists.txt
+++ b/kwin/CMakeLists.txt
@@ -263,6 +263,7 @@ set(kwin_KDE_LIBS
set(kwin_XLIB_LIBS
${X11_X11_LIB}
+ ${X11_Xext_LIB}
${X11_Xcursor_LIB}
${X11_ICE_LIB}
${X11_SM_LIB}
diff --git a/kwin/client.cpp b/kwin/client.cpp
index 065b10f..ae74d30 100644
--- a/kwin/client.cpp
+++ b/kwin/client.cpp
@@ -55,6 +55,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QScriptProgram>
#endif
#include <QWhatsThis>
+// XLib
+#include <X11/extensions/sync.h>
// system
#include <unistd.h>
#include <signal.h>
@@ -2113,27 +2115,30 @@ void Client::getSyncCounter()
0, 1, false, XA_CARDINAL, &retType, &formatRet, &nItemRet, &byteRet, &propRet);
if (ret == Success && formatRet == 32) {
- syncRequest.counter = *(long*)(propRet);
+ syncRequest.counter = *(xcb_sync_counter_t*)(propRet);
syncRequest.value.hi = 0;
syncRequest.value.lo = 0;
- xcb_sync_int64_t zero;
- zero.hi = 0;
- zero.lo = 0;
auto *c = connection();
- xcb_sync_set_counter(c, syncRequest.counter, zero);
+ xcb_sync_set_counter(c, syncRequest.counter, syncRequest.value);
if (syncRequest.alarm == XCB_NONE) {
- const uint32_t mask = XCB_SYNC_CA_COUNTER | XCB_SYNC_CA_VALUE_TYPE | XCB_SYNC_CA_VALUE | XCB_SYNC_CA_TEST_TYPE | XCB_SYNC_CA_DELTA ;
+ const uint32_t mask = XCB_SYNC_CA_COUNTER | XCB_SYNC_CA_VALUE_TYPE | XCB_SYNC_CA_TEST_TYPE | XCB_SYNC_CA_EVENTS;
const uint32_t values[] = {
syncRequest.counter,
XCB_SYNC_VALUETYPE_RELATIVE,
- 0,
- 1,
XCB_SYNC_TESTTYPE_POSITIVE_TRANSITION,
- 0,
1
};
syncRequest.alarm = xcb_generate_id(c);
- xcb_sync_create_alarm(c, syncRequest.alarm, mask, values);
+ auto cookie = xcb_sync_create_alarm_checked(c, syncRequest.alarm, mask, values);
+ ScopedCPointer<xcb_generic_error_t> error(xcb_request_check(c, cookie));
+ if (!error.isNull()) {
+ syncRequest.alarm = XCB_NONE;
+ } else {
+ XSyncAlarmAttributes attrs;
+ XSyncIntToValue(&attrs.trigger.wait_value, 1);
+ XSyncIntToValue(&attrs.delta, 1);
+ XSyncChangeAlarm(display(), syncRequest.alarm, XSyncCADelta | XSyncCAValue, &attrs);
+ }
}
}