cleanup: Stop using g_get_current_time ()

It has been deprecated because it isn't Y2k38 ready, so replace it
with g_get_real_time () which is.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/708
This commit is contained in:
Florian Müllner 2019-08-01 00:21:03 +02:00 committed by Florian Müllner
parent b95d7e8276
commit 56a5c5e4d1
4 changed files with 11 additions and 29 deletions

View File

@ -18,7 +18,7 @@
typedef struct _TestState
{
ClutterTimeline *timeline;
GTimeVal start_time;
int64_t start_time;
guint new_frame_counter;
gint expected_frame;
gint completion_count;
@ -31,18 +31,17 @@ new_frame_cb (ClutterTimeline *timeline,
gint frame_num,
TestState *state)
{
GTimeVal current_time;
int64_t current_time;
gint current_frame;
glong msec_diff;
gint loop_overflow = 0;
static gint step = 1;
g_get_current_time (&current_time);
current_time = g_get_real_time ();
current_frame = clutter_timeline_get_elapsed_time (state->timeline);
msec_diff = (current_time.tv_sec - state->start_time.tv_sec) * 1000;
msec_diff += (current_time.tv_usec - state->start_time.tv_usec)/1000;
msec_diff = (current_time - state->start_time) / G_TIME_SPAN_MILLISECOND;
/* If we expect to have interpolated past the end of the timeline
* we keep track of the overflow so we can determine when
@ -153,7 +152,7 @@ timeline_interpolation (void)
state.passed = TRUE;
state.expected_frame = 0;
g_get_current_time (&state.start_time);
state.start_time = g_get_real_time ();
clutter_timeline_start (state.timeline);
clutter_main();

View File

@ -191,7 +191,7 @@ struct _MetaDisplay
MetaRectangle grab_initial_window_pos;
int grab_initial_x, grab_initial_y; /* These are only relevant for */
gboolean grab_threshold_movement_reached; /* raise_on_click == FALSE. */
GTimeVal grab_last_moveresize_time;
int64_t grab_last_moveresize_time;
MetaEdgeResistanceData *grab_edge_resistance_data;
unsigned int grab_last_user_action_was_snap;

View File

@ -1783,8 +1783,7 @@ meta_display_begin_grab_op (MetaDisplay *display,
display->grab_anchor_root_y = root_y;
display->grab_latest_motion_x = root_x;
display->grab_latest_motion_y = root_y;
display->grab_last_moveresize_time.tv_sec = 0;
display->grab_last_moveresize_time.tv_usec = 0;
display->grab_last_moveresize_time = 0;
display->grab_last_user_action_was_snap = FALSE;
display->grab_frame_action = frame_action;

View File

@ -5908,32 +5908,16 @@ meta_window_titlebar_is_onscreen (MetaWindow *window)
return is_onscreen;
}
static double
timeval_to_ms (const GTimeVal *timeval)
{
return (timeval->tv_sec * G_USEC_PER_SEC + timeval->tv_usec) / 1000.0;
}
static double
time_diff (const GTimeVal *first,
const GTimeVal *second)
{
double first_ms = timeval_to_ms (first);
double second_ms = timeval_to_ms (second);
return first_ms - second_ms;
}
static gboolean
check_moveresize_frequency (MetaWindow *window,
gdouble *remaining)
{
GTimeVal current_time;
int64_t current_time;
const double max_resizes_per_second = 25.0;
const double ms_between_resizes = 1000.0 / max_resizes_per_second;
double elapsed;
g_get_current_time (&current_time);
current_time = g_get_real_time ();
/* If we are throttling via _NET_WM_SYNC_REQUEST, we don't need
* an artificial timeout-based throttled */
@ -5941,7 +5925,7 @@ check_moveresize_frequency (MetaWindow *window,
window->sync_request_alarm != None)
return TRUE;
elapsed = time_diff (&current_time, &window->display->grab_last_moveresize_time);
elapsed = (current_time - window->display->grab_last_moveresize_time) / 1000;
if (elapsed >= 0.0 && elapsed < ms_between_resizes)
{
@ -6358,7 +6342,7 @@ update_resize (MetaWindow *window,
/* Store the latest resize time, if we actually resized. */
if (window->rect.width != old.width || window->rect.height != old.height)
g_get_current_time (&window->display->grab_last_moveresize_time);
window->display->grab_last_moveresize_time = g_get_real_time ();
}
static void