[gtk/glib-build-fix] x11: Stop using GTimeVal
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/glib-build-fix] x11: Stop using GTimeVal
- Date: Fri, 31 Jul 2020 14:59:11 +0000 (UTC)
commit 2dfa5ac80416424c849484b2ee5cfc2512f9ff23
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Jul 31 10:54:41 2020 -0400
x11: Stop using GTimeVal
It has been deprecated, and that is breaking our
ci builds with -Werror.
gdk/x11/gdkapplaunchcontext-x11.c | 14 ++++++--------
gdk/x11/gdkscreen-x11.c | 8 ++++----
gdk/x11/gdkscreen-x11.h | 2 +-
3 files changed, 11 insertions(+), 13 deletions(-)
---
diff --git a/gdk/x11/gdkapplaunchcontext-x11.c b/gdk/x11/gdkapplaunchcontext-x11.c
index b0a8985640..206c34e52d 100644
--- a/gdk/x11/gdkapplaunchcontext-x11.c
+++ b/gdk/x11/gdkapplaunchcontext-x11.c
@@ -127,13 +127,13 @@ end_startup_notification (GdkDisplay *display,
* the sequence (don’t use an SnMonitorContext)
*/
#define STARTUP_TIMEOUT_LENGTH_SECONDS 30
-#define STARTUP_TIMEOUT_LENGTH (STARTUP_TIMEOUT_LENGTH_SECONDS * 1000)
+#define STARTUP_TIMEOUT_LENGTH (STARTUP_TIMEOUT_LENGTH_SECONDS * 1000) /* ms */
typedef struct
{
GdkDisplay *display;
char *startup_id;
- GTimeVal time;
+ gint64 time;
} StartupNotificationData;
static void
@@ -175,14 +175,14 @@ startup_timeout (void *data)
{
StartupTimeoutData *std;
GSList *tmp;
- GTimeVal now;
+ gint64 now;
int min_timeout;
std = data;
min_timeout = STARTUP_TIMEOUT_LENGTH;
- g_get_current_time (&now);
+ now = g_get_monotonic_time ();
tmp = std->contexts;
while (tmp != NULL)
@@ -194,9 +194,7 @@ startup_timeout (void *data)
sn_data = tmp->data;
next = tmp->next;
- elapsed =
- ((((double) now.tv_sec - sn_data->time.tv_sec) * G_USEC_PER_SEC +
- (now.tv_usec - sn_data->time.tv_usec))) / 1000.0;
+ elapsed = (now - sn_data->time) / 1000.0;
if (elapsed >= STARTUP_TIMEOUT_LENGTH)
{
@@ -246,7 +244,7 @@ add_startup_timeout (GdkX11Screen *screen,
sn_data = g_new (StartupNotificationData, 1);
sn_data->display = g_object_ref (GDK_SCREEN_DISPLAY (screen));
sn_data->startup_id = g_strdup (startup_id);
- g_get_current_time (&sn_data->time);
+ sn_data->time = g_get_monotonic_time ();
data->contexts = g_slist_prepend (data->contexts, sn_data);
diff --git a/gdk/x11/gdkscreen-x11.c b/gdk/x11/gdkscreen-x11.c
index bfc0b2c80f..672165412e 100644
--- a/gdk/x11/gdkscreen-x11.c
+++ b/gdk/x11/gdkscreen-x11.c
@@ -1131,7 +1131,7 @@ fetch_net_wm_check_window (GdkX11Screen *x11_screen)
{
GdkDisplay *display;
Window window;
- GTimeVal tv;
+ guint64 now;
int error;
display = x11_screen->display;
@@ -1141,9 +1141,9 @@ fetch_net_wm_check_window (GdkX11Screen *x11_screen)
if (x11_screen->wmspec_check_window != None)
return; /* already have it */
- g_get_current_time (&tv);
+ now = g_get_monotonic_time ();
- if (ABS (tv.tv_sec - x11_screen->last_wmspec_check_time) < 15)
+ if ((now - x11_screen->last_wmspec_check_time) / 1e6 < 15)
return; /* we've checked recently */
window = get_net_supporting_wm_check (x11_screen, x11_screen->xroot_window);
@@ -1170,7 +1170,7 @@ fetch_net_wm_check_window (GdkX11Screen *x11_screen)
return;
x11_screen->wmspec_check_window = window;
- x11_screen->last_wmspec_check_time = tv.tv_sec;
+ x11_screen->last_wmspec_check_time = now;
x11_screen->need_refetch_net_supported = TRUE;
x11_screen->need_refetch_wm_name = TRUE;
diff --git a/gdk/x11/gdkscreen-x11.h b/gdk/x11/gdkscreen-x11.h
index 0d7bead87e..83f1933db7 100644
--- a/gdk/x11/gdkscreen-x11.h
+++ b/gdk/x11/gdkscreen-x11.h
@@ -50,7 +50,7 @@ struct _GdkX11Screen
int xft_dpi;
/* Window manager */
- long last_wmspec_check_time;
+ gint64 last_wmspec_check_time;
Window wmspec_check_window;
char *window_manager_name;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]