[unique] [app] Use X11-specific API under guards



commit 2e06eb42059afea94e89cf106ed7d7de4cb4db5e
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Sun May 3 10:55:07 2009 +0100

    [app] Use X11-specific API under guards
    
    We should be using X11-specific API (either GDK-X11 or direct
    Xlib calls) only under the GDK_WINDOWING_X11 define.
    
    The only X11-specific code is the slowly_and_stupidly_obtain_timestamp()
    function we ported over from Nautilus. This function only has sense when
    dealing with startup notification on X11, so if we are not building for
    X11 we can safely use g_get_current_time() (we are building a fake startup
    notification id anyway).
    
    This commit should hopefully make Libunique a tad more portable; we still
    need a replacement IPC mechanism for non-Unix platforms, but I hope in
    D-Bus being ported first. Other platforms startup notification mechanisms
    should be implemented in GTK+ already.
---
 unique/uniqueapp.c |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/unique/uniqueapp.c b/unique/uniqueapp.c
index 031da2c..56257c5 100644
--- a/unique/uniqueapp.c
+++ b/unique/uniqueapp.c
@@ -57,7 +57,10 @@
 #include <glib/gi18n-lib.h>
 
 #include <gdk/gdk.h>
+
+#ifdef GDK_WINDOWING_X11
 #include <gdk/gdkx.h>
+#endif
 
 #include "uniquebackend.h"
 #include "uniqueapp.h"
@@ -149,6 +152,7 @@ enum
 
 static guint unique_app_signals[LAST_SIGNAL] = { 0, };
 
+#ifdef GDK_WINDOWING_X11
 /* taken from nautilus */
 static guint32
 slowly_and_stupidly_obtain_timestamp (GdkDisplay *display)
@@ -195,6 +199,20 @@ slowly_and_stupidly_obtain_timestamp (GdkDisplay *display)
   return event.xproperty.time;
 }
 
+#else /* !GDK_WINDOWING_X11 */
+
+static guint32
+slowly_and_stupidly_obtain_timestamp (GdkDisplay *display G_GNUC_UNUSED)
+{
+  GTimeVal timeval = { 0, };
+
+  g_get_current_time (&timeval);
+
+  return timeval.tv_sec;
+}
+
+#endif /* GDK_WINDOWING_X11 */
+
 static void
 set_startup_id (UniqueBackend *backend,
                 const gchar   *startup_id)
@@ -209,8 +227,10 @@ set_startup_id (UniqueBackend *backend,
 
       /* try and get the startup notification id from GDK, the environment
        * or, if everything else failed, fake one.
-      */
+       */
+#ifdef GDK_WINDOWING_X11
       startup_id = gdk_x11_display_get_startup_notification_id (display);
+#endif /* GDK_WINDOWING_X11 */
 
       if (!startup_id || startup_id[0] == '\0')
         startup_id = g_getenv ("DESKTOP_STARTUP_ID");



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]