From 06afa8d63ed51abcfe3316ec94359b79fa4e43f9 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Thu, 14 Dec 2006 16:23:06 +0000 Subject: [PATCH] Fix ps backend in multihead systems. 2006-12-14 Carlos Garcia Campos * configure.ac: * ps/ps-document.c: (start_interpreter), (ps_document_next_page): Fix ps backend in multihead systems. --- ChangeLog | 7 +++++++ configure.ac | 5 ++++- ps/ps-document.c | 31 +++++++++++++++++++++++-------- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 31adf503..969c9b77 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-12-14 Carlos Garcia Campos + + * configure.ac: + * ps/ps-document.c: (start_interpreter), (ps_document_next_page): + + Fix ps backend in multihead systems. + 2006-12-14 Carlos Garcia Campos * ps/ps-document.c: (setup_page), (ps_document_get_page_size): diff --git a/configure.ac b/configure.ac index 30421997..2e431cf9 100644 --- a/configure.ac +++ b/configure.ac @@ -55,6 +55,9 @@ PKG_CHECK_MODULES(BACKEND, gtk+-2.0 >= $GTK_REQUIRED gnome-vfs-2.0) PKG_CHECK_MODULES(FRONTEND_CORE, gtk+-2.0 >= $GTK_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED gnome-icon-theme >= $GNOME_ICON_THEME_REQUIRED libglade-2.0) PKG_CHECK_MODULES(SHELL_CORE, gtk+-2.0 >= $GTK_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED gnome-vfs-2.0 libglade-2.0 gconf-2.0 gnome-keyring-1 >= $KEYRING_REQUIRED) +BACKEND_CFLAGS="$BACKEND_CFLAGS -DGDK_MULTIHEAD_SAFE -DGTK_MULTIHEAD_SAFE" +AC_SUBST(BACKEND_CFLAGS) + GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0` AC_SUBST(GLIB_GENMARSHAL) @@ -130,7 +133,7 @@ if test "x$enable_dbus" = "xyes" ; then AC_DEFINE_UNQUOTED(DBUS_VERSION, $DBUS_VERSION, [DBUS version.]) fi -SHELL_CFLAGS="$SHELL_CORE_CFLAGS $DBUS_CFLAGS" +SHELL_CFLAGS="$SHELL_CORE_CFLAGS $DBUS_CFLAGS -DGDK_MULTIHEAD_SAFE -DGTK_MULTIHEAD_SAFE" SHELL_LIBS="$SHELL_CORE_LIBS $DBUS_LIBS -lz" AC_SUBST(SHELL_CFLAGS) AC_SUBST(SHELL_LIBS) diff --git a/ps/ps-document.c b/ps/ps-document.c index cd120aaa..1500b7b4 100644 --- a/ps/ps-document.c +++ b/ps/ps-document.c @@ -610,6 +610,7 @@ start_interpreter (PSDocument *gs) char *argv[NUM_ARGS], *dir, *gv_env, *gs_path; char **gs_args, **alpha_args = NULL; + char **gv_env_vars = NULL; int argc = 0, i; LOG ("Start the interpreter"); @@ -665,9 +666,10 @@ start_interpreter (PSDocument *gs) return -1; } - gv_env = g_strdup_printf ("GHOSTVIEW=%ld %ld", + gv_env = g_strdup_printf ("GHOSTVIEW=%ld %ld;DISPLAY=%s", gdk_x11_drawable_get_xid (gs->pstarget), - gdk_x11_drawable_get_xid (gs->bpixmap)); + gdk_x11_drawable_get_xid (gs->bpixmap), + gdk_display_get_name (gdk_drawable_get_display (gs->pstarget))); LOG ("Launching ghostview with env %s", gv_env); gs->interpreter_pid = fork (); @@ -703,7 +705,11 @@ start_interpreter (PSDocument *gs) } } - putenv(gv_env); + gv_env_vars = g_strsplit (gv_env, ";", -1); + g_free (gv_env); + for (i = 0; gv_env_vars[i]; i++) { + putenv (gv_env_vars[i]); + } /* change to directory where the input file is. This helps * with postscript-files which include other files using @@ -717,8 +723,8 @@ start_interpreter (PSDocument *gs) /* Notify error */ g_critical ("Unable to execute [%s]\n", argv[0]); g_strfreev (gs_args); - g_free (gv_env); g_strfreev (alpha_args); + g_strfreev (gv_env_vars); _exit (1); break; default: /* parent */ @@ -976,7 +982,10 @@ document_load (PSDocument *gs, const gchar *fname) static gboolean ps_document_next_page (PSDocument *gs) { - XEvent event; + XEvent event; + GdkScreen *screen; + GdkDisplay *display; + Display *dpy; LOG ("Make ghostscript render next page"); @@ -986,14 +995,20 @@ ps_document_next_page (PSDocument *gs) gs->busy = TRUE; + screen = gtk_window_get_screen (GTK_WINDOW (gs->target_window)); + display = gdk_screen_get_display (screen); + dpy = gdk_x11_display_get_xdisplay (display); + event.xclient.type = ClientMessage; - event.xclient.display = gdk_display; + event.xclient.display = dpy; event.xclient.window = gs->message_window; - event.xclient.message_type = gdk_x11_atom_to_xatom(gs_class->next_atom); + event.xclient.message_type = + gdk_x11_atom_to_xatom_for_display (display, + gs_class->next_atom); event.xclient.format = 32; gdk_error_trap_push (); - XSendEvent (gdk_display, gs->message_window, FALSE, 0, &event); + XSendEvent (dpy, gs->message_window, FALSE, 0, &event); gdk_flush (); gdk_error_trap_pop (); -- 2.43.5