diff --git a/src/modules/conf_randr/e_int_config_randr.c b/src/modules/conf_randr/e_int_config_randr.c index 8265a9320..edd0a14c9 100644 --- a/src/modules/conf_randr/e_int_config_randr.c +++ b/src/modules/conf_randr/e_int_config_randr.c @@ -2,13 +2,14 @@ #include "e_mod_main.h" #include "e_int_config_randr.h" #include "e_smart_randr.h" +#include "e_smart_monitor.h" /* local structures */ struct _E_Config_Dialog_Data { Evas_Object *o_randr; - int restore; + int restore, primary; }; /* local function prototypes */ @@ -63,6 +64,7 @@ _create_data(E_Config_Dialog *cfd EINA_UNUSED) return NULL; cfdata->restore = e_randr_cfg->restore; + cfdata->primary = e_randr_cfg->primary; return cfdata; } @@ -86,7 +88,10 @@ _basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata) { Evas_Object *o; Evas_Object *ow; - Evas_Coord mw = 0, mh = 0, ch = 0; + Evas_Coord mw = 0, mh = 0, ch = 0, fh = 0; + E_Radio_Group *rg; + Eina_List *l; + Evas_Object *mon, *of; /* create the base list widget */ o = e_widget_list_add(evas, 0, 0); @@ -111,12 +116,28 @@ _basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata) e_smart_randr_min_size_get(cfdata->o_randr, &mw, &mh); } + of = e_widget_framelist_add(evas, _("Primary Output"), 0); + rg = e_widget_radio_group_new(&(cfdata->primary)); + EINA_LIST_FOREACH(e_smart_randr_monitors_get(cfdata->o_randr), l, mon) + { + int output; + const char *name; + + name = e_smart_monitor_name_get(mon); + output = (int)e_smart_monitor_output_get(mon); + + ow = e_widget_radio_add(evas, name, output, rg); + e_widget_framelist_object_append(of, ow); + } + e_widget_list_object_append(o, of, 1, 0, 0.5); + e_widget_size_min_get(of, NULL, &fh); + ow = e_widget_check_add(evas, _("Restore On Startup"), &(cfdata->restore)); e_widget_list_object_append(o, ow, 1, 0, 0.5); e_widget_size_min_get(ow, NULL, &ch); /* set min size of the list widget */ - e_widget_size_min_set(o, mw, mh + ch); + e_widget_size_min_set(o, mw, mh + fh + ch); e_util_win_auto_resize_fill(cfd->dia->win); e_win_centered_set(cfd->dia->win, 1); @@ -127,9 +148,18 @@ _basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata) static int _basic_apply(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata) { + Eina_Bool change_primary = EINA_FALSE; + + change_primary = (e_randr_cfg->primary != cfdata->primary); + + e_randr_cfg->primary = cfdata->primary; e_randr_cfg->restore = cfdata->restore; e_randr_config_save(); + if (change_primary) + ecore_x_randr_primary_output_set(ecore_x_window_root_first_get(), + (Ecore_X_Randr_Output)cfdata->primary); + e_smart_randr_changes_apply(cfdata->o_randr); return 1; @@ -138,7 +168,8 @@ _basic_apply(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata) static int _basic_check(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata) { - return (e_randr_cfg->restore != cfdata->restore); + return ((e_randr_cfg->restore != cfdata->restore) || + (e_randr_cfg->primary != cfdata->primary)); } static void diff --git a/src/modules/conf_randr/e_smart_monitor.c b/src/modules/conf_randr/e_smart_monitor.c index ecd743b81..b1d7904fc 100644 --- a/src/modules/conf_randr/e_smart_monitor.c +++ b/src/modules/conf_randr/e_smart_monitor.c @@ -54,6 +54,7 @@ struct _E_Smart_Data /* output config */ Ecore_X_Randr_Output output; + Eina_Bool primary : 1; struct { @@ -375,7 +376,8 @@ e_smart_monitor_output_set(Evas_Object *obj, Ecore_X_Randr_Output output) } /* set if it's primary */ - if (output == primary) + sd->primary = (output == primary); + if (sd->primary) edje_object_signal_emit(sd->o_frame, "e,state,primary,on", "e"); else edje_object_signal_emit(sd->o_frame, "e,state,primary,off", "e"); @@ -743,7 +745,7 @@ e_smart_monitor_changes_apply(Evas_Object *obj) { E_Smart_Data *sd; Ecore_X_Window root = 0; - Ecore_X_Randr_Output *outputs; + Ecore_X_Randr_Output *outputs, primary = 0; int noutputs = 0; Ecore_X_Randr_Mode_Info *mode_info; Ecore_X_Randr_Mode mode; @@ -755,6 +757,14 @@ e_smart_monitor_changes_apply(Evas_Object *obj) /* try to get the objects smart data */ if (!(sd = evas_object_smart_data_get(obj))) return EINA_FALSE; + primary = (Ecore_X_Randr_Output)e_randr_cfg->primary; + sd->primary = (sd->output == primary); + + if (sd->primary) + edje_object_signal_emit(sd->o_frame, "e,state,primary,on", "e"); + else + edje_object_signal_emit(sd->o_frame, "e,state,primary,off", "e"); + /* if we have no changes to apply, get out */ if (sd->changes <= E_SMART_MONITOR_CHANGED_NONE) return EINA_FALSE; @@ -855,6 +865,28 @@ e_smart_monitor_changes_apply(Evas_Object *obj) return EINA_TRUE; } +const char * +e_smart_monitor_name_get(Evas_Object *obj) +{ + E_Smart_Data *sd; + + /* try to get the objects smart data */ + if (!(sd = evas_object_smart_data_get(obj))) return NULL; + + /* get output name */ + return edje_object_part_text_get(sd->o_frame, "e.text.name"); +} + +Ecore_X_Randr_Output +e_smart_monitor_output_get(Evas_Object *obj) +{ + E_Smart_Data *sd; + + /* try to get the objects smart data */ + if (!(sd = evas_object_smart_data_get(obj))) return 0; + return sd->output; +} + /* smart functions */ static void _e_smart_add(Evas_Object *obj) diff --git a/src/modules/conf_randr/e_smart_monitor.h b/src/modules/conf_randr/e_smart_monitor.h index 79ba0ae9d..f2f053a05 100644 --- a/src/modules/conf_randr/e_smart_monitor.h +++ b/src/modules/conf_randr/e_smart_monitor.h @@ -7,10 +7,11 @@ typedef enum _E_Smart_Monitor_Changes E_Smart_Monitor_Changes; enum _E_Smart_Monitor_Changes { E_SMART_MONITOR_CHANGED_NONE = 0, - E_SMART_MONITOR_CHANGED_MODE = (1 << 0), - E_SMART_MONITOR_CHANGED_POSITION = (1 << 1), - E_SMART_MONITOR_CHANGED_ORIENTATION = (1 << 2), - E_SMART_MONITOR_CHANGED_ENABLED = (1 << 3) + E_SMART_MONITOR_CHANGED_MODE = (1 << 0), + E_SMART_MONITOR_CHANGED_POSITION = (1 << 1), + E_SMART_MONITOR_CHANGED_ORIENTATION = (1 << 2), + E_SMART_MONITOR_CHANGED_ENABLED = (1 << 3), + E_SMART_MONITOR_CHANGED_PRIMARY = (1 << 4) }; Evas_Object *e_smart_monitor_add(Evas *evas); @@ -26,6 +27,8 @@ void e_smart_monitor_clone_set(Evas_Object *obj, Evas_Object *parent); Evas_Object *e_smart_monitor_clone_parent_get(Evas_Object *obj); E_Smart_Monitor_Changes e_smart_monitor_changes_get(Evas_Object *obj); Eina_Bool e_smart_monitor_changes_apply(Evas_Object *obj); +const char *e_smart_monitor_name_get(Evas_Object *obj); +Ecore_X_Randr_Output e_smart_monitor_output_get(Evas_Object *obj); # endif #endif diff --git a/src/modules/conf_randr/e_smart_randr.c b/src/modules/conf_randr/e_smart_randr.c index f925abcb2..c55ba653f 100644 --- a/src/modules/conf_randr/e_smart_randr.c +++ b/src/modules/conf_randr/e_smart_randr.c @@ -403,6 +403,16 @@ e_smart_randr_changes_apply(Evas_Object *obj) ecore_x_randr_screen_reset(ecore_x_window_root_first_get()); } +Eina_List * +e_smart_randr_monitors_get(Evas_Object *obj) +{ + E_Smart_Data *sd; + + /* try to get the objects smart data */ + if (!(sd = evas_object_smart_data_get(obj))) return NULL; + return sd->monitors; +} + /* local functions */ static void _e_smart_add(Evas_Object *obj) diff --git a/src/modules/conf_randr/e_smart_randr.h b/src/modules/conf_randr/e_smart_randr.h index 2062e03ae..37cd7d9a6 100644 --- a/src/modules/conf_randr/e_smart_randr.h +++ b/src/modules/conf_randr/e_smart_randr.h @@ -9,6 +9,7 @@ void e_smart_randr_monitors_create(Evas_Object *obj); void e_smart_randr_min_size_get(Evas_Object *obj, Evas_Coord *mw, Evas_Coord *mh); Eina_Bool e_smart_randr_changed_get(Evas_Object *obj); void e_smart_randr_changes_apply(Evas_Object *obj); +Eina_List *e_smart_randr_monitors_get(Evas_Object *obj); # endif #endif