[Xfce4-commits] <xfce4-settings:master> Fix compilation without device property supprt (bug #8611).

Nick Schermer noreply at xfce.org
Sun Apr 1 11:52:01 CEST 2012


Updating branch refs/heads/master
         to 633ce648c579bc0004a97e937a839f206e22af6e (commit)
       from c2d927750b66a50dec00f10ca76035d59ecea102 (commit)

commit 633ce648c579bc0004a97e937a839f206e22af6e
Author: Nick Schermer <nick at xfce.org>
Date:   Sun Apr 1 11:48:47 2012 +0200

    Fix compilation without device property supprt (bug #8611).
    
    This fixes compilation of the different modules in Solaris 10.

 dialogs/mouse-settings/main.c  |   67 ++++++++++++++++++++++++----------------
 xfsettingsd/pointers-defines.h |   52 +++++++++++++++++++++++++++++++
 xfsettingsd/pointers.c         |   49 ++++++++++++-----------------
 3 files changed, 112 insertions(+), 56 deletions(-)

diff --git a/dialogs/mouse-settings/main.c b/dialogs/mouse-settings/main.c
index 2a567a9..86230c5 100644
--- a/dialogs/mouse-settings/main.c
+++ b/dialogs/mouse-settings/main.c
@@ -31,11 +31,7 @@
 #include <math.h>
 #endif
 
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-#include <X11/extensions/XI.h>
-#include <X11/extensions/XInput.h>
-#include <X11/extensions/XIproto.h>
+#include <xfsettingsd/pointers-defines.h>
 #ifdef HAVE_XCURSOR
 #include <X11/Xcursor/Xcursor.h>
 #endif /* !HAVE_XCURSOR */
@@ -49,20 +45,6 @@
 
 #include "mouse-dialog_ui.h"
 
-/* test if the required version of inputproto (1.4.2) is available */
-#if XI_Add_DevicePresenceNotify_Major >= 1 && defined (DeviceRemoved)
-#define HAS_DEVICE_HOTPLUGGING
-#else
-#undef HAS_DEVICE_HOTPLUGGING
-#endif
-#ifndef IsXExtensionPointer
-#define IsXExtensionPointer 4
-#endif
-
-/* Xi 1.4 is required */
-#define MIN_XI_VERS_MAJOR 1
-#define MIN_XI_VERS_MINOR 4
-
 /* settings */
 #ifdef HAVE_XCURSOR
 #define PREVIEW_ROWS    (3)
@@ -82,7 +64,7 @@ static gint locked = 0;
 /* device update id */
 static guint timeout_id = 0;
 
-#ifdef HAS_DEVICE_HOTPLUGGING
+#ifdef DEVICE_HOTPLUGGING
 /* event id for device add/remove */
 static gint device_presence_event_type = 0;
 #endif
@@ -582,6 +564,7 @@ mouse_settings_themes_populate_store (GtkBuilder *builder)
 
 
 
+#ifdef DEVICE_PROPERTIES
 static gint
 mouse_settings_device_get_int_property (XDevice *device,
                                         Atom     prop,
@@ -615,6 +598,7 @@ mouse_settings_device_get_int_property (XDevice *device,
 
     return val;
 }
+#endif
 
 
 
@@ -660,6 +644,7 @@ mouse_settings_device_get_selected (GtkBuilder  *builder,
 
 
 
+#ifdef DEVICE_PROPERTIES
 static void
 mouse_settings_wacom_set_rotation (GtkComboBox *combobox,
                                    GtkBuilder  *builder)
@@ -691,9 +676,11 @@ mouse_settings_wacom_set_rotation (GtkComboBox *combobox,
 
     g_free (name);
 }
+#endif
 
 
 
+#ifdef DEVICE_PROPERTIES
 static void
 mouse_settings_wacom_set_mode (GtkComboBox *combobox,
                                GtkBuilder  *builder)
@@ -728,9 +715,11 @@ mouse_settings_wacom_set_mode (GtkComboBox *combobox,
 
     g_free (name);
 }
+#endif
 
 
 
+#ifdef DEVICE_PROPERTIES
 static void
 mouse_settings_synaptics_set_tap_to_click (GtkBuilder *builder)
 {
@@ -793,9 +782,11 @@ mouse_settings_synaptics_set_tap_to_click (GtkBuilder *builder)
 
     g_free (name);
 }
+#endif
 
 
 
+#ifdef DEVICE_PROPERTIES
 static void
 mouse_settings_synaptics_hscroll_sensitive (GtkBuilder *builder)
 {
@@ -815,9 +806,11 @@ mouse_settings_synaptics_hscroll_sensitive (GtkBuilder *builder)
     object = gtk_builder_get_object (builder, "synaptics-scroll-horiz");
     gtk_widget_set_sensitive (GTK_WIDGET (object), sensitive);
 }
+#endif
 
 
 
+#ifdef DEVICE_PROPERTIES
 static void
 mouse_settings_synaptics_set_scrolling (GtkWidget  *widget,
                                         GtkBuilder *builder)
@@ -880,10 +873,11 @@ mouse_settings_synaptics_set_scrolling (GtkWidget  *widget,
 
     g_free (name);
 }
+#endif
 
 
 
-
+#ifdef DEVICE_PROPERTIES
 static void
 mouse_settings_device_set_enabled (GtkToggleButton *button,
                                    GtkBuilder      *builder)
@@ -909,6 +903,7 @@ mouse_settings_device_set_enabled (GtkToggleButton *button,
 
     g_free (name);
 }
+#endif
 
 
 
@@ -931,6 +926,9 @@ mouse_settings_device_selection_changed (GtkBuilder *builder)
     gint               threshold = -1;
     GObject           *object;
     gint               ndevices;
+    gboolean           is_synaptics = FALSE;
+    gboolean           is_wacom = FALSE;
+#ifdef DEVICE_PROPERTIES
     Atom               synaptics_prop;
     Atom               wacom_prop;
     Atom               synaptics_tap_prop;
@@ -939,8 +937,6 @@ mouse_settings_device_selection_changed (GtkBuilder *builder)
     Atom               device_enabled_prop;
     Atom               wacom_rotation_prop;
     gint               is_enabled = -1;
-    gboolean           is_synaptics = FALSE;
-    gboolean           is_wacom = FALSE;
     gint               synaptics_tap_to_click = -1;
     gint               synaptics_edge_scroll = -1;
     gint               synaptics_edge_hscroll = -1;
@@ -950,6 +946,7 @@ mouse_settings_device_selection_changed (GtkBuilder *builder)
     Atom              *props;
     gint               nprops;
     gint               wacom_mode = -1;
+#endif
 
     /* lock the dialog */
     locked++;
@@ -972,8 +969,10 @@ mouse_settings_device_selection_changed (GtkBuilder *builder)
                 {
                     if (any->class == ButtonClass)
                         nbuttons = ((XButtonInfoPtr) any)->num_buttons;
+#ifdef DEVICE_PROPERTIES
                     else if (any->class == ValuatorClass)
                         wacom_mode = ((XValuatorInfoPtr) any)->mode == Absolute ? 0 : 1;
+#endif
 
                     any = (XAnyClassPtr) ((gchar *) any + any->length);
                 }
@@ -1040,6 +1039,7 @@ mouse_settings_device_selection_changed (GtkBuilder *builder)
             XFreeFeedbackList (states);
         }
 
+#ifdef DEVICE_PROPERTIES
         /* wacom and synaptics specific properties */
         device_enabled_prop = XInternAtom (xdisplay, "Device Enabled", True);
         synaptics_prop = XInternAtom (xdisplay, "Synaptics Off", True);
@@ -1074,6 +1074,7 @@ mouse_settings_device_selection_changed (GtkBuilder *builder)
 
             XFree (props);
         }
+#endif
 
         /* close the device */
         XCloseDevice (xdisplay, device);
@@ -1098,16 +1099,21 @@ mouse_settings_device_selection_changed (GtkBuilder *builder)
     gtk_widget_set_sensitive (GTK_WIDGET (object), threshold != -1);
 
     object = gtk_builder_get_object (builder, "device-enabled");
+#ifdef DEVICE_PROPERTIES
     gtk_widget_set_sensitive (GTK_WIDGET (object), is_enabled != -1);
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (object), is_enabled > 0);
 
     object = gtk_builder_get_object (builder, "device-notebook");
     gtk_widget_set_sensitive (GTK_WIDGET (object), is_enabled == 1);
+#else
+    gtk_widget_set_visible (GTK_WIDGET (object), FALSE);
+#endif
 
     /* synaptics options */
     object = gtk_builder_get_object (builder, "synaptics-tab");
     gtk_widget_set_visible (GTK_WIDGET (object), is_synaptics);
 
+#ifdef DEVICE_PROPERTIES
     if (is_synaptics)
     {
         object = gtk_builder_get_object (builder, "synaptics-tap-to-click");
@@ -1130,11 +1136,13 @@ mouse_settings_device_selection_changed (GtkBuilder *builder)
         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (object),
                                       synaptics_edge_hscroll == 1 || synaptics_two_hscroll == 1);
     }
