mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 23:50:41 -05:00
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:
parent
b95d7e8276
commit
56a5c5e4d1
@ -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 (¤t_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();
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 (¤t_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 (¤t_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
|
||||
|
Loading…
Reference in New Issue
Block a user