Add support for compiling against Gtk+3 with and without Wayland backend support.

master-1.22
Mark Thomas 2014-02-11 23:50:14 +00:00
parent 393743c91f
commit 8d8570556a
3 changed files with 58 additions and 26 deletions

View File

@ -27,8 +27,13 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
#include <gdk/gdk.h>
#ifdef GDK_WINDOWING_X11 #ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h> #include <gdk/gdkx.h>
#ifndef GDK_IS_X11_DISPLAY
#define GDK_IS_X11_DISPLAY(display) 1
#endif
#endif #endif
#include "terminal-accels.h" #include "terminal-accels.h"
@ -1360,6 +1365,7 @@ get_child_environment (TerminalScreen *screen,
TerminalScreenPrivate *priv = screen->priv; TerminalScreenPrivate *priv = screen->priv;
GtkWidget *term = GTK_WIDGET (screen); GtkWidget *term = GTK_WIDGET (screen);
GtkWidget *window; GtkWidget *window;
GdkDisplay *display;
char **env; char **env;
char *e, *v; char *e, *v;
GHashTable *env_table; GHashTable *env_table;
@ -1372,6 +1378,7 @@ get_child_environment (TerminalScreen *screen,
window = gtk_widget_get_toplevel (term); window = gtk_widget_get_toplevel (term);
g_assert (window != NULL); g_assert (window != NULL);
g_assert (gtk_widget_is_toplevel (window)); g_assert (gtk_widget_is_toplevel (window));
display = gdk_window_get_display (gtk_widget_get_window (window));
env_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); env_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
@ -1404,8 +1411,11 @@ get_child_environment (TerminalScreen *screen,
#ifdef GDK_WINDOWING_X11 #ifdef GDK_WINDOWING_X11
/* FIXME: moving the tab between windows, or the window between displays will make the next two invalid... */ /* 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_XWINDOW (gtk_widget_get_window (window)))); if (GDK_IS_X11_DISPLAY(display))
g_hash_table_replace (env_table, g_strdup ("DISPLAY"), g_strdup (gdk_display_get_name (gtk_widget_get_display (window)))); {
g_hash_table_replace (env_table, g_strdup ("WINDOWID"), g_strdup_printf ("%ld", GDK_WINDOW_XWINDOW (gtk_widget_get_window (window))));
g_hash_table_replace (env_table, g_strdup ("DISPLAY"), g_strdup (gdk_display_get_name (display)));
}
#endif #endif
list_schemas = g_settings_list_schemas(); list_schemas = g_settings_list_schemas();

View File

@ -24,6 +24,9 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#ifdef GDK_WINDOWING_X11 #ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h> #include <gdk/gdkx.h>
#ifndef GDK_IS_X11_DISPLAY
#define GDK_IS_X11_DISPLAY(display) 1
#endif
#endif #endif
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
@ -1523,7 +1526,7 @@ terminal_window_realize (GtkWidget *widget)
{ {
TerminalWindow *window = TERMINAL_WINDOW (widget); TerminalWindow *window = TERMINAL_WINDOW (widget);
TerminalWindowPrivate *priv = window->priv; TerminalWindowPrivate *priv = window->priv;
#ifdef GDK_WINDOWING_X11 #if defined(GDK_WINDOWING_X11) || defined(GDK_WINDOWING_WAYLAND)
GdkScreen *screen; GdkScreen *screen;
GtkAllocation widget_allocation; GtkAllocation widget_allocation;
#if GTK_CHECK_VERSION (3, 0, 0) #if GTK_CHECK_VERSION (3, 0, 0)
@ -1737,12 +1740,15 @@ terminal_window_screen_update (TerminalWindow *window,
{ {
TerminalApp *app; TerminalApp *app;
terminal_window_window_manager_changed_cb (screen, window);
g_signal_connect (screen, "window-manager-changed",
G_CALLBACK (terminal_window_window_manager_changed_cb), window);
#ifdef GDK_WINDOWING_X11 #ifdef GDK_WINDOWING_X11
g_signal_connect (screen, "composited-changed", if (GDK_IS_X11_DISPLAY (gdk_screen_get_display (screen)))
G_CALLBACK (terminal_window_composited_changed_cb), window); {
terminal_window_window_manager_changed_cb (screen, window);
g_signal_connect (screen, "window-manager-changed",
G_CALLBACK (terminal_window_window_manager_changed_cb), window);
g_signal_connect (screen, "composited-changed",
G_CALLBACK (terminal_window_composited_changed_cb), window);
}
#endif #endif
if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (screen), "GT::HasSettingsConnection"))) if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (screen), "GT::HasSettingsConnection")))
@ -1778,13 +1784,16 @@ terminal_window_screen_changed (GtkWidget *widget,
if (previous_screen) if (previous_screen)
{ {
g_signal_handlers_disconnect_by_func (previous_screen,
G_CALLBACK (terminal_window_window_manager_changed_cb),
window);
#ifdef GDK_WINDOWING_X11 #ifdef GDK_WINDOWING_X11
g_signal_handlers_disconnect_by_func (previous_screen, if (GDK_IS_X11_DISPLAY (gdk_screen_get_display (previous_screen)))
G_CALLBACK (terminal_window_composited_changed_cb), {
window); g_signal_handlers_disconnect_by_func (previous_screen,
G_CALLBACK (terminal_window_window_manager_changed_cb),
window);
g_signal_handlers_disconnect_by_func (previous_screen,
G_CALLBACK (terminal_window_composited_changed_cb),
window);
}
#endif #endif
} }
@ -2333,13 +2342,16 @@ terminal_window_dispose (GObject *object)
screen = gtk_widget_get_screen (GTK_WIDGET (object)); screen = gtk_widget_get_screen (GTK_WIDGET (object));
if (screen) if (screen)
{ {
g_signal_handlers_disconnect_by_func (screen,
G_CALLBACK (terminal_window_window_manager_changed_cb),
window);
#ifdef GDK_WINDOWING_X11 #ifdef GDK_WINDOWING_X11
g_signal_handlers_disconnect_by_func (screen, if (GDK_IS_X11_DISPLAY (gdk_screen_get_display (screen)))
G_CALLBACK (terminal_window_composited_changed_cb), {
window); g_signal_handlers_disconnect_by_func (screen,
G_CALLBACK (terminal_window_window_manager_changed_cb),
window);
g_signal_handlers_disconnect_by_func (screen,
G_CALLBACK (terminal_window_composited_changed_cb),
window);
}
#endif #endif
} }

View File

@ -31,7 +31,14 @@
#include <glib/gstdio.h> #include <glib/gstdio.h>
#include <gio/gio.h> #include <gio/gio.h>
#include <gdk/gdk.h>
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h> #include <gdk/gdkx.h>
#ifndef GDK_IS_X11_DISPLAY
#define GDK_IS_X11_DISPLAY(display) 1
#endif
#endif
#ifdef WITH_SMCLIENT #ifdef WITH_SMCLIENT
#include "eggsmclient.h" #include "eggsmclient.h"
@ -427,6 +434,7 @@ name_lost_cb (GDBusConnection *connection,
* *
*/ */
#ifdef GDK_WINDOWING_X11
/* Copied from libcaja/caja-program-choosing.c; Needed in case /* Copied from libcaja/caja-program-choosing.c; Needed in case
* we have no DESKTOP_STARTUP_ID (with its accompanying timestamp). * we have no DESKTOP_STARTUP_ID (with its accompanying timestamp).
*/ */
@ -477,6 +485,7 @@ slowly_and_stupidly_obtain_timestamp (Display *xdisplay)
return event.xproperty.time; return event.xproperty.time;
} }
#endif
static char * static char *
get_factory_name_for_display (const char *display_name) get_factory_name_for_display (const char *display_name)
@ -573,8 +582,12 @@ main (int argc, char **argv)
g_unsetenv ("GIO_LAUNCHED_DESKTOP_FILE_PID"); g_unsetenv ("GIO_LAUNCHED_DESKTOP_FILE_PID");
g_unsetenv ("GIO_LAUNCHED_DESKTOP_FILE"); g_unsetenv ("GIO_LAUNCHED_DESKTOP_FILE");
/* Do this here so that gdk_display is initialized */ display = gdk_display_get_default ();
if (options->startup_id == NULL) display_name = gdk_display_get_name (display);
options->display_name = g_strdup (display_name);
#ifdef GDK_WINDOWING_X11
if (GDK_IS_X11_DISPLAY(display) && options->startup_id == NULL)
{ {
/* Create a fake one containing a timestamp that we can use */ /* Create a fake one containing a timestamp that we can use */
Time timestamp; Time timestamp;
@ -583,10 +596,7 @@ main (int argc, char **argv)
options->startup_id = g_strdup_printf ("_TIME%lu", timestamp); options->startup_id = g_strdup_printf ("_TIME%lu", timestamp);
} }
#endif
display = gdk_display_get_default ();
display_name = gdk_display_get_name (display);
options->display_name = g_strdup (display_name);
if (options->use_factory) if (options->use_factory)
{ {