Compare commits

...

4 Commits

Author SHA1 Message Date
rafspiny 53a5551a67 Use strdup 2023-08-02 22:23:31 +02:00
rafspiny 5b98e0021d Removed dbus initialization 2023-08-02 21:56:51 +02:00
rafspiny 3b984163d6 Address calloc failure 2023-08-02 21:53:59 +02:00
rafspiny 0c309c467f Address linting comments. 2023-08-02 21:43:51 +02:00
7 changed files with 59 additions and 40 deletions

View File

@ -10,7 +10,9 @@
DbusAccelerometer* accelerometer_dbus;
DbusAccelerometer* sensor_proxy_init() {
DbusAccelerometer*
sensor_proxy_init()
{
// Initialise DBUS component
if (accelerometer_dbus != NULL)
{
@ -18,17 +20,11 @@ DbusAccelerometer* sensor_proxy_init() {
return accelerometer_dbus;
}
accelerometer_dbus = calloc(1, sizeof(DbusAccelerometer));
EINA_SAFETY_ON_NULL_RETURN_VAL(accelerometer_dbus, NULL);
// The next line is probably redundant
accelerometer_dbus->orientation = undefined;
DBG("Before eldbus initialization");
int initialization = eldbus_init();
if (initialization == EXIT_FAILURE)
{
ERR("Unable to initialise ELDBUS");
}
INF("Getting dbus interfaces");
accelerometer_dbus->sensor_proxy = get_dbus_interface(EFL_DBUS_ACC_IFACE);
accelerometer_dbus->sensor_proxy_properties = get_dbus_interface(ELDBUS_FDO_INTERFACE_PROPERTIES);
@ -58,7 +54,8 @@ DbusAccelerometer* sensor_proxy_init() {
return accelerometer_dbus;
}
void sensor_proxy_shutdown()
void
sensor_proxy_shutdown(void)
{
INF("Removing signal handler dbus_property_changed_sh");
eldbus_signal_handler_del(accelerometer_dbus->dbus_property_changed_sh);
@ -77,11 +74,14 @@ void sensor_proxy_shutdown()
eldbus_shutdown();
}
int _convertible_rotation_get(const enum screen_rotation orientation);
int
_convertible_rotation_get(const enum screen_rotation orientation);
int _is_device_a_touch_pointer(int dev_counter, int num_properties, char **iterator);
int
_is_device_a_touch_pointer(int dev_counter, int num_properties, char **iterator);
Eldbus_Proxy *get_dbus_interface(const char *IFACE)
Eldbus_Proxy *
get_dbus_interface(const char *IFACE)
{
DBG("Working on interface: %s", IFACE);
Eldbus_Connection *conn;
@ -110,7 +110,8 @@ Eldbus_Proxy *get_dbus_interface(const char *IFACE)
return sensor_proxy;
}
enum screen_rotation access_string_property(const Eldbus_Message *msg, Eldbus_Message_Iter **variant, Eina_Bool* result)
enum screen_rotation
access_string_property(const Eldbus_Message *msg, Eldbus_Message_Iter **variant, Eina_Bool* result)
{
const char *type = NULL;
*result = EINA_TRUE;
@ -140,6 +141,7 @@ enum screen_rotation access_string_property(const Eldbus_Message *msg, Eldbus_Me
*result = EINA_FALSE;
}
const char **string_property_value = calloc(PATH_MAX, sizeof(char));
EINA_SAFETY_ON_NULL_RETURN_VAL(string_property_value, EINA_FALSE);
if (!eldbus_message_iter_arguments_get((*variant), "s", string_property_value))
{
WARN("error in eldbus_message_iter_arguments_get()");
@ -234,6 +236,7 @@ on_accelerometer_orientation(void *data, const Eldbus_Message *msg, Eldbus_Pendi
enum screen_rotation orientation;
Eldbus_Message_Iter *variant = NULL;
Eina_Bool* result = calloc(1, sizeof(Eina_Bool));
EINA_SAFETY_ON_NULL_RETURN_VAL(result, NULL);
if (eldbus_message_error_get(msg, &errname, &errmsg))
{
@ -267,7 +270,8 @@ on_accelerometer_orientation(void *data, const Eldbus_Message *msg, Eldbus_Pendi
}
}
int _convertible_rotation_get(const enum screen_rotation orientation)
int
_convertible_rotation_get(const enum screen_rotation orientation)
{
switch (orientation)
{
@ -280,7 +284,8 @@ int _convertible_rotation_get(const enum screen_rotation orientation)
}
}
const float * _get_matrix_rotation_transformation(int rotation)
const float *
_get_matrix_rotation_transformation(int rotation)
{
const float *transformation;
switch (rotation) {
@ -299,7 +304,8 @@ const float * _get_matrix_rotation_transformation(int rotation)
return transformation;
}
int _fetch_X_device_input_number()
int
_fetch_X_device_input_number(void)
{
// I should get the touchscreen associated with the screen probably by looking at the classes of the input devices
// I need to submit my patch to add getters for other XIDeviceInfo fields, like raster mentioned in his commit.
@ -335,7 +341,8 @@ int _fetch_X_device_input_number()
return dev_number;
}
int _is_device_a_touch_pointer(int dev_counter, int num_properties, char **iterator)
int
_is_device_a_touch_pointer(int dev_counter, int num_properties, char **iterator)
{
// Looking for a device with either a libinput property for calibration or the old evdev Axlis labels property.
int is_correct_device = EINA_FALSE;
@ -360,7 +367,9 @@ int _is_device_a_touch_pointer(int dev_counter, int num_properties, char **itera
return is_correct_device;
}
void _fetch_and_rotate_screen(const char* randr_id, enum screen_rotation orientation) {
void
_fetch_and_rotate_screen(const char* randr_id, enum screen_rotation orientation)
{
DBG("Working on screen %s", randr_id);
E_Randr2_Screen *rotatable_screen = e_randr2_screen_id_find(randr_id);
E_Config_Randr2_Screen *screen_randr_cfg = e_randr2_config_screen_find(rotatable_screen, e_randr2_cfg);
@ -388,6 +397,7 @@ void _fetch_and_rotate_screen(const char* randr_id, enum screen_rotation orienta
Ecore_X_Atom format_ret;
char *result = NULL;
TransformationMatrix *matrix = calloc(1, sizeof(TransformationMatrix));
EINA_SAFETY_ON_NULL_RETURN_VAL(matrix, NULL);
result = ecore_x_input_device_property_get(x_dev_num, CTM_name, &num_ret, &format_ret, &unit_size_ret);
if (result != NULL)
{

View File

@ -29,12 +29,14 @@ struct _DbusAccelerometer
DbusAccelerometer* sensor_proxy_init();
void sensor_proxy_shutdown();
void
sensor_proxy_shutdown(void);
/**
* Helper to get the interface
* */
Eldbus_Proxy *get_dbus_interface(const char *IFACE);
Eldbus_Proxy *
get_dbus_interface(const char *IFACE);
/**
* Helper function to extract ta string property from the message
@ -100,5 +102,6 @@ on_accelerometer_released(void *data EINA_UNUSED, const Eldbus_Message *msg, Eld
* @param randr_id The randr2 id
* @param rotation The expected rotation
*/
void _fetch_and_rotate_screen(const char* randr_id, enum screen_rotation orientation);
void
_fetch_and_rotate_screen(const char* randr_id, enum screen_rotation orientation);
#endif

View File

@ -8,7 +8,8 @@
/* LIST OF INSTANCES */
static Eina_List *instances = NULL;
void _update_instances(const Instance *current_instance)
void
_update_instances(const Instance *current_instance)
{
Eina_List *l;
Instance *instance = NULL;
@ -25,7 +26,8 @@ void _update_instances(const Instance *current_instance)
}
}
void _rotation_signal_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const char *sig EINA_UNUSED,
void
_rotation_signal_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const char *sig EINA_UNUSED,
const char *src EINA_UNUSED)
{
DBG("Rotation: Signal %s received from %s", sig, src);
@ -37,7 +39,8 @@ void _rotation_signal_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, c
_update_instances(inst);
}
void _keyboard_signal_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const char *sig EINA_UNUSED,
void
_keyboard_signal_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const char *sig EINA_UNUSED,
const char *src EINA_UNUSED)
{
DBG("Keyboard: Signal %s received from %s", sig, src);
@ -56,6 +59,7 @@ _gadget_created(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_
}
void update_instances(Eina_List *new_instances) {
void
update_instances(Eina_List *new_instances) {
instances = new_instances;
}

View File

@ -15,7 +15,8 @@ _rotation_signal_cb(void *data EINA_UNUSED, Evas_Object *obj, const char *sig EI
void
_keyboard_signal_cb(void *data EINA_UNUSED, Evas_Object *obj, const char *sig EINA_UNUSED, const char *src EINA_UNUSED);
void update_instances(Eina_List *instances);
void
update_instances(Eina_List *instances);
/* end gadcon callback for actions */

View File

@ -139,7 +139,7 @@ e_int_config_convertible_module(Evas_Object *comp, const char *p EINA_UNUSED)
}
void
econvertible_config_init()
econvertible_config_init(void)
{
_econvertible_config_dd_new();
_config = e_config_domain_load("module.econvertible", edd);
@ -153,7 +153,7 @@ econvertible_config_init()
DBG("Config loaded");
}
void econvertible_config_shutdown()
void econvertible_config_shutdown(void)
{
E_CONFIG_DD_FREE(edd);
E_FREE(convertible_config);

View File

@ -34,11 +34,16 @@ struct _E_Config_Dialog_Data
Evas_Object *inputs;
};
E_Config_Dialog* e_int_config_convertible_module(Evas_Object *comp, const char *p);
void econvertible_config_init();
void econvertible_config_shutdown();
E_Config_Dialog*
e_int_config_convertible_module(Evas_Object *comp, const char *p);
void
econvertible_config_init(void);
void
econvertible_config_shutdown(void);
//E_Config_Dialog* econvertible_config_init(Evas_Object *comp, const char*p);
void _menu_new(Instance *inst, Evas_Event_Mouse_Down *ev);
void _mouse_down_cb(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event);
void
_menu_new(Instance *inst, Evas_Event_Mouse_Down *ev);
void
_mouse_down_cb(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event);
#endif //E_GADGET_CONVERTIBLE_E_MOD_CONFIG_H

View File

@ -305,12 +305,8 @@ e_modapi_init(E_Module *m)
// Arbitrarily chosen a condition to check that rotation is enabled
if (screen->info.can_rot_90 == EINA_TRUE)
{
int max_screen_length = 300;
char *randr2_id = malloc(sizeof(char) * max_screen_length);
int copied_chars = eina_strlcpy(randr2_id, zone->randr2_id, max_screen_length);
if (copied_chars > max_screen_length)
ERR("Screen name %s has been truncated. Cannot handle screens.", randr2_id);
if (copied_chars < 0)
char *randr2_id = strdup(zone->randr2_id);
if (randr2_id == NULL)
ERR("Can't copy the screen name");
inst->randr2_ids = eina_list_append(inst->randr2_ids, randr2_id);