[gnome-terminal] Add runtime checks for X11 specific code



commit c5e0da0d6dc3f6cc0c5ba76649a9c2db0028ceba
Author: Alexander Larsson <alexl redhat com>
Date:   Fri Jan 27 08:46:08 2012 +0100

    Add runtime checks for X11 specific code
    
    With this in place things work with the broadway backend too.

 src/terminal-client-utils.c |   18 +++++++++++++++++-
 src/terminal-screen.c       |   13 ++++++++-----
 src/terminal-window.c       |   10 ++++++++--
 3 files changed, 33 insertions(+), 8 deletions(-)
---
diff --git a/src/terminal-client-utils.c b/src/terminal-client-utils.c
index 166b033..de497c3 100644
--- a/src/terminal-client-utils.c
+++ b/src/terminal-client-utils.c
@@ -28,7 +28,10 @@
 #include <string.h>
 
 #include <gio/gio.h>
+
+#if GDK_WINDOWING_X11
 #include <gdk/gdkx.h>
+#endif
 
 /**
  * terminal_client_append_create_instance_options:
@@ -121,11 +124,17 @@ terminal_client_append_exec_options (GVariantBuilder *builder,
 void 
 terminal_client_get_fallback_startup_id  (char **startup_id)
 {
+#if GDK_WINDOWING_X11
+  GdkDisplay *display;
   Display *xdisplay;
   Window xwindow;
   XEvent event;
 
-  xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
+  display = gdk_display_get_default ();
+  if (!GDK_IS_X11_DISPLAY (display))
+    goto out;
+
+  xdisplay = GDK_DISPLAY_XDISPLAY (display);
 
   {
     XSetWindowAttributes attrs;
@@ -168,4 +177,11 @@ terminal_client_get_fallback_startup_id  (char **startup_id)
 
   if (startup_id)
     *startup_id = g_strdup_printf ("_TIME%lu", event.xproperty.time);
+
+  return;
+
+out:
+#endif
+  if (startup_id)
+    *startup_id = NULL;
 }
diff --git a/src/terminal-screen.c b/src/terminal-screen.c
index 899260e..cee03a6 100644
--- a/src/terminal-screen.c
+++ b/src/terminal-screen.c
@@ -1287,11 +1287,14 @@ get_child_environment (TerminalScreen *screen,
   g_hash_table_replace (env_table, g_strdup ("COLORTERM"), g_strdup (EXECUTABLE_NAME));
   
 #ifdef GDK_WINDOWING_X11
-  /* FIXME: moving the tab between windows, or the window between displays will make the next two invalid... */
-  g_hash_table_replace (env_table, g_strdup ("WINDOWID"), 
-                        g_strdup_printf ("%ld", 
-                                         GDK_WINDOW_XID (gtk_widget_get_window (window))));
-  g_hash_table_replace (env_table, g_strdup ("DISPLAY"), g_strdup (gdk_display_get_name (gtk_widget_get_display (window))));
+  if (GDK_IS_X11_SCREEN (gtk_widget_get_screen (window)))
+    {
+      /* FIXME: moving the tab between windows, or the window between displays will make the next two invalid... */
+      g_hash_table_replace (env_table, g_strdup ("WINDOWID"),
+			    g_strdup_printf ("%ld",
+					     GDK_WINDOW_XID (gtk_widget_get_window (window))));
+      g_hash_table_replace (env_table, g_strdup ("DISPLAY"), g_strdup (gdk_display_get_name (gtk_widget_get_display (window))));
+    }
 #endif
 
   terminal_util_add_proxy_env (env_table);
diff --git a/src/terminal-window.c b/src/terminal-window.c
index 31a75dc..8ca4987 100644
--- a/src/terminal-window.c
+++ b/src/terminal-window.c
@@ -1451,6 +1451,7 @@ terminal_window_realize (GtkWidget *widget)
   GtkAllocation widget_allocation;
 
   gtk_widget_get_allocation (widget, &widget_allocation);
+
   _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY,
                          "[window %p] realize, size %d : %d at (%d, %d)\n",
                          widget,
@@ -1484,7 +1485,9 @@ terminal_window_map_event (GtkWidget    *widget,
   if (priv->clear_demands_attention)
     {
 #ifdef GDK_WINDOWING_X11
-      terminal_util_x11_clear_demands_attention (gtk_widget_get_window (widget));
+      GdkWindow *window = gtk_widget_get_window (widget);
+      if (GDK_IS_X11_WINDOW (window))
+	terminal_util_x11_clear_demands_attention (window);
 #endif
 
       priv->clear_demands_attention = FALSE;
@@ -1534,7 +1537,10 @@ terminal_window_window_manager_changed_cb (GdkScreen *screen,
   GtkAction *action;
   gboolean supports_fs;
 
-  supports_fs = gdk_x11_screen_supports_net_wm_hint (screen, gdk_atom_intern ("_NET_WM_STATE_FULLSCREEN", FALSE));
+  if (GDK_IS_X11_SCREEN (screen))
+    supports_fs = gdk_x11_screen_supports_net_wm_hint (screen, gdk_atom_intern ("_NET_WM_STATE_FULLSCREEN", FALSE));
+  else
+    supports_fs = FALSE;
 
   action = gtk_action_group_get_action (priv->action_group, "ViewFullscreen");
   gtk_action_set_sensitive (action, supports_fs);



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