static GtkWidget *window;
static int window_width = WIDTH, window_height = HEIGHT;
+gint64 start_frame_time;
static double angle;
static int max_stats = -1;
}
static void
-handle_frame_stats (GdkFrameHistory *frame_history)
+handle_frame_stats (GdkFrameClock *frame_clock)
{
static int num_stats = 0;
static double last_print_time = 0;
frames_since_last_print++;
for (frame_counter = last_handled_frame;
- frame_counter < gdk_frame_history_get_frame_counter (frame_history);
+ frame_counter < gdk_frame_clock_get_frame_counter (frame_clock);
frame_counter++)
{
- GdkFrameTimings *timings = gdk_frame_history_get_timings (frame_history, frame_counter);
- GdkFrameTimings *previous_timings = gdk_frame_history_get_timings (frame_history, frame_counter - 1);
+ GdkFrameTimings *timings = gdk_frame_clock_get_timings (frame_clock, frame_counter);
+ GdkFrameTimings *previous_timings = gdk_frame_clock_get_timings (frame_clock, frame_counter - 1);
if (!timings || gdk_frame_timings_get_complete (timings))
last_handled_frame = frame_counter;
}
static void
-on_frame (GtkTimeline *timeline,
- double progress)
+on_frame (double progress)
{
GdkFrameClock *frame_clock = gtk_widget_get_frame_clock (window);
int jitter;
if (frame_clock)
- {
- GdkFrameHistory *history = gdk_frame_clock_get_history (frame_clock);
- handle_frame_stats (history);
- }
+ handle_frame_stats (frame_clock);
angle = 2 * M_PI * progress;
jitter = WINDOW_SIZE_JITTER * sin(angle);
gtk_widget_queue_draw (window);
}
+static gboolean
+tick_callback (GtkWidget *widget,
+ GdkFrameClock *frame_clock,
+ gpointer user_data)
+{
+ gint64 frame_time = gdk_frame_clock_get_frame_time (frame_clock);
+ double scaled_time;
+
+ if (start_frame_time == 0)
+ start_frame_time = frame_time;
+
+ scaled_time = (frame_time - start_frame_time) / (CYCLE_TIME * 1000000);
+ on_frame (scaled_time - floor (scaled_time));
+
+ return G_SOURCE_CONTINUE;
+}
+
static gboolean
on_map_event (GtkWidget *widget,
- GdkEventAny *event,
- GtkTimeline *timeline)
+ GdkEventAny *event)
{
- gtk_timeline_start (timeline);
+ gtk_widget_add_tick_callback (window, tick_callback, NULL, NULL);
return FALSE;
}
GError *error = NULL;
GdkScreen *screen;
GdkRectangle monitor_bounds;
- GtkTimeline *timeline;
if (!gtk_init_with_args (&argc, &argv, "",
options, NULL, &error))
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_main_quit), NULL);
- timeline = gtk_timeline_new (window, CYCLE_TIME * 1000);
- gtk_timeline_set_loop (timeline, TRUE);
- gtk_timeline_set_progress_type (timeline, GTK_TIMELINE_PROGRESS_LINEAR);
-
- g_signal_connect (timeline, "frame",
- G_CALLBACK (on_frame), NULL);
g_signal_connect (window, "map-event",
- G_CALLBACK (on_map_event), timeline);
- on_frame (timeline, 0.);
+ G_CALLBACK (on_map_event), NULL);
+ on_frame (0.);
screen = gtk_widget_get_screen (window);
gdk_screen_get_monitor_geometry (screen,