Sync LED state when gaining focus

The state might have changed when we didn't have focus. Get
everything back in sync once we're back in control.
diff --git a/vncviewer/cocoa.mm b/vncviewer/cocoa.mm
index 6483291..e26851d 100644
--- a/vncviewer/cocoa.mm
+++ b/vncviewer/cocoa.mm
@@ -447,6 +447,23 @@
   return KERN_SUCCESS;
 }
 
+static int cocoa_get_modifier_lock_state(int modifier, bool *on)
+{
+  kern_return_t ret;
+  io_connect_t ioc;
+
+  ret = cocoa_open_hid(&ioc);
+  if (ret != KERN_SUCCESS)
+    return ret;
+
+  ret = IOHIDGetModifierLockState(ioc, modifier, on);
+  IOServiceClose(ioc);
+  if (ret != KERN_SUCCESS)
+    return ret;
+
+  return KERN_SUCCESS;
+}
+
 int cocoa_set_caps_lock_state(bool on)
 {
   return cocoa_set_modifier_lock_state(kIOHIDCapsLockState, on);
@@ -456,3 +473,13 @@
 {
   return cocoa_set_modifier_lock_state(kIOHIDNumLockState, on);
 }
+
+int cocoa_get_caps_lock_state(bool *on)
+{
+  return cocoa_get_modifier_lock_state(kIOHIDCapsLockState, on);
+}
+
+int cocoa_get_num_lock_state(bool *on)
+{
+  return cocoa_get_modifier_lock_state(kIOHIDNumLockState, on);
+}