Commit 626de2ac authored by Jasper St. Pierre's avatar Jasper St. Pierre Committed by Bastien Nocera
Browse files

idle-monitor: Clarify code and comments about alarm rescheduling workaround

Segment the code out in its own function, point out that this is an Xorg
bug, and don't actually set any attributes -- just call XSyncChangeAlarm.

https://bugzilla.gnome.org/show_bug.cgi?id=688227
parent b28ff3f0
......@@ -120,6 +120,18 @@ _xsync_alarm_set (GnomeIdleMonitor *monitor,
return XSyncCreateAlarm (monitor->priv->display, flags, &attr);
}
static void
ensure_alarm_rescheduled (Display *dpy,
XSyncAlarm alarm)
{
XSyncAlarmAttributes attr;
/* Some versions of Xorg have an issue where alarms aren't
* always rescheduled. Calling XSyncChangeAlarm, even
* without any attributes, will reschedule the alarm. */
XSyncChangeAlarm (dpy, alarm, 0, &attr);
}
static GnomeIdleMonitorWatch *
find_watch_for_alarm (GnomeIdleMonitor *monitor,
XSyncAlarm alarm)
......@@ -144,7 +156,6 @@ handle_alarm_notify_event (GnomeIdleMonitor *monitor,
g_signal_emit (monitor, signals[BECAME_ACTIVE], 0);
} else {
GnomeIdleMonitorWatch *watch;
XSyncAlarmAttributes attr;
watch = find_watch_for_alarm (monitor, alarm_event->alarm);
if (watch == NULL)
......@@ -158,9 +169,8 @@ handle_alarm_notify_event (GnomeIdleMonitor *monitor,
watch->user_data);
}
/* Reset the alarm so it can be triggered again */
attr.events = TRUE;
XSyncChangeAlarm (watch->display, watch->xalarm, XSyncCAEvents, &attr);
ensure_alarm_rescheduled (monitor->priv->display,
watch->xalarm);
}
}
......
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