From f61adb00cf92c93dfa6c04f9fcd713349de6c78c Mon Sep 17 00:00:00 2001
From: Christoph Haag <christoph.haag@collabora.com>
Date: Tue, 13 Aug 2019 05:19:54 +0200
Subject: [PATCH] uppercase the backend enum values and add documentation

---
 examples/inputsynth.c    |  4 ++--
 src/inputsynth.c         | 39 ++++++++++++++++++++++++++++++++++++---
 src/inputsynth.h         | 21 +++++++++++++++------
 tests/test_load_plugin.c |  2 +-
 4 files changed, 54 insertions(+), 12 deletions(-)

diff --git a/examples/inputsynth.c b/examples/inputsynth.c
index 9cce592..aa8f869 100644
--- a/examples/inputsynth.c
+++ b/examples/inputsynth.c
@@ -48,11 +48,11 @@ int main (int argc, char **argv)
   InputSynth *input = NULL;
   if (strncmp (backend, "xdo", 4) == 0)
     {
-      input = INPUT_SYNTH (input_synth_new (InputsynthBackend_XDO));
+      input = INPUT_SYNTH (input_synth_new (INPUTSYNTH_BACKEND_XDO));
     }
   else if (strncmp (backend, "xi2", 4) == 0)
     {
-      input = INPUT_SYNTH (input_synth_new (InputsynthBackend_XI2));
+      input = INPUT_SYNTH (input_synth_new (INPUTSYNTH_BACKEND_XI2));
     }
   else
     {
diff --git a/src/inputsynth.c b/src/inputsynth.c
index 32a2400..145612a 100644
--- a/src/inputsynth.c
+++ b/src/inputsynth.c
@@ -45,15 +45,15 @@ _load_library (InputsynthBackend backend)
   GString *module_name = g_string_new ("inputsynth_");
   switch (backend)
     {
-    case InputsynthBackend_XDO:
+    case INPUTSYNTH_BACKEND_XDO:
       func_name = "input_synth_xdo_new";
       g_string_append (module_name, "xdo");
       break;
-    case InputsynthBackend_XI2:
+    case INPUTSYNTH_BACKEND_XI2:
       func_name = "input_synth_xi2_new";
       g_string_append (module_name, "xi2");
       break;
-    case InputsynthBackend_WAYLAND_CLUTTER:
+    case INPUTSYNTH_BACKEND_WAYLAND_CLUTTER:
       func_name = "input_synth_wayland_clutter_new";
       g_string_append (module_name, "wayland_clutter");
       break;
@@ -123,6 +123,12 @@ input_synth_class_init (InputSynthClass *klass)
   object_class->finalize = input_synth_finalize;
 }
 
+/**
+ * input_synth_move_cursor:
+ * @self: The #InputSynth
+ * @x: The x coordinate to move to
+ * @y: The y coordinate to move to
+ */
 void
 input_synth_move_cursor (InputSynth *self, int x, int y)
 {
@@ -131,6 +137,22 @@ input_synth_move_cursor (InputSynth *self, int x, int y)
   klass->move_cursor (self, x, y);
 }
 
+/**
+ * input_synth_click:
+ * @self: The #InputSynth
+ * @x: The x coordinate to click at (may have no effect depending on backend)
+ * @y: The y coordinate to click at (may have no effect depending on backend)
+ * @button: The button to click.
+ * Usual Bindings:
+ *  * Button 1: Left Click
+ *  * Button 2: Right Click
+ *  * Button 3: Middle (Mouse Wheel) Click
+ *  * Button 4: Scroll Up
+ *  * Button 5: Scroll Down
+ *  * Button 6: Scroll Left
+ *  * Button 7: Scroll right
+ * @press: Whether to press or release the button
+ */
 void
 input_synth_click (InputSynth *self, int x, int y,
                         int button, gboolean press)
@@ -140,6 +162,11 @@ input_synth_click (InputSynth *self, int x, int y,
   klass->click (self, x, y, button, press);
 }
 
+/**
+ * input_synth_character:
+ * @self: The #InputSynth
+ * @c: The ASCII character to input.
+ */
 void
 input_synth_character (InputSynth *self, char c)
 {
@@ -148,6 +175,12 @@ input_synth_character (InputSynth *self, char c)
   klass->character (self, c);
 }
 
+/**
+ * input_synth_get_backend_name:
+ * @self: The #InputSynth
+ * Returns: A purely informational descriptive name for the backend
+ * currently in use. Can be used to test if loading of backend succeeds.
+ */
 GString *
 input_synth_get_backend_name (InputSynth *self)
 {
diff --git a/src/inputsynth.h b/src/inputsynth.h
index 8564cb4..ff0189c 100644
--- a/src/inputsynth.h
+++ b/src/inputsynth.h
@@ -28,16 +28,25 @@ struct _InputSynthClass
   GString * (*get_backend_name) (InputSynth *self);
 };
 
-typedef enum
-{
-  InputsynthBackend_XI2,
-  InputsynthBackend_XDO,
-  InputsynthBackend_WAYLAND_CLUTTER
+/**
+ * InputsynthBackend:
+ * @INPUTSYNTH_BACKEND_XI2: Use XTestFake events to synthesize input.
+ * Optionally create a second mouse cursor with xinput2.
+ * @INPUTSYNTH_BACKEND_XDO: Use libxdo from xdotools.
+ * @INPUTSYNTH_BACKEND_WAYLAND_CLUTTER: Use Clutter's remote input API to
+ * synthesize input on gnome wayland.
+ *
+ * Type of backend to use.
+ *
+ */
+typedef enum {
+  INPUTSYNTH_BACKEND_XI2,
+  INPUTSYNTH_BACKEND_XDO,
+  INPUTSYNTH_BACKEND_WAYLAND_CLUTTER
 } InputsynthBackend;
 
 InputSynth *input_synth_new (InputsynthBackend backend);
 
-/* the x and y coordinates are relative to the entire desktop */
 void
 input_synth_move_cursor (InputSynth *self, int x, int y);
 
diff --git a/tests/test_load_plugin.c b/tests/test_load_plugin.c
index a2d276b..ff97f00 100644
--- a/tests/test_load_plugin.c
+++ b/tests/test_load_plugin.c
@@ -10,7 +10,7 @@
 int
 main ()
 {
-  InputSynth *input = INPUT_SYNTH (input_synth_new (InputsynthBackend_XDO));
+  InputSynth *input = INPUT_SYNTH (input_synth_new (INPUTSYNTH_BACKEND_XDO));
   g_assert (input != NULL);
   GString *name = input_synth_get_backend_name (input);
   g_print ("Input Synth Backend: %s\n", name->str);
-- 
GitLab