aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/dix
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/dix')
-rw-r--r--xorg-server/dix/dixfonts.c5
-rw-r--r--xorg-server/dix/events.c73
-rw-r--r--xorg-server/dix/globals.c1
-rw-r--r--xorg-server/dix/window.c4
4 files changed, 67 insertions, 16 deletions
diff --git a/xorg-server/dix/dixfonts.c b/xorg-server/dix/dixfonts.c
index 22c236553..dd7700860 100644
--- a/xorg-server/dix/dixfonts.c
+++ b/xorg-server/dix/dixfonts.c
@@ -1459,6 +1459,7 @@ doImageText(ClientPtr client, ITclosurePtr c)
GC *pGC;
unsigned char *data;
ITclosurePtr new_closure;
+ ITclosurePtr old_closure;
/* We're putting the client to sleep. We need to
save some state. Similar problem to that handled
@@ -1470,12 +1471,14 @@ doImageText(ClientPtr client, ITclosurePtr c)
err = BadAlloc;
goto bail;
}
+ old_closure = c;
*new_closure = *c;
c = new_closure;
data = malloc(c->nChars * itemSize);
if (!data) {
free(c);
+ c = old_closure;
err = BadAlloc;
goto bail;
}
@@ -1486,6 +1489,7 @@ doImageText(ClientPtr client, ITclosurePtr c)
if (!pGC) {
free(c->data);
free(c);
+ c = old_closure;
err = BadAlloc;
goto bail;
}
@@ -1498,6 +1502,7 @@ doImageText(ClientPtr client, ITclosurePtr c)
FreeScratchGC(pGC);
free(c->data);
free(c);
+ c = old_closure;
err = BadAlloc;
goto bail;
}
diff --git a/xorg-server/dix/events.c b/xorg-server/dix/events.c
index 191a49377..f61c7c7eb 100644
--- a/xorg-server/dix/events.c
+++ b/xorg-server/dix/events.c
@@ -262,6 +262,11 @@ InputInfo inputInfo;
EventSyncInfoRec syncEvents;
+static struct DeviceEventTime {
+ Bool reset;
+ TimeStamp time;
+} lastDeviceEventTime[MAXDEVICES];
+
/**
* The root window the given device is currently on.
*/
@@ -1046,33 +1051,73 @@ XineramaGetCursorScreen(DeviceIntPtr pDev)
#define TIMESLOP (5 * 60 * 1000) /* 5 minutes */
static void
-MonthChangedOrBadTime(InternalEvent *ev)
+MonthChangedOrBadTime(CARD32 *ms)
{
/* If the ddx/OS is careless about not processing timestamped events from
* different sources in sorted order, then it's possible for time to go
* backwards when it should not. Here we ensure a decent time.
*/
- if ((currentTime.milliseconds - ev->any.time) > TIMESLOP)
+ if ((currentTime.milliseconds - *ms) > TIMESLOP)
currentTime.months++;
else
- ev->any.time = currentTime.milliseconds;
+ *ms = currentTime.milliseconds;
+}
+
+void
+NoticeTime(const DeviceIntPtr dev, TimeStamp time)
+{
+ lastDeviceEventTime[XIAllDevices].time = currentTime;
+ lastDeviceEventTime[dev->id].time = currentTime;
+
+ LastEventTimeToggleResetFlag(dev->id, TRUE);
+ LastEventTimeToggleResetFlag(XIAllDevices, TRUE);
}
static void
-NoticeTime(InternalEvent *ev, DeviceIntPtr dev)
+NoticeTimeMillis(const DeviceIntPtr dev, CARD32 *ms)
{
- if (ev->any.time < currentTime.milliseconds)
- MonthChangedOrBadTime(ev);
- currentTime.milliseconds = ev->any.time;
- lastDeviceEventTime[XIAllDevices] = currentTime;
- lastDeviceEventTime[dev->id] = currentTime;
+ TimeStamp time;
+ if (*ms < currentTime.milliseconds)
+ MonthChangedOrBadTime(ms);
+ time.months = currentTime.months;
+ time.milliseconds = *ms;
+ NoticeTime(dev, time);
}
void
NoticeEventTime(InternalEvent *ev, DeviceIntPtr dev)
{
if (!syncEvents.playingEvents)
- NoticeTime(ev, dev);
+ NoticeTimeMillis(dev, &ev->any.time);
+}
+
+TimeStamp
+LastEventTime(int deviceid)
+{
+ return lastDeviceEventTime[deviceid].time;
+}
+
+Bool
+LastEventTimeWasReset(int deviceid)
+{
+ return lastDeviceEventTime[deviceid].reset;
+}
+
+void
+LastEventTimeToggleResetFlag(int deviceid, Bool state)
+{
+ lastDeviceEventTime[deviceid].reset = state;
+}
+
+void
+LastEventTimeToggleResetAll(Bool state)
+{
+ DeviceIntPtr dev;
+ nt_list_for_each_entry(dev, inputInfo.devices, next) {
+ LastEventTimeToggleResetFlag(dev->id, FALSE);
+ }
+ LastEventTimeToggleResetFlag(XIAllDevices, FALSE);
+ LastEventTimeToggleResetFlag(XIAllMasterDevices, FALSE);
}
/**************************************************************************
@@ -1096,7 +1141,7 @@ EnqueueEvent(InternalEvent *ev, DeviceIntPtr device)
if (!xorg_list_is_empty(&syncEvents.pending))
tail = xorg_list_last_entry(&syncEvents.pending, QdEventRec, next);
- NoticeTime((InternalEvent *)event, device);
+ NoticeTimeMillis(device, &ev->any.time);
/* Fix for key repeating bug. */
if (device->key != NULL && device->key->xkbInfo != NULL &&
@@ -5281,8 +5326,12 @@ InitEvents(void)
inputInfo.pointer = (DeviceIntPtr) NULL;
for (i = 0; i < MAXDEVICES; i++) {
+ DeviceIntRec dummy;
memcpy(&event_filters[i], default_filter, sizeof(default_filter));
- lastDeviceEventTime[i] = currentTime;
+
+ dummy.id = i;
+ NoticeTime(&dummy, currentTime);
+ LastEventTimeToggleResetFlag(i, FALSE);
}
syncEvents.replayDev = (DeviceIntPtr) NULL;
diff --git a/xorg-server/dix/globals.c b/xorg-server/dix/globals.c
index 332b91f5c..ad9145b01 100644
--- a/xorg-server/dix/globals.c
+++ b/xorg-server/dix/globals.c
@@ -122,7 +122,6 @@ Bool party_like_its_1989 = FALSE;
Bool whiteRoot = FALSE;
TimeStamp currentTime;
-TimeStamp lastDeviceEventTime[MAXDEVICES];
int defaultColorVisualClass = -1;
int monitorResolution = 0;
diff --git a/xorg-server/dix/window.c b/xorg-server/dix/window.c
index 804b54c32..112417ebf 100644
--- a/xorg-server/dix/window.c
+++ b/xorg-server/dix/window.c
@@ -3092,9 +3092,7 @@ dixSaveScreens(ClientPtr client, int on, int mode)
DeviceIntPtr dev;
UpdateCurrentTimeIf();
nt_list_for_each_entry(dev, inputInfo.devices, next)
- lastDeviceEventTime[dev->id] = currentTime;
- lastDeviceEventTime[XIAllDevices] = currentTime;
- lastDeviceEventTime[XIAllMasterDevices] = currentTime;
+ NoticeTime(dev, currentTime);
}
SetScreenSaverTimer();
}