This commit is contained in:
rafspiny 2023-12-31 14:03:56 +01:00 committed by Carsten Haitzler
parent bb37914492
commit dcf621326b
4 changed files with 63 additions and 62 deletions

View File

@ -65,6 +65,7 @@ _is_device_a_touch_pointer(int dev_counter, int num_properties, char **iterator)
} }
DBG("Looks like I found a device with calibration capabilities"); DBG("Looks like I found a device with calibration capabilities");
is_correct_device = EINA_TRUE; is_correct_device = EINA_TRUE;
free(result);
} }
iterator++; iterator++;
} }
@ -101,6 +102,7 @@ _fetch_X_device_input_number(void)
{ {
dev_number = dev_counter; dev_number = dev_counter;
DBG("Setting device: %d", dev_number); DBG("Setting device: %d", dev_number);
break;
} }
iterator++; iterator++;
} }
@ -120,7 +122,18 @@ _fetch_and_rotate_screen(const char* randr_id, enum screen_rotation orientation)
{ {
DBG("Working on screen %s", randr_id); DBG("Working on screen %s", randr_id);
E_Randr2_Screen *rotatable_screen = e_randr2_screen_id_find(randr_id); E_Randr2_Screen *rotatable_screen = e_randr2_screen_id_find(randr_id);
if (rotatable_screen == NULL)
{
DBG("Failed to load screen for id %s", randr_id);
return;
}
E_Config_Randr2_Screen *screen_randr_cfg = e_randr2_config_screen_find(rotatable_screen, e_randr2_cfg); E_Config_Randr2_Screen *screen_randr_cfg = e_randr2_config_screen_find(rotatable_screen, e_randr2_cfg);
if (screen_randr_cfg == NULL)
{
DBG("Failed to load screen configuration for id %s", randr_id);
return;
}
int rotation = _convertible_rotation_get(orientation); int rotation = _convertible_rotation_get(orientation);
DBG("Screen %s is going to be rotated to %d", randr_id, rotation); DBG("Screen %s is going to be rotated to %d", randr_id, rotation);
@ -165,6 +178,7 @@ _fetch_and_rotate_screen(const char* randr_id, enum screen_rotation orientation)
} else { } else {
ERR("Unable to fetch coordinates transformation matrix for device %d", x_dev_num); ERR("Unable to fetch coordinates transformation matrix for device %d", x_dev_num);
} }
free(result);
free(matrix); free(matrix);
} }
} }
@ -173,7 +187,7 @@ _fetch_and_rotate_screen(const char* randr_id, enum screen_rotation orientation)
* Helper to get the interface * Helper to get the interface
* */ * */
static Eldbus_Proxy * static Eldbus_Proxy *
get_dbus_interface(const char *IFACE) _get_dbus_interface(const char *IFACE)
{ {
DBG("Working on interface: %s", IFACE); DBG("Working on interface: %s", IFACE);
Eldbus_Connection *conn; Eldbus_Connection *conn;
@ -228,16 +242,19 @@ _access_bool_property(const Eldbus_Message *msg, Eldbus_Message_Iter **variant,
return res; return res;
} }
if (type[0] != 'b')
{
WARN("Expected type is int.");
res = EINA_FALSE;
free(type);
return res;
}
if (type[1]) if (type[1])
{ {
WARN("It is a complex type, not handle yet."); WARN("It is a complex type, not handle yet.");
res = EINA_FALSE; res = EINA_FALSE;
} }
if (type[0] != 'b')
{
WARN("Expected type is int.");
res = EINA_FALSE;
}
if (!eldbus_message_iter_arguments_get((*variant), "b", boolean_property_value)) if (!eldbus_message_iter_arguments_get((*variant), "b", boolean_property_value))
{ {
WARN("error in eldbus_message_iter_arguments_get()"); WARN("error in eldbus_message_iter_arguments_get()");
@ -379,16 +396,13 @@ sensor_proxy_shutdown(void)
eldbus_shutdown(); eldbus_shutdown();
} }
int
_convertible_rotation_get(const enum screen_rotation orientation);
/** /**
* Helper function to extract ta string property from the message * Helper function to extract ta string property from the message
* @param msg The message coming from the get property invocation * @param msg The message coming from the get property invocation
* @param variant * @param variant
* @return Enum specifying the orientation. UNDEFINED by default * @return Enum specifying the orientation. UNDEFINED by default
*/ */
enum screen_rotation static enum screen_rotation
_access_string_property(const Eldbus_Message *msg, Eldbus_Message_Iter **variant) _access_string_property(const Eldbus_Message *msg, Eldbus_Message_Iter **variant)
{ {
enum screen_rotation rotation = UNDEFINED; enum screen_rotation rotation = UNDEFINED;
@ -404,34 +418,33 @@ _access_string_property(const Eldbus_Message *msg, Eldbus_Message_Iter **variant
WARN("Unable to get the type."); WARN("Unable to get the type.");
return rotation; return rotation;
} }
if (type[0] != 's')
type = eldbus_message_iter_signature_get((*variant)); {
WARN("Expected type is string(s).");
free(type);
return rotation;
}
if (type[1]) if (type[1])
{ {
WARN("It is a complex type, not handle yet."); WARN("It is a complex type, not handle yet.");
} }
if (type[0] != 's')
{ const char *string_property_value;
WARN("Expected type is string(s)."); if (!eldbus_message_iter_arguments_get(variant, "s", &string_property_value))
}
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()"); WARN("error in eldbus_message_iter_arguments_get()");
} }
if (!strcmp(ACCELEROMETER_ORIENTATION_RIGHT, *string_property_value)) if (strcmp(ACCELEROMETER_ORIENTATION_RIGHT, string_property_value) == 0)
rotation = RIGHT_UP; rotation = RIGHT_UP;
if (!strcmp(ACCELEROMETER_ORIENTATION_LEFT, *string_property_value)) if (strcmp(ACCELEROMETER_ORIENTATION_LEFT, string_property_value) == 0)
rotation = LEFT_UP; rotation = LEFT_UP;
if (!strcmp(ACCELEROMETER_ORIENTATION_BOTTOM, *string_property_value)) if (strcmp(ACCELEROMETER_ORIENTATION_BOTTOM, string_property_value) == 0)
rotation = FLIPPED; rotation = FLIPPED;
if (!strcmp(ACCELEROMETER_ORIENTATION_NORMAL, *string_property_value)) if (strcmp(ACCELEROMETER_ORIENTATION_NORMAL, string_property_value) == 0)
rotation = NORMAL; rotation = NORMAL;
free(type); free(type);
free(string_property_value);
return rotation; return rotation;
} }
@ -439,7 +452,7 @@ void
on_accelerometer_orientation(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED) on_accelerometer_orientation(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED)
{ {
INF("New orientation received"); INF("New orientation received");
Instance *inst = (Instance *) data; Instance *inst = data;
if (inst->locked_position == EINA_TRUE) if (inst->locked_position == EINA_TRUE)
{ {
@ -447,7 +460,6 @@ on_accelerometer_orientation(void *data, const Eldbus_Message *msg, Eldbus_Pendi
return; return;
} }
const char *errname, *errmsg; const char *errname, *errmsg;
enum screen_rotation orientation; enum screen_rotation orientation;
Eldbus_Message_Iter *variant = NULL; Eldbus_Message_Iter *variant = NULL;

View File

@ -26,11 +26,13 @@ struct _DbusAccelerometer
/** /**
* Fetch the DBUS interfaces and fill the DbusAccelerometer struct * Fetch the DBUS interfaces and fill the DbusAccelerometer struct
* */ * */
DbusAccelerometer* sensor_proxy_init(void); DbusAccelerometer* sensor_proxy_init();
void sensor_proxy_shutdown();
void void
sensor_proxy_shutdown(void); on_has_accelerometer(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED);
/** /**
* Callback definition to handle the request of the accelerometer property of DBUS interface net.hadess.SensorProxy * Callback definition to handle the request of the accelerometer property of DBUS interface net.hadess.SensorProxy

View File

@ -12,7 +12,7 @@ static void
_update_instances(const Instance *current_instance) _update_instances(const Instance *current_instance)
{ {
Eina_List *l; Eina_List *l;
Instance *instance = NULL; Instance *instance;
EINA_LIST_FOREACH(instances, l, instance) EINA_LIST_FOREACH(instances, l, instance)
{ {
if (current_instance != instance) if (current_instance != instance)

View File

@ -17,9 +17,8 @@ E_Module *convertible_module;
Instance *inst; Instance *inst;
// Configuration // Configuration
extern Convertible_Config *convertible_config = NULL; extern Convertible_Config *convertible_config;
static E_Config_DD *conf_edd = NULL; extern E_Config_DD *edd;
Convertible_Config *conf = NULL;
// Logger // Logger
int _convertible_log_dom; int _convertible_log_dom;
@ -35,9 +34,6 @@ E_API E_Module_Api e_modapi =
/* LIST OF INSTANCES */ /* LIST OF INSTANCES */
static Eina_List *instances = NULL; static Eina_List *instances = NULL;
/* Other functions for configuration */
static void _conf_new(void);
static void _conf_free(void);
/* gadcon requirements */ /* gadcon requirements */
static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style); static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style);
@ -124,10 +120,10 @@ static void
_gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient) _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient)
{ {
Evas_Coord mw, mh; Evas_Coord mw, mh;
char buf[4096]; char buf[PATH_MAX];
const char *s = "float"; const char *s = "float";
Instance *instance = gcc->data; Instance *current_instance = gcc->data;
switch (orient) switch (orient)
{ {
case E_GADCON_ORIENT_FLOAT: case E_GADCON_ORIENT_FLOAT:
@ -194,13 +190,13 @@ _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient)
break; break;
} }
snprintf(buf, sizeof(buf), "e,state,orientation,%s", s); snprintf(buf, sizeof(buf), "e,state,orientation,%s", s);
edje_object_signal_emit(instance->o_button, buf, "e"); edje_object_signal_emit(current_instance->o_button, buf, "e");
edje_object_message_signal_process(instance->o_button); edje_object_message_signal_process(current_instance->o_button);
mw = 0, mh = 0; mw = 0, mh = 0;
edje_object_size_min_get(instance->o_button, &mw, &mh); edje_object_size_min_get(current_instance->o_button, &mw, &mh);
if ((mw < 1) || (mh < 1)) if ((mw < 1) || (mh < 1))
edje_object_size_min_calc(instance->o_button, &mw, &mh); edje_object_size_min_calc(current_instance->o_button, &mw, &mh);
if (mw < 4) mw = 4; if (mw < 4) mw = 4;
if (mh < 4) mh = 4; if (mh < 4) mh = 4;
e_gadcon_client_aspect_set(gcc, mw, mh); e_gadcon_client_aspect_set(gcc, mw, mh);
@ -228,7 +224,7 @@ _gc_icon(const E_Gadcon_Client_Class *client_class EINA_UNUSED, Evas *evas)
static const char * static const char *
_gc_id_new(const E_Gadcon_Client_Class *client_class EINA_UNUSED) _gc_id_new(const E_Gadcon_Client_Class *client_class EINA_UNUSED)
{ {
static char buf[4096]; static char buf[PATH_MAX];
snprintf(buf, sizeof(buf), "%s.%d", client_class->name, snprintf(buf, sizeof(buf), "%s.%d", client_class->name,
eina_list_count(instances) + 1); eina_list_count(instances) + 1);
@ -242,16 +238,16 @@ _gc_id_new(const E_Gadcon_Client_Class *client_class EINA_UNUSED)
static void static void
_cb_properties_changed(void *data, const Eldbus_Message *msg) _cb_properties_changed(void *data, const Eldbus_Message *msg)
{ {
Instance *instance = (Instance *) data; Instance *current_instance = data;
Eldbus_Message_Iter *array, *invalidate; Eldbus_Message_Iter *array, *invalidate;
char *iface; char *iface;
if (!eldbus_message_arguments_get(msg, "sa{sv}as", &iface, &array, &invalidate)) if (!eldbus_message_arguments_get(msg, "sa{sv}as", &iface, &array, &invalidate))
ERR("Error getting data from properties changed signal."); ERR("Error getting data from properties changed signal.");
// Given that the property changed, let's get the new value // Given that the property changed, let's get the new value
Eldbus_Pending *pending_operation = eldbus_proxy_property_get(instance->accelerometer->sensor_proxy, Eldbus_Pending *pending_operation = eldbus_proxy_property_get(current_instance->accelerometer->sensor_proxy,
"AccelerometerOrientation", "AccelerometerOrientation",
on_accelerometer_orientation, instance); on_accelerometer_orientation, current_instance);
if (!pending_operation) if (!pending_operation)
ERR("Error: could not get property AccelerometerOrientation"); ERR("Error: could not get property AccelerometerOrientation");
} }
@ -305,14 +301,15 @@ e_modapi_init(E_Module *m)
E_Randr2_Screen *screen = e_randr2_screen_id_find(zone->randr2_id); E_Randr2_Screen *screen = e_randr2_screen_id_find(zone->randr2_id);
DBG("name randr2 id %s", zone->randr2_id); DBG("name randr2 id %s", zone->randr2_id);
DBG("rot_90 %i", screen->info.can_rot_90); DBG("rot_90 %i", screen->info.can_rot_90);
// Arbitrarily chosen a condition to check that rotation is enabled // Arbitrarily chosen a condition to check that rotation is enabled
if (screen->info.can_rot_90 == EINA_TRUE) if (screen->info.can_rot_90 == EINA_TRUE)
{ {
char *randr2_id = strdup(zone->randr2_id); char *randr2_id = strdup(zone->randr2_id);
if (randr2_id == NULL) if (randr2_id == NULL)
ERR("Can't copy the screen name"); ERR("Can't copy the screen name");
else
inst->randr2_ids = eina_list_append(inst->randr2_ids, randr2_id); inst->randr2_ids = eina_list_append(inst->randr2_ids, randr2_id);
if (eina_error_get()) if (eina_error_get())
ERR("Memory is low. List allocation failed."); ERR("Memory is low. List allocation failed.");
} }
@ -326,12 +323,10 @@ e_modapi_init(E_Module *m)
e_gadcon_provider_register(&_gadcon_class); e_gadcon_provider_register(&_gadcon_class);
INF("Creating menu entries for settings"); INF("Creating menu entries for settings");
/* create Screen configuration category e_configure_registry_category_add("extensions", 90, "Extensions", NULL,
* "preferences-extensions");
* NB: If the category already exists, this function just returns */ e_configure_registry_item_add("extensions/convertible", 30, "convertible", NULL,
e_configure_registry_category_add("screen", 30, _("Screen"), NULL, "preferences-desktop-display"); "preferences-desktop-convertible", e_int_config_convertible_module);
e_configure_registry_item_add("screen/convertible", 30, "convertible", NULL,
theme_overlay_path, e_int_config_convertible_module);
instances = eina_list_append(instances, inst); instances = eina_list_append(instances, inst);
@ -373,15 +368,7 @@ e_modapi_save(E_Module *m EINA_UNUSED)
{ {
if (convertible_config) if (convertible_config)
{ {
e_config_domain_save("module.convertible", conf_edd, convertible_config); e_config_domain_save("module.convertible", edd, convertible_config);
} }
return 1; return 1;
} }
static void
_conf_new(void)
{
conf = E_NEW(Convertible_Config, 1);
conf->disable_keyboard_on_rotation = 1;
e_config_save_queue();
}