From: Enlightenment S. <no-...@en...> - 2012-04-05 22:21:37
|
Log: make placement work with e_layout and fix other issues. Author: leif Date: 2012-04-05 15:21:29 -0700 (Thu, 05 Apr 2012) New Revision: 69937 Trac: http://trac.enlightenment.org/e/changeset/69937 Added: trunk/e/src/modules/conf_randr/e_int_config_randr_policy.c trunk/e/src/modules/conf_randr/e_int_config_randr_resolution.c Removed: trunk/e/src/modules/conf_randr/e_int_config_randr_policies.c trunk/e/src/modules/conf_randr/e_int_config_randr_resolutions.c Modified: trunk/e/src/bin/e_randr_12_crtc.c trunk/e/src/bin/e_randr_serialization.c trunk/e/src/modules/conf_randr/Makefile.am trunk/e/src/modules/conf_randr/e-module-conf_randr.edc trunk/e/src/modules/conf_randr/e_int_config_randr.c trunk/e/src/modules/conf_randr/e_int_config_randr.h trunk/e/src/modules/conf_randr/e_int_config_randr_arrangement.c trunk/e/src/modules/conf_randr/e_int_config_randr_orientation.c Modified: trunk/e/src/bin/e_randr_12_crtc.c =================================================================== --- trunk/e/src/bin/e_randr_12_crtc.c 2012-04-05 22:21:24 UTC (rev 69936) +++ trunk/e/src/bin/e_randr_12_crtc.c 2012-04-05 22:21:29 UTC (rev 69937) @@ -140,14 +140,17 @@ { 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))) Modified: trunk/e/src/bin/e_randr_serialization.c =================================================================== --- trunk/e/src/bin/e_randr_serialization.c 2012-04-05 22:21:24 UTC (rev 69936) +++ trunk/e/src/bin/e_randr_serialization.c 2012-04-05 22:21:29 UTC (rev 69937) @@ -30,7 +30,12 @@ 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) { Modified: trunk/e/src/modules/conf_randr/Makefile.am =================================================================== --- trunk/e/src/modules/conf_randr/Makefile.am 2012-04-05 22:21:24 UTC (rev 69936) +++ trunk/e/src/modules/conf_randr/Makefile.am 2012-04-05 22:21:29 UTC (rev 69937) @@ -34,9 +34,9 @@ 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 Modified: trunk/e/src/modules/conf_randr/e-module-conf_randr.edc =================================================================== --- trunk/e/src/modules/conf_randr/e-module-conf_randr.edc 2012-04-05 22:21:24 UTC (rev 69936) +++ trunk/e/src/modules/conf_randr/e-module-conf_randr.edc 2012-04-05 22:21:29 UTC (rev 69937) @@ -473,7 +473,7 @@ 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 } /* Modified: trunk/e/src/modules/conf_randr/e_int_config_randr.c =================================================================== --- trunk/e/src/modules/conf_randr/e_int_config_randr.c 2012-04-05 22:21:24 UTC (rev 69936) +++ trunk/e/src/modules/conf_randr/e_int_config_randr.c 2012-04-05 22:21:29 UTC (rev 69937) @@ -105,8 +105,8 @@ 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(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(resolution_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 @@ 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 @@ 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,15 +250,8 @@ 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); + _e_conf_randr_confirmation_dialog_keep_cb(data, dia); - //cleanup dialog - _e_conf_randr_confirmation_dialog_delete_cb(dia->win); - //but actually trigger saving the stuff e_randr_store_configuration(modifier); @@ -305,8 +306,8 @@ 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 @@ //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_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 @@ 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)); } Modified: trunk/e/src/modules/conf_randr/e_int_config_randr.h =================================================================== --- trunk/e/src/modules/conf_randr/e_int_config_randr.h 2012-04-05 22:21:24 UTC (rev 69936) +++ trunk/e/src/modules/conf_randr/e_int_config_randr.h 2012-04-05 22:21:29 UTC (rev 69937) @@ -24,7 +24,9 @@ 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 @@ 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 @@ { 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 @@ 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); Modified: trunk/e/src/modules/conf_randr/e_int_config_randr_arrangement.c =================================================================== --- trunk/e/src/modules/conf_randr/e_int_config_randr_arrangement.c 2012-04-05 22:21:24 UTC (rev 69936) +++ trunk/e/src/modules/conf_randr/e_int_config_randr_arrangement.c 2012-04-05 22:21:29 UTC (rev 69937) @@ -9,20 +9,77 @@ #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); static inline void _arrangement_widget_make_suggestion(Evas_Object *obj); @@ -33,6 +90,8 @@ 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,34 +102,70 @@ { 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 = POS_UNSET; + odd->previous_pos.y = POS_UNSET; + } +} - odd->previous_pos.x = 0; - odd->previous_pos.y = 0; +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 @@ -78,9 +173,6 @@ { 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 @@ 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 @@ 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,12 +217,32 @@ { 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 @@ 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 @@ 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 @@ } 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,29 +453,23 @@ 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 @@ _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; + max_dist = e_config_runtime_info->gui.widgets.arrangement.suggestion_dist_max; - 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; - } - //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; + possible_reps = eina_list_append(possible_reps, odd->rep); + } - 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)) + 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 (visible) { - s_geo.x = rep_geo.x; - dxa = abs(s_geo.x - rep_geo.x); + 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; + } - 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; - } + /* + 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"); - 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; - } + e_layout_child_geometry_get(obj, &o_geo.x, &o_geo.y, &o_geo.w, &o_geo.h); - 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; - } + 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; + } - //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); - } + 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; + } - 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; - } + if (_arrangemnet_rep_illegal_overlapping(odd) || ps->distance > max_dist) + odd->new_pos.x = odd->new_pos.y = POS_UNSET; - 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; - } - } - - if ((s_geo.x != geo.x) || (s_geo.y != geo.y)) + if ((odd->new_pos.x != POS_UNSET) && (odd->new_pos.y != POS_UNSET)) { - 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 (!evas_object_visible_get(e_config_runtime_info->gui.widgets.arrangement.suggestion)) + 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 @@ 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 @@ 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 @@ 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 @@ 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; +} Modified: trunk/e/src/modules/conf_randr/e_int_config_randr_orientation.c =================================================================== --- trunk/e/src/modules/conf_randr/e_int_config_randr_orientation.c 2012-04-05 22:21:24 UTC (rev 69936) +++ trunk/e/src/modules/conf_randr/e_int_config_randr_orientation.c 2012-04-05 22:21:29 UTC (rev 69937) @@ -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 @@ 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,13 +116,15 @@ 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: * "sadly" the evas callbacks are called before radio_val is set to its new @@ -141,15 +139,13 @@ 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 @@ { //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 @@ //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 @@ 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 @@ { //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 @@ 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 @@ EINA_LI... [truncated message content] |