diff --git a/src/bin/e_randr_12_crtc.c b/src/bin/e_randr_12_crtc.c index d0ec1ce74..c03a25216 100644 --- a/src/bin/e_randr_12_crtc.c +++ b/src/bin/e_randr_12_crtc.c @@ -140,14 +140,17 @@ _crtc_mode_intersects_crtcs(E_Randr_Crtc_Info *crtc_info, Ecore_X_Randr_Mode_Inf { Eina_List *iter; E_Randr_Crtc_Info *tmp; + int width, height; EINA_LIST_FOREACH(e_randr_screen_info.rrvd_info.randr_info_12->crtcs, iter, tmp) { if ((tmp == crtc_info) || ((tmp->geometry.w <= 0) || (tmp->geometry.h <= 0))) continue; + width = (mode->width > INT_MAX) ? INT_MAX : mode->width; + height = (mode->height > INT_MAX) ? INT_MAX : mode->height; if (E_INTERSECTS(crtc_info->geometry.x, crtc_info->geometry.y, - mode->width, mode->height, tmp->geometry.x, + width, height, tmp->geometry.x, tmp->geometry.y, tmp->geometry.w, tmp->geometry.h) && ((crtc_info->geometry.x != tmp->geometry.x) && (crtc_info->geometry.y != tmp->geometry.y))) diff --git a/src/bin/e_randr_serialization.c b/src/bin/e_randr_serialization.c index 1efaee840..988d0cd69 100644 --- a/src/bin/e_randr_serialization.c +++ b/src/bin/e_randr_serialization.c @@ -30,7 +30,12 @@ e_randr_store_configuration(E_Randr_Configuration_Store_Modifier modifier) if (!e_config->randr_serialized_setup) e_config->randr_serialized_setup = _new_serialized_setup(); - fprintf(stderr, "E_RANDR: Configuration shall be stored using the following modifier: %d.\n", modifier); + fprintf(stderr, "E_RANDR: Configuration shall be stored using the following modifier:%s\n%s%s%s%s", + ((!modifier) ? "NONE" : ""), + ((modifier & E_RANDR_CONFIGURATION_STORE_POLICIES) ? "\tPOLICIES\n" : ""), + ((modifier & E_RANDR_CONFIGURATION_STORE_RESOLUTIONS) ? "\tRESOLUTIONS\n" : ""), + ((modifier & E_RANDR_CONFIGURATION_STORE_ARRANGEMENT) ? "\tARRANGEMENTS\n" : ""), + ((modifier & E_RANDR_CONFIGURATION_STORE_ORIENTATIONS) ? "\tORIENTATIONS\n" : "")); if (e_randr_screen_info.randr_version == ECORE_X_RANDR_1_1) { diff --git a/src/modules/conf_randr/Makefile.am b/src/modules/conf_randr/Makefile.am index 213c5c0de..25c3759a0 100644 --- a/src/modules/conf_randr/Makefile.am +++ b/src/modules/conf_randr/Makefile.am @@ -34,9 +34,9 @@ pkg_LTLIBRARIES = module.la module_la_SOURCES = e_mod_main.c \ e_mod_main.h \ e_int_config_randr_orientation.c \ - e_int_config_randr_resolutions.c \ + e_int_config_randr_resolution.c \ e_int_config_randr_arrangement.c \ - e_int_config_randr_policies.c \ + e_int_config_randr_policy.c \ e_int_config_randr.c \ e_int_config_randr.h diff --git a/src/modules/conf_randr/e-module-conf_randr.edc b/src/modules/conf_randr/e-module-conf_randr.edc index b74200cfe..6dbe5f66e 100644 --- a/src/modules/conf_randr/e-module-conf_randr.edc +++ b/src/modules/conf_randr/e-module-conf_randr.edc @@ -473,7 +473,7 @@ collections { group{ name: "e/conf/randr/dialog/widget/arrangement/suggestion"; data { - item: "distance_min" "20"; + item: "distance_max" "100"; // real pixel delta in the e_layout between output and suggested element } /* diff --git a/src/modules/conf_randr/e_int_config_randr.c b/src/modules/conf_randr/e_int_config_randr.c index 2fb2e800b..8d42ca39e 100644 --- a/src/modules/conf_randr/e_int_config_randr.c +++ b/src/modules/conf_randr/e_int_config_randr.c @@ -105,8 +105,8 @@ create_data(E_Config_Dialog *cfd) e_config_runtime_info->output_dialog_data_list = eina_list_append(e_config_runtime_info->output_dialog_data_list, odd); } //FIXME: Properly (stack-like) free data when creation fails - EINA_SAFETY_ON_FALSE_GOTO(arrangement_widget_create_data(e_config_runtime_info), _e_conf_randr_create_data_failed_free_data); EINA_SAFETY_ON_FALSE_GOTO(resolution_widget_create_data(e_config_runtime_info), _e_conf_randr_create_data_failed_free_data); + EINA_SAFETY_ON_FALSE_GOTO(arrangement_widget_create_data(e_config_runtime_info), _e_conf_randr_create_data_failed_free_data); EINA_SAFETY_ON_FALSE_GOTO(policy_widget_create_data(e_config_runtime_info), _e_conf_randr_create_data_failed_free_data); EINA_SAFETY_ON_FALSE_GOTO(orientation_widget_create_data(e_config_runtime_info), _e_conf_randr_create_data_failed_free_data); @@ -124,12 +124,17 @@ free_cfdata(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) EINA_SAFETY_ON_TRUE_RETURN(!E_RANDR_12); - arrangement_widget_free_data(cfd, cfdata); + arrangement_widget_free_cfdata(cfd, cfdata); + policy_widget_free_cfdata(cfd, cfdata); + resolution_widget_free_cfdata(cfd, cfdata); + orientation_widget_free_cfdata(cfd, cfdata); + /* evas_object_del(cfdata->gui.widgets.arrangement.widget); - evas_object_del(cfdata->gui.widgets.policies.widget); - evas_object_del(cfdata->gui.widgets.resolutions.widget); + evas_object_del(cfdata->gui.widgets.policy.widget); + evas_object_del(cfdata->gui.widgets.resolution.widget); evas_object_del(cfdata->gui.widgets.orientation.widget); + */ EINA_LIST_FREE(cfdata->output_dialog_data_list, dialog_data) { @@ -200,10 +205,13 @@ _e_conf_randr_confirmation_dialog_keep_cb(void *data, E_Dialog *dia) if (!cdd) return; + //ordinary "keep" functionality arrangement_widget_keep_changes(cdd->cfdata); orientation_widget_keep_changes(cdd->cfdata); policy_widget_keep_changes(cdd->cfdata); resolution_widget_keep_changes(cdd->cfdata); + + //cleanup dialog _e_conf_randr_confirmation_dialog_delete_cb(dia->win); } @@ -242,14 +250,7 @@ _e_conf_randr_confirmation_dialog_store_cb(void *data, E_Dialog *dia) if (orientation_widget_basic_check_changed(NULL, e_config_runtime_info)) modifier |= E_RANDR_CONFIGURATION_STORE_ORIENTATIONS; - //ordinary "keep" functionality - arrangement_widget_keep_changes(cdd->cfdata); - orientation_widget_keep_changes(cdd->cfdata); - policy_widget_keep_changes(cdd->cfdata); - resolution_widget_keep_changes(cdd->cfdata); - - //cleanup dialog - _e_conf_randr_confirmation_dialog_delete_cb(dia->win); + _e_conf_randr_confirmation_dialog_keep_cb(data, dia); //but actually trigger saving the stuff e_randr_store_configuration(modifier); @@ -305,8 +306,8 @@ basic_create_widgets(E_Config_Dialog *cfd, Evas *canvas, E_Config_Dialog_Data *c e_config_runtime_info->gui.canvas = canvas; if (!(cfdata->gui.widgets.arrangement.widget = arrangement_widget_basic_create_widgets(canvas))) goto _dialog_create_widget_arrangement_fail; - if (!(cfdata->gui.widgets.policies.widget = policy_widget_basic_create_widgets(canvas))) goto _dialog_create_widget_policies_fail; - if (!(cfdata->gui.widgets.resolutions.widget = resolution_widget_basic_create_widgets(canvas))) goto _dialog_create_widget_resolutions_fail; + if (!(cfdata->gui.widgets.policy.widget = policy_widget_basic_create_widgets(canvas))) goto _dialog_create_widget_policies_fail; + if (!(cfdata->gui.widgets.resolution.widget = resolution_widget_basic_create_widgets(canvas))) goto _dialog_create_widget_resolutions_fail; if (!(cfdata->gui.widgets.orientation.widget = orientation_widget_basic_create_widgets(canvas))) goto _dialog_create_widget_orientation_fail; EINA_SAFETY_ON_FALSE_GOTO((table = e_widget_table_add(canvas, EINA_FALSE)), _dialog_create_widgets_fail); @@ -315,14 +316,14 @@ basic_create_widgets(E_Config_Dialog *cfd, Evas *canvas, E_Config_Dialog_Data *c //e_widget_table_object_append(Evas_Object *obj, Evas_Object *sobj, int col, int row, int colspan, int rowspan, int fill_w, int fill_h, int expand_w, int expand_h); e_widget_table_object_append(table, cfdata->gui.widgets.arrangement.widget, 1, 1, 1, 1, 1, 1, 1, 1); /* - e_widget_table_object_append(table, cfdata->gui.widgets.policies.widget, 1, 2, 1, 1, 0, 0, 0, 0); + e_widget_table_object_append(table, cfdata->gui.widgets.policy.widget, 1, 2, 1, 1, 0, 0, 0, 0); e_widget_table_object_append(table, cfdata->gui.widgets.orientation.widget, 2, 2, 1, 1, 0, 0, 0, 0); - e_widget_table_object_append(table, cfdata->gui.widgets.resolutions.widget, 3, 2, 1, 1, EVAS_HINT_FILL, EVAS_HINT_FILL, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + e_widget_table_object_append(table, cfdata->gui.widgets.resolution.widget, 3, 2, 1, 1, EVAS_HINT_FILL, EVAS_HINT_FILL, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); */ //e_widget_list_object_append(Evas_Object *obj, Evas_Object *sobj, int fill, int expand, double align); - e_widget_list_object_append(wl, cfdata->gui.widgets.policies.widget, 0, 0, 0.0); + e_widget_list_object_append(wl, cfdata->gui.widgets.policy.widget, 0, 0, 0.0); e_widget_list_object_append(wl, cfdata->gui.widgets.orientation.widget, 0, 0, 0.0); - e_widget_list_object_append(wl, cfdata->gui.widgets.resolutions.widget, EVAS_HINT_FILL, EVAS_HINT_EXPAND, 1.0); + e_widget_list_object_append(wl, cfdata->gui.widgets.resolution.widget, EVAS_HINT_FILL, EVAS_HINT_EXPAND, 1.0); e_widget_table_object_append(table, wl, 1, 2, 1, 1, EVAS_HINT_FILL, EVAS_HINT_FILL, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); cfdata->gui.widget_list = wl; @@ -337,9 +338,9 @@ _dialog_create_widget_list_fail: _dialog_create_widgets_fail: evas_object_del(cfdata->gui.widgets.orientation.widget); _dialog_create_widget_orientation_fail: - evas_object_del(cfdata->gui.widgets.resolutions.widget); + evas_object_del(cfdata->gui.widgets.resolution.widget); _dialog_create_widget_resolutions_fail: - evas_object_del(cfdata->gui.widgets.policies.widget); + evas_object_del(cfdata->gui.widgets.policy.widget); _dialog_create_widget_policies_fail: evas_object_del(cfdata->gui.widgets.arrangement.widget); _dialog_create_widget_arrangement_fail: @@ -429,11 +430,12 @@ _deferred_noxrandr_error(void *data __UNUSED__) static int basic_check_changed(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) { - if (!cfdata) return EINA_FALSE; - else - return arrangement_widget_basic_check_changed(cfd, cfdata) - || policy_widget_basic_check_changed(cfd, cfdata) - || orientation_widget_basic_check_changed(cfd, cfdata) - || resolution_widget_basic_check_changed(cfd, cfdata); + if (!cfdata) + return EINA_FALSE; + + return (arrangement_widget_basic_check_changed(cfd, cfdata) + || policy_widget_basic_check_changed(cfd, cfdata) + || orientation_widget_basic_check_changed(cfd, cfdata) + || resolution_widget_basic_check_changed(cfd, cfdata)); } diff --git a/src/modules/conf_randr/e_int_config_randr.h b/src/modules/conf_randr/e_int_config_randr.h index 94e9e16cc..9e1efcefd 100644 --- a/src/modules/conf_randr/e_int_config_randr.h +++ b/src/modules/conf_randr/e_int_config_randr.h @@ -24,7 +24,9 @@ struct _E_Config_Dialog_Data struct { struct { Evas_Object *widget, *scrollframe, *area, *widget_list, *swallowing_edje, *suggestion, *check_display_disconnected_outputs; - int suggestion_dist_min, check_val_display_disconnected_outputs; + int suggestion_dist_max, check_val_display_disconnected_outputs; + Evas_Coord_Point sel_rep_previous_pos; + Eina_Rectangle dummy_geo; } arrangement; struct { Evas_Object *widget; @@ -32,10 +34,10 @@ struct _E_Config_Dialog_Data Evas_Object *radio_above, *radio_right, *radio_below, *radio_left, *radio_clone, *radio_none; int radio_val; //Evas_Object *current_displays_setup, *current_displays_setup_background, *new_display, *new_display_background; - } policies; + } policy; struct { Evas_Object *widget; - } resolutions; + } resolution; struct { Evas_Object *widget; //Evas_Object *swallowing_edje; @@ -52,10 +54,10 @@ struct _E_Config_Randr_Dialog_Output_Dialog_Data { E_Randr_Crtc_Info *crtc; E_Randr_Output_Info *output; - Evas_Coord_Point previous_pos; Ecore_X_Randr_Mode_Info *previous_mode, *new_mode, *preferred_mode; Ecore_X_Randr_Orientation previous_orientation, new_orientation; Ecore_X_Randr_Output_Policy previous_policy, new_policy; + Evas_Coord_Point previous_pos, new_pos; Evas_Object *bg, *rep; }; @@ -80,33 +82,37 @@ Eina_Bool arrangement_widget_create_data(E_Config_Dialog_Data *cfdata); Evas_Object *arrangement_widget_basic_create_widgets(Evas *canvas); Eina_Bool arrangement_widget_basic_check_changed(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); Eina_Bool arrangement_widget_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); -void arrangement_widget_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); +void arrangement_widget_free_cfdata(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); void arrangement_widget_keep_changes(E_Config_Dialog_Data *cfdata); void arrangement_widget_discard_changes(E_Config_Dialog_Data *cfdata); +void arrangement_widget_rep_update(E_Config_Randr_Dialog_Output_Dialog_Data *odd); // Functions for the policies widget interaction Eina_Bool policy_widget_create_data(E_Config_Dialog_Data *cfdata); Evas_Object *policy_widget_basic_create_widgets(Evas *canvas); Eina_Bool policy_widget_basic_check_changed(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); Eina_Bool policy_widget_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); +void policy_widget_free_cfdata(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); void policy_widget_keep_changes(E_Config_Dialog_Data *cfdata); void policy_widget_discard_changes(E_Config_Dialog_Data *cfdata); -void policy_widget_update_radio_buttons(Evas_Object *crtc); +void policy_widget_update_radio_buttons(Evas_Object *crtc); // Functions for the resolutions widget interaction Eina_Bool resolution_widget_create_data(E_Config_Dialog_Data *cfdata); Evas_Object *resolution_widget_basic_create_widgets(Evas *canvas); Eina_Bool resolution_widget_basic_check_changed(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); Eina_Bool resolution_widget_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); +void resolution_widget_free_cfdata(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); void resolution_widget_keep_changes(E_Config_Dialog_Data *cfdata); void resolution_widget_discard_changes(E_Config_Dialog_Data *cfdata); -void resolution_widget_update_list(Evas_Object *crtc); +void resolution_widget_update_list(Evas_Object *crtc); // Functions for the orientation widget interaction Eina_Bool orientation_widget_create_data(E_Config_Dialog_Data *cfdata); Evas_Object *orientation_widget_basic_create_widgets(Evas *canvas); Eina_Bool orientation_widget_basic_check_changed(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); Eina_Bool orientation_widget_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); +void orientation_widget_free_cfdata(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); void orientation_widget_update_radio_buttons(Evas_Object *crtc); void orientation_widget_update_edje(Evas_Object *crtc); void orientation_widget_keep_changes(E_Config_Dialog_Data *cfdata); diff --git a/src/modules/conf_randr/e_int_config_randr_arrangement.c b/src/modules/conf_randr/e_int_config_randr_arrangement.c index 5f72126a3..97d1e2eee 100644 --- a/src/modules/conf_randr/e_int_config_randr_arrangement.c +++ b/src/modules/conf_randr/e_int_config_randr_arrangement.c @@ -9,19 +9,76 @@ #define ECORE_X_RANDR_1_3 ((1 << 16) | 3) #endif -#ifndef Ecore_X_Randr_Unset -#define Ecore_X_Randr_Unset -1 +#ifdef POS_UNSET +#undef POS_UNSET #endif +#define POS_UNSET -1 #define DOUBLECLICK_TIMEOUT 0.2 #define CRTC_THUMB_SIZE_W 300 #define CRTC_THUMB_SIZE_H 300 -Eina_Bool arrangement_widget_create_data(E_Config_Dialog_Data *e_config_runtime_info); -Evas_Object *arrangement_widget_basic_create_widgets(Evas *canvas); -Eina_Bool arrangement_widget_basic_check_changed(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); -Eina_Bool arrangement_widget_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); -void arrangement_widget_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); +/* + * + * TOP_TOP + * ************************************************ + * * TOP_BOTTOM * + * * * + * * * + * * * + * LEFT_LEFT * LEFT_RIGHT RIGHT_LEFT * RIGHT_RIGHT + * * * + * * * + * * * + * * BOTTOM_TOP * + * ************************************************ + * BOTTOM_BOTTOM + * + */ +typedef enum { + EVAS_OBJECT_REL_POS_NONE = 0, + EVAS_OBJECT_REL_POS_TOP_TOP = (1 << 0), + EVAS_OBJECT_REL_POS_TOP_BOTTOM = (1 << 1), + EVAS_OBJECT_REL_POS_RIGHT_LEFT = (1 << 2), + EVAS_OBJECT_REL_POS_RIGHT_RIGHT = (1 << 3), + EVAS_OBJECT_REL_POS_BOTTOM_TOP = (1 << 4), + EVAS_OBJECT_REL_POS_BOTTOM_BOTTOM = (1 << 5), + EVAS_OBJECT_REL_POS_LEFT_LEFT = (1 << 6), + EVAS_OBJECT_REL_POS_LEFT_RIGHT = (1 << 7), + EVAS_OBJECT_REL_POS_X_ZERO = (1 << 8), + EVAS_OBJECT_REL_POS_Y_ZERO = (1 << 9), + EVAS_OBJECT_REL_POS_INSIDE = ( + EVAS_OBJECT_REL_POS_TOP_BOTTOM | + EVAS_OBJECT_REL_POS_RIGHT_LEFT | + EVAS_OBJECT_REL_POS_BOTTOM_TOP | + EVAS_OBJECT_REL_POS_LEFT_RIGHT), + EVAS_OBJECT_REL_POS_OUTSIDE = ( + EVAS_OBJECT_REL_POS_TOP_TOP | + EVAS_OBJECT_REL_POS_RIGHT_RIGHT | + EVAS_OBJECT_REL_POS_BOTTOM_BOTTOM | + EVAS_OBJECT_REL_POS_LEFT_LEFT), + EVAS_OBJECT_REL_POS_ALL = ( + EVAS_OBJECT_REL_POS_INSIDE | + EVAS_OBJECT_REL_POS_OUTSIDE) +} Evas_Object_Rel_Pos; + +typedef enum { + EVAS_OBJECT_DIRECTION_TOP = (1 << 0), + EVAS_OBJECT_DIRECTION_RIGHT = (1 << 1), + EVAS_OBJECT_DIRECTION_BOTTOM = (1 << 2), + EVAS_OBJECT_DIRECTION_LEFT = (1 << 3) +} Evas_Object_Direction; + +typedef struct { + struct { + Evas_Object *x, *y; + struct { + Evas_Object_Rel_Pos x, y; + } pos_rel; + } closest_objects; + Evas_Coord_Point pos; + int distance; +} Position_Suggestion; //static inline E_Config_Randr_Dialog_Output_Dialog_Data *_arrangement_widget_rep_dialog_data_new (E_Randr_Crtc_Info *crtc_info, E_Randr_Output_Info *output_info); static inline Evas_Object *_arrangement_widget_suggestion_add(Evas *evas); @@ -33,6 +90,8 @@ static void _arrangement_widget_rep_mouse_move_cb(void *data, Evas static void _arrangement_widget_rep_mouse_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); static void _arrangement_widget_check_mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); static void _arrangement_widget_update(void); +static Position_Suggestion *e_layout_pos_sug_from_children_get(Evas_Object *child, Eina_List *children, int max_distance, Evas_Object_Rel_Pos allowed_pos); +Eina_Bool _arrangemnet_rep_illegal_overlapping(E_Config_Randr_Dialog_Output_Dialog_Data *odd); extern E_Config_Dialog_Data *e_config_runtime_info; extern Config *randr_dialog_config; @@ -43,44 +102,77 @@ _arrangement_widget_rep_dialog_data_fill(E_Config_Randr_Dialog_Output_Dialog_Dat { if (!odd) return; + odd->new_pos.x = POS_UNSET; + odd->new_pos.y = POS_UNSET; + if (odd->crtc) { //already enabled screen odd->previous_pos.x = odd->crtc->geometry.x; odd->previous_pos.y = odd->crtc->geometry.y; - odd->previous_mode = odd->crtc->current_mode; } - else if (odd->output) + else { - //disabled monitor - odd->previous_mode = NULL; - if (odd->output->monitor) - { - //try to get a mode from the preferred list, else use default list - if (!(odd->preferred_mode = (Ecore_X_Randr_Mode_Info *)eina_list_data_get(eina_list_last(odd->output->monitor->preferred_modes)))) - { - if (odd->output->monitor->modes) - odd->preferred_mode = (Ecore_X_Randr_Mode_Info *)eina_list_data_get(eina_list_last(odd->output->monitor->modes)); - } - } - else - { - odd->preferred_mode = NULL; - } - - odd->previous_pos.x = 0; - odd->previous_pos.y = 0; + odd->previous_pos.x = POS_UNSET; + odd->previous_pos.y = POS_UNSET; } } +void +arrangement_widget_rep_update(E_Config_Randr_Dialog_Output_Dialog_Data *odd) +{ + Eina_Rectangle geo = {.x = 0, .y = 0, .w = 0, .h = 0}; + + //Get width, height + if (odd->new_mode) + { + geo.w = odd->new_mode->width; + geo.h = odd->new_mode->height; + } + else if (odd->crtc) + { + geo.w = odd->crtc->geometry.w; + geo.h = odd->crtc->geometry.h; + } + else if (odd->preferred_mode) + { + geo.w = odd->preferred_mode->width; + geo.h = odd->preferred_mode->height; + } + else + { + geo.w = e_config_runtime_info->gui.widgets.arrangement.dummy_geo.w; + geo.h = e_config_runtime_info->gui.widgets.arrangement.dummy_geo.h; + } + + //Get x, y + if ((odd->new_pos.x != POS_UNSET) && (odd->new_pos.y != POS_UNSET)) + { + geo.x = odd->new_pos.x; + geo.y = odd->new_pos.y; + } + else if (odd->crtc && odd->crtc->current_mode) + { + geo.x = odd->crtc->geometry.x; + geo.y = odd->crtc->geometry.y; + } + else + { + geo.x = e_config_runtime_info->gui.widgets.arrangement.dummy_geo.x; + geo.y = e_config_runtime_info->gui.widgets.arrangement.dummy_geo.y; + } + + e_layout_child_raise(odd->rep); + e_layout_child_resize(odd->rep, geo.w, geo.h); + e_layout_child_move(odd->rep, geo.x, geo.y); + fprintf(stderr, "CONF_RANDR: Representation (%p) updated with geo %d.%d %dx%d.\n", odd->rep, geo.x, geo.y, geo.w, geo.h); +} + void _arrangement_widget_update(void) { static Evas_Object *area = NULL; E_Config_Randr_Dialog_Output_Dialog_Data *odd = NULL; - static Eina_Rectangle default_geo; - Eina_Rectangle geo = {.x = 0, .y = 0, .w = 0, .h = 0}; - static char *edje_data_item = NULL; Eina_List *iter; area = e_config_runtime_info->gui.widgets.arrangement.area; @@ -88,21 +180,6 @@ _arrangement_widget_update(void) if (!e_config_runtime_info || !e_config_runtime_info->gui.canvas || !e_config_runtime_info->output_dialog_data_list || !area) return; fprintf(stderr, "CONF_RANDR: Display disconnected outputs: %s\n", (randr_dialog_config->display_disconnected_outputs ? "YES" : "NO")); - - if (!edje_data_item) - { - if(!(edje_data_item = edje_file_data_get(_theme_file_path, "disabled_output_width"))) - edje_data_item = "1024"; - default_geo.w = atoi(edje_data_item); - - if(!(edje_data_item = edje_file_data_get(_theme_file_path, "disabled_output_height"))) - edje_data_item = "768"; - default_geo.h = atoi(edje_data_item); - - default_geo.x = e_randr_screen_info.rrvd_info.randr_info_12->max_size.width - default_geo.w; - default_geo.y = 0; - } - e_layout_freeze(area); e_layout_unpack(area); e_layout_virtual_size_set(area, e_randr_screen_info.rrvd_info.randr_info_12->max_size.width, e_randr_screen_info.rrvd_info.randr_info_12->max_size.height); @@ -120,25 +197,11 @@ _arrangement_widget_update(void) fprintf(stderr, "CONF_RANDR: Could not add rep for CRTC %p/ output %p.\n", odd->crtc, odd->output); continue; } - if (odd->crtc && odd->crtc->current_mode) - { - geo.x = odd->crtc->geometry.x; - geo.y = odd->crtc->geometry.y; - geo.w = odd->crtc->geometry.w; - geo.h = odd->crtc->geometry.h; - } - else - { - memcpy(&geo, &default_geo, sizeof(geo)); - } + e_layout_pack(area, odd->rep); + arrangement_widget_rep_update(odd); + evas_object_data_set(odd->rep, "rep_info", odd); evas_object_show(odd->rep); - e_layout_pack(area, odd->rep); - e_layout_child_raise(odd->rep); - e_layout_child_resize(odd->rep, geo.w, geo.h); - e_layout_child_move(odd->rep, geo.x, geo.y); - - fprintf(stderr, "CONF_RANDR: Representation (%p) added with geo %d.%d %dx%d.\n", odd->rep, geo.x, geo.y, geo.w, geo.h); } if (e_config_runtime_info->gui.widgets.arrangement.suggestion) @@ -154,11 +217,31 @@ arrangement_widget_create_data(E_Config_Dialog_Data *data) { Eina_List *iter; E_Config_Randr_Dialog_Output_Dialog_Data *dialog_data; + char *theme_data_item = NULL; + Eina_Rectangle dummy_geo; + int max_dist = 0; EINA_LIST_FOREACH(data->output_dialog_data_list, iter, dialog_data) - { - _arrangement_widget_rep_dialog_data_fill(dialog_data); - } + _arrangement_widget_rep_dialog_data_fill(dialog_data); + + //Read in maximum distance of objects before a position is suggested + if ((theme_data_item = edje_file_data_get(_theme_file_path, "distance_max"))) + max_dist = atoi(theme_data_item); + else + max_dist = 100; + + e_config_runtime_info->gui.widgets.arrangement.suggestion_dist_max = max_dist; + + + dummy_geo.x = e_randr_screen_info.rrvd_info.randr_info_12->max_size.width - dummy_geo.w; + dummy_geo.y = 0; + //Read in size used for disabled outputs + theme_data_item = edje_file_data_get(_theme_file_path, "disabled_output_width"); + dummy_geo.w = theme_data_item ? atoi(theme_data_item) : 1024; + theme_data_item = edje_file_data_get(_theme_file_path, "disabled_output_height"); + dummy_geo.h = theme_data_item ? atoi(theme_data_item) : 768; + + memcpy(&e_config_runtime_info->gui.widgets.arrangement.dummy_geo, &dummy_geo, sizeof(e_config_runtime_info->gui.widgets.arrangement.dummy_geo)); return EINA_TRUE; } @@ -245,9 +328,9 @@ _arrangement_widget_rep_add(Evas *canvas, E_Config_Randr_Dialog_Output_Dialog_Da if (output_name) edje_object_part_text_set(rep, "output_txt", output_name); - evas_object_event_callback_add (rep, EVAS_CALLBACK_MOUSE_DOWN, _arrangement_widget_rep_mouse_down_cb, NULL); - evas_object_event_callback_add (rep, EVAS_CALLBACK_MOUSE_MOVE, _arrangement_widget_rep_mouse_move_cb, NULL); - evas_object_event_callback_add (rep, EVAS_CALLBACK_MOUSE_UP, _arrangement_widget_rep_mouse_up_cb, NULL); + evas_object_event_callback_add(rep, EVAS_CALLBACK_MOUSE_DOWN, _arrangement_widget_rep_mouse_down_cb, NULL); + evas_object_event_callback_add(rep, EVAS_CALLBACK_MOUSE_MOVE, _arrangement_widget_rep_mouse_move_cb, NULL); + evas_object_event_callback_add(rep, EVAS_CALLBACK_MOUSE_UP, _arrangement_widget_rep_mouse_up_cb, NULL); return rep; @@ -274,7 +357,7 @@ _arrangement_widget_rep_del(E_Config_Randr_Dialog_Output_Dialog_Data *odd) odd->bg = NULL; //update output orientation - orientation_widget_update_edje(NULL); + orientation_widget_update_radio_buttons(NULL); evas_object_del(odd->rep); odd->rep = NULL; @@ -307,7 +390,9 @@ _arrangement_widget_rep_mouse_down_cb(void *data __UNUSED__, Evas *e __UNUSED__, } edje_object_signal_emit(obj, "select", "e"); - //update data for other dialogs + + e_layout_child_geometry_get(obj, &e_config_runtime_info->gui.widgets.arrangement.sel_rep_previous_pos.x, &e_config_runtime_info->gui.widgets.arrangement.sel_rep_previous_pos.y, NULL, NULL); + //update data for other logs e_config_runtime_info->gui.selected_eo = obj; e_config_runtime_info->gui.selected_output_dd = (E_Config_Randr_Dialog_Output_Dialog_Data*)evas_object_data_get(obj, "rep_info"); @@ -368,28 +453,22 @@ _arrangement_widget_rep_mouse_up_cb(void *data __UNUSED__, Evas *e __UNUSED__, E edje_object_signal_emit(e_config_runtime_info->gui.widgets.arrangement.suggestion, "hide", "e"); evas_object_hide(e_config_runtime_info->gui.widgets.arrangement.suggestion); e_layout_child_geometry_get(e_config_runtime_info->gui.widgets.arrangement.suggestion, &coords.x, &coords.y, NULL, NULL); - e_layout_child_move(obj, coords.x, coords.y); } + else + { + coords.x = e_config_runtime_info->gui.widgets.arrangement.sel_rep_previous_pos.x; + coords.y = e_config_runtime_info->gui.widgets.arrangement.sel_rep_previous_pos.y; + } + e_layout_child_move(obj, coords.x, coords.y); } Evas_Object * _arrangement_widget_suggestion_add(Evas *evas) { Evas_Object *sug = NULL; - const char *theme_data_item = NULL; - int min_dist = 0; - Evas_Coord parent_x; - - evas_object_geometry_get(e_config_runtime_info->gui.widgets.arrangement.area, &parent_x, NULL, NULL, NULL); sug = edje_object_add(evas); edje_object_file_set(sug, _theme_file_path, "e/conf/randr/dialog/widget/arrangement/suggestion"); - if ((theme_data_item = edje_object_data_get(sug, "distance_min"))) - min_dist = MAX(atoi(theme_data_item), 0); - else - min_dist = 20; - - e_layout_coord_canvas_to_virtual(e_config_runtime_info->gui.widgets.arrangement.area, (parent_x + min_dist), 0, &e_config_runtime_info->gui.widgets.arrangement.suggestion_dist_min, NULL); return sug; } @@ -398,132 +477,93 @@ void _arrangement_widget_make_suggestion(Evas_Object *obj) { E_Config_Randr_Dialog_Output_Dialog_Data *odd = NULL; - Evas_Object *rep = NULL; - Eina_Rectangle p_geo = {.x = 0, .y = 0, .w = 0, .h = 0}, geo, rep_geo, s_geo; - int dxa = INT_MAX, dya = INT_MAX, tmp, min_dist; - Eina_List *li; + Eina_List *possible_reps = NULL, *li; + Position_Suggestion *ps; + int max_dist; + Eina_Bool visible; + Eina_Rectangle o_geo; + const Evas_Object_Rel_Pos allowed_pos = (EVAS_OBJECT_REL_POS_ALL | EVAS_OBJECT_REL_POS_X_ZERO | EVAS_OBJECT_REL_POS_Y_ZERO); if (!obj) return; - min_dist = e_config_runtime_info->gui.widgets.arrangement.suggestion_dist_min; - - e_layout_child_geometry_get(obj, &geo.x, &geo.y, &geo.w, &geo.h); - e_layout_virtual_size_get(e_config_runtime_info->gui.widgets.arrangement.area, &p_geo.w, &p_geo.h); - - s_geo.x = geo.x; - s_geo.y = geo.y; - s_geo.w = geo.w; - s_geo.h = geo.h; - - //compare possible positions - //aritifical (relative) 0x0 element - tmp = s_geo.x; - if ((tmp < dxa) && (tmp < min_dist)) - { - s_geo.x = p_geo.x; - dxa = tmp; - } - tmp = s_geo.y; - if ((tmp < dya) && (tmp < min_dist)) - { - s_geo.y = p_geo.y; - dya = tmp; - } + max_dist = e_config_runtime_info->gui.widgets.arrangement.suggestion_dist_max; //iterate rep list EINA_LIST_FOREACH(e_config_runtime_info->output_dialog_data_list, li, odd) { - if (!odd) continue; - rep = odd->rep; - if (!rep || (rep == obj)) + if (!odd || !odd->rep || (odd->rep == obj) || !(odd->crtc) || !(odd->crtc->current_mode)) continue; - - e_layout_child_geometry_get(rep, &rep_geo.x, &rep_geo.y, &rep_geo.w, &rep_geo.h); - //X-Axis - tmp = abs(s_geo.x - rep_geo.x); - if ((tmp < dxa) && (tmp < min_dist)) - { - s_geo.x = rep_geo.x; - dxa = abs(s_geo.x - rep_geo.x); - } - - tmp = abs(s_geo.x - (rep_geo.x + rep_geo.w)); - if ((tmp < dxa) && (tmp < min_dist)) - { - s_geo.x = (rep_geo.x + rep_geo.w); - dxa = tmp; - } - - tmp = abs((s_geo.x + s_geo.w) - (rep_geo.x - 1)); - if ((tmp < dxa) && (tmp < min_dist)) - { - s_geo.x = (rep_geo.x - s_geo.w); - dxa = tmp; - } - - tmp = abs((s_geo.x + s_geo.w) - (rep_geo.x + rep_geo.w)); - if ((tmp < dxa) && (tmp < min_dist)) - { - s_geo.x = (rep_geo.x + rep_geo.w - s_geo.w); - dxa = tmp; - } - - //Y-Axis - tmp = abs(s_geo.y - rep_geo.y); - if ((tmp < dya) && (tmp < min_dist)) - { - s_geo.y = rep_geo.y; - dya = abs(s_geo.y - rep_geo.y); - } - - tmp = abs(s_geo.y - (rep_geo.y + rep_geo.h)); - if ((tmp < dya) && (tmp < min_dist)) - { - s_geo.y = (rep_geo.y + rep_geo.h); - dya = tmp; - } - - tmp = abs((s_geo.y + s_geo.h) - (rep_geo.y - 1)); - if ((tmp < dya) && (tmp < min_dist)) - { - s_geo.y = (rep_geo.y - s_geo.h); - dya = tmp; - } - - tmp = abs((s_geo.y + s_geo.h) - (rep_geo.y + rep_geo.h)); - if ((tmp < dya) && (tmp < min_dist)) - { - s_geo.y = (rep_geo.y + rep_geo.h - s_geo.h); - dya = tmp; - } + possible_reps = eina_list_append(possible_reps, odd->rep); } - if ((s_geo.x != geo.x) || (s_geo.y != geo.y)) + ps = e_layout_pos_sug_from_children_get(obj, possible_reps, max_dist, allowed_pos); + visible = evas_object_visible_get(e_config_runtime_info->gui.widgets.arrangement.suggestion); + if (!ps) { - if (s_geo.x < p_geo.x) s_geo.x = p_geo.x; - if ((s_geo.x + s_geo.w) > (p_geo.x + p_geo.w)) s_geo.x = ((p_geo.x + p_geo.w) - s_geo.w); - if (s_geo.y < p_geo.y) s_geo.y = p_geo.y; - if ((s_geo.y + s_geo.h) > (p_geo.y + p_geo.h)) s_geo.y = ((p_geo.y + p_geo.h) - s_geo.h); + if (visible) + { + edje_object_signal_emit(e_config_runtime_info->gui.widgets.arrangement.suggestion, "hide", "e"); + evas_object_hide(e_config_runtime_info->gui.widgets.arrangement.suggestion); + } + goto _mk_sug_free_ret; + } - if (!evas_object_visible_get(e_config_runtime_info->gui.widgets.arrangement.suggestion)) + /* + fprintf(stderr, "CONF_RANDR: Suggestion:\n" + "\tpos.x: %d\n" + "\tpos.y: %d\n" + "\tclsst.x: %p\n" + "\tclsst.y: %p\n", + ps->pos.x, ps->pos.y, ps->closest_objects.x, ps->closest_objects.y); + */ + odd = evas_object_data_get(obj, "rep_info"); + + e_layout_child_geometry_get(obj, &o_geo.x, &o_geo.y, &o_geo.w, &o_geo.h); + + if (ps->pos.x != POS_UNSET) + { + odd->new_pos.x = ps->pos.x; + if ((odd->new_pos.x + o_geo.w) > e_randr_screen_info.rrvd_info.randr_info_12->max_size.width) + odd->new_pos.x = POS_UNSET; + else if (odd->new_pos.x < 0) + odd->new_pos.x = 0; + } + + if (ps->pos.y != POS_UNSET) + { + odd->new_pos.y = ps->pos.y; + if ((odd->new_pos.y + o_geo.h) > e_randr_screen_info.rrvd_info.randr_info_12->max_size.height) + odd->new_pos.y = POS_UNSET; + else if (odd->new_pos.y < 0) + odd->new_pos.y = 0; + } + + if (_arrangemnet_rep_illegal_overlapping(odd) || ps->distance > max_dist) + odd->new_pos.x = odd->new_pos.y = POS_UNSET; + + if ((odd->new_pos.x != POS_UNSET) && (odd->new_pos.y != POS_UNSET)) + { + if (!visible) { evas_object_show(e_config_runtime_info->gui.widgets.arrangement.suggestion); edje_object_signal_emit(e_config_runtime_info->gui.widgets.arrangement.suggestion, "show", "e"); } - e_layout_child_resize(e_config_runtime_info->gui.widgets.arrangement.suggestion, s_geo.w, s_geo.h); - e_layout_child_move(e_config_runtime_info->gui.widgets.arrangement.suggestion, s_geo.x, s_geo.y); + e_layout_child_move(e_config_runtime_info->gui.widgets.arrangement.suggestion, odd->new_pos.x, odd->new_pos.y); + e_layout_child_resize(e_config_runtime_info->gui.widgets.arrangement.suggestion, o_geo.w, o_geo.h); e_layout_child_raise(e_config_runtime_info->gui.widgets.arrangement.suggestion); } - else + else if (visible) { edje_object_signal_emit(e_config_runtime_info->gui.widgets.arrangement.suggestion, "hide", "e"); evas_object_hide(e_config_runtime_info->gui.widgets.arrangement.suggestion); } +_mk_sug_free_ret: + free(ps); } void -arrangement_widget_free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata) +arrangement_widget_free_cfdata(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata) { E_Config_Randr_Dialog_Output_Dialog_Data *dialog_data; Eina_List *iter; @@ -544,29 +584,24 @@ Eina_Bool arrangement_widget_basic_apply_data(E_Config_Dialog *cfd __UNUSED__ , E_Config_Dialog_Data *cfdata) { E_Config_Randr_Dialog_Output_Dialog_Data *odd; - Evas_Coord_Point pos = {.x = 0, .y = 0}; Eina_Bool success = EINA_TRUE; Eina_List *iter; + //create list of all evas objects we concern EINA_LIST_FOREACH(cfdata->output_dialog_data_list, iter, odd) { - if (!odd->crtc || !odd->crtc->current_mode) + if (!odd->crtc || !odd->crtc->current_mode || (odd->new_pos.x == POS_UNSET) || (odd->new_pos.y == POS_UNSET)) continue; - e_layout_child_geometry_get(odd->rep, &pos.x, &pos.y, NULL, NULL); - fprintf(stderr, "CONF_RANDR: Rearranging CRTC %d to %d,%d\n", odd->crtc->xid, pos.x, pos.y); - /* -#define EQL(c) (pos.c == odd->crtc->geometry.c) + fprintf(stderr, "CONF_RANDR: Rearranging CRTC %d to %d,%d\n", odd->crtc->xid, odd->new_pos.x, odd->new_pos.y); +#define EQL(c) (odd->new_pos.c == odd->crtc->geometry.c) if (!EQL(x) || !EQL(y)) - success |= ecore_x_randr_crtc_pos_set(cfd->con->manager->root, odd->crtc->xid, pos.x, pos.y); + { + if (!ecore_x_randr_crtc_pos_set(cfd->con->manager->root, odd->crtc->xid, odd->new_pos.x, odd->new_pos.y)) + success = EINA_FALSE; + } #undef EQL -*/ - odd->previous_pos.x = odd->crtc->geometry.x; - odd->previous_pos.y = odd->crtc->geometry.y; } - /* - if (success) - ecore_x_randr_screen_reset(cfd->con->manager->root); - */ + ecore_x_randr_screen_reset(cfd->con->manager->root); return success; } @@ -574,16 +609,18 @@ Eina_Bool arrangement_widget_basic_check_changed(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata) { E_Config_Randr_Dialog_Output_Dialog_Data *odd = NULL; - Evas_Coord_Point pos = {.x = 0, .y = 0}; Eina_List *iter; + /* + * This assumes that only positions for elements are allowed, that have been + * previously suggested. Thus every element has its position already assigned. + */ EINA_LIST_FOREACH(cfdata->output_dialog_data_list, iter, odd) { - if (!odd->crtc || !odd->crtc->current_mode) + fprintf(stderr, "CONF_RANDR: Checking coord of odd %p. new_pos is: %d,%d\n", odd, odd->new_pos.x, odd->new_pos.y); + if (!odd->crtc || !odd->crtc->current_mode || (odd->new_pos.x == POS_UNSET) || (odd->new_pos.y == POS_UNSET)) continue; - e_layout_child_geometry_get(odd->rep, &pos.x, &pos.y, NULL, NULL); - fprintf(stderr, "CONF_RANDR: Checking coord of CRTC %d. They are: %d,%d\n", odd->crtc->xid, pos.x, pos.y); -#define EQL(c) (pos.c == odd->crtc->geometry.c) +#define EQL(c) (odd->new_pos.c == odd->crtc->geometry.c) if (!EQL(x) || !EQL(y)) return EINA_TRUE; #undef EQL @@ -594,7 +631,18 @@ arrangement_widget_basic_check_changed(E_Config_Dialog *cfd __UNUSED__, E_Config void arrangement_widget_keep_changes(E_Config_Dialog_Data *cfdata __UNUSED__) { - return; + E_Config_Randr_Dialog_Output_Dialog_Data *odd = NULL; + Eina_List *iter; + + EINA_LIST_FOREACH(cfdata->output_dialog_data_list, iter, odd) + { + if (!odd->crtc || !odd->crtc->current_mode || (odd->new_pos.x == POS_UNSET) || (odd->new_pos.y == POS_UNSET)) + continue; + //FIXME Rely on RandRR events to update data! + odd->previous_pos.x = odd->new_pos.x; + odd->previous_pos.y = odd->new_pos.y; + odd->new_pos.x = odd->new_pos.y = POS_UNSET; + } } void @@ -607,15 +655,214 @@ arrangement_widget_discard_changes(E_Config_Dialog_Data *cfdata) EINA_LIST_FOREACH(cfdata->output_dialog_data_list, iter, odd) { - if (!odd->crtc || ((odd->previous_pos.x == Ecore_X_Randr_Unset) || (odd->previous_pos.y == Ecore_X_Randr_Unset))) continue; - if (ecore_x_randr_crtc_pos_set(cfdata->manager->root, odd->crtc->xid, odd->previous_pos.x, odd->previous_pos.y)) - { + if (!odd->crtc || ((odd->previous_pos.x == POS_UNSET) || (odd->previous_pos.y == POS_UNSET))) continue; #define EQL(c) (odd->previous_pos.c == odd->crtc->geometry.c) - if (!EQL(x) || !EQL(y)) - ecore_x_randr_crtc_pos_set(cfdata->manager->root, odd->crtc->xid, odd->previous_pos.x, odd->previous_pos.y); + if (!EQL(x) || !EQL(y)) + ecore_x_randr_crtc_pos_set(cfdata->manager->root, odd->crtc->xid, odd->previous_pos.x, odd->previous_pos.y); #undef EQL - ecore_x_randr_screen_reset(cfdata->manager->root); - } } + ecore_x_randr_screen_reset(cfdata->manager->root); } +/** + * @brief suggests a position for an e_layout child @p child based on positions of objects in @p list. + * @param child The object for which a suggestion should be made + * @param children A list of e_layout children on whose positions the suggestion will be + * base + * @param max_distance The maximum distance a border is allowed to be away form + * @p obj border + * @param allowed_pos A mask defining which positions are allowed to be + * suggested. + * @return a suggested position together with the closest children + */ +static Position_Suggestion +*e_layout_pos_sug_from_children_get(Evas_Object *child, Eina_List *children, int max_distance, Evas_Object_Rel_Pos allowed_pos) +{ + Position_Suggestion *ps = NULL; + Evas_Object *io = NULL; + Eina_Rectangle og, ig; + Evas_Coord_Point cd, d; + Eina_List *iter; + + if (!child || !children || !allowed_pos) + return NULL; + + //General initialization + e_layout_child_geometry_get(child, &og.x, &og.y, &og.w, &og.h); + cd.x = d.x = INT_MAX; + cd.y = d.y = INT_MAX; + + //initialize returned object + ps = E_NEW(Position_Suggestion, 1); + ps->closest_objects.pos_rel.x = ps->closest_objects.pos_rel.y = EVAS_OBJECT_REL_POS_NONE; + ps->pos.x = ps->pos.y = POS_UNSET; + + EINA_LIST_FOREACH(children, iter, io) + { + if (!io) + continue; + + e_layout_child_geometry_get(io, &ig.x, &ig.y, &ig.w, &ig.h); + + // Top + if (allowed_pos & EVAS_OBJECT_REL_POS_TOP_TOP) + { + cd.y = abs((og.y + og.h) - ig.y); + if ((cd.y <= max_distance) && (cd.y < d.y)) + { + d.y = cd.y; + ps->pos.y = ig.y - og.h; + ps->closest_objects.y = io; + ps->closest_objects.pos_rel.y = EVAS_OBJECT_REL_POS_TOP_TOP; + } + } + + if (allowed_pos & EVAS_OBJECT_REL_POS_TOP_BOTTOM) + { + cd.y = abs(og.y - ig.y); + if ((cd.y <= max_distance) && (cd.y < d.y)) + { + d.y = cd.y; + ps->pos.y = ig.y; + ps->closest_objects.y = io; + ps->closest_objects.pos_rel.y = EVAS_OBJECT_REL_POS_TOP_BOTTOM; + } + } + + + // Right + if (allowed_pos & EVAS_OBJECT_REL_POS_RIGHT_RIGHT) + { + cd.x = abs(og.x - (ig.x + ig.w)); + if ((cd.x <= max_distance) && (cd.x < d.x)) + { + d.x = cd.x; + ps->pos.x = ig.x + ig.w; + ps->closest_objects.x = io; + ps->closest_objects.pos_rel.x = EVAS_OBJECT_REL_POS_RIGHT_RIGHT; + } + } + + if (allowed_pos & EVAS_OBJECT_REL_POS_RIGHT_LEFT) + { + cd.x = abs((og.x + og.w) - (ig.x + ig.w)); + if ((cd.x <= max_distance) && (cd.x < d.x)) + { + d.x = cd.x; + ps->pos.x = (ig.x + ig.w) - og.w; + ps->closest_objects.x = io; + ps->closest_objects.pos_rel.x = EVAS_OBJECT_REL_POS_RIGHT_LEFT; + } + } + + + // BOTTOM + if (allowed_pos & EVAS_OBJECT_REL_POS_BOTTOM_BOTTOM) + { + cd.y = abs(og.y - (ig.y + ig.h)); + if ((cd.y <= max_distance) && (cd.y < d.y)) + { + d.y = cd.y; + ps->pos.y = ig.y + ig.h; + ps->closest_objects.y = io; + ps->closest_objects.pos_rel.y = EVAS_OBJECT_REL_POS_BOTTOM_BOTTOM; + } + } + + if (allowed_pos & EVAS_OBJECT_REL_POS_BOTTOM_TOP) + { + cd.y = abs((ig.y + ig.h) - (og.y + og.h)); + if ((cd.y <= max_distance) && (cd.y < d.y)) + { + d.y = cd.y; + ps->pos.y = (ig.y + ig.h) - og.h; + ps->closest_objects.y = io; + ps->closest_objects.pos_rel.y = EVAS_OBJECT_REL_POS_BOTTOM_TOP; + } + } + + + // Left + if (allowed_pos & EVAS_OBJECT_REL_POS_LEFT_LEFT) + { + cd.x = abs((og.x + og.w) - ig.x); + if ((cd.x <= max_distance) && (cd.x < d.x)) + { + d.x = cd.x; + ps->pos.x = (ig.x - og.w); + ps->closest_objects.x = io; + ps->closest_objects.pos_rel.x = EVAS_OBJECT_REL_POS_LEFT_LEFT; + } + } + + if (allowed_pos & EVAS_OBJECT_REL_POS_LEFT_RIGHT) + { + cd.x = abs(og.x - ig.x); + if ((cd.x <= max_distance) && (cd.x < d.x)) + { + d.x = cd.x; + ps->pos.x = ig.x; + ps->closest_objects.x = io; + ps->closest_objects.pos_rel.x = EVAS_OBJECT_REL_POS_LEFT_RIGHT; + } + } + } + + //FIXME: these are copied from the loop above, thus dupclicated code! + if (allowed_pos & EVAS_OBJECT_REL_POS_X_ZERO) + { + io = NULL; + ig.x = 0; + cd.x = abs(og.x - ig.x); + if ((cd.x <= max_distance) && (cd.x < d.x)) + { + d.x = cd.x; + ps->pos.x = ig.x; + ps->closest_objects.x = io; + ps->closest_objects.pos_rel.x = EVAS_OBJECT_REL_POS_X_ZERO; + } + } + if (allowed_pos & EVAS_OBJECT_REL_POS_Y_ZERO) + { + io = NULL; + ig.y = 0; + cd.y = abs(og.y - ig.y); + if ((cd.y <= max_distance) && (cd.y < d.y)) + { + d.y = cd.y; + ps->pos.y = ig.y; + ps->closest_objects.y = io; + ps->closest_objects.pos_rel.y = EVAS_OBJECT_REL_POS_Y_ZERO; + } + } + ps->distance = MIN(d.x, d.y); + + return ps; +} + +/* + * E17 does not allow CRTCs (or rather zones) to overlap. + * This functions evaluates whether a new position does interfere with already + * available zones. + */ +Eina_Bool +_arrangemnet_rep_illegal_overlapping(E_Config_Randr_Dialog_Output_Dialog_Data *odd) +{ + E_Config_Randr_Dialog_Output_Dialog_Data *r_odd = NULL; + Eina_List *it; + Eina_Rectangle o_geo, r_geo; + + e_layout_child_geometry_get(odd->rep, &o_geo.x, &o_geo.y, &o_geo.w, &o_geo.h); + EINA_LIST_FOREACH(e_config_runtime_info->output_dialog_data_list, it, r_odd) + { + if (!odd || (r_odd == odd)) + continue; + e_layout_child_geometry_get(r_odd->rep, &r_geo.x, &r_geo.y, &r_geo.w, &r_geo.h); + + if (eina_rectangles_intersect(&o_geo, &r_geo) + && memcmp(&o_geo, &r_geo, sizeof(Eina_Rectangle))) + return EINA_TRUE; + } + + return EINA_FALSE; +} diff --git a/src/modules/conf_randr/e_int_config_randr_orientation.c b/src/modules/conf_randr/e_int_config_randr_orientation.c index 8b006b678..cdc14e0b5 100644 --- a/src/modules/conf_randr/e_int_config_randr_orientation.c +++ b/src/modules/conf_randr/e_int_config_randr_orientation.c @@ -5,53 +5,49 @@ #define Ecore_X_Randr_Unset -1 #endif -#define RANDR_DIALOG_ORIENTATION_ALL (ECORE_X_RANDR_ORIENTATION_ROT_0 | ECORE_X_RANDR_ORIENTATION_ROT_90 | ECORE_X_RANDR_ORIENTATION_ROT_180 | ECORE_X_RANDR_ORIENTATION_ROT_270 | ECORE_X_RANDR_ORIENTATION_ROT_270 | ECORE_X_RANDR_ORIENTATION_FLIP_X | ECORE_X_RANDR_ORIENTATION_FLIP_Y) - -Eina_Bool orientation_widget_create_data(E_Config_Dialog_Data *cfdata); -Evas_Object *orientation_widget_basic_create_widgets(Evas *canvas); -Eina_Bool orientation_widget_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); -Eina_Bool orientation_widget_basic_check_changed(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); -Eina_Bool orientation_widget_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); -void orientation_widget_update_radio_buttons(Evas_Object *crtc); -void orientation_widget_update_edje(Evas_Object *crtc); - -//static void _orientation_widget_mouse_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void _orientation_widget_mouse_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void _orientation_widget_radio_add_callbacks(void); extern E_Config_Dialog_Data *e_config_runtime_info; extern char _theme_file_path[]; /* - static void - _orientation_widget_radio_add_callbacks(void) - { - evas_object_event_callback_add (e_config_runtime_info->gui.widgets.orientation.radio_reflect_vertical, EVAS_CALLBACK_MOUSE_UP, _orientation_widget_mouse_up_cb, NULL); - evas_object_event_callback_add (e_config_runtime_info->gui.widgets.orientation.radio_reflect_horizontal, EVAS_CALLBACK_MOUSE_UP, _orientation_widget_mouse_up_cb, NULL); - evas_object_event_callback_add (e_config_runtime_info->gui.widgets.orientation.radio_rot270, EVAS_CALLBACK_MOUSE_UP, _orientation_widget_mouse_up_cb, NULL); - evas_object_event_callback_add (e_config_runtime_info->gui.widgets.orientation.radio_rot180, EVAS_CALLBACK_MOUSE_UP, _orientation_widget_mouse_up_cb, NULL); - evas_object_event_callback_add (e_config_runtime_info->gui.widgets.orientation.radio_rot90, EVAS_CALLBACK_MOUSE_UP, _orientation_widget_mouse_up_cb, NULL); - evas_object_event_callback_add (e_config_runtime_info->gui.widgets.orientation.radio_normal, EVAS_CALLBACK_MOUSE_UP, _orientation_widget_mouse_up_cb, NULL); - } - */ +static const char *_ORIENTATION_STRINGS[] = { + "Normal", + "Rotated, 90°", + "Rotated, 180°", + "Rotated, 270°", + "Flipped, Horizontally", + "Flipped, Vertically" }; + */ Eina_Bool orientation_widget_create_data(E_Config_Dialog_Data *cfdata) { E_Config_Randr_Dialog_Output_Dialog_Data *odd; - E_Randr_Crtc_Info *ci; Eina_List *iter; if (!cfdata || !cfdata->output_dialog_data_list) return EINA_FALSE; EINA_LIST_FOREACH(cfdata->output_dialog_data_list, iter, odd) { - ci = odd->crtc; - if (!ci || !ci->current_mode) continue; odd->new_orientation = Ecore_X_Randr_Unset; - odd->previous_orientation = ci->current_orientation; + odd->previous_orientation = odd->crtc ? odd->crtc->current_orientation : Ecore_X_Randr_Unset; } return EINA_TRUE; } +void +orientation_widget_free_cfdata(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata) +{ + evas_object_event_callback_del(cfdata->gui.widgets.orientation.radio_reflect_vertical, EVAS_CALLBACK_MOUSE_UP, _orientation_widget_mouse_up_cb); + evas_object_event_callback_del(cfdata->gui.widgets.orientation.radio_reflect_horizontal, EVAS_CALLBACK_MOUSE_UP, _orientation_widget_mouse_up_cb); + evas_object_event_callback_del(cfdata->gui.widgets.orientation.radio_rot270, EVAS_CALLBACK_MOUSE_UP, _orientation_widget_mouse_up_cb); + evas_object_event_callback_del(cfdata->gui.widgets.orientation.radio_rot180, EVAS_CALLBACK_MOUSE_UP, _orientation_widget_mouse_up_cb); + evas_object_event_callback_del(cfdata->gui.widgets.orientation.radio_rot90, EVAS_CALLBACK_MOUSE_UP, _orientation_widget_mouse_up_cb); + evas_object_event_callback_del(cfdata->gui.widgets.orientation.radio_normal, EVAS_CALLBACK_MOUSE_UP, _orientation_widget_mouse_up_cb); +} + Evas_Object * orientation_widget_basic_create_widgets(Evas *canvas) { @@ -86,7 +82,7 @@ orientation_widget_basic_create_widgets(Evas *canvas) e_config_runtime_info->gui.widgets.orientation.radio_reflect_vertical = e_widget_radio_add(canvas, _("Flipped, vertically"), ECORE_X_RANDR_OUTPUT_POLICY_NONE, rg); e_widget_framelist_object_append(widget, e_config_runtime_info->gui.widgets.orientation.radio_reflect_vertical); - //_orientation_widget_radio_add_callbacks(); + _orientation_widget_radio_add_callbacks(); /* // Add orientation demonstration edje @@ -120,12 +116,14 @@ _orientation_widget_radio_add_fail: return NULL; } -#if 0 static void -_orientation_widget_mouse_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) +_orientation_widget_mouse_up_cb(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) { - char signal[40]; - int orientation = ECORE_X_RANDR_ORIENTATION_ROT_0; + //char signal[40]; + int orientation = Ecore_X_Randr_Unset; + + if (!e_config_runtime_info->gui.selected_output_dd) + return; /* * IMPROVABLE: @@ -141,15 +139,13 @@ _orientation_widget_mouse_up_cb(void *data, Evas *e, Evas_Object *obj, void *eve if (obj == e_config_runtime_info->gui.widgets.orientation.radio_reflect_horizontal) orientation = ECORE_X_RANDR_ORIENTATION_FLIP_X; if (obj == e_config_runtime_info->gui.widgets.orientation.radio_reflect_vertical) orientation = ECORE_X_RANDR_ORIENTATION_FLIP_Y; - snprintf(signal, sizeof(signal), "conf,randr,dialog,orientation,%d", orientation); + e_config_runtime_info->gui.selected_output_dd->new_orientation = orientation; - edje_object_signal_emit(e_config_runtime_info->gui.widgets.orientation.swallowing_edje, signal, "e"); + //edje_object_signal_emit(e_config_runtime_info->gui.widgets.orientation.swallowing_edje, signal, "e"); - fprintf(stderr, "CONF_RANDR: mouse button released. Emitted signal to orientation: %s\n", signal); + //fprintf(stderr, "CONF_RANDR: mouse button released. Emitted signal to orientation: %s\n", signal); } -#endif - void orientation_widget_update_radio_buttons(Evas_Object *crtc) { @@ -174,14 +170,14 @@ orientation_widget_update_radio_buttons(Evas_Object *crtc) { //enabled monitor supported_oris = output_dialog_data->crtc->orientations; - ori = output_dialog_data->crtc->current_orientation; + ori = (output_dialog_data->new_orientation != Ecore_X_Randr_Unset) ? output_dialog_data->new_orientation : output_dialog_data->crtc->current_orientation; } else { //disabled monitor //assume all orientations are supported - supported_oris = RANDR_DIALOG_ORIENTATION_ALL; - ori = ECORE_X_RANDR_ORIENTATION_ROT_0; + supported_oris = Ecore_X_Randr_Unset; + ori = Ecore_X_Randr_Unset; } if (supported_oris & ECORE_X_RANDR_ORIENTATION_ROT_0) @@ -217,6 +213,10 @@ orientation_widget_update_radio_buttons(Evas_Object *crtc) //toggle the switch of the currently used orientation switch (ori) { + case ECORE_X_RANDR_ORIENTATION_ROT_0: + e_widget_radio_toggle_set(e_config_runtime_info->gui.widgets.orientation.radio_normal, EINA_TRUE); + break; + case ECORE_X_RANDR_ORIENTATION_ROT_90: e_widget_radio_toggle_set(e_config_runtime_info->gui.widgets.orientation.radio_rot90, EINA_TRUE); break; @@ -237,11 +237,12 @@ orientation_widget_update_radio_buttons(Evas_Object *crtc) e_widget_radio_toggle_set(e_config_runtime_info->gui.widgets.orientation.radio_reflect_vertical, EINA_TRUE); break; - default: //== ECORE_X_RANDR_ORIENTATION_ROT_0: - e_widget_radio_toggle_set(e_config_runtime_info->gui.widgets.orientation.radio_normal, EINA_TRUE); + default: + break; } } +/* void orientation_widget_update_edje(Evas_Object *crtc) { @@ -261,6 +262,7 @@ orientation_widget_update_edje(Evas_Object *crtc) { //disabled monitor //assume all orientations are supported + //#define RANDR_DIALOG_ORIENTATION_ALL (ECORE_X_RANDR_ORIENTATION_ROT_0 | ECORE_X_RANDR_ORIENTATION_ROT_90 | ECORE_X_RANDR_ORIENTATION_ROT_180 | ECORE_X_RANDR_ORIENTATION_ROT_270 | ECORE_X_RANDR_ORIENTATION_ROT_270 | ECORE_X_RANDR_ORIENTATION_FLIP_X | ECORE_X_RANDR_ORIENTATION_FLIP_Y) supported_oris = RANDR_DIALOG_ORIENTATION_ALL; ori = ECORE_X_RANDR_ORIENTATION_ROT_0; } @@ -270,38 +272,46 @@ orientation_widget_update_edje(Evas_Object *crtc) snprintf(signal, sizeof(signal), "conf,randr,dialog,orientation,current,%d", ori); edje_object_signal_emit(crtc, signal, "e"); } +*/ Eina_Bool -orientation_widget_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata __UNUSED__) +orientation_widget_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) { - Ecore_X_Randr_Orientation orientation; - E_Config_Randr_Dialog_Output_Dialog_Data *output_dialog_data; + E_Config_Randr_Dialog_Output_Dialog_Data *odd; + Eina_List *iter; + Eina_Bool success = EINA_TRUE; - if (!e_config_runtime_info->gui.widgets.orientation.widget || !e_config_runtime_info->gui.selected_eo || !(output_dialog_data = evas_object_data_get(e_config_runtime_info->gui.selected_eo, "rep_info")) || !output_dialog_data->crtc) return EINA_FALSE; + if (!cfdata) return EINA_FALSE; - orientation = e_config_runtime_info->gui.widgets.orientation.radio_val; - - fprintf(stderr, "CONF_RANDR: Change orientation of crtc %d to %d.\n", output_dialog_data->crtc->xid, orientation); - - if (ecore_x_randr_crtc_orientation_set(cfd->con->manager->root, output_dialog_data->crtc->xid, orientation)) + EINA_LIST_FOREACH(cfdata->output_dialog_data_list, iter, odd) { - ecore_x_randr_screen_reset(cfd->con->manager->root); - output_dialog_data->previous_orientation = output_dialog_data->new_orientation; - output_dialog_data->new_orientation = orientation; - return EINA_TRUE; + if (!odd || !odd->crtc || ((int)odd->new_orientation == Ecore_X_Randr_Unset)) + continue; + fprintf(stderr, "CONF_RANDR: Change orientation of crtc %d to %d.\n", odd->crtc->xid, odd->new_orientation); + if (!ecore_x_randr_crtc_orientation_set(cfd->con->manager->root, odd->crtc->xid, odd->new_orientation)) + success = EINA_FALSE; } - else - return EINA_FALSE; + + return success; } Eina_Bool -orientation_widget_basic_check_changed(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata __UNUSED__) +orientation_widget_basic_check_changed(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata) { - E_Config_Randr_Dialog_Output_Dialog_Data *output_dialog_data; + E_Config_Randr_Dialog_Output_Dialog_Data *odd; + Eina_List *iter; - if (!e_config_runtime_info->gui.widgets.orientation.widget || !e_config_runtime_info->gui.selected_eo || !(output_dialog_data = evas_object_data_get(e_config_runtime_info->gui.selected_eo, "rep_info"))) return EINA_FALSE; + if (!cfdata) return EINA_FALSE; - return (int)output_dialog_data->previous_orientation != (int)e_config_runtime_info->gui.widgets.orientation.radio_val; + EINA_LIST_FOREACH(cfdata->output_dialog_data_list, iter, odd) + { + if (!odd || !odd->crtc || ((int)odd->previous_orientation == Ecore_X_Randr_Unset) || ((int)odd->new_orientation == Ecore_X_Randr_Unset)) + continue; + if (odd->previous_orientation != odd->new_orientation) + return EINA_TRUE; + } + + return EINA_FALSE; } void @@ -314,7 +324,8 @@ orientation_widget_keep_changes(E_Config_Dialog_Data *cfdata) EINA_LIST_FOREACH(cfdata->output_dialog_data_list, iter, odd) { - if (!odd || ((int)odd->previous_orientation == Ecore_X_Randr_Unset)) continue; + if (!odd || ((int)odd->previous_orientation == Ecore_X_Randr_Unset)) + continue; odd->previous_orientation = odd->new_orientation; odd->new_orientation = Ecore_X_Randr_Unset; } @@ -330,13 +341,20 @@ orientation_widget_discard_changes(E_Config_Dialog_Data *cfdata) EINA_LIST_FOREACH(cfdata->output_dialog_data_list, iter, odd) { - if (!odd->crtc || ((int)odd->previous_orientation == Ecore_X_Randr_Unset)) continue; - if (ecore_x_randr_crtc_orientation_set(cfdata->manager->root, odd->crtc->xid, odd->previous_orientation)) - { - odd->new_orientation = odd->previous_orientation; - odd->previous_orientation = Ecore_X_Randr_Unset; - ecore_x_randr_screen_reset(cfdata->manager->root); - } + if (!odd->crtc || ((int)odd->previous_orientation == Ecore_X_Randr_Unset)) + continue; + ecore_x_randr_crtc_orientation_set(cfdata->manager->root, odd->crtc->xid, odd->previous_orientation); + odd->new_orientation = Ecore_X_Randr_Unset; } } + static void +_orientation_widget_radio_add_callbacks(void) +{ + evas_object_event_callback_add(e_config_runtime_info->gui.widgets.orientation.radio_reflect_vertical, EVAS_CALLBACK_MOUSE_UP, _orientation_widget_mouse_up_cb, NULL); + evas_object_event_callback_add(e_config_runtime_info->gui.widgets.orientation.radio_reflect_horizontal, EVAS_CALLBACK_MOUSE_UP, _orientation_widget_mouse_up_cb, NULL); + evas_object_event_callback_add(e_config_runtime_info->gui.widgets.orientation.radio_rot270, EVAS_CALLBACK_MOUSE_UP, _orientation_widget_mouse_up_cb, NULL); + evas_object_event_callback_add(e_config_runtime_info->gui.widgets.orientation.radio_rot180, EVAS_CALLBACK_MOUSE_UP, _orientation_widget_mouse_up_cb, NULL); + evas_object_event_callback_add(e_config_runtime_info->gui.widgets.orientation.radio_rot90, EVAS_CALLBACK_MOUSE_UP, _orientation_widget_mouse_up_cb, NULL); + evas_object_event_callback_add(e_config_runtime_info->gui.widgets.orientation.radio_normal, EVAS_CALLBACK_MOUSE_UP, _orientation_widget_mouse_up_cb, NULL); +} diff --git a/src/modules/conf_randr/e_int_config_randr_policies.c b/src/modules/conf_randr/e_int_config_randr_policies.c deleted file mode 100644 index 159715baf..000000000 --- a/src/modules/conf_randr/e_int_config_randr_policies.c +++ /dev/null @@ -1,317 +0,0 @@ -#include "e_int_config_randr.h" -#include "e_randr.h" - -#ifndef ECORE_X_RANDR_1_2 -#define ECORE_X_RANDR_1_2 ((1 << 16) | 2) -#endif -#ifndef ECORE_X_RANDR_1_3 -#define ECORE_X_RANDR_1_3 ((1 << 16) | 3) -#endif - -#ifndef Ecore_X_Randr_Unset -#define Ecore_X_Randr_Unset -1 -#endif - -#define E_RANDR_12 (e_randr_screen_info.rrvd_info.randr_info_12) - -Evas_Object *policy_widget_basic_create_widgets(Evas *canvas); -Eina_Bool policy_widget_create_data(E_Config_Dialog_Data *e_config_runtime_info); -Eina_Bool policy_widget_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); -Eina_Bool policy_widget_basic_check_changed(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); -Eina_Bool policy_widget_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); -void policy_widget_update_radio_buttons(Evas_Object *rep); - -//static void _policy_widget_policy_mouse_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); -extern E_Config_Dialog_Data *e_config_runtime_info; -extern char _theme_file_path[]; - -static const char *_POLICIES_STRINGS[] = { - "ABOVE", - "RIGHT", - "BELOW", - "LEFT", - "CLONE", - "NONE"}; - - -/* - static void - _policy_widget_radio_add_callbacks(void) - { - evas_object_event_callback_add(e_config_runtime_info->gui.widgets.policies.radio_none, EVAS_CALLBACK_MOUSE_UP, _policy_widget_policy_mouse_up_cb, NULL); - evas_object_event_callback_add(e_config_runtime_info->gui.widgets.policies.radio_clone, EVAS_CALLBACK_MOUSE_UP, _policy_widget_policy_mouse_up_cb, NULL); - evas_object_event_callback_add(e_config_runtime_info->gui.widgets.policies.radio_left, EVAS_CALLBACK_MOUSE_UP, _policy_widget_policy_mouse_up_cb, NULL); - evas_object_event_callback_add(e_config_runtime_info->gui.widgets.policies.radio_below, EVAS_CALLBACK_MOUSE_UP, _policy_widget_policy_mouse_up_cb, NULL); - evas_object_event_callback_add(e_config_runtime_info->gui.widgets.policies.radio_above, EVAS_CALLBACK_MOUSE_UP, _policy_widget_policy_mouse_up_cb, NULL); - evas_object_event_callback_add(e_config_runtime_info->gui.widgets.policies.radio_right, EVAS_CALLBACK_MOUSE_UP, _policy_widget_policy_mouse_up_cb, NULL); - } - */ - -Eina_Bool -policy_widget_create_data(E_Config_Dialog_Data *data) -{ - E_Config_Randr_Dialog_Output_Dialog_Data *odd; - E_Randr_Output_Info *oi = NULL; - Eina_List *iter; - - if (!data || !data->output_dialog_data_list) return EINA_FALSE; - - EINA_LIST_FOREACH(data->output_dialog_data_list, iter, odd) - { - if (odd->crtc) - oi = eina_list_data_get(odd->crtc->outputs); - else if (odd->output) - oi = odd->output; - if (!oi) - continue; - odd->previous_policy = oi->policy; - odd->new_policy = oi->policy; - fprintf(stderr, "CONF_RANDR: Read in policy of %d as %s.\n", oi->xid, _POLICIES_STRINGS[odd->new_policy - 1]); - } - - return EINA_TRUE; -} - -Evas_Object * -policy_widget_basic_create_widgets(Evas *canvas) -{ - Evas_Object *widget; - E_Radio_Group *rg; - //char signal[29]; - - if (!canvas || !e_config_runtime_info) return NULL; - - if (e_config_runtime_info->gui.widgets.policies.widget) return e_config_runtime_info->gui.widgets.policies.widget; - - if (!(widget = e_widget_framelist_add(canvas, _("Screen attachement policy"), EINA_FALSE))) return NULL; - - // Add radio buttons - if (!(rg = e_widget_radio_group_new(&e_config_runtime_info->gui.widgets.policies.radio_val))) goto _policy_widget_radio_add_fail; - - //IMPROVABLE: use enum to determine objects via 'switch'-statement - e_config_runtime_info->gui.widgets.policies.radio_above = e_widget_radio_add(canvas, _("Above"), ECORE_X_RANDR_OUTPUT_POLICY_ABOVE, rg); - e_widget_framelist_object_append(widget, e_config_runtime_info->gui.widgets.policies.radio_above); - - e_config_runtime_info->gui.widgets.policies.radio_right = e_widget_radio_add(canvas, _("Right"), ECORE_X_RANDR_OUTPUT_POLICY_RIGHT, rg); - e_widget_framelist_object_append(widget, e_config_runtime_info->gui.widgets.policies.radio_right); - - e_config_runtime_info->gui.widgets.policies.radio_below = e_widget_radio_add(canvas, _("Below"), ECORE_X_RANDR_OUTPUT_POLICY_BELOW, rg); - e_widget_framelist_object_append(widget, e_config_runtime_info->gui.widgets.policies.radio_below); - - e_config_runtime_info->gui.widgets.policies.radio_left = e_widget_radio_add(canvas, _("Left"), ECORE_X_RANDR_OUTPUT_POLICY_LEFT, rg); - e_widget_framelist_object_append(widget, e_config_runtime_info->gui.widgets.policies.radio_left); - - e_config_runtime_info->gui.widgets.policies.radio_clone = e_widget_radio_add(canvas, _("Clone display content"), ECORE_X_RANDR_OUTPUT_POLICY_CLONE, rg); - e_widget_framelist_object_append(widget, e_config_runtime_info->gui.widgets.policies.radio_clone); - - e_config_runtime_info->gui.widgets.policies.radio_none = e_widget_radio_add(canvas, _("No reaction"), ECORE_X_RANDR_OUTPUT_POLICY_NONE, rg); - e_widget_framelist_object_append(widget, e_config_runtime_info->gui.widgets.policies.radio_none); - - //_policy_widget_radio_add_callbacks(); - - /* - // Add policies demonstration edje - if (!(e_config_runtime_info->gui.widgets.policies.swallowing_edje = edje_object_add(canvas))) - { - goto _policy_widget_edje_add_fail; - - } - if (!edje_object_file_set(e_config_runtime_info->gui.widgets.policies.swallowing_edje, _theme_file_path, "e/conf/randr/dialog/widget/policies")) - { - goto _policy_widget_edje_set_fail; - } - - e_widget_table_object_align_append(widget, e_config_runtime_info->gui.widgets.policies.swallowing_edje, 1, 0, 1, 1, 1, 1, 1, 1, 1.0, 1.0); - */ - - /* - evas_object_show(e_config_runtime_info->gui.widgets.policies.swallowing_edje); - - //emit signal to edje so a demonstration can be shown - snprintf(signal, sizeof(signal), "conf,randr,dialog,policies,%d", e_randr_screen_info->rrvd_info.randr_info_12->output_policy); - edje_object_signal_emit(e_config_runtime_info->gui.widgets.policies.swallowing_edje, signal, "e"); - fprintf(stderr, "CONF_RANDR: Initial signal emitted to policy dialog: %s\n", signal); - - //Use theme's background as screen representation - e_config_runtime_info->gui.widgets.policies.new_display = edje_object_add(canvas); - e_theme_edje_object_set(e_config_runtime_info->gui.widgets.policies.new_display, "base/theme/widgets", "e/widgets/frame"); - e_config_runtime_info->gui.widgets.policies.new_display_background = edje_object_add(canvas); - e_theme_edje_object_set(e_config_runtime_info->gui.widgets.policies.new_display_background, "base/theme/background", "e/desktop/background"); - edje_object_part_swallow(e_config_runtime_info->gui.widgets.policies.new_display, "e.swallow.content", e_config_runtime_info->gui.widgets.policies.new_display_background); - edje_object_part_text_set(e_config_runtime_info->gui.widgets.policies.new_display, "e.text.label", _("New display")); - edje_object_part_swallow(e_config_runtime_info->gui.widgets.policies.swallowing_edje, "new_display.swallow.content", e_config_runtime_info->gui.widgets.policies.new_display); - //add theme's frame - //for now use the theme's background for the new display as well - e_config_runtime_info->gui.widgets.policies.current_displays_setup = edje_object_add(canvas); - e_theme_edje_object_set(e_config_runtime_info->gui.widgets.policies.current_displays_setup, "base/theme/widgets", "e/widgets/frame"); - e_config_runtime_info->gui.widgets.policies.current_displays_setup_background = edje_object_add(canvas); - e_theme_edje_object_set(e_config_runtime_info->gui.widgets.policies.current_displays_setup_background, "base/theme/background", "e/desktop/background"); - edje_object_part_swallow(e_config_runtime_info->gui.widgets.policies.current_displays_setup, "e.swallow.content", e_config_runtime_info->gui.widgets.policies.current_displays_setup_background); - edje_object_part_text_set(e_config_runtime_info->gui.widgets.policies.current_displays_setup, "e.text.label", _("Used display")); - edje_object_part_swallow(e_config_runtime_info->gui.widgets.policies.swallowing_edje, "current_displays_setup.swallow.content", e_config_runtime_info->gui.widgets.policies.current_displays_setup); - */ - - evas_object_show(widget); - - return widget; - - /* - _policy_widget_edje_set_fail: - evas_object_del(e_config_runtime_info->gui.widgets.policies.swallowing_edje); - _policy_widget_edje_add_fail: - fprintf(stderr, "CONF_RANDR: Couldn't set edj for policies widget!\n"); - evas_object_del(widget); - return NULL; - */ -_policy_widget_radio_add_fail: - evas_object_del(widget); - return NULL; -} - -/* - * The current dialog does not demonstrate what the policies mean, so disabled - * for now. - * -static void -_policy_widget_policy_mouse_up_cb(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) -{ - char signal[29]; - int policy = ECORE_X_RANDR_OUTPUT_POLICY_NONE; - - * IMPROVABLE: - * "sadly" the evas callbacks are called before radio_val is set to its new - * value. If that is ever changed, remove the used code below and just use the - * 1-liner below. - * snprintf(signal, sizeof(signal), "conf,randr,dialog,policies,%d", e_config_runtime_info->gui.widgets.policies.radio_val); - * / - if (obj == e_config_runtime_info->gui.widgets.policies.radio_above) policy = ECORE_X_RANDR_OUTPUT_POLICY_ABOVE; - if (obj == e_config_runtime_info->gui.widgets.policies.radio_right) policy = ECORE_X_RANDR_OUTPUT_POLICY_RIGHT; - if (obj == e_config_runtime_info->gui.widgets.policies.radio_below) policy = ECORE_X_RANDR_OUTPUT_POLICY_BELOW; - if (obj == e_config_runtime_info->gui.widgets.policies.radio_left) policy = ECORE_X_RANDR_OUTPUT_POLICY_LEFT; - if (obj == e_config_runtime_info->gui.widgets.policies.radio_clone) policy = ECORE_X_RANDR_OUTPUT_POLICY_CLONE; - if (obj == e_config_runtime_info->gui.widgets.policies.radio_none) policy = ECORE_X_RANDR_OUTPUT_POLICY_NONE; - - snprintf(signal, sizeof(signal), "conf,randr,dialog,policies,%d", policy); - - //edje_object_signal_emit(e_config_runtime_info->gui.widgets.policies.swallowing_edje, signal, "e"); - - fprintf(stderr, "CONF_RANDR: mouse button released. Emitted signal to policy: %s\n", signal); -} -*/ - -Eina_Bool -policy_widget_basic_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata __UNUSED__) -{ - if (!E_RANDR_12 || !e_config_runtime_info->gui.selected_output_dd) return EINA_FALSE; - - //policy update - e_config_runtime_info->gui.selected_output_dd->previous_policy = e_config_runtime_info->gui.selected_output_dd->new_policy; - e_config_runtime_info->gui.selected_output_dd->new_policy = e_config_runtime_info->gui.widgets.policies.radio_val; - fprintf(stderr, "CONF_RANDR: 'New display attached'-policy set to %s.\n", _POLICIES_STRINGS[e_config_runtime_info->gui.selected_output_dd->new_policy - 1]); - - return EINA_TRUE; -} - -Eina_Bool -policy_widget_basic_check_changed(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata) -{ - if (!E_RANDR_12 || !cfdata || !cfdata->gui.selected_output_dd || !cfdata->gui.selected_output_dd->output) return EINA_FALSE; - - return (int)cfdata->gui.selected_output_dd->previous_policy != (int)cfdata->gui.widgets.policies.radio_val; -} - -void -policy_widget_update_radio_buttons(Evas_Object *rep) -{ - E_Config_Randr_Dialog_Output_Dialog_Data *output_dialog_data; - Ecore_X_Randr_Output_Policy policy; - - //disable widgets, if no rep is selected - if (!rep || !(output_dialog_data = evas_object_data_get(rep, "rep_info"))) - { - //Evas_Object *radio_above, *radio_right, *radio_below, *radio_left, *radio_clone, *radio_none; - e_widget_disabled_set(e_config_runtime_info->gui.widgets.policies.radio_above, EINA_TRUE); - e_widget_disabled_set(e_config_runtime_info->gui.widgets.policies.radio_right, EINA_TRUE); - e_widget_disabled_set(e_config_runtime_info->gui.widgets.policies.radio_below, EINA_TRUE); - e_widget_disabled_set(e_config_runtime_info->gui.widgets.policies.radio_left, EINA_TRUE); - e_widget_disabled_set(e_config_runtime_info->gui.widgets.policies.radio_clone, EINA_TRUE); - e_widget_disabled_set(e_config_runtime_info->gui.widgets.policies.radio_none, EINA_TRUE); - return; - } - else - { - e_widget_disabled_set(e_config_runtime_info->gui.widgets.policies.radio_above, EINA_FALSE); - e_widget_disabled_set(e_config_runtime_info->gui.widgets.policies.radio_right, EINA_FALSE); - e_widget_disabled_set(e_config_runtime_info->gui.widgets.policies.radio_below, EINA_FALSE); - e_widget_disabled_set(e_config_runtime_info->gui.widgets.policies.radio_left, EINA_FALSE); - e_widget_disabled_set(e_config_runtime_info->gui.widgets.policies.radio_clone, EINA_FALSE); - e_widget_disabled_set(e_config_runtime_info->gui.widgets.policies.radio_none, EINA_FALSE); - } - - policy = output_dialog_data->new_policy; - e_config_runtime_info->gui.selected_output_dd = output_dialog_data; - //toggle the switch of the currently used policies - switch (policy) - { - case ECORE_X_RANDR_OUTPUT_POLICY_RIGHT: - e_widget_radio_toggle_set(e_config_runtime_info->gui.widgets.policies.radio_right, EINA_TRUE); - break; - - case ECORE_X_RANDR_OUTPUT_POLICY_BELOW: - e_widget_radio_toggle_set(e_config_runtime_info->gui.widgets.policies.radio_below, EINA_TRUE); - break; - - case ECORE_X_RANDR_OUTPUT_POLICY_LEFT: - e_widget_radio_toggle_set(e_config_runtime_info->gui.widgets.policies.radio_left, EINA_TRUE); - break; - - case ECORE_X_RANDR_OUTPUT_POLICY_CLONE: - e_widget_radio_toggle_set(e_config_runtime_info->gui.widgets.policies.radio_clone, EINA_TRUE); - break; - - case ECORE_X_RANDR_OUTPUT_POLICY_NONE: - e_widget_radio_toggle_set(e_config_runtime_info->gui.widgets.policies.radio_none, EINA_TRUE); - break; - - default: //== ECORE_X_RANDR_OUTPUT_POLICY_ABOVE: - e_widget_radio_toggle_set(e_config_runtime_info->gui.widgets.policies.radio_above, EINA_TRUE); - } -} - -void -policy_widget_keep_changes(E_Config_Dialog_Data *cfdata) -{ - E_Config_Randr_Dialog_Output_Dialog_Data *odd; - E_Randr_Output_Info *oi; - Eina_List *iter; - - if (!cfdata || !cfdata->gui.selected_output_dd || !cfdata->gui.selected_output_dd->output) return; - - odd = cfdata->gui.selected_output_dd; - odd->previous_policy = odd->new_policy; - if (odd->crtc) - { - EINA_LIST_FOREACH(odd->crtc->outputs, iter, oi) - { - oi->policy = odd->new_policy; - fprintf(stderr, "CONF_RANDR: Policy change to %s kept for output %d.\n", _POLICIES_STRINGS[odd->new_policy - 1], oi->xid); - } - } - else if (odd->output) - { - odd->output->policy = odd->new_policy; - fprintf(stderr, "CONF_RANDR: Policy change to %s kept for output %d.\n", _POLICIES_STRINGS[odd->new_policy - 1], odd->output->xid); - } -} - -void -policy_widget_discard_changes(E_Config_Dialog_Data *cfdata) -{ - E_Config_Randr_Dialog_Output_Dialog_Data *odd; - - if (!cfdata || !cfdata->gui.selected_output_dd || !cfdata->gui.selected_output_dd->output) return; - - odd = cfdata->gui.selected_output_dd; - odd->new_policy = odd->previous_policy; -} - diff --git a/src/modules/conf_randr/e_int_config_randr_policy.c b/src/modules/conf_randr/e_int_config_randr_policy.c new file mode 100644 index 000000000..9b1675683 --- /dev/null +++ b/src/modules/conf_randr/e_int_config_randr_policy.c @@ -0,0 +1,354 @@ +#include "e_int_config_randr.h" +#include "e_randr.h" + +#ifndef ECORE_X_RANDR_1_2 +#define ECORE_X_RANDR_1_2 ((1 << 16) | 2) +#endif +#ifndef ECORE_X_RANDR_1_3 +#define ECORE_X_RANDR_1_3 ((1 << 16) | 3) +#endif + +#ifndef Ecore_X_Randr_Unset +#define Ecore_X_Randr_Unset -1 +#endif + +#define E_RANDR_12 (e_randr_screen_info.rrvd_info.randr_info_12) + +static void _policy_widget_mouse_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); +extern E_Config_Dialog_Data *e_config_runtime_info; +extern char _theme_file_path[]; + +static const char *_POLICIES_STRINGS[] = { + "ABOVE", + "RIGHT", + "BELOW", + "LEFT", + "CLONE", + "NONE"}; + + + static void +_policy_widget_radio_add_callbacks(void) +{ + evas_object_event_callback_add(e_config_runtime_info->gui.widgets.policy.radio_none, EVAS_CALLBACK_MOUSE_UP, _policy_widget_mouse_up_cb, NULL); + evas_object_event_callback_add(e_config_runtime_info->gui.widgets.policy.radio_clone, EVAS_CALLBACK_MOUSE_UP, _policy_widget_mouse_up_cb, NULL); + evas_object_event_callback_add(e_config_runtime_info->gui.widgets.policy.radio_left, EVAS_CALLBACK_MOUSE_UP, _policy_widget_mouse_up_cb, NULL); + evas_object_event_callback_add(e_config_runtime_info->gui.widgets.policy.radio_below, EVAS_CALLBACK_MOUSE_UP, _policy_widget_mouse_up_cb, NULL); + evas_object_event_callback_add(e_config_runtime_info->gui.widgets.policy.radio_above, EVAS_CALLBACK_MOUSE_UP, _policy_widget_mouse_up_cb, NULL); + evas_object_event_callback_add(e_config_runtime_info->gui.widgets.policy.radio_right, EVAS_CALLBACK_MOUSE_UP, _policy_widget_mouse_up_cb, NULL); +} + +Eina_Bool +policy_widget_create_data(E_Config_Dialog_Data *data) +{ + E_Config_Randr_Dialog_Output_Dialog_Data *odd; + E_Randr_Output_Info *oi = NULL; + Eina_List *iter; + + if (!data || !data->output_dialog_data_list) return EINA_FALSE; + + EINA_LIST_FOREACH(data->output_dialog_data_list, iter, odd) + { + if (odd->crtc) + oi = eina_list_data_get(odd->crtc->outputs); + else if (odd->output) + oi = odd->output; + odd->previous_policy = oi ? oi->policy : Ecore_X_Randr_Unset; + odd->new_policy = Ecore_X_Randr_Unset; + fprintf(stderr, "CONF_RANDR: Read in policy of %d as %s.\n", oi->xid, ((odd->previous_policy != Ecore_X_Randr_Unset) ? _POLICIES_STRINGS[odd->previous_policy - 1] : "unset")); + } + + return EINA_TRUE; +} + +void +policy_widget_free_cfdata(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata) +{ + evas_object_event_callback_del(cfdata->gui.widgets.policy.widget, EVAS_CALLBACK_MOUSE_UP, _policy_widget_mouse_up_cb); +} + +Evas_Object * +policy_widget_basic_create_widgets(Evas *canvas) +{ + Evas_Object *widget; + E_Radio_Group *rg; + //char signal[29]; + + if (!canvas || !e_config_runtime_info) return NULL; + + if (e_config_runtime_info->gui.widgets.policy.widget) return e_config_runtime_info->gui.widgets.policy.widget; + + if (!(widget = e_widget_framelist_add(canvas, _("Screen attachement policy"), EINA_FALSE))) return NULL; + + // Add radio buttons + if (!(rg = e_widget_radio_group_new(&e_config_runtime_info->gui.widgets.policy.radio_val))) goto _policy_widget_radio_add_fail; + + //IMPROVABLE: use enum to determine objects via 'switch'-statement + e_config_runtime_info->gui.widgets.policy.radio_above = e_widget_radio_add(canvas, _("Above"), ECORE_X_RANDR_OUTPUT_POLICY_ABOVE, rg); + e_widget_framelist_object_append(widget, e_config_runtime_info->gui.widgets.policy.radio_above); + + e_config_runtime_info->gui.widgets.policy.radio_right = e_widget_radio_add(canvas, _("Right"), ECORE_X_RANDR_OUTPUT_POLICY_RIGHT, rg); + e_widget_framelist_object_append(widget, e_config_runtime_info->gui.widgets.policy.radio_right); + + e_config_runtime_info->gui.widgets.policy.radio_below = e_widget_radio_add(canvas, _("Below"), ECORE_X_RANDR_OUTPUT_POLICY_BELOW, rg); + e_widget_framelist_object_append(widget, e_config_runtime_info->gui.widgets.policy.radio_below); + + e_config_runtime_info->gui.widgets.policy.radio_left = e_widget_radio_add(canvas, _("Left"), ECORE_X_RANDR_OUTPUT_POLICY_LEFT, rg); + e_widget_framelist_object_append(widget, e_config_runtime_info->gui.widgets.policy.radio_left); + + e_config_runtime_info->gui.widgets.policy.radio_clone = e_widget_radio_add(canvas, _("Clone display content"), ECORE_X_RANDR_OUTPUT_POLICY_CLONE, rg); + e_widget_framelist_object_append(widget, e_config_runtime_info->gui.widgets.policy.radio_clone); + + e_config_runtime_info->gui.widgets.policy.radio_none = e_widget_radio_add(canvas, _("No reaction"), ECORE_X_RANDR_OUTPUT_POLICY_NONE, rg); + e_widget_framelist_object_append(widget, e_config_runtime_info->gui.widgets.policy.radio_none); + + _policy_widget_radio_add_callbacks(); + + /* + // Add policies demonstration edje + if (!(e_config_runtime_info->gui.widgets.policy.swallowing_edje = edje_object_add(canvas))) + { + goto _policy_widget_edje_add_fail; + + } + if (!edje_object_file_set(e_config_runtime_info->gui.widgets.policy.swallowing_edje, _theme_file_path, "e/conf/randr/dialog/widget/policies")) + { + goto _policy_widget_edje_set_fail; + } + + e_widget_table_object_align_append(widget, e_config_runtime_info->gui.widgets.policy.swallowing_edje, 1, 0, 1, 1, 1, 1, 1, 1, 1.0, 1.0); + */ + + /* + evas_object_show(e_config_runtime_info->gui.widgets.policy.swallowing_edje); + + //emit signal to edje so a demonstration can be shown + snprintf(signal, sizeof(signal), "conf,randr,dialog,policies,%d", e_randr_screen_info->rrvd_info.randr_info_12->output_policy); + edje_object_signal_emit(e_config_runtime_info->gui.widgets.policy.swallowing_edje, signal, "e"); + fprintf(stderr, "CONF_RANDR: Initial signal emitted to policy dialog: %s\n", signal); + + //Use theme's background as screen representation + e_config_runtime_info->gui.widgets.policy.new_display = edje_object_add(canvas); + e_theme_edje_object_set(e_config_runtime_info->gui.widgets.policy.new_display, "base/theme/widgets", "e/widgets/frame"); + e_config_runtime_info->gui.widgets.policy.new_display_background = edje_object_add(canvas); + e_theme_edje_object_set(e_config_runtime_info->gui.widgets.policy.new_display_background, "base/theme/background", "e/desktop/background"); + edje_object_part_swallow(e_config_runtime_info->gui.widgets.policy.new_display, "e.swallow.content", e_config_runtime_info->gui.widgets.policy.new_display_background); + edje_object_part_text_set(e_config_runtime_info->gui.widgets.policy.new_display, "e.text.label", _("New display")); + edje_object_part_swallow(e_config_runtime_info->gui.widgets.policy.swallowing_edje, "new_display.swallow.content", e_config_runtime_info->gui.widgets.policy.new_display); + //add theme's frame + //for now use the theme's background for the new display as well + e_config_runtime_info->gui.widgets.policy.current_displays_setup = edje_object_add(canvas); + e_theme_edje_object_set(e_config_runtime_info->gui.widgets.policy.current_displays_setup, "base/theme/widgets", "e/widgets/frame"); + e_config_runtime_info->gui.widgets.policy.current_displays_setup_background = edje_object_add(canvas); + e_theme_edje_object_set(e_config_runtime_info->gui.widgets.policy.current_displays_setup_background, "base/theme/background", "e/desktop/background"); + edje_object_part_swallow(e_config_runtime_info->gui.widgets.policy.current_displays_setup, "e.swallow.content", e_config_runtime_info->gui.widgets.policy.current_displays_setup_background); + edje_object_part_text_set(e_config_runtime_info->gui.widgets.policy.current_displays_setup, "e.text.label", _("Used display")); + edje_object_part_swallow(e_config_runtime_info->gui.widgets.policy.swallowing_edje, "current_displays_setup.swallow.content", e_config_runtime_info->gui.widgets.policy.current_displays_setup); + */ + + evas_object_show(widget); + + return widget; + + /* + _policy_widget_edje_set_fail: + evas_object_del(e_config_runtime_info->gui.widgets.policy.swallowing_edje); + _policy_widget_edje_add_fail: + fprintf(stderr, "CONF_RANDR: Couldn't set edj for policies widget!\n"); + evas_object_del(widget); + return NULL; + */ +_policy_widget_radio_add_fail: + evas_object_del(widget); + return NULL; +} + +static void +_policy_widget_mouse_up_cb(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) +{ + //char signal[29]; + int policy = ECORE_X_RANDR_OUTPUT_POLICY_NONE; + + if (!e_config_runtime_info->gui.selected_output_dd) + return; + /* + * IMPROVABLE: + * "sadly" the evas callbacks are called before radio_val is set to its new + * value. If that is ever changed, remove the used code below and just use the + * 1-liner below. + * snprintf(signal, sizeof(signal), "conf,randr,dialog,policies,%d", e_config_runtime_info->gui.widgets.policy.radio_val); + */ + if (obj == e_config_runtime_info->gui.widgets.policy.radio_above) policy = ECORE_X_RANDR_OUTPUT_POLICY_ABOVE; + if (obj == e_config_runtime_info->gui.widgets.policy.radio_right) policy = ECORE_X_RANDR_OUTPUT_POLICY_RIGHT; + if (obj == e_config_runtime_info->gui.widgets.policy.radio_below) policy = ECORE_X_RANDR_OUTPUT_POLICY_BELOW; + if (obj == e_config_runtime_info->gui.widgets.policy.radio_left) policy = ECORE_X_RANDR_OUTPUT_POLICY_LEFT; + if (obj == e_config_runtime_info->gui.widgets.policy.radio_clone) policy = ECORE_X_RANDR_OUTPUT_POLICY_CLONE; + if (obj == e_config_runtime_info->gui.widgets.policy.radio_none) policy = ECORE_X_RANDR_OUTPUT_POLICY_NONE; + + e_config_runtime_info->gui.selected_output_dd->new_policy = policy; +/* + * The current dialog does not demonstrate what the policies mean, so disabled + * for now. + * + snprintf(signal, sizeof(signal), "conf,randr,dialog,policies,%d", policy); + //edje_object_signal_emit(e_config_runtime_info->gui.widgets.policy.swallowing_edje, signal, "e"); + fprintf(stderr, "CONF_RANDR: mouse button released. Emitted signal to policy: %s\n", signal); +*/ +} + +Eina_Bool +policy_widget_basic_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata) +{ + E_Config_Randr_Dialog_Output_Dialog_Data *odd; + Eina_List *it, *it2; + E_Randr_Output_Info *oi = NULL; + + if (!E_RANDR_12 || !cfdata->output_dialog_data_list) return EINA_FALSE; + + EINA_LIST_FOREACH(cfdata->output_dialog_data_list, it, odd) + { + if (odd->new_policy == Ecore_X_Randr_Unset) + continue; + if (odd->crtc) + { + EINA_LIST_FOREACH(odd->crtc->outputs, it2, oi) + { + oi->policy = odd->new_policy; + fprintf(stderr, "CONF_RANDR: 'New display attached'-policy for output %d set to %s.\n", odd->output->xid, _POLICIES_STRINGS[odd->new_policy - 1]); + } + } + else if (odd->output) + { + odd->output->policy = odd->new_policy; + fprintf(stderr, "CONF_RANDR: 'New display attached'-policy for output %d set to %s.\n", odd->output->xid, _POLICIES_STRINGS[odd->new_policy - 1]); + } + } + + return EINA_TRUE; +} + +Eina_Bool +policy_widget_basic_check_changed(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata) +{ + E_Config_Randr_Dialog_Output_Dialog_Data *odd; + Eina_List *it; + + if (!E_RANDR_12 || !cfdata->output_dialog_data_list) return EINA_FALSE; + + EINA_LIST_FOREACH(cfdata->output_dialog_data_list, it, odd) + { + if ((odd->new_policy == Ecore_X_Randr_Unset) || (odd->previous_policy == Ecore_X_Randr_Unset)) + continue; + if (odd->new_policy != odd->previous_policy) + return EINA_TRUE; + } + + return EINA_FALSE; +} + +void +policy_widget_update_radio_buttons(Evas_Object *rep) +{ + E_Config_Randr_Dialog_Output_Dialog_Data *output_dialog_data; + Ecore_X_Randr_Output_Policy policy; + + //disable widgets, if no rep is selected + if (!rep || !(output_dialog_data = evas_object_data_get(rep, "rep_info"))) + { + //Evas_Object *radio_above, *radio_right, *radio_below, *radio_left, *radio_clone, *radio_none; + e_widget_disabled_set(e_config_runtime_info->gui.widgets.policy.radio_above, EINA_TRUE); + e_widget_disabled_set(e_config_runtime_info->gui.widgets.policy.radio_right, EINA_TRUE); + e_widget_disabled_set(e_config_runtime_info->gui.widgets.policy.radio_below, EINA_TRUE); + e_widget_disabled_set(e_config_runtime_info->gui.widgets.policy.radio_left, EINA_TRUE); + e_widget_disabled_set(e_config_runtime_info->gui.widgets.policy.radio_clone, EINA_TRUE); + e_widget_disabled_set(e_config_runtime_info->gui.widgets.policy.radio_none, EINA_TRUE); + return; + } + else + { + e_widget_disabled_set(e_config_runtime_info->gui.widgets.policy.radio_above, EINA_FALSE); + e_widget_disabled_set(e_config_runtime_info->gui.widgets.policy.radio_right, EINA_FALSE); + e_widget_disabled_set(e_config_runtime_info->gui.widgets.policy.radio_below, EINA_FALSE); + e_widget_disabled_set(e_config_runtime_info->gui.widgets.policy.radio_left, EINA_FALSE); + e_widget_disabled_set(e_config_runtime_info->gui.widgets.policy.radio_clone, EINA_FALSE); + e_widget_disabled_set(e_config_runtime_info->gui.widgets.policy.radio_none, EINA_FALSE); + } + + policy = (output_dialog_data->new_policy != Ecore_X_Randr_Unset) ? output_dialog_data->new_policy : output_dialog_data->previous_policy; + //toggle the switch of the currently used policies + switch (policy) + { + case ECORE_X_RANDR_OUTPUT_POLICY_RIGHT: + e_widget_radio_toggle_set(e_config_runtime_info->gui.widgets.policy.radio_right, EINA_TRUE); + break; + + case ECORE_X_RANDR_OUTPUT_POLICY_BELOW: + e_widget_radio_toggle_set(e_config_runtime_info->gui.widgets.policy.radio_below, EINA_TRUE); + break; + + case ECORE_X_RANDR_OUTPUT_POLICY_LEFT: + e_widget_radio_toggle_set(e_config_runtime_info->gui.widgets.policy.radio_left, EINA_TRUE); + break; + + case ECORE_X_RANDR_OUTPUT_POLICY_CLONE: + e_widget_radio_toggle_set(e_config_runtime_info->gui.widgets.policy.radio_clone, EINA_TRUE); + break; + + case ECORE_X_RANDR_OUTPUT_POLICY_NONE: + e_widget_radio_toggle_set(e_config_runtime_info->gui.widgets.policy.radio_none, EINA_TRUE); + break; + + case ECORE_X_RANDR_OUTPUT_POLICY_ABOVE: + e_widget_radio_toggle_set(e_config_runtime_info->gui.widgets.policy.radio_above, EINA_TRUE); + break; + + default: + break; + } +} + +void +policy_widget_keep_changes(E_Config_Dialog_Data *cfdata) +{ + E_Config_Randr_Dialog_Output_Dialog_Data *odd; + Eina_List *it; + + if (!E_RANDR_12 || !cfdata->output_dialog_data_list) + return; + + EINA_LIST_FOREACH(cfdata->output_dialog_data_list, it, odd) + { + odd->previous_policy = odd->new_policy; + odd->new_policy = Ecore_X_Randr_Unset; + } +} + +void +policy_widget_discard_changes(E_Config_Dialog_Data *cfdata) +{ + E_Config_Randr_Dialog_Output_Dialog_Data *odd; + Eina_List *it, *it2; + E_Randr_Output_Info *oi = NULL; + + if (!E_RANDR_12 || !cfdata->output_dialog_data_list) + return; + + EINA_LIST_FOREACH(cfdata->output_dialog_data_list, it, odd) + { + if (odd->crtc) + { + EINA_LIST_FOREACH(odd->crtc->outputs, it2, oi) + { + oi->policy = odd->previous_policy; + fprintf(stderr, "CONF_RANDR: 'New display attached'-policy for output %d restored to %s.\n", oi->xid, _POLICIES_STRINGS[odd->previous_policy - 1]); + } + } + else if (odd->output) + { + odd->output->policy = odd->previous_policy; + fprintf(stderr, "CONF_RANDR: 'New display attached'-policy for output %d restored to %s.\n", odd->output->xid, _POLICIES_STRINGS[odd->previous_policy - 1]); + } + } + + return; +} diff --git a/src/modules/conf_randr/e_int_config_randr_resolutions.c b/src/modules/conf_randr/e_int_config_randr_resolution.c similarity index 50% rename from src/modules/conf_randr/e_int_config_randr_resolutions.c rename to src/modules/conf_randr/e_int_config_randr_resolution.c index 6ccf10b94..c0d4ea3ae 100644 --- a/src/modules/conf_randr/e_int_config_randr_resolutions.c +++ b/src/modules/conf_randr/e_int_config_randr_resolution.c @@ -18,15 +18,9 @@ #define ICON_HEIGHT 10 #define RESOLUTION_TXT_MAX_LENGTH 50 -Evas_Object *resolution_widget_basic_create_widgets(Evas *canvas); -Eina_Bool resolution_widget_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); -Eina_Bool resolution_widget_basic_check_changed(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); -void resolution_widget_update_list(Evas_Object *crtc); -void resolution_widget_keep_changes(E_Config_Dialog_Data *cfdata); -void resolution_widget_discard_changes(E_Config_Dialog_Data *cfdata); - extern E_Config_Dialog_Data *e_config_runtime_info; static Ecore_X_Randr_Mode_Info disabled_mode = {.xid = Ecore_X_Randr_None}; +void _resolution_widget_mouse_up_cb(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__); Eina_Bool resolution_widget_create_data(E_Config_Dialog_Data *cfdata) @@ -38,37 +32,41 @@ resolution_widget_create_data(E_Config_Dialog_Data *cfdata) EINA_LIST_FOREACH(cfdata->output_dialog_data_list, iter, odd) { - if (odd->previous_mode || odd->preferred_mode) - { - //this means, that mode info is already filled - //(by the display arrangement code) - break; - } if (odd->crtc) { odd->preferred_mode = (Ecore_X_Randr_Mode_Info *)eina_list_data_get(odd->crtc->outputs_common_modes); - odd->previous_mode = odd->crtc->current_mode; + odd->previous_mode = odd->crtc->current_mode ? odd->crtc->current_mode : &disabled_mode; } else if (odd->output && odd->output->monitor) { odd->previous_mode = NULL; odd->preferred_mode = (Ecore_X_Randr_Mode_Info *)eina_list_data_get(odd->output->monitor->preferred_modes); } + odd->new_mode = NULL; } return EINA_TRUE; } +void +resolution_widget_free_cfdata(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata) +{ + evas_object_event_callback_del(cfdata->gui.widgets.resolution.widget, EVAS_CALLBACK_MOUSE_UP, _resolution_widget_mouse_up_cb); +} + Evas_Object * resolution_widget_basic_create_widgets(Evas *canvas) { Evas_Object *widget; - if (!canvas || !e_config_runtime_info || e_config_runtime_info->gui.widgets.resolutions.widget || !(widget = e_widget_ilist_add(canvas, ICON_WIDTH * e_scale, ICON_HEIGHT * e_scale, NULL))) return NULL; + if (e_config_runtime_info->gui.widgets.resolution.widget) + return e_config_runtime_info->gui.widgets.resolution.widget; + else if (!canvas || !e_config_runtime_info || !(widget = e_widget_ilist_add(canvas, ICON_WIDTH * e_scale, ICON_HEIGHT * e_scale, NULL))) + return NULL; + evas_object_event_callback_add(widget, EVAS_CALLBACK_MOUSE_UP, _resolution_widget_mouse_up_cb, NULL); e_widget_ilist_multi_select_set(widget, EINA_FALSE); e_widget_disabled_set(widget, EINA_TRUE); - evas_object_show(widget); return widget; @@ -77,84 +75,74 @@ resolution_widget_basic_create_widgets(Evas *canvas) Eina_Bool resolution_widget_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata __UNUSED__) { - //Apply new mode - Ecore_X_Randr_Mode_Info *selected_mode; - Ecore_X_Randr_Mode mode; - E_Config_Randr_Dialog_Output_Dialog_Data *output_dialog_data; + E_Config_Randr_Dialog_Output_Dialog_Data *odd; Ecore_X_Randr_Output *outputs = NULL; - E_Randr_Crtc_Info *crtc_info = NULL, *crtc_iter; - Eina_List *iter; + E_Randr_Crtc_Info *crtc_info = NULL; + Eina_List *it, *it2; int noutputs = Ecore_X_Randr_Unset; + Eina_Bool success = EINA_TRUE; - if (!e_config_runtime_info->gui.selected_eo || !(output_dialog_data = evas_object_data_get(e_config_runtime_info->gui.selected_eo, "rep_info"))) + EINA_LIST_FOREACH(e_config_runtime_info->output_dialog_data_list, it, odd) { - fprintf(stderr, "CONF_RADNR: no crtc was selected or no output info could be retrieved for the selected crtc element (%p).\n", e_config_runtime_info->gui.selected_eo); - return EINA_FALSE; - } + if (!odd || !odd->new_mode || (odd->new_mode == odd->previous_mode)) + continue; - if (output_dialog_data->crtc) - { - //CRTC is already asssigned, easy one! - crtc_info = output_dialog_data->crtc; - } - else if (output_dialog_data->output) - { - //CRTC not assigned yet. Let's try to find a non occupied one. - fprintf(stderr, "CONF_RANDR: Trying to find a CRTC for output %d, %d crtcs are possible.\n", output_dialog_data->output->xid, eina_list_count(output_dialog_data->output->possible_crtcs)); - outputs = &output_dialog_data->output->xid; - noutputs = 1; - EINA_LIST_FOREACH(output_dialog_data->output->possible_crtcs, iter, crtc_iter) + if (odd->crtc) + crtc_info = odd->crtc; //CRTC is already asssigned, easy one! + else if (odd->output) { - if (!crtc_iter->outputs) + //CRTC not assigned yet. Let's try to find a non occupied one. + fprintf(stderr, "CONF_RANDR: Trying to find a CRTC for output %d, %d crtcs are possible.\n", odd->output->xid, eina_list_count(odd->output->possible_crtcs)); + outputs = &odd->output->xid; + noutputs = 1; + EINA_LIST_FOREACH(odd->output->possible_crtcs, it2, crtc_info) { - //CRTC is not occupied yet - crtc_info = crtc_iter; - break; + if (crtc_info->outputs) + crtc_info = NULL; //CRTC is not occupied yet + else + break; } } - } - if (!crtc_info) - { - fprintf(stderr, "CONF_RANDR: Changing mode failed, no unoccupied CRTC found!\n"); - return EINA_FALSE; - } - //get selected mode - if ((selected_mode = (Ecore_X_Randr_Mode_Info *)e_widget_ilist_selected_data_get(e_config_runtime_info->gui.widgets.resolutions.widget))) - { - mode = selected_mode->xid; - } - if (selected_mode == crtc_info->current_mode) - { - if (output_dialog_data->output && (eina_list_data_find(crtc_info->outputs, output_dialog_data->output))) + if (!crtc_info) { - fprintf(stderr, "CONF_RANDR: Nothing to be done for output %s.\n", output_dialog_data->output->name); - return EINA_TRUE; + fprintf(stderr, "CONF_RANDR: Changing mode failed, no unoccupied CRTC found!\n"); + success = EINA_FALSE; + continue; } - fprintf(stderr, "CONF_RANDR: Resolution remains unchanged for CRTC %d.\n", crtc_info->xid); - return EINA_TRUE; - } - fprintf(stderr, "CONF_RANDR: Changing mode of crtc %d to %d.\n", crtc_info->xid, mode); + if (odd->new_mode == crtc_info->current_mode) + { + if (odd->output && (eina_list_data_find(crtc_info->outputs, odd->output))) + fprintf(stderr, "CONF_RANDR: Nothing to be done for output %s.\n", odd->output->name); + fprintf(stderr, "CONF_RANDR: Resolution remains unchanged for CRTC %d.\n", crtc_info->xid); + continue; + } + fprintf(stderr, "CONF_RANDR: Changing mode of crtc %d to %d.\n", crtc_info->xid, odd->new_mode->xid); - if (ecore_x_randr_crtc_mode_set(cfd->con->manager->root, crtc_info->xid, outputs, noutputs, mode)) - { - //update information - output_dialog_data->crtc = crtc_info; - output_dialog_data->new_mode = selected_mode; - return EINA_TRUE; + if (ecore_x_randr_crtc_mode_set(cfd->con->manager->root, crtc_info->xid, outputs, noutputs, odd->new_mode->xid)) + { + //update information + odd->crtc = crtc_info; + } } - return EINA_FALSE; + return success; } Eina_Bool resolution_widget_basic_check_changed(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata __UNUSED__) { - Ecore_X_Randr_Mode_Info *selected_mode; - E_Config_Randr_Dialog_Output_Dialog_Data *output_dialog_data; + E_Config_Randr_Dialog_Output_Dialog_Data *odd; + Eina_List *it; - if (!e_config_runtime_info->gui.selected_eo || !(selected_mode = (Ecore_X_Randr_Mode_Info *)e_widget_ilist_selected_data_get(e_config_runtime_info->gui.widgets.resolutions.widget)) || !(output_dialog_data = evas_object_data_get(e_config_runtime_info->gui.selected_eo, "rep_info"))) return EINA_FALSE; + EINA_LIST_FOREACH(e_config_runtime_info->output_dialog_data_list, it, odd) + { + if (!odd || !odd->new_mode) + continue; + if (odd->new_mode != odd->previous_mode) + return EINA_TRUE; + } - return selected_mode != output_dialog_data->previous_mode; + return EINA_FALSE; } void @@ -162,30 +150,34 @@ resolution_widget_update_list(Evas_Object *rep) { Eina_List *iter, *modelist = NULL; E_Config_Randr_Dialog_Output_Dialog_Data *output_dialog_data; - Ecore_X_Randr_Mode_Info *mode_info, *current_mode; + Ecore_X_Randr_Mode_Info *mode_info, *current_mode = NULL; char resolution_text[RESOLUTION_TXT_MAX_LENGTH]; float rate; Eina_Bool enable = EINA_FALSE; int i = 0; - e_widget_ilist_freeze(e_config_runtime_info->gui.widgets.resolutions.widget); - e_widget_ilist_clear(e_config_runtime_info->gui.widgets.resolutions.widget); + e_widget_ilist_freeze(e_config_runtime_info->gui.widgets.resolution.widget); + e_widget_ilist_clear(e_config_runtime_info->gui.widgets.resolution.widget); if (!rep || !(output_dialog_data = evas_object_data_get(rep, "rep_info"))) goto _go_and_return; //select correct mode list + if (output_dialog_data->new_mode) + current_mode = output_dialog_data->new_mode; + else if (output_dialog_data->crtc) + { + if (!output_dialog_data->crtc->current_mode) + current_mode = &disabled_mode; + else + current_mode = output_dialog_data->crtc->current_mode; + } + if (output_dialog_data->crtc) - { - current_mode = output_dialog_data->crtc->current_mode; - modelist = output_dialog_data->crtc->outputs_common_modes; - } + modelist = output_dialog_data->crtc->outputs_common_modes; else if (output_dialog_data->output && output_dialog_data->output->monitor) - { - current_mode = NULL; - if (output_dialog_data->output->monitor->modes) - modelist = output_dialog_data->output->monitor->modes; - } + modelist = output_dialog_data->output->monitor->modes; + if (!modelist) goto _go_and_return; @@ -204,24 +196,24 @@ resolution_widget_update_list(Evas_Object *rep) else snprintf(resolution_text, (RESOLUTION_TXT_MAX_LENGTH - 1), "%dx%d@%.1fHz", mode_info->width, mode_info->height, rate); - e_widget_ilist_append(e_config_runtime_info->gui.widgets.resolutions.widget, NULL, resolution_text, NULL, mode_info, NULL); + e_widget_ilist_append(e_config_runtime_info->gui.widgets.resolution.widget, NULL, resolution_text, NULL, mode_info, NULL); //select currently enabled mode if (mode_info == current_mode) - e_widget_ilist_selected_set(e_config_runtime_info->gui.widgets.resolutions.widget, i); + e_widget_ilist_selected_set(e_config_runtime_info->gui.widgets.resolution.widget, i); i++; } //append 'disabled' mode - e_widget_ilist_append(e_config_runtime_info->gui.widgets.resolutions.widget, NULL, _("Disabled"), NULL, &disabled_mode, NULL); + e_widget_ilist_append(e_config_runtime_info->gui.widgets.resolution.widget, NULL, _("Disabled"), NULL, &disabled_mode, NULL); //reenable widget enable = EINA_TRUE; _go_and_return: - e_widget_disabled_set(e_config_runtime_info->gui.widgets.resolutions.widget, enable); - e_widget_ilist_go(e_config_runtime_info->gui.widgets.resolutions.widget); - e_widget_ilist_thaw(e_config_runtime_info->gui.widgets.resolutions.widget); + e_widget_disabled_set(e_config_runtime_info->gui.widgets.resolution.widget, enable); + e_widget_ilist_go(e_config_runtime_info->gui.widgets.resolution.widget); + e_widget_ilist_thaw(e_config_runtime_info->gui.widgets.resolution.widget); } void @@ -234,11 +226,10 @@ resolution_widget_keep_changes(E_Config_Dialog_Data *cfdata) EINA_LIST_FOREACH(cfdata->output_dialog_data_list, iter, odd) { - if (odd && odd->new_mode && (odd->new_mode != odd->previous_mode)) - { - odd->previous_mode = odd->new_mode; - odd->new_mode = NULL; - } + if (!odd || !odd->new_mode || (odd->new_mode == odd->previous_mode)) + continue; + odd->previous_mode = odd->new_mode; + odd->new_mode = NULL; } } @@ -255,12 +246,23 @@ resolution_widget_discard_changes(E_Config_Dialog_Data *cfdata) //for now, there is no way to redisable an output during discartion if (!odd->crtc || !odd->previous_mode) continue; //use currently used outputs (noutputs == Ecore_X_Randr_Unset) - if (ecore_x_randr_crtc_mode_set(cfdata->manager->root, odd->crtc->xid, NULL, Ecore_X_Randr_Unset, odd->previous_mode->xid)) - { - odd->new_mode = odd->previous_mode; - odd->previous_mode = NULL; - ecore_x_randr_screen_reset(cfdata->manager->root); - } + ecore_x_randr_crtc_mode_set(cfdata->manager->root, odd->crtc->xid, NULL, Ecore_X_Randr_Unset, odd->previous_mode->xid); } + ecore_x_randr_screen_reset(cfdata->manager->root); } +void +_resolution_widget_mouse_up_cb(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + Ecore_X_Randr_Mode_Info *selected_mode; + if (!e_config_runtime_info->gui.selected_output_dd) + { + fprintf(stderr, "CONF_RANDR: Can't set newly selected resolution, because no odd was set \"selected\" yet!\n"); + return; + } + + if ((selected_mode = (Ecore_X_Randr_Mode_Info *)e_widget_ilist_selected_data_get(e_config_runtime_info->gui.widgets.resolution.widget))) + e_config_runtime_info->gui.selected_output_dd->new_mode = selected_mode; + + fprintf(stderr, "CONF_RANDR: Mode %s was selected for crtc/output %d!\n", (selected_mode ? selected_mode->name : "None"), (e_config_runtime_info->gui.selected_output_dd->crtc ? e_config_runtime_info->gui.selected_output_dd->crtc->xid : e_config_runtime_info->gui.selected_output_dd->output->xid)); +}