forked from enlightenment/enlightenment
Remove old randr code.
Signed-off-by: Christopher Michael <cp.michael@samsung.com> SVN revision: 81071
This commit is contained in:
parent
e41c2b9343
commit
3b74f38de2
|
@ -1,282 +0,0 @@
|
|||
#include "e.h"
|
||||
#include "e_mod_main.h"
|
||||
#include "e_smart_randr.h"
|
||||
#include "e_smart_monitor.h"
|
||||
|
||||
/* local structures */
|
||||
struct _E_Config_Dialog_Data
|
||||
{
|
||||
Evas_Object *o_scroll;
|
||||
};
|
||||
|
||||
/* local function prototypes */
|
||||
static void *_create_data(E_Config_Dialog *cfd __UNUSED__);
|
||||
static void _free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata);
|
||||
static int _basic_apply(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata);
|
||||
static Evas_Object *_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
|
||||
static void _randr_cb_changed(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__);
|
||||
|
||||
/* local variables */
|
||||
|
||||
E_Config_Dialog *
|
||||
e_int_config_randr(E_Container *con, const char *params __UNUSED__)
|
||||
{
|
||||
E_Config_Dialog *cfd;
|
||||
E_Config_Dialog_View *v;
|
||||
|
||||
if (e_randr_screen_info.randr_version < ECORE_X_RANDR_1_2)
|
||||
return NULL;
|
||||
|
||||
if (e_config_dialog_find("E", "screen/screen_setup")) return NULL;
|
||||
|
||||
if (!(v = E_NEW(E_Config_Dialog_View, 1))) return NULL;
|
||||
|
||||
v->create_cfdata = _create_data;
|
||||
v->free_cfdata = _free_data;
|
||||
v->basic.create_widgets = _basic_create;
|
||||
v->basic.apply_cfdata = _basic_apply;
|
||||
|
||||
v->override_auto_apply = EINA_TRUE;
|
||||
|
||||
cfd = e_config_dialog_new(con, _("Screen Setup"),
|
||||
"E", "screen/screen_setup",
|
||||
"preferences-system-screen-resolution",
|
||||
0, v, NULL);
|
||||
|
||||
/* NB: These are just arbitrary values I picked. Feel free to change */
|
||||
e_win_size_min_set(cfd->dia->win, 180, 230);
|
||||
|
||||
return cfd;
|
||||
}
|
||||
|
||||
/* local functions */
|
||||
static void *
|
||||
_create_data(E_Config_Dialog *cfd __UNUSED__)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
||||
if (!(cfdata = E_NEW(E_Config_Dialog_Data, 1))) return NULL;
|
||||
return cfdata;
|
||||
}
|
||||
|
||||
static void
|
||||
_free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
evas_object_smart_callback_del(cfdata->o_scroll, "changed",
|
||||
_randr_cb_changed);
|
||||
evas_object_del(cfdata->o_scroll);
|
||||
|
||||
E_FREE(cfdata);
|
||||
}
|
||||
|
||||
static int
|
||||
_basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
Eina_List *l;
|
||||
Evas_Object *mon;
|
||||
Ecore_X_Window root;
|
||||
Eina_Bool reset = EINA_FALSE;
|
||||
|
||||
root = cfd->con->manager->root;
|
||||
|
||||
EINA_LIST_FOREACH(e_smart_randr_monitors_get(cfdata->o_scroll), l, mon)
|
||||
{
|
||||
E_Randr_Crtc_Info *crtc;
|
||||
E_Randr_Output_Info *output;
|
||||
E_Smart_Monitor_Changes changes = E_SMART_MONITOR_CHANGED_NONE;
|
||||
|
||||
if (!(output = e_smart_monitor_output_get(mon)))
|
||||
continue;
|
||||
|
||||
if (!(crtc = e_smart_monitor_crtc_get(mon)))
|
||||
{
|
||||
Eina_List *c;
|
||||
|
||||
EINA_LIST_FOREACH(E_RANDR_12->crtcs, c, crtc)
|
||||
{
|
||||
if (crtc->current_mode)
|
||||
{
|
||||
crtc = NULL;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!crtc) continue;
|
||||
|
||||
if (!(changes = e_smart_monitor_changes_get(mon)))
|
||||
continue;
|
||||
|
||||
if (changes & E_SMART_MONITOR_CHANGED_ENABLED)
|
||||
{
|
||||
if (e_smart_monitor_enabled_get(mon))
|
||||
{
|
||||
if (crtc)
|
||||
{
|
||||
Ecore_X_Randr_Output *outputs;
|
||||
Ecore_X_Randr_Mode_Info *mode;
|
||||
Ecore_X_Randr_Orientation orient;
|
||||
Evas_Coord mx, my;
|
||||
int noutputs = -1;
|
||||
|
||||
mode = e_smart_monitor_mode_get(mon);
|
||||
orient = e_smart_monitor_orientation_get(mon);
|
||||
e_smart_monitor_position_get(mon, &mx, &my);
|
||||
|
||||
noutputs = eina_list_count(crtc->outputs);
|
||||
if (noutputs < 1)
|
||||
{
|
||||
outputs = calloc(1, sizeof(Ecore_X_Randr_Output));
|
||||
outputs[0] = output->xid;
|
||||
noutputs = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
outputs =
|
||||
calloc(noutputs, sizeof(Ecore_X_Randr_Output));
|
||||
for (i = 0; i < noutputs; i++)
|
||||
{
|
||||
E_Randr_Output_Info *ero;
|
||||
|
||||
ero = eina_list_data_get(eina_list_nth(crtc->outputs, i));
|
||||
outputs[i] = ero->xid;
|
||||
}
|
||||
}
|
||||
|
||||
ecore_x_randr_crtc_settings_set(root, crtc->xid,
|
||||
outputs,
|
||||
noutputs, mx, my,
|
||||
mode->xid, orient);
|
||||
if (outputs) free(outputs);
|
||||
}
|
||||
}
|
||||
else
|
||||
ecore_x_randr_crtc_settings_set(root, crtc->xid,
|
||||
NULL, 0, 0, 0, 0,
|
||||
ECORE_X_RANDR_ORIENTATION_ROT_0);
|
||||
|
||||
reset = EINA_TRUE;
|
||||
}
|
||||
|
||||
if (changes & E_SMART_MONITOR_CHANGED_POSITION)
|
||||
{
|
||||
if (crtc)
|
||||
{
|
||||
Evas_Coord mx, my;
|
||||
Evas_Coord cx, cy;
|
||||
|
||||
e_smart_monitor_position_get(mon, &mx, &my);
|
||||
ecore_x_randr_crtc_pos_get(root, crtc->xid, &cx, &cy);
|
||||
if ((cx != mx) || (cy != my))
|
||||
{
|
||||
ecore_x_randr_crtc_pos_set(root, crtc->xid, mx, my);
|
||||
reset = EINA_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (changes & E_SMART_MONITOR_CHANGED_ROTATION)
|
||||
{
|
||||
if (crtc)
|
||||
{
|
||||
Ecore_X_Randr_Orientation orient;
|
||||
|
||||
orient = e_smart_monitor_orientation_get(mon);
|
||||
if ((crtc) && (orient != crtc->current_orientation))
|
||||
{
|
||||
ecore_x_randr_crtc_orientation_set(root,
|
||||
crtc->xid, orient);
|
||||
reset = EINA_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((changes & E_SMART_MONITOR_CHANGED_REFRESH) ||
|
||||
(changes & E_SMART_MONITOR_CHANGED_RESOLUTION))
|
||||
{
|
||||
if (crtc)
|
||||
{
|
||||
Ecore_X_Randr_Mode_Info *mode;
|
||||
Ecore_X_Randr_Output *outputs = NULL;
|
||||
int noutputs = -1;
|
||||
|
||||
if (output) outputs = &output->xid;
|
||||
|
||||
if ((crtc) && (crtc->outputs))
|
||||
noutputs = eina_list_count(crtc->outputs);
|
||||
|
||||
mode = e_smart_monitor_mode_get(mon);
|
||||
ecore_x_randr_crtc_mode_set(root, crtc->xid,
|
||||
outputs, noutputs, mode->xid);
|
||||
reset = EINA_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (reset)
|
||||
{
|
||||
/* monitors changes have been sent. Signal this monitor so that
|
||||
* we can reset the 'original' values to the 'current' values
|
||||
* and reset the 'changes' variable */
|
||||
e_smart_monitor_changes_sent(mon);
|
||||
}
|
||||
}
|
||||
|
||||
if (reset) ecore_x_randr_screen_reset(root);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
Evas_Object *o;
|
||||
Eina_List *l;
|
||||
E_Randr_Output_Info *output;
|
||||
|
||||
o = e_widget_list_add(evas, 0, 0);
|
||||
|
||||
cfdata->o_scroll = e_smart_randr_add(evas);
|
||||
e_smart_randr_virtual_size_set(cfdata->o_scroll,
|
||||
E_RANDR_12->max_size.width,
|
||||
E_RANDR_12->max_size.height);
|
||||
evas_object_show(cfdata->o_scroll);
|
||||
|
||||
evas_object_smart_callback_add(cfdata->o_scroll, "changed",
|
||||
_randr_cb_changed, cfd);
|
||||
|
||||
/* create monitors based on 'outputs' */
|
||||
EINA_LIST_FOREACH(E_RANDR_12->outputs, l, output)
|
||||
{
|
||||
Evas_Object *m;
|
||||
|
||||
if (!output) continue;
|
||||
|
||||
if (output->connection_status !=
|
||||
ECORE_X_RANDR_CONNECTION_STATUS_CONNECTED)
|
||||
continue;
|
||||
|
||||
if (!(m = e_smart_monitor_add(evas))) continue;
|
||||
e_smart_monitor_info_set(m, output, output->crtc);
|
||||
e_smart_randr_monitor_add(cfdata->o_scroll, m);
|
||||
evas_object_show(m);
|
||||
}
|
||||
|
||||
e_widget_list_object_append(o, cfdata->o_scroll, 1, 1, 0.5);
|
||||
|
||||
e_dialog_resizable_set(cfd->dia, 1);
|
||||
return o;
|
||||
}
|
||||
|
||||
static void
|
||||
_randr_cb_changed(void *data, Evas_Object *obj, void *event __UNUSED__)
|
||||
{
|
||||
E_Config_Dialog *cfd;
|
||||
Eina_Bool changed = EINA_FALSE;
|
||||
|
||||
if (!(cfd = data)) return;
|
||||
changed = e_smart_randr_changed_get(obj);
|
||||
e_config_dialog_changed_set(cfd, changed);
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
#include "e.h"
|
||||
#include "e_mod_main.h"
|
||||
|
||||
const char *mod_dir = NULL;
|
||||
|
||||
EAPI E_Module_Api e_modapi =
|
||||
{
|
||||
E_MODULE_API_VERSION, "Settings - Screen Setup"
|
||||
};
|
||||
|
||||
EAPI void *
|
||||
e_modapi_init(E_Module *m)
|
||||
{
|
||||
e_configure_registry_category_add("screen", 30, _("Screen"),
|
||||
NULL, "preferences-desktop-display");
|
||||
e_configure_registry_item_add("screen/screen_setup", 20, _("Screen Setup"), NULL,
|
||||
"preferences-system-screen-resolution",
|
||||
e_int_config_randr);
|
||||
e_module_delayed_set(m, 1);
|
||||
|
||||
mod_dir = eina_stringshare_add(m->dir);
|
||||
return m;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_modapi_shutdown(E_Module *m __UNUSED__)
|
||||
{
|
||||
E_Config_Dialog *cfd;
|
||||
|
||||
if (mod_dir) eina_stringshare_del(mod_dir);
|
||||
mod_dir = NULL;
|
||||
|
||||
while ((cfd = e_config_dialog_get("E", "screen/screen_setup")))
|
||||
e_object_del(E_OBJECT(cfd));
|
||||
|
||||
e_configure_registry_item_del("screen/screen_setup");
|
||||
e_configure_registry_category_del("screen");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_modapi_save(E_Module *m __UNUSED__)
|
||||
{
|
||||
return 1;
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
#ifndef E_MOD_MAIN_H
|
||||
# define E_MOD_MAIN_H
|
||||
|
||||
#ifndef ECORE_X_RANDR_1_2
|
||||
# define ECORE_X_RANDR_1_2 ((1 << 16) | 2)
|
||||
#endif
|
||||
|
||||
#ifndef ECORE_X_RANDR_1_3
|
||||
# define ECORE_X_RANDR_1_3 ((1 << 16) | 3)
|
||||
#endif
|
||||
|
||||
#ifndef E_RANDR_12
|
||||
# define E_RANDR_12 (e_randr_screen_info.rrvd_info.randr_info_12)
|
||||
#endif
|
||||
|
||||
E_Config_Dialog *e_int_config_randr(E_Container *con, const char *params __UNUSED__);
|
||||
extern const char *mod_dir;
|
||||
|
||||
/**
|
||||
* @addtogroup Optional_Conf
|
||||
* @{
|
||||
*
|
||||
* @defgroup Module_Conf_RandR RandR (Screen Resize, Rotate and Mirror)
|
||||
*
|
||||
* Configures size, rotation and mirroring of screen. Uses the X11
|
||||
* RandR protocol (does not work with NVidia proprietary drivers).
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -1,38 +0,0 @@
|
|||
#ifdef E_TYPEDEFS
|
||||
#else
|
||||
# ifndef E_SMART_MONITOR_H
|
||||
|
||||
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_CRTC = (1 << 0),
|
||||
E_SMART_MONITOR_CHANGED_MODE = (1 << 1),
|
||||
E_SMART_MONITOR_CHANGED_POSITION = (1 << 2),
|
||||
E_SMART_MONITOR_CHANGED_ROTATION = (1 << 3),
|
||||
E_SMART_MONITOR_CHANGED_REFRESH = (1 << 4),
|
||||
E_SMART_MONITOR_CHANGED_RESOLUTION = (1 << 5),
|
||||
E_SMART_MONITOR_CHANGED_ENABLED = (1 << 6)
|
||||
};
|
||||
|
||||
Evas_Object *e_smart_monitor_add(Evas *evas);
|
||||
void e_smart_monitor_layout_set(Evas_Object *obj, Evas_Object *layout);
|
||||
void e_smart_monitor_info_set(Evas_Object *obj, E_Randr_Output_Info *output, E_Randr_Crtc_Info *crtc);
|
||||
E_Randr_Crtc_Info *e_smart_monitor_crtc_get(Evas_Object *obj);
|
||||
E_Randr_Output_Info *e_smart_monitor_output_get(Evas_Object *obj);
|
||||
void e_smart_monitor_crtc_geometry_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
|
||||
void e_smart_monitor_move_geometry_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
|
||||
Eina_Bool e_smart_monitor_changed_get(Evas_Object *obj);
|
||||
E_Smart_Monitor_Changes e_smart_monitor_changes_get(Evas_Object *obj);
|
||||
void e_smart_monitor_changes_sent(Evas_Object *obj);
|
||||
|
||||
|
||||
Eina_Bool e_smart_monitor_moving_get(Evas_Object *obj);
|
||||
void e_smart_monitor_position_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
|
||||
Ecore_X_Randr_Orientation e_smart_monitor_orientation_get(Evas_Object *obj);
|
||||
Ecore_X_Randr_Mode_Info *e_smart_monitor_mode_get(Evas_Object *obj);
|
||||
Eina_Bool e_smart_monitor_enabled_get(Evas_Object *obj);
|
||||
|
||||
# define E_SMART_MONITOR_H
|
||||
# endif
|
||||
#endif
|
|
@ -1,500 +0,0 @@
|
|||
#include "e.h"
|
||||
#include "e_mod_main.h"
|
||||
#include "e_smart_randr.h"
|
||||
#include "e_smart_monitor.h"
|
||||
|
||||
/* 'Smart' widget to wrap a pan and scroll into one */
|
||||
|
||||
typedef struct _E_Smart_Data E_Smart_Data;
|
||||
struct _E_Smart_Data
|
||||
{
|
||||
/* changed flag */
|
||||
Eina_Bool changed : 1;
|
||||
|
||||
/* visible flag */
|
||||
Eina_Bool visible : 1;
|
||||
|
||||
/* objects in this widget */
|
||||
Evas_Object *o_scroll, *o_layout;
|
||||
|
||||
/* list of monitors */
|
||||
Eina_List *items;
|
||||
};
|
||||
|
||||
/* 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);
|
||||
static void _e_smart_randr_layout_adjust(E_Smart_Data *sd, Evas_Object *obj);
|
||||
static void _e_smart_randr_layout_reposition(E_Smart_Data *sd, Evas_Object *obj);
|
||||
static void _e_smart_randr_changed_set(Evas_Object *obj);
|
||||
|
||||
static void _e_smart_cb_monitor_resized(void *data, Evas_Object *obj, void *event __UNUSED__);
|
||||
static void _e_smart_cb_monitor_rotated(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__);
|
||||
static void _e_smart_cb_monitor_moved(void *data, Evas_Object *obj, void *event __UNUSED__);
|
||||
static void _e_smart_cb_monitor_toggled(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__);
|
||||
static void _e_smart_cb_monitor_deleted(void *data __UNUSED__, Evas *evas __UNUSED__, Evas_Object *obj, void *event __UNUSED__);
|
||||
|
||||
/* public functions */
|
||||
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 (!smart)
|
||||
if (!(smart = evas_smart_class_new(&sc)))
|
||||
return NULL;
|
||||
|
||||
return evas_object_smart_add(evas, smart);
|
||||
}
|
||||
|
||||
void
|
||||
e_smart_randr_virtual_size_set(Evas_Object *obj, Evas_Coord vw, Evas_Coord vh)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
|
||||
if (!(sd = evas_object_smart_data_get(obj)))
|
||||
return;
|
||||
|
||||
/* set virutal size for layout */
|
||||
e_layout_virtual_size_set(sd->o_layout, vw, vh);
|
||||
}
|
||||
|
||||
void
|
||||
e_smart_randr_monitor_add(Evas_Object *obj, Evas_Object *mon)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
Evas_Coord cx, cy, cw, ch;
|
||||
|
||||
if (!(sd = evas_object_smart_data_get(obj)))
|
||||
return;
|
||||
|
||||
/* tell monitor what layout it is in */
|
||||
e_smart_monitor_layout_set(mon, sd->o_layout);
|
||||
|
||||
/* add listeners for when this monitor changes */
|
||||
evas_object_smart_callback_add(mon, "monitor_resized",
|
||||
_e_smart_cb_monitor_resized, obj);
|
||||
evas_object_smart_callback_add(mon, "monitor_rotated",
|
||||
_e_smart_cb_monitor_rotated, obj);
|
||||
evas_object_smart_callback_add(mon, "monitor_moved",
|
||||
_e_smart_cb_monitor_moved, obj);
|
||||
evas_object_smart_callback_add(mon, "monitor_toggled",
|
||||
_e_smart_cb_monitor_toggled, obj);
|
||||
|
||||
/* add listener for when this monitor gets removed */
|
||||
evas_object_event_callback_add(mon, EVAS_CALLBACK_DEL,
|
||||
_e_smart_cb_monitor_deleted, sd);
|
||||
|
||||
/* pack this monitor into the layout */
|
||||
e_layout_pack(sd->o_layout, mon);
|
||||
|
||||
e_smart_monitor_crtc_geometry_get(mon, &cx, &cy, &cw, &ch);
|
||||
e_layout_child_move(mon, cx, cy);
|
||||
e_layout_child_resize(mon, cw, ch);
|
||||
|
||||
e_layout_child_lower(mon);
|
||||
|
||||
/* append this monitor to our list */
|
||||
sd->items = eina_list_append(sd->items, mon);
|
||||
}
|
||||
|
||||
Eina_List *
|
||||
e_smart_randr_monitors_get(Evas_Object *obj)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
|
||||
if (!(sd = evas_object_smart_data_get(obj)))
|
||||
return NULL;
|
||||
|
||||
return sd->items;
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
e_smart_randr_changed_get(Evas_Object *obj)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
|
||||
if (!(sd = evas_object_smart_data_get(obj)))
|
||||
return EINA_FALSE;
|
||||
|
||||
return sd->changed;
|
||||
}
|
||||
|
||||
/* local functions */
|
||||
static void
|
||||
_e_smart_add(Evas_Object *obj)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
Evas *evas;
|
||||
|
||||
if (!(sd = calloc(1, sizeof(E_Smart_Data))))
|
||||
return;
|
||||
|
||||
evas = evas_object_evas_get(obj);
|
||||
|
||||
/* add layout object */
|
||||
sd->o_layout = e_layout_add(evas);
|
||||
evas_object_resize(sd->o_layout,
|
||||
E_RANDR_12->max_size.width / 8,
|
||||
E_RANDR_12->max_size.height / 8);
|
||||
evas_object_show(sd->o_layout);
|
||||
|
||||
/* add scroll object */
|
||||
sd->o_scroll = e_scrollframe_add(evas);
|
||||
e_scrollframe_child_set(sd->o_scroll, sd->o_layout);
|
||||
evas_object_smart_member_add(sd->o_scroll, obj);
|
||||
|
||||
evas_object_smart_data_set(obj, sd);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_smart_del(Evas_Object *obj)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
Evas_Object *mon;
|
||||
|
||||
if (!(sd = evas_object_smart_data_get(obj)))
|
||||
return;
|
||||
|
||||
/* delete the monitors */
|
||||
EINA_LIST_FREE(sd->items, mon)
|
||||
evas_object_del(mon);
|
||||
|
||||
/* delete objects */
|
||||
evas_object_del(sd->o_layout);
|
||||
evas_object_del(sd->o_scroll);
|
||||
|
||||
E_FREE(sd);
|
||||
|
||||
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;
|
||||
|
||||
if (!(sd = evas_object_smart_data_get(obj)))
|
||||
return;
|
||||
|
||||
evas_object_move(sd->o_scroll, x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
|
||||
if (!(sd = evas_object_smart_data_get(obj)))
|
||||
return;
|
||||
|
||||
evas_object_resize(sd->o_scroll, w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_smart_show(Evas_Object *obj)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
|
||||
if (!(sd = evas_object_smart_data_get(obj)))
|
||||
return;
|
||||
|
||||
if (sd->visible) return;
|
||||
evas_object_show(sd->o_scroll);
|
||||
sd->visible = EINA_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_smart_hide(Evas_Object *obj)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
|
||||
if (!(sd = evas_object_smart_data_get(obj)))
|
||||
return;
|
||||
|
||||
if (!sd->visible) return;
|
||||
evas_object_hide(sd->o_scroll);
|
||||
sd->visible = EINA_FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_smart_clip_set(Evas_Object *obj, Evas_Object *clip)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
|
||||
if (!(sd = evas_object_smart_data_get(obj)))
|
||||
return;
|
||||
|
||||
evas_object_clip_set(sd->o_scroll, clip);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_smart_clip_unset(Evas_Object *obj)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
|
||||
if (!(sd = evas_object_smart_data_get(obj)))
|
||||
return;
|
||||
|
||||
evas_object_clip_unset(sd->o_scroll);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_smart_randr_layout_adjust(E_Smart_Data *sd, Evas_Object *obj)
|
||||
{
|
||||
Eina_List *l = NULL;
|
||||
Evas_Object *mon;
|
||||
Eina_Rectangle o;
|
||||
|
||||
if (!sd) return;
|
||||
|
||||
/* grab the geometry of this monitor (returned in virtual coords) */
|
||||
e_layout_child_geometry_get(obj, &o.x, &o.y, &o.w, &o.h);
|
||||
|
||||
/* freeze layout */
|
||||
e_layout_freeze(sd->o_layout);
|
||||
|
||||
/* find any monitors to the right or below this one */
|
||||
/* NB: We do not have to worry about monitors to the left or above as their
|
||||
* size will not change because of this resize event */
|
||||
EINA_LIST_FOREACH(sd->items, l, mon)
|
||||
{
|
||||
Eina_Rectangle m;
|
||||
|
||||
/* skip if it's the current monitor */
|
||||
if ((mon == obj)) continue;
|
||||
|
||||
/* grab the geometry of this monitor (returned in virtual coords) */
|
||||
e_layout_child_geometry_get(mon, &m.x, &m.y, &m.w, &m.h);
|
||||
|
||||
if ((m.x >= (o.x + o.w)))
|
||||
{
|
||||
/* if this monitor is to the right, move it */
|
||||
e_layout_child_move(mon, (o.x + o.w), m.y);
|
||||
}
|
||||
else if ((m.y >= (o.y + o.h)))
|
||||
{
|
||||
/* if this monitor is below, move it */
|
||||
e_layout_child_move(mon, m.x, (o.y + o.h));
|
||||
}
|
||||
}
|
||||
|
||||
/* thaw layout to allow redraw */
|
||||
e_layout_thaw(sd->o_layout);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_smart_randr_layout_reposition(E_Smart_Data *sd, Evas_Object *obj)
|
||||
{
|
||||
Eina_List *l = NULL;
|
||||
Evas_Object *mon;
|
||||
Eina_Rectangle o, r;
|
||||
Evas_Coord px, py, lx, ly;
|
||||
|
||||
if (!sd) return;
|
||||
|
||||
/* get the layout geometry */
|
||||
evas_object_geometry_get(sd->o_layout, &lx, &ly, NULL, NULL);
|
||||
|
||||
e_smart_monitor_move_geometry_get(obj, &px, &py, NULL, NULL);
|
||||
/* we need to subtract the layout object position from the
|
||||
* returned values here because e_layout adds them to the
|
||||
* child position whenever the child gets moved */
|
||||
if (px > 0) px -= lx;
|
||||
if (py > 0) py -= ly;
|
||||
/* printf("Start Position: %d %d\n", px, py); */
|
||||
|
||||
/* grab the geometry of this monitor (returned in virtual coords) */
|
||||
e_layout_child_geometry_get(obj, &o.x, &o.y, &o.w, &o.h);
|
||||
|
||||
/* we need to subtract the layout object position from the
|
||||
* returned values here because e_layout adds them to the
|
||||
* child position whenever the child gets moved */
|
||||
if (o.x > 0) o.x -= lx;
|
||||
if (o.y > 0) o.y -= ly;
|
||||
/* printf("\tObj Pos: %d %d\n", o.x, o.y); */
|
||||
|
||||
/* copy the rectangle */
|
||||
eina_rectangle_coords_from(&r, o.x, o.y, o.w, o.h);
|
||||
|
||||
/* freeze layout */
|
||||
e_layout_freeze(sd->o_layout);
|
||||
|
||||
EINA_LIST_FOREACH(sd->items, l, mon)
|
||||
{
|
||||
Eina_Rectangle m;
|
||||
|
||||
/* skip if it's the current monitor */
|
||||
if ((mon == obj)) continue;
|
||||
|
||||
/* grab the geometry of this monitor (returned in virtual coords) */
|
||||
e_layout_child_geometry_get(mon, &m.x, &m.y, &m.w, &m.h);
|
||||
/* printf("\tThis Mon Position: %d %d\n", m.x, m.y); */
|
||||
|
||||
/* we need to subtract the layout object position from the
|
||||
* returned values here because e_layout adds them to the
|
||||
* child position whenever the child gets moved */
|
||||
if (m.x > 0) m.x -= lx;
|
||||
if (m.y > 0) m.y -= ly;
|
||||
|
||||
/* this function modifies the dest rectangle, hence the copy above */
|
||||
if (eina_rectangle_intersection(&r, &m))
|
||||
{
|
||||
/* printf("\tHave Intersection\n"); */
|
||||
/* printf("\t\tMonitor At: %d %d %d %d\n", m.x, m.y, m.w, m.h); */
|
||||
/* printf("\t\tDifference: %d %d %d %d\n", r.x, r.y, r.w, r.h); */
|
||||
|
||||
if ((o.x != px) && (r.x > (m.w * 0.25)))
|
||||
{
|
||||
if (r.w > (m.w * 0.25))
|
||||
{
|
||||
if (r.w >= (m.x + (m.w - (m.w * 0.75))))
|
||||
e_layout_child_move(mon, (o.x + o.w), m.y);
|
||||
else
|
||||
e_layout_child_move(mon, (o.x - m.w), m.y);
|
||||
}
|
||||
}
|
||||
else if ((o.y != py) && (r.y > (m.h * 0.25)))
|
||||
{
|
||||
if (r.h > (m.h * 0.25))
|
||||
{
|
||||
if ((r.y + r.h) >= (m.y + (m.h - (m.h * 0.25))))
|
||||
e_layout_child_move(mon, m.x, (o.y + o.h));
|
||||
else
|
||||
e_layout_child_move(mon, m.x, (o.y - m.h));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((o.x > px) || (o.x < px))
|
||||
{
|
||||
if (m.x < 0)
|
||||
e_layout_child_move(mon, (o.x - m.w), m.y);
|
||||
else if (m.x > (o.x + o.w))
|
||||
e_layout_child_move(mon, (o.x + o.w), m.y);
|
||||
}
|
||||
else if ((o.y > py) || (o.y < py))
|
||||
{
|
||||
if (m.y < 0)
|
||||
e_layout_child_move(mon, m.x, (o.y - m.h));
|
||||
else if (m.y > (o.y + o.h))
|
||||
e_layout_child_move(mon, m.x, (o.y + o.h));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* thaw layout to allow redraw */
|
||||
e_layout_thaw(sd->o_layout);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_smart_randr_changed_set(Evas_Object *obj)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
Evas_Object *mon = NULL;
|
||||
Eina_List *l = NULL;
|
||||
|
||||
if (!(sd = evas_object_smart_data_get(obj)))
|
||||
return;
|
||||
|
||||
sd->changed = EINA_FALSE;
|
||||
EINA_LIST_FOREACH(sd->items, l, mon)
|
||||
{
|
||||
E_Smart_Monitor_Changes changes = E_SMART_MONITOR_CHANGED_NONE;
|
||||
|
||||
changes = e_smart_monitor_changes_get(mon);
|
||||
if (changes > E_SMART_MONITOR_CHANGED_NONE)
|
||||
{
|
||||
sd->changed = EINA_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
evas_object_smart_callback_call(obj, "changed", NULL);
|
||||
}
|
||||
|
||||
/* callback received from the monitor object to let us know that it was
|
||||
* resized, and we should adjust position of any adjacent monitors */
|
||||
static void
|
||||
_e_smart_cb_monitor_resized(void *data, Evas_Object *obj, void *event __UNUSED__)
|
||||
{
|
||||
Evas_Object *o_randr;
|
||||
E_Smart_Data *sd;
|
||||
|
||||
if (!(o_randr = data)) return;
|
||||
if (!(sd = evas_object_smart_data_get(o_randr)))
|
||||
return;
|
||||
|
||||
_e_smart_randr_layout_adjust(sd, obj);
|
||||
|
||||
_e_smart_randr_changed_set(o_randr);
|
||||
}
|
||||
|
||||
/* callback received from the monitor object to let us know that it was
|
||||
* rotated, and we should adjust position of any adjacent monitors */
|
||||
static void
|
||||
_e_smart_cb_monitor_rotated(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
|
||||
{
|
||||
Evas_Object *o_randr;
|
||||
|
||||
if (!(o_randr = data)) return;
|
||||
|
||||
_e_smart_randr_changed_set(o_randr);
|
||||
}
|
||||
|
||||
/* callback received from the monitor object to let us know that it was
|
||||
* moved, and we should adjust position of any adjacent monitors */
|
||||
static void
|
||||
_e_smart_cb_monitor_moved(void *data, Evas_Object *obj, void *event __UNUSED__)
|
||||
{
|
||||
Evas_Object *o_randr;
|
||||
E_Smart_Data *sd;
|
||||
|
||||
if (!(o_randr = data)) return;
|
||||
if (!(sd = evas_object_smart_data_get(o_randr)))
|
||||
return;
|
||||
|
||||
_e_smart_randr_layout_reposition(sd, obj);
|
||||
|
||||
_e_smart_randr_changed_set(o_randr);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_smart_cb_monitor_toggled(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
|
||||
{
|
||||
Evas_Object *o_randr;
|
||||
|
||||
if (!(o_randr = data)) return;
|
||||
|
||||
_e_smart_randr_changed_set(o_randr);
|
||||
}
|
||||
|
||||
/* callback received from the monitor object to let us know that it was
|
||||
* deleted, and we should cleanup */
|
||||
static void
|
||||
_e_smart_cb_monitor_deleted(void *data __UNUSED__, Evas *evas __UNUSED__, Evas_Object *obj, void *event __UNUSED__)
|
||||
{
|
||||
evas_object_smart_callback_del(obj, "monitor_resized",
|
||||
_e_smart_cb_monitor_resized);
|
||||
evas_object_smart_callback_del(obj, "monitor_rotated",
|
||||
_e_smart_cb_monitor_rotated);
|
||||
evas_object_smart_callback_del(obj, "monitor_moved",
|
||||
_e_smart_cb_monitor_moved);
|
||||
evas_object_smart_callback_del(obj, "monitor_toggled",
|
||||
_e_smart_cb_monitor_toggled);
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
#ifdef E_TYPEDEFS
|
||||
#else
|
||||
# ifndef E_SMART_RANDR_H
|
||||
# define E_SMART_RANDR_H
|
||||
|
||||
Evas_Object *e_smart_randr_add(Evas *evas);
|
||||
void e_smart_randr_virtual_size_set(Evas_Object *obj, Evas_Coord vw, Evas_Coord vh);
|
||||
void e_smart_randr_monitor_add(Evas_Object *obj, Evas_Object *mon);
|
||||
Eina_List *e_smart_randr_monitors_get(Evas_Object *obj);
|
||||
Eina_Bool e_smart_randr_changed_get(Evas_Object *obj);
|
||||
|
||||
# endif
|
||||
#endif
|
Loading…
Reference in New Issue