@@ -107,20 +107,23 @@ end
107
107
function save_history (wm:: XWindowManager , queue:: EventQueue{XWindowManager,XCBWindow} )
108
108
events = Event{WindowRef}[]
109
109
windows = XCBWindow[]
110
+ previous_time = 0.0
110
111
for event in queue. history
111
112
i = findfirst (== (event. win), windows)
112
113
isnothing (i) && push! (windows, event. win)
113
114
winref = WindowRef (something (i, lastindex (windows)))
114
- push! (events, Event (event. type, event. data, event. location, event. time, winref))
115
+ Δt = previous_time == 0 ? 0.0 : event. time - previous_time
116
+ previous_time = event. time
117
+ push! (events, Event (event. type, event. data, event. location, Δt, winref))
115
118
end
116
119
events
117
120
end
118
121
119
122
# FIXME : Events will be triggered multiple times if an event triggers another. How should we tackle that?
120
- function replay_history (wm:: XWindowManager , events:: AbstractVector{Event{WindowRef}} )
123
+ function replay_history (wm:: XWindowManager , events:: AbstractVector{Event{WindowRef}} ; time_factor = 1.0 )
121
124
windows = Dict {WindowRef,XCBWindow} ()
122
125
all_windows = xcb_window_t[]
123
- replay_time = nothing
126
+ replay_time = time ()
124
127
for event in events
125
128
win = get! (windows, event. win) do
126
129
# Assume that window IDs will be ordered chronologically.
@@ -129,9 +132,9 @@ function replay_history(wm::XWindowManager, events::AbstractVector{Event{WindowR
129
132
i = event. win. number
130
133
wm. windows[all_windows[i]]
131
134
end
132
- wait_for (event . time - something (replay_time, event. time))
133
- replay_time = event . time
134
- event = Event (event. type, event. data, event. location, time () , win)
135
+ Δt = event. time * time_factor
136
+ wait_for (Δt)
137
+ event = Event (event. type, event. data, event. location, replay_time + Δt , win)
135
138
send_event (wm, event)
136
139
end
137
140
end
0 commit comments