diff --git a/examples/inputsynth.c b/examples/inputsynth.c index 9cce5926495bd66c02a16745b61a055d98128100..aa8f8698481e12ec1e1171d385b6b6edb05b808c 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 32a24008a3fb4814a36c92af9c6415f5296870f0..145612a8c3241459c448e1299fe2d04d8dc62637 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 8564cb419bd405c21370dcb7fe03f61d2cf69f94..ff0189c623ec58b7eecd7e1b4be27b294b0f8584 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 a2d276b6c7d060f39806bcaf86593eb0eaee045d..ff97f003a2452fe7bd992c72cf4a5fd108b77655 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);