+#endif
 
     /* wacom options */
     object = gtk_builder_get_object (builder, "wacom-tab");
     gtk_widget_set_visible (GTK_WIDGET (object), is_wacom);
 
+#ifdef DEVICE_PROPERTIES
     if (is_wacom)
     {
         object = gtk_builder_get_object (builder, "wacom-mode");
@@ -1152,6 +1160,7 @@ mouse_settings_device_selection_changed (GtkBuilder *builder)
             wacom_rotation = 0;
         gtk_combo_box_set_active (GTK_COMBO_BOX (object), wacom_rotation);
     }
+#endif
 
     /* unlock */
     locked--;
@@ -1432,7 +1441,7 @@ mouse_settings_device_reset (GtkWidget  *button,
 
 
 
-#ifdef HAS_DEVICE_HOTPLUGGING
+#ifdef DEVICE_HOTPLUGGING
 static GdkFilterReturn
 mouse_settings_event_filter (GdkXEvent *xevent,
                              GdkEvent  *gdk_event,
@@ -1497,10 +1506,12 @@ main (gint argc, gchar **argv)
     GError            *error = NULL;
     GObject           *object;
     XExtensionVersion *version = NULL;
+#ifdef DEVICE_PROPERTIES
     gchar             *syndaemon;
     guint              i;
     const gchar       *synaptics_scroll[] = { "synaptics-scroll-no", "synaptics-scroll-edge",
                                               "synaptics-scroll-two", "synaptics-scroll-horiz" };
+#endif
 
     /* setup translation domain */
     xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8");
@@ -1588,9 +1599,11 @@ main (gint argc, gchar **argv)
             mouse_settings_device_populate_store (builder, TRUE);
 
             /* connect signals */
+#ifdef DEVICE_PROPERTIES
             object = gtk_builder_get_object (builder, "device-enabled");
             g_signal_connect (G_OBJECT (object), "toggled",
                               G_CALLBACK (mouse_settings_device_set_enabled), builder);
+#endif
 
             object = gtk_builder_get_object (builder, "device-acceleration-scale");
             g_signal_connect_swapped (G_OBJECT (object), "value-changed",
@@ -1618,6 +1631,7 @@ main (gint argc, gchar **argv)
             g_signal_connect (G_OBJECT (object), "clicked",
                               G_CALLBACK (mouse_settings_device_reset), builder);
 
+#ifdef DEVICE_PROPERTIES
             object = gtk_builder_get_object (builder, "synaptics-disable-while-type");
             syndaemon = g_find_program_in_path ("syndaemon");
             gtk_widget_set_sensitive (GTK_WIDGET (object), syndaemon != NULL);
@@ -1643,8 +1657,7 @@ main (gint argc, gchar **argv)
             object = gtk_builder_get_object (builder, "wacom-rotation");
             g_signal_connect (G_OBJECT (object), "changed",
                               G_CALLBACK (mouse_settings_wacom_set_rotation), builder);
-
-
+#endif
 
 #ifdef HAVE_XCURSOR
             /* populate the themes treeview */
@@ -1685,7 +1698,7 @@ main (gint argc, gchar **argv)
             g_signal_connect (G_OBJECT (object), "format-value",
                               G_CALLBACK (mouse_settings_format_value_px), NULL);
 
-#ifdef HAS_DEVICE_HOTPLUGGING
+#ifdef DEVICE_HOTPLUGGING
             /* create the event filter for device monitoring */
             mouse_settings_create_event_filter (builder);
 #endif
diff --git a/xfsettingsd/pointers-defines.h b/xfsettingsd/pointers-defines.h
new file mode 100644
index 0000000..932d9d5
--- /dev/null
+++ b/xfsettingsd/pointers-defines.h
@@ -0,0 +1,52 @@
+/*
+ *  Copyright (c) 2011 Nick Schermer <nick at xfce.org>
+ *
+ *  This program 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.
+ *
+ *  This program 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 Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/XIproto.h>
+
+#ifndef __POINTERS_DEFINES_H__
+#define __POINTERS_DEFINES_H__
+
+/* Xi 1.4 is required */
+#define MIN_XI_VERS_MAJOR 1
+#define MIN_XI_VERS_MINOR 4
+
+/* test if the required version of inputproto (1.4.2) is available */
+#undef DEVICE_HOTPLUGGING
+#ifdef XI_Add_DevicePresenceNotify_Major
+#  if XI_Add_DevicePresenceNotify_Major >= 1 && defined (DeviceRemoved)
+#    define DEVICE_HOTPLUGGING
+#  else
+#    undef DEVICE_HOTPLUGGING
+#  endif
+#endif
+
+/* test if device properties are available */
+#undef DEVICE_PROPERTIES
+#ifdef XI_Add_DeviceProperties_Major
+#  define DEVICE_PROPERTIES
+#endif
+
+#ifndef IsXExtensionPointer
+#define IsXExtensionPointer 4
+#endif
+
+#endif /* !__POINTERS_DEFINES_H__ */
diff --git a/xfsettingsd/pointers.c b/xfsettingsd/pointers.c
index 98f691f..a060051 100644
--- a/xfsettingsd/pointers.c
+++ b/xfsettingsd/pointers.c
@@ -30,13 +30,6 @@
 #include <string.h>
 #endif
 
-
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-#include <X11/extensions/XI.h>
-#include <X11/extensions/XInput.h>
-#include <X11/extensions/XIproto.h>
-
 #include <glib.h>
 #include <gdk/gdk.h>
 #include <gdk/gdkx.h>
@@ -47,27 +40,13 @@
 
 #include "debug.h"
 #include "pointers.h"
-
+#include "pointers-defines.h"
 
 
 #define MAX_DENOMINATOR (100.00)
 
 #define XFCONF_TYPE_G_VALUE_ARRAY (dbus_g_type_get_collection ("GPtrArray", G_TYPE_VALUE))
 
-/* Xi 1.4 is required */
-#define MIN_XI_VERS_MAJOR 1
-#define MIN_XI_VERS_MINOR 4
-
-/* test if the required version of inputproto (1.4.2) is available */
-#if XI_Add_DevicePresenceNotify_Major >= 1 && defined (DeviceRemoved)
-#define HAS_DEVICE_HOTPLUGGING
-#else
-#undef HAS_DEVICE_HOTPLUGGING
-#endif
-#ifndef IsXExtensionPointer
-#define IsXExtensionPointer 4
-#endif
-
 
 
 static void             xfce_pointers_helper_finalize                 (GObject            *object);
@@ -79,7 +58,7 @@ static void             xfce_pointers_helper_channel_property_changed (XfconfCha
                                                                        const gchar        *property_name,
                                                                        const GValue       *value,
                                                                        XfcePointersHelper *helper);
-#ifdef HAS_DEVICE_HOTPLUGGING
+#ifdef DEVICE_HOTPLUGGING
 static GdkFilterReturn  xfce_pointers_helper_event_filter             (GdkXEvent          *xevent,
                                                                        GdkEvent           *gdk_event,
                                                                        gpointer            user_data);
@@ -99,9 +78,11 @@ struct _XfcePointersHelper
     /* xfconf channel */
     XfconfChannel *channel;
 
+#ifdef DEVICE_PROPERTIES
     GPid           syndaemon_pid;
+#endif
 
-#ifdef HAS_DEVICE_HOTPLUGGING
+#ifdef DEVICE_HOTPLUGGING
     /* device presence event type */
     gint           device_presence_event_type;
 #endif
@@ -137,12 +118,10 @@ xfce_pointers_helper_init (XfcePointersHelper *helper)
 {
     XExtensionVersion *version = NULL;
     Display           *xdisplay;
-#ifdef HAS_DEVICE_HOTPLUGGING
+#ifdef DEVICE_HOTPLUGGING
     XEventClass        event_class;
 #endif
 
-    helper->syndaemon_pid = 0;
-
     /* get the default display */
     xdisplay = gdk_x11_display_get_xdisplay (gdk_display_get_default ());
 
@@ -180,7 +159,7 @@ xfce_pointers_helper_init (XfcePointersHelper *helper)
         /* launch syndaemon if required */
         xfce_pointers_helper_syndaemon_check (helper);
 
-#ifdef HAS_DEVICE_HOTPLUGGING
+#ifdef DEVICE_HOTPLUGGING
         if (G_LIKELY (xdisplay != NULL))
         {
             /* monitor device changes */
@@ -213,6 +192,7 @@ xfce_pointers_helper_finalize (GObject *object)
 static void
 xfce_pointers_helper_syndaemon_stop (XfcePointersHelper *helper)
 {
+#ifdef DEVICE_PROPERTIES
     if (helper->syndaemon_pid != 0)
     {
         xfsettings_dbg (XFSD_DEBUG_POINTERS, "Killed syndaemon with pid %d",
@@ -222,6 +202,7 @@ xfce_pointers_helper_syndaemon_stop (XfcePointersHelper *helper)
         g_spawn_close_pid (helper->syndaemon_pid);
         helper->syndaemon_pid = 0;
     }
+#endif
 }
 
 
@@ -229,6 +210,7 @@ xfce_pointers_helper_syndaemon_stop (XfcePointersHelper *helper)
 static void
 xfce_pointers_helper_syndaemon_check (XfcePointersHelper *helper)
 {
+#ifdef DEVICE_PROPERTIES
     Display     *xdisplay = GDK_DISPLAY ();
     XDeviceInfo *device_list;
     XDevice     *device;
@@ -309,6 +291,7 @@ xfce_pointers_helper_syndaemon_check (XfcePointersHelper *helper)
         /* stop the daemon */
         xfce_pointers_helper_syndaemon_stop (helper);
     }
+#endif
 }
 
 
@@ -632,6 +615,7 @@ xfce_pointers_helper_device_xfconf_name (const gchar *name)
 
 
 
+#ifdef DEVICE_PROPERTIES
 static void
 xfce_pointers_helper_change_property (XDeviceInfo  *device_info,
                                       XDevice      *device,
@@ -799,6 +783,7 @@ xfce_pointers_helper_change_properties (gpointer key,
                                           pointer_data->xdisplay,
                                           prop_name, value);
 }
+#endif
 
 
 
@@ -816,8 +801,10 @@ xfce_pointers_helper_restore_devices (XfcePointersHelper *helper,
     gboolean         reverse_scrolling;
     gint             threshold;
     gdouble          acceleration;
+#ifdef DEVICE_PROPERTIES
     GHashTable      *props;
     XfcePointerData  pointer_data;
+#endif
     const gchar     *mode;
 
     gdk_error_trap_push ();
@@ -885,6 +872,7 @@ xfce_pointers_helper_restore_devices (XfcePointersHelper *helper,
         if (mode != NULL)
             xfce_pointers_helper_change_mode (device_info, device, xdisplay, mode);
 
+#ifdef DEVICE_PROPERTIES
         /* set device properties */
         g_snprintf (prop, sizeof (prop), "/%s/Properties", device_name);
         props = xfconf_channel_get_properties (helper->channel, prop);
@@ -900,6 +888,7 @@ xfce_pointers_helper_restore_devices (XfcePointersHelper *helper,
 
             g_hash_table_destroy (props);
         }
+#endif
 
         g_free (device_name);
         XCloseDevice (xdisplay, device);
@@ -988,11 +977,13 @@ xfce_pointers_helper_channel_property_changed (XfconfChannel      *channel,
                     xfce_pointers_helper_change_feedback (device_info, device, xdisplay,
                                                           -2, g_value_get_double (value));
                 }
+#ifdef DEVICE_PROPERTIES
                 else if (strcmp (names[1], "Properties") == 0)
                 {
                     xfce_pointers_helper_change_property (device_info, device, xdisplay,
                                                           names[2], value);
                 }
+#endif
                 else if (strcmp (names[1], "Mode") == 0)
                 {
                     xfce_pointers_helper_change_mode (device_info, device, xdisplay,
@@ -1021,7 +1012,7 @@ xfce_pointers_helper_channel_property_changed (XfconfChannel      *channel,
 
 
 
-#ifdef HAS_DEVICE_HOTPLUGGING
+#ifdef DEVICE_HOTPLUGGING
 static GdkFilterReturn
 xfce_pointers_helper_event_filter (GdkXEvent *xevent,
                                    GdkEvent  *gdk_event,


More information about the Xfce4-commits mailing list