bug 1313376 - reinstall the key event snooper when necessary r=davidb
authorTrevor Saunders <tbsaunde@tbsaunde.org>
Thu, 27 Oct 2016 13:16:01 -0400
changeset 346566 f686f5590975a862d85e61f643c6dc39b1a8ee8f
parent 346565 4ad62b743d5a1c41d4e71f6fb5f4e976f1899cd8
child 346567 81a257aa9c4e194750afb65dd666ea600981d99a
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdavidb
bugs1313376
milestone52.0a1
bug 1313376 - reinstall the key event snooper when necessary r=davidb If we unregister the last key event listener we will uninstall the key event snooper, so we need to reinstall it when a new key event listener is added.
accessible/atk/UtilInterface.cpp
--- a/accessible/atk/UtilInterface.cpp
+++ b/accessible/atk/UtilInterface.cpp
@@ -256,18 +256,24 @@ mai_util_add_key_event_listener(AtkKeySn
   if (MOZ_UNLIKELY(!listener)) {
     return 0;
   }
 
   static guint key = 0;
 
   if (!sKey_listener_list) {
     sKey_listener_list = g_hash_table_new(nullptr, nullptr);
+  }
+
+  // If we have no registered event listeners then we need to (re)install the
+  // key event snooper.
+  if (g_hash_table_size(sKey_listener_list) == 0) {
     sKey_snooper_id = gtk_key_snooper_install(mai_key_snooper, data);
   }
+
   AtkKeySnoopFuncPointer atkKeySnoop;
   atkKeySnoop.func_ptr = listener;
   key++;
   g_hash_table_insert(sKey_listener_list, GUINT_TO_POINTER(key),
                       atkKeySnoop.data);
   return key;
 }