diff --git a/src/modules/conf_display/e_int_config_display.c b/src/modules/conf_display/e_int_config_display.c index e544464c7..d6de603ee 100644 --- a/src/modules/conf_display/e_int_config_display.c +++ b/src/modules/conf_display/e_int_config_display.c @@ -5,447 +5,14 @@ * Give list some icons. */ +#define RANDR_11 ((1 << 16) | 1) + static void _fill_data (E_Config_Dialog_Data *cfdata); static void *_create_data (E_Config_Dialog *cfd); static void _free_data (E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); static int _basic_check_changed (E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); static int _basic_apply_data (E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); static Evas_Object *_basic_create_widgets (E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata); - -struct _E_Config_Dialog_Data -{ - E_Config_Dialog *cfd; - - Evas_Object *scr_list; - Evas_Object *res_list; - Evas_Object *policy_list; - - const char *cur_scr; - - int restore; - int orientation; - int flip_x; - int flip_y; -}; - -E_Config_Dialog * -e_int_config_display(E_Container *con, const char *params __UNUSED__) -{ - E_Config_Dialog *cfd; - E_Config_Dialog_View *v; - - if (e_config_dialog_find("E", "screen/screen_resolution")) return NULL; - v = E_NEW(E_Config_Dialog_View, 1); - v->create_cfdata = _create_data; - v->free_cfdata = _free_data; - v->basic.apply_cfdata = _basic_apply_data; - v->basic.create_widgets = _basic_create_widgets; - v->basic.check_changed = _basic_check_changed; - v->override_auto_apply = 1; - - cfd = e_config_dialog_new(con, _("Screen Resolution Settings"), - "E", "screen/screen_resolution", - "preferences-system-screen-resolution", 0, v, NULL); - return cfd; -} - -static void -_fill_data(E_Config_Dialog_Data *cfdata) -{ -} - -static void * -_create_data(E_Config_Dialog *cfd) -{ - E_Config_Dialog_Data *cfdata; - - cfdata = E_NEW(E_Config_Dialog_Data, 1); - _fill_data(cfdata); - cfdata->cfd = cfd; - return cfdata; -} - -static void -_free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata) -{ - if (cfdata->cur_scr) eina_stringshare_del(cfdata->cur_scr); - E_FREE(cfdata); -} - -static int -_basic_check_changed(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata) -{ - return 1; -} - -static int -_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) -{ - return 1; -} - -static void -_res_get(E_Config_Dialog_Data *cfdata) -{ - Eina_List *l; - E_Randr_Output_Info *oi = NULL; - Ecore_X_Randr_Mode_Info *mode; - - e_widget_ilist_clear(cfdata->res_list); - if (!cfdata->cur_scr) return; - - if (e_randr_screen_info.rrvd_info.randr_info_12) - { - EINA_LIST_FOREACH - (e_randr_screen_info.rrvd_info.randr_info_12->outputs, l, oi) - { - char buf[512]; - - strncpy(buf, oi->name, sizeof(buf) - 1); - buf[oi->name_length] = 0; - if (!strcmp(buf, cfdata->cur_scr)) break; - oi = NULL; - } - } - if (!oi) return; - if (!oi->monitor) return; - - switch (oi->policy) - { - case ECORE_X_RANDR_OUTPUT_POLICY_ABOVE: - printf(" policy: ABOVE\n"); break; - case ECORE_X_RANDR_OUTPUT_POLICY_RIGHT: - printf(" policy: RIGHT\n"); break; - case ECORE_X_RANDR_OUTPUT_POLICY_BELOW: - printf(" policy: BELOW\n"); break; - case ECORE_X_RANDR_OUTPUT_POLICY_LEFT: - printf(" policy: LEFT\n"); break; - case ECORE_X_RANDR_OUTPUT_POLICY_CLONE: - printf(" policy: CLONE\n"); break; - case ECORE_X_RANDR_OUTPUT_POLICY_NONE: - printf(" policy: NONE\n"); break; - default: - printf(" policy: unknown\n"); break; - break; - } - if (oi->crtc) - { - mode = oi->crtc->current_mode; - if (mode) - { - if ((mode->hTotal > 0) && (mode->vTotal > 0) && (mode->dotClock > 0)) - { - double hz = (double)mode->dotClock / - (double)(mode->hTotal * mode->vTotal); - printf( " %ix%i %1.1fHz\n", mode->width, mode->height, hz); - } - } - printf(" geometry: %i %i %ix%i\n", - oi->crtc->geometry.x, oi->crtc->geometry.y, - oi->crtc->geometry.w, oi->crtc->geometry.h); - if (oi->crtc->current_orientation & ECORE_X_RANDR_ORIENTATION_ROT_0) - printf(" orient: 0\n"); - if (oi->crtc->current_orientation & ECORE_X_RANDR_ORIENTATION_ROT_90) - printf(" orient: 90\n"); - if (oi->crtc->current_orientation & ECORE_X_RANDR_ORIENTATION_ROT_180) - printf(" orient: 180\n"); - if (oi->crtc->current_orientation & ECORE_X_RANDR_ORIENTATION_ROT_270) - printf(" orient: 270\n"); - if (oi->crtc->current_orientation & ECORE_X_RANDR_ORIENTATION_FLIP_X) - printf(" orient: flip x\n"); - if (oi->crtc->current_orientation & ECORE_X_RANDR_ORIENTATION_FLIP_Y) - printf(" orient: flip y\n"); - printf(" can do:\n"); - if (oi->crtc->orientations & ECORE_X_RANDR_ORIENTATION_ROT_0) - printf(" orient: 0\n"); - if (oi->crtc->orientations & ECORE_X_RANDR_ORIENTATION_ROT_90) - printf(" orient: 90\n"); - if (oi->crtc->orientations & ECORE_X_RANDR_ORIENTATION_ROT_180) - printf(" orient: 180\n"); - if (oi->crtc->orientations & ECORE_X_RANDR_ORIENTATION_ROT_270) - printf(" orient: 270\n"); - if (oi->crtc->orientations & ECORE_X_RANDR_ORIENTATION_FLIP_X) - printf(" orient: flip x\n"); - if (oi->crtc->orientations & ECORE_X_RANDR_ORIENTATION_FLIP_Y) - printf(" orient: flip y\n"); - } - - printf(" monitor is %ix%i mm\n", - oi->monitor->size_mm.width, oi->monitor->size_mm.height); - - EINA_LIST_FOREACH(oi->monitor->modes, l, mode) - { - char buf[512]; - - if ((mode->hTotal > 0) && (mode->vTotal > 0) && (mode->dotClock > 0)) - { - double hz = (double)mode->dotClock / - (double)(mode->hTotal * mode->vTotal); - - snprintf(buf, sizeof(buf), "%ix%i %1.1fHz", - mode->width, mode->height, hz); - e_widget_ilist_append(cfdata->res_list, NULL, buf, NULL, cfdata, NULL); - } - } -} - -static void -_screens_select(void *data) -{ - E_Config_Dialog_Data *cfdata = data; - _res_get(cfdata); -} - -static void -_screens_get(E_Config_Dialog_Data *cfdata) -{ - Eina_List *l; - E_Randr_Output_Info *oi; - - if (e_randr_screen_info.rrvd_info.randr_info_12) - { - EINA_LIST_FOREACH - (e_randr_screen_info.rrvd_info.randr_info_12->outputs, l, oi) - { - char buf[512]; - - strncpy(buf, oi->name, sizeof(buf) - 1); - buf[oi->name_length] = 0; - printf("%s:\n", buf); - switch (oi->connection_status) - { - case ECORE_X_RANDR_CONNECTION_STATUS_CONNECTED: - printf(" connect: connected\n"); break; - case ECORE_X_RANDR_CONNECTION_STATUS_DISCONNECTED: - printf(" connect: disconnected\n"); break; - default: - printf(" connect: unknown\n"); break; - } - switch (oi->connector_type) - { - case ECORE_X_RANDR_EDID_DISPLAY_INTERFACE_DVI: - printf(" type DVI\n"); break; - case ECORE_X_RANDR_EDID_DISPLAY_INTERFACE_HDMI_A: - printf(" type HDMI_A\n"); break; - case ECORE_X_RANDR_EDID_DISPLAY_INTERFACE_HDMI_B: - printf(" type HDMI_B\n"); break; - case ECORE_X_RANDR_EDID_DISPLAY_INTERFACE_MDDI: - printf(" type MDDI\n"); break; - case ECORE_X_RANDR_EDID_DISPLAY_INTERFACE_DISPLAY_PORT: - printf(" type DISPLAY_PORT\n"); break; - default: - printf(" type unknown\n"); break; - } - e_widget_ilist_append(cfdata->scr_list, NULL, buf, _screens_select, cfdata, buf); - } - } -} - -static Evas_Object * -_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata) -{ - Evas_Object *o, *of, *ob, *ot; - E_Radio_Group *rg; - - o = e_widget_table_add(evas, 0); - - of = e_widget_framelist_add(evas, _("Outputs"), 0); - ob = e_widget_ilist_add(evas, 16, 16, &(cfdata->cur_scr)); - cfdata->scr_list = ob; - e_widget_size_min_set(ob, 128, 200); - e_widget_framelist_object_append(of, ob); - e_widget_table_object_append(o, of, 0, 0, 1, 1, 1, 1, 1, 1); - - of = e_widget_framelist_add(evas, _("Modes"), 0); - ob = e_widget_ilist_add(evas, 16, 16, NULL); - cfdata->res_list = ob; - e_widget_size_min_set(ob, 192, 200); - e_widget_framelist_object_append(of, ob); - e_widget_table_object_append(o, of, 1, 0, 1, 1, 1, 1, 1, 1); - - ob = e_widget_check_add(evas, _("Restore on login"), &cfdata->restore); - e_widget_table_object_append(o, ob, 1, 1, 2, 1, 1, 1, 0, 0); - - ot = e_widget_table_add(evas, 0); - of = e_widget_framelist_add(evas, _("Policy"), 0); - ob = e_widget_ilist_add(evas, 16, 16, NULL); - cfdata->policy_list = ob; - e_widget_size_min_set(ob, 100, 80); - e_widget_framelist_object_append(of, ob); - e_widget_table_object_append(ot, of, 0, 0, 1, 1, 1, 1, 1, 1); - - of = e_widget_framelist_add(evas, _("Rotation"), 0); - rg = e_widget_radio_group_new(&(cfdata->orientation)); - ob = e_widget_radio_icon_add(evas, NULL, "preferences-screen-normal", 24, 24, ECORE_X_RANDR_ORIENTATION_ROT_0, rg); - e_widget_framelist_object_append(of, ob); - ob = e_widget_radio_icon_add(evas, NULL, "preferences-screen-left", 24, 24, ECORE_X_RANDR_ORIENTATION_ROT_90, rg); - e_widget_framelist_object_append(of, ob); - ob = e_widget_radio_icon_add(evas, NULL, "preferences-screen-around", 24, 24, ECORE_X_RANDR_ORIENTATION_ROT_180, rg); - e_widget_framelist_object_append(of, ob); - ob = e_widget_radio_icon_add(evas, NULL, "preferences-screen-right", 24, 24, ECORE_X_RANDR_ORIENTATION_ROT_270, rg); - e_widget_framelist_object_append(of, ob); - e_widget_table_object_append(ot, of, 0, 1, 1, 1, 1, 0, 1, 0); - - of = e_widget_framelist_add(evas, _("Mirroring"), 0); - ob = e_widget_check_icon_add(evas, NULL, "preferences-screen-hflip", 24, 24, &(cfdata->flip_x)); - e_widget_framelist_object_append(of, ob); - ob = e_widget_check_icon_add(evas, NULL, "preferences-screen-vflip", 24, 24, &(cfdata->flip_y)); - e_widget_framelist_object_append(of, ob); - e_widget_table_object_append(ot, of, 0, 2, 1, 1, 1, 0, 1, 0); - - e_widget_table_object_append(o, ot, 2, 0, 1, 1, 1, 1, 1, 1); - e_dialog_resizable_set(cfd->dia, 1); - - _screens_get(cfdata); - return o; -} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#if 0 - - -/* - man = e_manager_current_get(); - sizes = ecore_x_randr_screen_primary_output_sizes_get(man->root, &s); - cfdata->has_rates = EINA_FALSE; - - if ((!sizes) || (s == 0)) - ecore_timer_add(0.5, _deferred_noxrandr_error, NULL); - else - { - ecore_x_randr_screen_primary_output_current_size_get(man->root, &cfdata->orig_size.width, &cfdata->orig_size.height, NULL, NULL, &cfdata->orig_size_index); - cfdata->orig_rate = ecore_x_randr_screen_primary_output_current_refresh_rate_get(man->root); - - for (i = 0; i < (s - 1); i++) - { - Resolution * res; - Ecore_X_Randr_Refresh_Rate * rates; - int r = 0, j; - - res = E_NEW(Resolution, 1); - if (!res) continue; - - res->size.width = sizes[i].width; - res->size.height = sizes[i].height; - res->size_index = i; - rates = ecore_x_randr_screen_primary_output_refresh_rates_get(man->root, i, &r); - for (j = 0; j < r; j++) - { - Ecore_X_Randr_Refresh_Rate * rt; - - cfdata->has_rates = EINA_TRUE; - rt = E_NEW(Ecore_X_Randr_Refresh_Rate, 1); - if (!rt) continue; - *rt = rates[j]; - res->rates = eina_list_append(res->rates, rt); - } - if (rates) E_FREE(rates); - cfdata->resolutions = eina_list_append(cfdata->resolutions, res); - } - - cfdata->resolutions = eina_list_sort(cfdata->resolutions, - eina_list_count(cfdata->resolutions), _sort_resolutions); - cfdata->resolutions = eina_list_reverse(cfdata->resolutions); - - _load_resolutions(cfdata); - if (!cfdata->has_rates) - ecore_timer_add(0.5, _deferred_norates_error, NULL); - } - - E_FREE(sizes); - - _load_rates(cfdata); - */ - -# define RANDR_11 ((1 << 16) | 1) - static void _load_resolutions (E_Config_Dialog_Data *cfdata); static void _load_rates (E_Config_Dialog_Data *cfdata); static void _ilist_item_change (void *data); @@ -473,6 +40,192 @@ struct _SureBox E_Config_Dialog_Data *cfdata; }; +struct _E_Config_Dialog_Data +{ + E_Config_Dialog *cfd; + Eina_List *resolutions; + Ecore_X_Randr_Screen_Size orig_size; + int orig_size_index; + Ecore_X_Randr_Refresh_Rate orig_rate; + int orig_orientation; + int orig_flip; + int restore; + int can_rotate; + int can_flip; + int orientation; + int flip; + int flip_x; + int flip_y; + Eina_Bool has_rates; + + Evas_Object *rate_list; + Evas_Object *res_list; + SureBox *surebox; +}; + +static void +_surebox_dialog_cb_delete(E_Win *win) +{ + E_Dialog *dia; + SureBox *sb; + E_Config_Dialog *cfd; + + dia = win->data; + sb = dia->data; + sb->cfdata->surebox = NULL; + cfd = sb->cfdata->cfd; + if (sb->timer) ecore_timer_del(sb->timer); + sb->timer = NULL; + free(sb); + e_object_del(E_OBJECT(dia)); + e_object_unref(E_OBJECT(cfd)); +} + +static void +_surebox_dialog_cb_yes(void *data, E_Dialog *dia) +{ + SureBox *sb; + + sb = data; + + if (sb->cfdata->restore) + e_randr_11_store_configuration(E_RANDR_CONFIGURATION_STORE_ALL); + + _fill_data(sb->cfdata); + _load_resolutions(sb->cfdata); + /* No need to load rates as the currently selected resolution has not been + * changed since last selection. */ + if (dia) _surebox_dialog_cb_delete(dia->win); +} + +static void +_surebox_dialog_cb_no(void *data, E_Dialog *dia) +{ + SureBox *sb; + + sb = data; + ecore_x_randr_screen_primary_output_refresh_rate_set(sb->dia->win->container->manager->root, + sb->cfdata->orig_size_index, sb->cfdata->orig_rate); + _load_resolutions(sb->cfdata); + _load_rates(sb->cfdata); + _surebox_dialog_cb_delete(dia->win); +} + +static void +_surebox_text_fill(SureBox *sb) +{ + char buf[4096]; + + if (!sb->dia) return; + if (sb->iterations > 1) + { + if (sb->cfdata->has_rates) + snprintf(buf, sizeof(buf), + _("Does this look OK? Save if it does, or Restore if not.
" + "If you do not press a button, the old resolution of
" + "%dx%d at %d Hz will be restored in %d seconds."), + sb->cfdata->orig_size.width, sb->cfdata->orig_size.height, + sb->cfdata->orig_rate, sb->iterations); + else + snprintf(buf, sizeof(buf), + _("Does this look OK? Save if it does, or Restore if not.
" + "If you do not press a button, the old resolution of
" + "%dx%d will be restored in %d seconds."), + sb->cfdata->orig_size.width, sb->cfdata->orig_size.height, + sb->iterations); + } + else + { + if (sb->cfdata->has_rates) + snprintf(buf, sizeof(buf), + _("Does this look OK? Save if it does, or Restore if not.
" + "If you do not press a button, the old resolution of
" + "%dx%d at %d Hz will be restored IMMEDIATELY."), + sb->cfdata->orig_size.width, sb->cfdata->orig_size.height, + sb->cfdata->orig_rate); + else + snprintf(buf, sizeof(buf), + _("Does this look OK? Save if it does, or Restore if not.
" + "If you do not press a button, the old resolution of
" + "%dx%d will be restored IMMEDIATELY."), + sb->cfdata->orig_size.width, sb->cfdata->orig_size.height); + } + e_dialog_text_set(sb->dia, buf); +} + +static Eina_Bool +_surebox_timer_cb(void *data) +{ + SureBox *sb; + + sb = data; + sb->iterations--; + _surebox_text_fill(sb); + if (sb->iterations == 0) + { + _surebox_dialog_cb_no(sb, sb->dia); + return ECORE_CALLBACK_CANCEL; + } + return ECORE_CALLBACK_RENEW; +} + +static SureBox * +_surebox_new(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) +{ + SureBox *sb; + + sb = E_NEW(SureBox, 1); + sb->dia = e_dialog_new(cfd->con, "E", "_display_res_sure_dialog"); + sb->timer = ecore_timer_add(1.0, _surebox_timer_cb, sb); + sb->iterations = 15; + sb->cfd = cfd; + sb->cfdata = cfdata; + cfdata->surebox = sb; + sb->dia->data = sb; + e_dialog_title_set(sb->dia, _("Resolution change")); + e_dialog_icon_set(sb->dia, "preferences-system-screen-resolution", 48); + _surebox_text_fill(sb); + e_win_delete_callback_set(sb->dia->win, _surebox_dialog_cb_delete); + e_dialog_button_add(sb->dia, _("Save"), NULL, _surebox_dialog_cb_yes, sb); + e_dialog_button_add(sb->dia, _("Restore"), NULL, _surebox_dialog_cb_no, sb); + e_dialog_button_focus_num(sb->dia, 1); + e_win_centered_set(sb->dia->win, 1); + e_win_borderless_set(sb->dia->win, 1); + e_win_layer_set(sb->dia->win, 6); + e_win_sticky_set(sb->dia->win, 1); + e_dialog_show(sb->dia); + e_object_ref(E_OBJECT(cfd)); + return sb; +} + +E_Config_Dialog * +e_int_config_display(E_Container *con, const char *params __UNUSED__) +{ + E_Config_Dialog *cfd; + E_Config_Dialog_View *v; + + if (!ecore_x_randr_query()) + { + ecore_timer_add(0.5, _deferred_noxrandr_error, NULL); + fprintf(stderr, "XRandR not present on this display.\n"); + return NULL; + } + + if (e_config_dialog_find("E", "screen/screen_resolution")) return NULL; + v = E_NEW(E_Config_Dialog_View, 1); + v->create_cfdata = _create_data; + v->free_cfdata = _free_data; + v->basic.apply_cfdata = _basic_apply_data; + v->basic.create_widgets = _basic_create_widgets; + v->basic.check_changed = _basic_check_changed; + v->override_auto_apply = 1; + + cfd = e_config_dialog_new(con, _("Screen Resolution Settings"), + "E", "screen/screen_resolution", + "preferences-system-screen-resolution", 0, v, NULL); + return cfd; +} + static void _fill_data(E_Config_Dialog_Data *cfdata) { @@ -508,6 +261,17 @@ _fill_data(E_Config_Dialog_Data *cfdata) } } +static void * +_create_data(E_Config_Dialog *cfd) +{ + E_Config_Dialog_Data *cfdata; + + cfdata = E_NEW(E_Config_Dialog_Data, 1); + _fill_data(cfdata); + cfdata->cfd = cfd; + return cfdata; +} + static void _free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata) { @@ -606,9 +370,127 @@ _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) cfdata->orig_orientation = cfdata->orientation; cfdata->orig_flip = cfdata->flip; } + return 1; } +static Evas_Object * +_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata) +{ + Evas_Object *o, *of, *ob, *ot; + E_Radio_Group *rg; + E_Manager *man; + Ecore_X_Randr_Screen_Size_MM *sizes; + int i, s; + + o = e_widget_table_add(evas, 0); + + of = e_widget_framelist_add(evas, _("Resolution"), 0); + ob = e_widget_ilist_add(evas, 16, 16, NULL); + cfdata->res_list = ob; + e_widget_size_min_set(ob, 170, 215); + e_widget_framelist_object_append(of, ob); + e_widget_table_object_append(o, of, 0, 0, 1, 1, 1, 1, 1, 1); + + ob = e_widget_check_add(evas, _("Restore on login"), &cfdata->restore); + e_widget_table_object_append(o, ob, 0, 1, 2, 1, 1, 1, 0, 0); + + ot = e_widget_table_add(evas, 0); + of = e_widget_framelist_add(evas, _("Refresh"), 0); + ob = e_widget_ilist_add(evas, 16, 16, NULL); + cfdata->rate_list = ob; + e_widget_size_min_set(ob, 100, 80); + e_widget_framelist_object_append(of, ob); + e_widget_table_object_append(ot, of, 0, 0, 1, 1, 1, 1, 1, 1); + + man = e_manager_current_get(); + sizes = ecore_x_randr_screen_primary_output_sizes_get(man->root, &s); + cfdata->has_rates = EINA_FALSE; + + if ((!sizes) || (s == 0)) + ecore_timer_add(0.5, _deferred_noxrandr_error, NULL); + else + { + ecore_x_randr_screen_primary_output_current_size_get(man->root, &cfdata->orig_size.width, &cfdata->orig_size.height, NULL, NULL, &cfdata->orig_size_index); + cfdata->orig_rate = ecore_x_randr_screen_primary_output_current_refresh_rate_get(man->root); + + for (i = 0; i < (s - 1); i++) + { + Resolution * res; + Ecore_X_Randr_Refresh_Rate * rates; + int r = 0, j; + + res = E_NEW(Resolution, 1); + if (!res) continue; + + res->size.width = sizes[i].width; + res->size.height = sizes[i].height; + res->size_index = i; + rates = ecore_x_randr_screen_primary_output_refresh_rates_get(man->root, i, &r); + for (j = 0; j < r; j++) + { + Ecore_X_Randr_Refresh_Rate * rt; + + cfdata->has_rates = EINA_TRUE; + rt = E_NEW(Ecore_X_Randr_Refresh_Rate, 1); + if (!rt) continue; + *rt = rates[j]; + res->rates = eina_list_append(res->rates, rt); + } + if (rates) E_FREE(rates); + cfdata->resolutions = eina_list_append(cfdata->resolutions, res); + } + + cfdata->resolutions = eina_list_sort(cfdata->resolutions, + eina_list_count(cfdata->resolutions), _sort_resolutions); + cfdata->resolutions = eina_list_reverse(cfdata->resolutions); + + _load_resolutions(cfdata); + if (!cfdata->has_rates) + ecore_timer_add(0.5, _deferred_norates_error, NULL); + } + + E_FREE(sizes); + + _load_rates(cfdata); + + if (cfdata->can_rotate) + { + of = e_widget_framelist_add(evas, _("Rotation"), 0); + rg = e_widget_radio_group_new(&(cfdata->orientation)); + ob = e_widget_radio_icon_add(evas, NULL, "preferences-screen-normal", 24, 24, ECORE_X_RANDR_ORIENTATION_ROT_0, rg); + e_widget_framelist_object_append(of, ob); + if (!(cfdata->can_rotate & ECORE_X_RANDR_ORIENTATION_ROT_0)) e_widget_disabled_set(ob, 1); + ob = e_widget_radio_icon_add(evas, NULL, "preferences-screen-left", 24, 24, ECORE_X_RANDR_ORIENTATION_ROT_90, rg); + e_widget_framelist_object_append(of, ob); + if (!(cfdata->can_rotate & ECORE_X_RANDR_ORIENTATION_ROT_90)) e_widget_disabled_set(ob, 1); + ob = e_widget_radio_icon_add(evas, NULL, "preferences-screen-around", 24, 24, ECORE_X_RANDR_ORIENTATION_ROT_180, rg); + e_widget_framelist_object_append(of, ob); + if (!(cfdata->can_rotate & ECORE_X_RANDR_ORIENTATION_ROT_180)) e_widget_disabled_set(ob, 1); + ob = e_widget_radio_icon_add(evas, NULL, "preferences-screen-right", 24, 24, ECORE_X_RANDR_ORIENTATION_ROT_270, rg); + e_widget_framelist_object_append(of, ob); + if (!(cfdata->can_rotate & ECORE_X_RANDR_ORIENTATION_ROT_270)) e_widget_disabled_set(ob, 1); + e_widget_table_object_append(ot, of, 0, 1, 1, 1, 1, 0, 1, 0); + } + + if (cfdata->can_flip) + { + of = e_widget_framelist_add(evas, _("Mirroring"), 0); + ob = e_widget_check_icon_add(evas, NULL, "preferences-screen-hflip", 24, 24, &(cfdata->flip_x)); + e_widget_framelist_object_append(of, ob); + if (!(cfdata->can_flip & ECORE_X_RANDR_ORIENTATION_FLIP_X)) e_widget_disabled_set(ob, 1); + ob = e_widget_check_icon_add(evas, NULL, "preferences-screen-vflip", 24, 24, &(cfdata->flip_y)); + e_widget_framelist_object_append(of, ob); + if (!(cfdata->can_flip & ECORE_X_RANDR_ORIENTATION_FLIP_Y)) + e_widget_disabled_set(ob, 1); + e_widget_table_object_append(ot, of, 0, 2, 1, 1, 1, 0, 1, 0); + } + + e_widget_table_object_append(o, ot, 1, 0, 1, 1, 1, 1, 1, 1); + e_dialog_resizable_set(cfd->dia, 1); + return o; +} + static int _sort_resolutions(const void *d1, const void *d2) { @@ -760,140 +642,3 @@ _deferred_norates_error(void *data __UNUSED__) "the resolution, which may cause damage to your screen.")); return ECORE_CALLBACK_CANCEL; } - - -static void -_surebox_dialog_cb_delete(E_Win *win) -{ - E_Dialog *dia; - SureBox *sb; - E_Config_Dialog *cfd; - - dia = win->data; - sb = dia->data; - sb->cfdata->surebox = NULL; - cfd = sb->cfdata->cfd; - if (sb->timer) ecore_timer_del(sb->timer); - sb->timer = NULL; - free(sb); - e_object_del(E_OBJECT(dia)); - e_object_unref(E_OBJECT(cfd)); -} - -static void -_surebox_dialog_cb_yes(void *data, E_Dialog *dia) -{ - SureBox *sb; - - sb = data; - - if (sb->cfdata->restore) - e_randr_11_store_configuration(E_RANDR_CONFIGURATION_STORE_ALL); - - _fill_data(sb->cfdata); - _load_resolutions(sb->cfdata); - /* No need to load rates as the currently selected resolution has not been - * changed since last selection. */ - if (dia) _surebox_dialog_cb_delete(dia->win); -} - -static void -_surebox_dialog_cb_no(void *data, E_Dialog *dia) -{ - SureBox *sb; - - sb = data; - ecore_x_randr_screen_primary_output_refresh_rate_set(sb->dia->win->container->manager->root, - sb->cfdata->orig_size_index, sb->cfdata->orig_rate); - _load_resolutions(sb->cfdata); - _load_rates(sb->cfdata); - _surebox_dialog_cb_delete(dia->win); -} - -static void -_surebox_text_fill(SureBox *sb) -{ - char buf[4096]; - - if (!sb->dia) return; - if (sb->iterations > 1) - { - if (sb->cfdata->has_rates) - snprintf(buf, sizeof(buf), - _("Does this look OK? Save if it does, or Restore if not.
" - "If you do not press a button, the old resolution of
" - "%dx%d at %d Hz will be restored in %d seconds."), - sb->cfdata->orig_size.width, sb->cfdata->orig_size.height, - sb->cfdata->orig_rate, sb->iterations); - else - snprintf(buf, sizeof(buf), - _("Does this look OK? Save if it does, or Restore if not.
" - "If you do not press a button, the old resolution of
" - "%dx%d will be restored in %d seconds."), - sb->cfdata->orig_size.width, sb->cfdata->orig_size.height, - sb->iterations); - } - else - { - if (sb->cfdata->has_rates) - snprintf(buf, sizeof(buf), - _("Does this look OK? Save if it does, or Restore if not.
" - "If you do not press a button, the old resolution of
" - "%dx%d at %d Hz will be restored IMMEDIATELY."), - sb->cfdata->orig_size.width, sb->cfdata->orig_size.height, - sb->cfdata->orig_rate); - else - snprintf(buf, sizeof(buf), - _("Does this look OK? Save if it does, or Restore if not.
" - "If you do not press a button, the old resolution of
" - "%dx%d will be restored IMMEDIATELY."), - sb->cfdata->orig_size.width, sb->cfdata->orig_size.height); - } - e_dialog_text_set(sb->dia, buf); -} - -static Eina_Bool -_surebox_timer_cb(void *data) -{ - SureBox *sb; - - sb = data; - sb->iterations--; - _surebox_text_fill(sb); - if (sb->iterations == 0) - { - _surebox_dialog_cb_no(sb, sb->dia); - return ECORE_CALLBACK_CANCEL; - } - return ECORE_CALLBACK_RENEW; -} - -static SureBox * -_surebox_new(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) -{ - SureBox *sb; - - sb = E_NEW(SureBox, 1); - sb->dia = e_dialog_new(cfd->con, "E", "_display_res_sure_dialog"); - sb->timer = ecore_timer_add(1.0, _surebox_timer_cb, sb); - sb->iterations = 15; - sb->cfd = cfd; - sb->cfdata = cfdata; - cfdata->surebox = sb; - sb->dia->data = sb; - e_dialog_title_set(sb->dia, _("Resolution change")); - e_dialog_icon_set(sb->dia, "preferences-system-screen-resolution", 48); - _surebox_text_fill(sb); - e_win_delete_callback_set(sb->dia->win, _surebox_dialog_cb_delete); - e_dialog_button_add(sb->dia, _("Save"), NULL, _surebox_dialog_cb_yes, sb); - e_dialog_button_add(sb->dia, _("Restore"), NULL, _surebox_dialog_cb_no, sb); - e_dialog_button_focus_num(sb->dia, 1); - e_win_centered_set(sb->dia->win, 1); - e_win_borderless_set(sb->dia->win, 1); - e_win_layer_set(sb->dia->win, 6); - e_win_sticky_set(sb->dia->win, 1); - e_dialog_show(sb->dia); - e_object_ref(E_OBJECT(cfd)); - return sb; -} -#endif