[gedit-list] [PATCH] Fix build and improve platform support v2



https://bugzilla.gnome.org/show_bug.cgi?id=751685

Hi. This v2 of my previous attemp.Since previous patch was so wrong

i wrote this patch.i learnt my lesson from my fault and gained

experience much.So i think this time i done it properly.

i tested like building as well as running it both x11(has two backend)

and wayland.(gdk has only wayland backend,system hasnt x11 libs)

The result is good.it built and worked properly with both.

On wayland it has one minor complain related to dbus-launch.

Because of dbus-launch is an x11 specific thing.

(gedit:3875): dconf-WARNING **: failed to commit changes to dconf:
Error spawning command line
'dbus-launch --autolaunch=728f1795972a440d994e36df8b1c8940
--binary-syntax --close-stderr': Child process exited with code 127

its maybe subject of another patch.Best reviews.

changes from commit aa7cd37ec9cfbd86d02692fff7f916e59f63e754

diff --git a/configure.ac b/configure.ac
index 42e93c4..fa7e88d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -121,22 +121,31 @@ AM_CONDITIONAL(PLATFORM_OSX, test "$platform_osx" = "yes")
 dnl check for native osx
 gdk_targets=`$PKG_CONFIG --variable=targets gdk-3.0`

-gdk_windowing="x11"
+gdk_has_quartz=""
+gdk_has_win32=""
+gdk_has_x11=""
+gdk_has_wayland=""

 for target in $gdk_targets;
 do
        case "$target" in
                quartz)
-                       gdk_windowing=quartz
-                       ;;
+                         gdk_has_quartz=yes
+                         ;;
                win32)
-                       gdk_windowing=win32
-                       ;;
+                         gdk_has_win32=yes
+                         ;;
+                x11)
+                          gdk_has_x11=yes
+                          ;;
+                wayland)
+                          gdk_has_wayland=yes
+                          ;;
        esac
 done

 AC_MSG_CHECKING([for native Mac OS X])
-if test "$gdk_windowing" = "quartz"; then
+if test "$gdk_has_quartz" = "yes"; then
        os_osx=yes
        ACTIVE_PLUGINS="${ACTIVE_PLUGINS}, 'checkupdate'"
 else
@@ -145,7 +154,12 @@ fi
 AC_MSG_RESULT([$os_osx])
 AM_CONDITIONAL(OS_OSX, test "$os_osx" = "yes")

-AM_CONDITIONAL(GDK_WINDOWING_X11, test "$gdk_windowing" = "x11")
+if test "$gdk_has_x11" = "yes"; then
+       AM_CONDITIONAL(GEDIT_APP_INHERIT, true)
+fi
+if test "$gdk_has_wayland" = "yes"; then
+       AM_CONDITIONAL(GEDIT_APP_INHERIT, true)
+fi

 if test "$platform_osx" = "yes"; then
        AC_DEFINE([PLATFORM_OSX],[1],[Defined if platform is Mac OSX])
@@ -330,8 +344,7 @@ PKG_CHECK_MODULES(GEDIT, [
        gsettings-desktop-schemas
 ])

-if test "$os_osx" = "no" &&
-   test "$os_win32" = "no"; then
+if test "$gdk_has_x11" = "yes"; then
        PKG_CHECK_MODULES(X11, [
                x11
        ])
@@ -340,6 +353,15 @@ else
        X11_LIBS=
 fi

