updateXTime uses QX11Info::getTimestamp
Requires 9c45260942c0ee32267e651d981bfa33a6acb64d from qtx11extras. Note: this does not fully replace the functionality which we used to have. The event queue is not yet searched for the first even with a timestamp.
This commit is contained in:
parent
5007a19062
commit
95f10a6c33
1 changed files with 4 additions and 53 deletions
57
utils.cpp
57
utils.cpp
|
@ -139,42 +139,6 @@ QByteArray getStringProperty(xcb_window_t w, xcb_atom_t prop, char separator)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef KCMRULES
|
#ifndef KCMRULES
|
||||||
static Time next_x_time;
|
|
||||||
static Bool update_x_time_predicate(Display*, XEvent* event, XPointer)
|
|
||||||
{
|
|
||||||
if (next_x_time != CurrentTime)
|
|
||||||
return False;
|
|
||||||
// from qapplication_x11.cpp
|
|
||||||
switch(event->type) {
|
|
||||||
case ButtonPress:
|
|
||||||
// fallthrough intended
|
|
||||||
case ButtonRelease:
|
|
||||||
next_x_time = event->xbutton.time;
|
|
||||||
break;
|
|
||||||
case MotionNotify:
|
|
||||||
next_x_time = event->xmotion.time;
|
|
||||||
break;
|
|
||||||
case KeyPress:
|
|
||||||
// fallthrough intended
|
|
||||||
case KeyRelease:
|
|
||||||
next_x_time = event->xkey.time;
|
|
||||||
break;
|
|
||||||
case PropertyNotify:
|
|
||||||
next_x_time = event->xproperty.time;
|
|
||||||
break;
|
|
||||||
case EnterNotify:
|
|
||||||
case LeaveNotify:
|
|
||||||
next_x_time = event->xcrossing.time;
|
|
||||||
break;
|
|
||||||
case SelectionClear:
|
|
||||||
next_x_time = event->xselectionclear.time;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return False;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Updates xTime(). This used to simply fetch current timestamp from the server,
|
Updates xTime(). This used to simply fetch current timestamp from the server,
|
||||||
but that can cause xTime() to be newer than timestamp of events that are
|
but that can cause xTime() to be newer than timestamp of events that are
|
||||||
|
@ -185,23 +149,10 @@ static Bool update_x_time_predicate(Display*, XEvent* event, XPointer)
|
||||||
*/
|
*/
|
||||||
void updateXTime()
|
void updateXTime()
|
||||||
{
|
{
|
||||||
static QWidget* w = 0;
|
// NOTE: QX11Info::getTimestamp does not yet search the event queue as the old
|
||||||
if (!w)
|
// solution did. This means there might be regressions currently. See the
|
||||||
w = new QWidget;
|
// documentation above on how it should be done properly.
|
||||||
long data = 1;
|
QX11Info::setAppTime(QX11Info::getTimestamp());
|
||||||
XChangeProperty(display(), w->winId(), atoms->kwin_running, atoms->kwin_running, 32,
|
|
||||||
PropModeAppend, (unsigned char*) &data, 1);
|
|
||||||
next_x_time = CurrentTime;
|
|
||||||
XEvent dummy;
|
|
||||||
XCheckIfEvent(display(), &dummy, update_x_time_predicate, NULL);
|
|
||||||
if (next_x_time == CurrentTime) {
|
|
||||||
XSync(display(), False);
|
|
||||||
XCheckIfEvent(display(), &dummy, update_x_time_predicate, NULL);
|
|
||||||
}
|
|
||||||
assert(next_x_time != CurrentTime);
|
|
||||||
QX11Info::setAppTime(next_x_time);
|
|
||||||
XEvent ev; // remove the PropertyNotify event from the events queue
|
|
||||||
XWindowEvent(display(), w->winId(), PropertyChangeMask, &ev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int server_grab_count = 0;
|
static int server_grab_count = 0;
|
||||||
|
|
Loading…
Reference in a new issue