Merge upstream branch 2.31.1 into branch origin/tizen
[platform/upstream/at-spi2-core.git] / registryd / deviceeventcontroller.c
index 8fefbd7..686f2cd 100644 (file)
@@ -23,7 +23,7 @@
 
 /* deviceeventcontroller.c: implement the DeviceEventController interface */
 
-#include <config.h>
+#include "config.h"
 
 #undef  SPI_XKB_DEBUG
 #undef  SPI_DEBUG
 #include <dbus/dbus.h>
 
 #include "paths.h"
-#include "keymasks.h"
 #include "de-types.h"
 #include "de-marshaller.h"
+#include "keymasks.h"
+
+#ifdef HAVE_X11
 #include "display.h"
 #include "event-source.h"
+#endif
 
 #include "deviceeventcontroller.h"
 #include "reentrant-list.h"
@@ -64,6 +67,7 @@ struct _SpiPoint {
     gint y;
 };
 typedef struct _SpiPoint SpiPoint;
+
 static unsigned int mouse_mask_state = 0;
 static unsigned int key_modifier_mask =
   SPI_KEYMASK_MOD1 | SPI_KEYMASK_MOD2 | SPI_KEYMASK_MOD3 | SPI_KEYMASK_MOD4 |
@@ -634,7 +638,7 @@ handle_keygrab (SpiDEController         *controller,
   grab_mask.mod_mask = key_listener->mask;
   if (g_slist_length (key_listener->keys) == 0) /* special case means AnyKey/AllKeys */
     {
-      grab_mask.key_val = AnyKey;
+      grab_mask.key_val = 0L; /* AnyKey */
 #ifdef SPI_DEBUG
       fprintf (stderr, "AnyKey grab!");
 #endif
@@ -923,6 +927,7 @@ send_and_allow_reentry (DBusConnection *bus, DBusMessage *message, int timeout,
       {
         const char *dest = dbus_message_get_destination (message);
         GSList *l;
+        dbus_bool_t result;
         gchar *bus_name_dup;
         dbus_message_ref (message);
         dbus_pending_call_set_notify (pending, reset_hung_process, message,
@@ -932,9 +937,9 @@ send_and_allow_reentry (DBusConnection *bus, DBusMessage *message, int timeout,
                                                 "Ping");
         if (!message)
           return NULL;
-        dbus_connection_send_with_reply (bus, message, &pending, -1);
+        result = dbus_connection_send_with_reply (bus, message, &pending, -1);
         dbus_message_unref (message);
-        if (!pending)
+        if (!result || !pending)
           return NULL;
         bus_name_dup = g_strdup (dest);
         dbus_pending_call_set_notify (pending, reset_hung_process_from_ping,
@@ -1361,6 +1366,7 @@ impl_register_keystroke_listener (DBusConnection *bus,
     Accessibility_KeyDefinition *kd = (Accessibility_KeyDefinition *)g_malloc(sizeof(Accessibility_KeyDefinition));
     if (!spi_dbus_message_iter_get_struct(&iter_array, DBUS_TYPE_INT32, &kd->keycode, DBUS_TYPE_INT32, &kd->keysym, DBUS_TYPE_STRING, &keystring, DBUS_TYPE_INVALID))
     {
+      g_free (kd);
       break;
     }
     kd->keystring = g_strdup (keystring);
@@ -1571,6 +1577,7 @@ impl_deregister_keystroke_listener (DBusConnection *bus,
 
     if (!spi_dbus_message_iter_get_struct(&iter_array, DBUS_TYPE_INT32, &kd->keycode, DBUS_TYPE_INT32, &kd->keysym, DBUS_TYPE_STRING, &keystring, DBUS_TYPE_INVALID))
     {
+      g_free(kd);
       break;
     }
     kd->keystring = g_strdup (keystring);
@@ -1751,13 +1758,19 @@ impl_generate_keyboard_event (DBusConnection *bus, DBusMessage *message, void *u
               * in our arg list; it can contain either
               * a keycode or a keysym.
               */
-             spi_dec_synth_keysym (controller, (KeySym) keycode);
+             spi_dec_synth_keysym (controller, keycode);
              break;
       case Accessibility_KEY_STRING:
              if (!spi_dec_plat_synth_keystring (controller, synth_type, keycode, keystring))
                      fprintf (stderr, "Keystring synthesis failure, string=%s\n",
                               keystring);
              break;
+      case Accessibility_KEY_LOCKMODIFIERS:
+             spi_dec_plat_lock_modifiers (controller, keycode);
+             break;
+      case Accessibility_KEY_UNLOCKMODIFIERS:
+             spi_dec_plat_unlock_modifiers (controller, keycode);
+             break;
     }
   reply = dbus_message_new_method_return (message);
   return reply;