+if test "$gdk_has_wayland" = "yes"; then
+       PKG_CHECK_MODULES(WAYLAND, [
+               wayland-client
+       ])
+else
+       WAYLAND_CFLAGS=
+       WAYLAND_LIBS=
+fi
+
 if test "$platform_win32" = "no"; then
        PKG_CHECK_MODULES(UNIX, [
                gio-unix-2.0 >= 2.25.5
@@ -349,8 +371,8 @@ else
        UNIX_LIBS=
 fi

-GEDIT_CFLAGS="$GEDIT_CFLAGS $X11_CFLAGS $UNIX_CFLAGS"
-GEDIT_LIBS="$GEDIT_LIBS $X11_LIBS $UNIX_LIBS"
+GEDIT_CFLAGS="$GEDIT_CFLAGS $X11_CFLAGS $WAYLAND_CFLAGS $UNIX_CFLAGS"
+GEDIT_LIBS="$GEDIT_LIBS $X11_LIBS $WAYLAND_LIBS $UNIX_LIBS"

 AC_SUBST(GEDIT_CFLAGS)
 AC_SUBST(GEDIT_LIBS)
@@ -482,7 +504,11 @@ Configuration:
        Gvfs metadata enabled:  $enable_gvfs_metadata
        Deprecations enabled:   $enable_deprecations
        GObject Introspection:  $enable_introspection
-       GDK Backend:            $gdk_windowing
+       ==== GDK Backends ====
+               x11:            $gdk_has_x11
+               wayland:        $gdk_has_wayland
+               quartz:         $gdk_has_quartz
+               win32:          $gdk_has_win32
        Python support:         $enable_python
        Vala support:           $enable_vala
 "
diff --git a/gedit/Makefile.am b/gedit/Makefile.am
index 7ff13d7..3c28610 100644
--- a/gedit/Makefile.am
+++ b/gedit/Makefile.am
@@ -78,18 +78,16 @@ gedit/gedit-res.o: gedit/gedit.rc
 gedit_gedit_LDADD += gedit/gedit-res.o
 endif

-# X11 convenience library
-if GDK_WINDOWING_X11
-noinst_LTLIBRARIES += gedit/libx11.la
+if GEDIT_APP_INHERIT
+noinst_LTLIBRARIES += gedit/libinherit.la
+gedit_libinherit_la_SOURCES =          \
+       gedit/gedit-app-inherit.c               \
+       gedit/gedit-app-inherit.h

-gedit_libx11_la_SOURCES =              \
-       gedit/gedit-app-x11.c           \
-       gedit/gedit-app-x11.h
+gedit_libinherit_la_CPPFLAGS = $(gedit_common_cppflags)
+gedit_libinherit_la_CFLAGS = $(gedit_common_cflags)

-gedit_libx11_la_CPPFLAGS = $(gedit_common_cppflags)
-gedit_libx11_la_CFLAGS = $(gedit_common_cflags)
-
-gedit_libgedit_la_LIBADD += gedit/libx11.la
+gedit_libgedit_la_LIBADD += gedit/libinherit.la
 endif

 gedit_built_sources =                  \
diff --git a/gedit/gedit-app-inherit.c b/gedit/gedit-app-inherit.c
new file mode 100644
index 0000000..a3d1d3e
--- /dev/null
+++ b/gedit/gedit-app-inherit.c
@@ -0,0 +1,109 @@
+/*
+ * gedit-app-inherit.c
+ * This file is part of gedit
+ *
+ * Copyright (C) 2010 - Jesse van den Kieboom
+ * Copyright (C) 2015 - Ahmet Acar
+ *
+ * gedit is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * gedit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with gedit; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA  02110-1301  USA
+ */
+
+#include "gedit-app-inherit.h"
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h>
+#include <X11/Xatom.h>
+#endif
+
+struct _GeditAppInherit
+{
+       GeditApp parent_instance;
+};
+
+G_DEFINE_TYPE (GeditAppInherit, gedit_app_inherit, GEDIT_TYPE_APP)
+
+static void
+gedit_app_add_platform_data (GApplication    *app,
+                             GVariantBuilder *builder)
+{
+ G_APPLICATION_CLASS (gedit_app_inherit_parent_class)->add_platform_data (app, builder);
+
+  /* In the event that we are launched from a terminal we will probably
+   * see that we have DISPLAY set, but not DESKTOP_STARTUP_ID.
+   *
+   * If we are the second instance, we want to bring the window of the
+   * existing instance forward.  Unfortunately, without
+ * DESKTOP_STARTUP_ID being set, we have no timestamp on which to base
+   * the claim that we are the representative of the user's last
+   * interaction.
+   *
+   * We need to fake it by finding out the current timestamp of the
+ * server and sending that along as if we had DESKTOP_STARTUP_ID given
+   * in the first place.
+   *
+ * We want to do this without initialising all of Gtk+, so we can just
+   * talk directly to the X server to find out...
+   *
+   * In order to get the current timestamp, we need to see a
+   * timestamp-tagged event sent by the server.  Property change
+   * notifications are probably the easiest to generate.  We create our
+   * own window so that we don't spam other people who may be watching
+   * for property notifies on the root window...
+   *
+   * We could use any property at all, but we may as well use the
+   * "_NET_WM_USER_TIME_WINDOW" one since that's what we're doing
+   * here...
+   */
+#ifdef GDK_WINDOWING_X11
+  if (!g_getenv ("DESKTOP_STARTUP_ID") && g_getenv ("DISPLAY") &&
+      GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
+    {
+      gchar *startup_id;
+      Display *display;
+      Window window;
+      XEvent event;
+      Atom atom;
+
+      display = XOpenDisplay (0);
+ window = XCreateWindow (display, DefaultRootWindow (display), 0, 0, 1, 1, 0, 0, InputOnly, 0, 0, NULL);
+      XSelectInput (display, window, PropertyChangeMask);
+      atom = XInternAtom (display, "_NET_WM_USER_TIME_WINDOW", False);
+ XChangeProperty (display, window, atom, XA_WINDOW, 32, PropModeReplace, (void *) &window, 1);
+      XNextEvent (display, &event);
+      g_assert (event.type == PropertyNotify);
+      XCloseDisplay (display);
+
+ startup_id = g_strdup_printf ("_TIME%u", (guint) ((XPropertyEvent *) &event)->time); + g_variant_builder_add (builder, "{sv}", "desktop-startup-id", g_variant_new_string (startup_id));
+      g_free (startup_id);
+    }
+#endif
+}
+
+static void
+gedit_app_inherit_class_init (GeditAppInheritClass *klass)
+{
+       GApplicationClass *app_class = G_APPLICATION_CLASS (klass);
+
+       app_class->add_platform_data = gedit_app_add_platform_data;
+}
+
+static void
+gedit_app_inherit_init (GeditAppInherit *self)
+{
+}
+
+/* ex:set ts=8 noet: */
diff --git a/gedit/gedit-app-inherit.h b/gedit/gedit-app-inherit.h
new file mode 100644
index 0000000..5fa3457
--- /dev/null
+++ b/gedit/gedit-app-inherit.h
@@ -0,0 +1,39 @@
+/*
+ * gedit-app-inherit.h
+ * This file is part of gedit
+ *
+ * Copyright (C) 2010 - Jesse van den Kieboom
+ * Copyright (C) 2015 - Ahmet Acar
+ *
+ * gedit is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * gedit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with gedit; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA  02110-1301  USA
+ */
+
+#ifndef __GEDIT_APP_INHERIT_H__
+#define __GEDIT_APP_INHERIT_H__
+
+#include "gedit-app.h"
+
+G_BEGIN_DECLS
+
+#define GEDIT_TYPE_APP_INHERIT         (gedit_app_inherit_get_type ())
+
+G_DECLARE_FINAL_TYPE (GeditAppInherit, gedit_app_inherit, GEDIT, APP_INHERIT, GeditApp)
+
+G_END_DECLS
+
+#endif /* __GEDIT_APP_INHERIT_H__ */
+
+/* ex:set ts=8 noet: */
diff --git a/gedit/gedit-app-x11.c b/gedit/gedit-app-x11.c
deleted file mode 100644
index 8436159..0000000
--- a/gedit/gedit-app-x11.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * gedit-app-x11.h
- * This file is part of gedit
- *
- * Copyright (C) 2010 - Jesse van den Kieboom
- *
- * gedit is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * gedit is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with gedit; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA  02110-1301  USA
- */
-
-#include "gedit-app-x11.h"
-
-#ifdef GDK_WINDOWING_X11
-#include <gdk/gdkx.h>
-#endif
-
-struct _GeditAppX11
-{
-       GeditApp parent_instance;
-};
-
-G_DEFINE_TYPE (GeditAppX11, gedit_app_x11, GEDIT_TYPE_APP)
-
-/* This should go in GtkApplication at some point... */
-
-#include <X11/Xatom.h>
-#include <X11/Xlib.h>
-
-static void
-gedit_app_add_platform_data (GApplication    *app,
-                             GVariantBuilder *builder)
-{
- G_APPLICATION_CLASS (gedit_app_x11_parent_class)->add_platform_data (app, builder);
-
-  /* In the event that we are launched from a terminal we will probably
-   * see that we have DISPLAY set, but not DESKTOP_STARTUP_ID.
-   *
-   * If we are the second instance, we want to bring the window of the
-   * existing instance forward.  Unfortunately, without
- * DESKTOP_STARTUP_ID being set, we have no timestamp on which to base
-   * the claim that we are the representative of the user's last
-   * interaction.
-   *
-   * We need to fake it by finding out the current timestamp of the
- * server and sending that along as if we had DESKTOP_STARTUP_ID given
-   * in the first place.
-   *
- * We want to do this without initialising all of Gtk+, so we can just
-   * talk directly to the X server to find out...
-   *
-   * In order to get the current timestamp, we need to see a
-   * timestamp-tagged event sent by the server.  Property change
-   * notifications are probably the easiest to generate.  We create our
-   * own window so that we don't spam other people who may be watching
-   * for property notifies on the root window...
-   *
-   * We could use any property at all, but we may as well use the
-   * "_NET_WM_USER_TIME_WINDOW" one since that's what we're doing
-   * here...
-   */
-  if (!g_getenv ("DESKTOP_STARTUP_ID") && g_getenv ("DISPLAY") &&
-      GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
-    {
-      gchar *startup_id;
-      Display *display;
-      Window window;
-      XEvent event;
-      Atom atom;
-
-      display = XOpenDisplay (0);
- window = XCreateWindow (display, DefaultRootWindow (display), 0, 0, 1, 1, 0, 0, InputOnly, 0, 0, NULL);
-      XSelectInput (display, window, PropertyChangeMask);
-      atom = XInternAtom (display, "_NET_WM_USER_TIME_WINDOW", False);
- XChangeProperty (display, window, atom, XA_WINDOW, 32, PropModeReplace, (void *) &window, 1);
-      XNextEvent (display, &event);
-      g_assert (event.type == PropertyNotify);
-      XCloseDisplay (display);
-
- startup_id = g_strdup_printf ("_TIME%u", (guint) ((XPropertyEvent *) &event)->time); - g_variant_builder_add (builder, "{sv}", "desktop-startup-id", g_variant_new_string (startup_id));
-      g_free (startup_id);
-    }
-}
-
-static void
-gedit_app_x11_class_init (GeditAppX11Class *klass)
-{
-       GApplicationClass *app_class = G_APPLICATION_CLASS (klass);
-
-       app_class->add_platform_data = gedit_app_add_platform_data;
-}
-
-static void
-gedit_app_x11_init (GeditAppX11 *self)
-{
-}
-
-/* ex:set ts=8 noet: */
diff --git a/gedit/gedit-app-x11.h b/gedit/gedit-app-x11.h
deleted file mode 100644
index 0935e7a..0000000
--- a/gedit/gedit-app-x11.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * gedit-app-x11.h
- * This file is part of gedit
- *
- * Copyright (C) 2010 - Jesse van den Kieboom
- *
- * gedit is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * gedit is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with gedit; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA  02110-1301  USA
- */
-
-#ifndef __GEDIT_APP_X11_H__
-#define __GEDIT_APP_X11_H__
-
-#include "gedit-app.h"
-
-G_BEGIN_DECLS
-
-#define GEDIT_TYPE_APP_X11             (gedit_app_x11_get_type ())
-
-G_DECLARE_FINAL_TYPE (GeditAppX11, gedit_app_x11, GEDIT, APP_X11, GeditApp)
-
-G_END_DECLS
-
-#endif /* __GEDIT_APP_X11_H__ */
-
-/* ex:set ts=8 noet: */
diff --git a/gedit/gedit.c b/gedit/gedit.c
index 6c330c2..d774ce0 100644
--- a/gedit/gedit.c
+++ b/gedit/gedit.c
@@ -29,7 +29,7 @@
 #ifdef G_OS_WIN32
 #include "gedit-app-win32.h"
 #else
-#include "gedit-app-x11.h"
+#include "gedit-app-inherit.h"
 #endif
 #endif

@@ -121,7 +121,7 @@ main (int argc, char *argv[])

        type = GEDIT_TYPE_APP_WIN32;
 #else
-       type = GEDIT_TYPE_APP_X11;
+       type = GEDIT_TYPE_APP_INHERIT;
 #endif
 #endif




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