2013-02-19 02:55:04 -08:00
|
|
|
#include "e.h"
|
|
|
|
#include "e_mod_main.h"
|
|
|
|
#include "e_smart_randr.h"
|
2013-02-19 02:55:36 -08:00
|
|
|
#include "e_smart_monitor.h"
|
2013-02-19 02:55:04 -08:00
|
|
|
|
|
|
|
/* local structures */
|
|
|
|
typedef struct _E_Smart_Data E_Smart_Data;
|
|
|
|
struct _E_Smart_Data
|
|
|
|
{
|
2013-02-19 02:55:14 -08:00
|
|
|
/* layout object */
|
|
|
|
Evas_Object *o_layout;
|
|
|
|
|
2013-02-19 02:55:04 -08:00
|
|
|
/* visible flag */
|
|
|
|
Eina_Bool visible : 1;
|
2013-02-19 02:55:39 -08:00
|
|
|
|
|
|
|
/* list of monitors */
|
|
|
|
Eina_List *monitors;
|
2013-02-19 02:55:04 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* local function prototypes */
|
|
|
|
static void _e_smart_add(Evas_Object *obj);
|
|
|
|
static void _e_smart_del(Evas_Object *obj);
|
|
|
|
static void _e_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
|
|
|
|
static void _e_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h);
|
|
|
|
static void _e_smart_show(Evas_Object *obj);
|
|
|
|
static void _e_smart_hide(Evas_Object *obj);
|
|
|
|
static void _e_smart_clip_set(Evas_Object *obj, Evas_Object *clip);
|
|
|
|
static void _e_smart_clip_unset(Evas_Object *obj);
|
|
|
|
|
|
|
|
/* external functions exposed by this widget */
|
|
|
|
Evas_Object *
|
|
|
|
e_smart_randr_add(Evas *evas)
|
|
|
|
{
|
|
|
|
static Evas_Smart *smart = NULL;
|
|
|
|
static const Evas_Smart_Class sc =
|
|
|
|
{
|
|
|
|
"smart_randr", EVAS_SMART_CLASS_VERSION,
|
|
|
|
_e_smart_add, _e_smart_del, _e_smart_move, _e_smart_resize,
|
|
|
|
_e_smart_show, _e_smart_hide, NULL,
|
|
|
|
_e_smart_clip_set, _e_smart_clip_unset,
|
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
/* if we have never created the smart class, do it now */
|
|
|
|
if (!smart)
|
|
|
|
if (!(smart = evas_smart_class_new(&sc)))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* return a newly created smart randr widget */
|
|
|
|
return evas_object_smart_add(evas, smart);
|
|
|
|
}
|
|
|
|
|
2013-02-19 02:55:36 -08:00
|
|
|
void
|
|
|
|
e_smart_randr_monitors_create(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
E_Smart_Data *sd;
|
2013-02-19 02:55:50 -08:00
|
|
|
Evas *evas;
|
|
|
|
Eina_List *l = NULL;
|
|
|
|
E_Randr_Crtc_Config *crtc;
|
2013-02-19 02:55:36 -08:00
|
|
|
|
|
|
|
/* try to get the objects smart data */
|
|
|
|
if (!(sd = evas_object_smart_data_get(obj))) return;
|
2013-02-19 02:55:50 -08:00
|
|
|
|
|
|
|
/* grab the canvas of the layout widget */
|
|
|
|
evas = evas_object_evas_get(sd->o_layout);
|
|
|
|
|
|
|
|
/* loop the list of crtcs in our config */
|
|
|
|
EINA_LIST_FOREACH(e_randr_cfg->crtcs, l, crtc)
|
|
|
|
{
|
|
|
|
Eina_List *o = NULL;
|
|
|
|
E_Randr_Output_Config *output;
|
|
|
|
|
|
|
|
/* loop the list of outputs in this crtc */
|
|
|
|
EINA_LIST_FOREACH(crtc->outputs, o, output)
|
|
|
|
{
|
|
|
|
Evas_Object *mon;
|
|
|
|
|
|
|
|
/* for each output, try to create a monitor */
|
|
|
|
if (!(mon = e_smart_monitor_add(evas)))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* tell monitor what crtc it uses */
|
|
|
|
e_smart_monitor_crtc_set(mon, crtc);
|
|
|
|
|
|
|
|
/* tell monitor what output it uses */
|
|
|
|
e_smart_monitor_output_set(mon, output);
|
|
|
|
}
|
|
|
|
}
|
2013-02-19 02:55:36 -08:00
|
|
|
}
|
|
|
|
|
2013-02-19 02:55:04 -08:00
|
|
|
/* local functions */
|
|
|
|
static void
|
|
|
|
_e_smart_add(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
E_Smart_Data *sd;
|
|
|
|
Evas *evas;
|
|
|
|
|
|
|
|
/* try to allocate the smart data structure */
|
|
|
|
if (!(sd = E_NEW(E_Smart_Data, 1))) return;
|
|
|
|
|
|
|
|
/* grab the canvas */
|
|
|
|
evas = evas_object_evas_get(obj);
|
2013-02-19 02:55:14 -08:00
|
|
|
|
|
|
|
/* create the layout object */
|
|
|
|
sd->o_layout = e_layout_add(evas);
|
|
|
|
|
|
|
|
/* set the object's smart data */
|
|
|
|
evas_object_smart_data_set(obj, sd);
|
2013-02-19 02:55:04 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_smart_del(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
E_Smart_Data *sd;
|
2013-02-19 02:55:39 -08:00
|
|
|
Evas_Object *mon;
|
2013-02-19 02:55:04 -08:00
|
|
|
|
|
|
|
/* try to get the objects smart data */
|
|
|
|
if (!(sd = evas_object_smart_data_get(obj))) return;
|
|
|
|
|
2013-02-19 02:55:39 -08:00
|
|
|
/* free the monitors */
|
|
|
|
EINA_LIST_FREE(sd->monitors, mon)
|
|
|
|
evas_object_del(mon);
|
|
|
|
|
2013-02-19 02:55:14 -08:00
|
|
|
/* delete the layout object */
|
|
|
|
if (sd->o_layout) evas_object_del(sd->o_layout);
|
|
|
|
|
2013-02-19 02:55:04 -08:00
|
|
|
/* try to free the allocated structure */
|
|
|
|
E_FREE(sd);
|
|
|
|
|
|
|
|
/* set the objects smart data to null */
|
|
|
|
evas_object_smart_data_set(obj, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
|
|
|
|
{
|
|
|
|
E_Smart_Data *sd;
|
|
|
|
|
|
|
|
/* try to get the objects smart data */
|
|
|
|
if (!(sd = evas_object_smart_data_get(obj))) return;
|
2013-02-19 02:55:14 -08:00
|
|
|
|
|
|
|
/* move the layout object */
|
|
|
|
if (sd->o_layout) evas_object_move(sd->o_layout, x, y);
|
2013-02-19 02:55:04 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
|
|
|
|
{
|
|
|
|
E_Smart_Data *sd;
|
|
|
|
|
|
|
|
/* try to get the objects smart data */
|
|
|
|
if (!(sd = evas_object_smart_data_get(obj))) return;
|
2013-02-19 02:55:14 -08:00
|
|
|
|
|
|
|
/* resize the layout object */
|
|
|
|
if (sd->o_layout) evas_object_resize(sd->o_layout, w, h);
|
2013-02-19 02:55:04 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_smart_show(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
E_Smart_Data *sd;
|
|
|
|
|
|
|
|
/* try to get the objects smart data */
|
|
|
|
if (!(sd = evas_object_smart_data_get(obj))) return;
|
|
|
|
|
|
|
|
/* if it is already visible, get out */
|
|
|
|
if (sd->visible) return;
|
|
|
|
|
2013-02-19 02:55:14 -08:00
|
|
|
/* show the layout object */
|
|
|
|
if (sd->o_layout) evas_object_show(sd->o_layout);
|
|
|
|
|
2013-02-19 02:55:04 -08:00
|
|
|
/* set visibility flag */
|
|
|
|
sd->visible = EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_smart_hide(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
E_Smart_Data *sd;
|
|
|
|
|
|
|
|
/* try to get the objects smart data */
|
|
|
|
if (!(sd = evas_object_smart_data_get(obj))) return;
|
|
|
|
|
|
|
|
/* if it is not visible, we have nothing to do */
|
|
|
|
if (!sd->visible) return;
|
|
|
|
|
2013-02-19 02:55:14 -08:00
|
|
|
/* hide the layout object */
|
|
|
|
if (sd->o_layout) evas_object_hide(sd->o_layout);
|
|
|
|
|
2013-02-19 02:55:04 -08:00
|
|
|
/* set visibility flag */
|
|
|
|
sd->visible = EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_smart_clip_set(Evas_Object *obj, Evas_Object *clip)
|
|
|
|
{
|
|
|
|
E_Smart_Data *sd;
|
|
|
|
|
|
|
|
/* try to get the objects smart data */
|
|
|
|
if (!(sd = evas_object_smart_data_get(obj))) return;
|
2013-02-19 02:55:14 -08:00
|
|
|
|
|
|
|
/* set the clip */
|
|
|
|
if (sd->o_layout) evas_object_clip_set(sd->o_layout, clip);
|
2013-02-19 02:55:04 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_smart_clip_unset(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
E_Smart_Data *sd;
|
|
|
|
|
|
|
|
/* try to get the objects smart data */
|
|
|
|
if (!(sd = evas_object_smart_data_get(obj))) return;
|
2013-02-19 02:55:14 -08:00
|
|
|
|
|
|
|
/* unset the clip */
|
|
|
|
if (sd->o_layout) evas_object_clip_unset(sd->o_layout);
|
2013-02-19 02:55:04 -08:00
|
|
|
}
|