E (RandR): Reimplement "resizing other monitors" when a specific

monitor gets resized, so that we update the visual layout
appropriately. Also, do not raise "monitor_moved" callback for every
little move, rather wait until the move is finished and raise the
callback once.

NB: The "monitor_moved" callback frequency may change in the future.




SVN revision: 77265
This commit is contained in:
Christopher Michael 2012-10-01 11:37:41 +00:00
parent e7cbbb4ed1
commit 54984d38ef
2 changed files with 44 additions and 54 deletions

View File

@ -897,6 +897,9 @@ _e_smart_cb_thumb_mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj,
/* update moving state */ /* update moving state */
sd->moving = EINA_FALSE; sd->moving = EINA_FALSE;
/* tell randr widget that we moved this monitor */
evas_object_smart_callback_call(mon, "monitor_moved", NULL);
} }
} }
@ -1079,7 +1082,7 @@ _e_smart_monitor_move(E_Smart_Data *sd, Evas_Object *mon, void *event)
if ((gx != nx) || (gy != ny)) if ((gx != nx) || (gy != ny))
e_layout_child_move(mon, nx, ny); e_layout_child_move(mon, nx, ny);
evas_object_smart_callback_call(mon, "monitor_moved", NULL); /* evas_object_smart_callback_call(mon, "monitor_moved", NULL); */
/* Hmm, this below code worked also ... and seems lighter. /* Hmm, this below code worked also ... and seems lighter.
* but the above code seems more "proper". * but the above code seems more "proper".

View File

@ -248,68 +248,49 @@ static void
_e_smart_cb_monitor_resized(void *data, Evas_Object *obj, void *event __UNUSED__) _e_smart_cb_monitor_resized(void *data, Evas_Object *obj, void *event __UNUSED__)
{ {
E_Smart_Data *sd; E_Smart_Data *sd;
Evas_Coord w, h, nw, nh; Eina_List *l = NULL;
Eina_List *l; Evas_Object *mon;
/* E_Randr_Crtc_Info *crtc; */ Eina_Rectangle o;
if (!(sd = data)) return; if (!(sd = data)) return;
/* get randr output info for this monitor */ /* get the geometry of this monitor */
/* crtc = e_smart_monitor_crtc_get(obj); */ e_layout_child_geometry_get(obj, &o.x, &o.y, &o.w, &o.h);
/* printf("Monitor Output Policy: %d\n", crtc->policy); */
/* grab size of this monitor object */
evas_object_geometry_get(obj, NULL, NULL, &w, &h);
/* convert to layout coords */
e_layout_coord_canvas_to_virtual(sd->o_layout, w, h, &nw, &nh);
/* freeze layout */ /* freeze layout */
e_layout_freeze(sd->o_layout); e_layout_freeze(sd->o_layout);
/* search for this monitor */ /* find any monitors to the right or below this one */
// if ((l = eina_list_data_find_list(sd->items, obj))) /* 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)
{ {
Evas_Object *mon; Eina_Rectangle m;
Evas_Coord mx, my;
Eina_Rectangle rm;
e_layout_child_geometry_get(obj, &mx, &my, NULL, NULL); /* skip if it's the current monitor */
/* printf("Monitor New Geom: %d %d %d %d\n", mx, my, nw, nh); */ if ((mon == obj)) continue;
EINA_RECTANGLE_SET(&rm, mx, my, nw, nh);
/* found monitor, check for one the will intersect */ /* get the geometry of this monitor */
EINA_LIST_FOREACH(sd->items, l, mon) e_layout_child_geometry_get(mon, &m.x, &m.y, &m.w, &m.h);
if ((m.x >= (o.x + o.w)))
{ {
/* E_Randr_Crtc_Info *cinfo; */ /* if this monitor is to the right, move it */
Evas_Coord cx, cy, cw, ch; e_layout_child_move(mon, (o.x + o.w), m.y);
Eina_Rectangle rc; }
else if ((m.y >= (o.y + o.h)))
if ((mon == obj)) continue; {
/* if this monitor is below, move it */
/* cinfo = e_smart_monitor_crtc_get(mon); */ e_layout_child_move(mon, m.x, (o.y + o.h));
/* printf("\tChild Policy: %d\n", cinfo->policy); */ }
else if (eina_rectangles_intersect(&o, &m))
e_layout_child_geometry_get(mon, &cx, &cy, &cw, &ch); {
/* printf("\tNext Mon Geom: %d %d %d %d\n", cx, cy, cw, ch); */ /* they intersect, we need to move this one */
EINA_RECTANGLE_SET(&rc, cx, cy, cw, ch); /* NB: This can happen when monitors get moved manually */
if ((m.x < (o.x + o.w)))
if (eina_rectangles_intersect(&rm, &rc)) e_layout_child_move(mon, (o.x + o.w), m.y);
{ else if ((m.y <= (o.y + o.h)))
printf("\nMONITORS INTERSECT !!\n"); e_layout_child_move(mon, m.x, (o.y + o.h));
/* if position of new monitor overlaps the existing one's
* X position, we need to move the existing one over */
if ((mx + nw) >= cx)
cx = (mx + nw);
else if ((my + nh) >= cy)
cy = (my + nh);
/* update This monitors position based on new size
* of the previous one (that was resized) */
/* e_layout_child_geometry_get(mon, &cx, &cy, NULL, NULL); */
e_layout_child_move(mon, cx, cy);
}
} }
} }
@ -317,18 +298,24 @@ _e_smart_cb_monitor_resized(void *data, Evas_Object *obj, void *event __UNUSED__
e_layout_thaw(sd->o_layout); e_layout_thaw(sd->o_layout);
} }
/* 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 static void
_e_smart_cb_monitor_rotated(void *data, Evas_Object *obj, void *event __UNUSED__) _e_smart_cb_monitor_rotated(void *data, Evas_Object *obj, void *event __UNUSED__)
{ {
printf("Monitor Rotated\n");
} }
/* 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 static void
_e_smart_cb_monitor_moved(void *data, Evas_Object *obj, void *event __UNUSED__) _e_smart_cb_monitor_moved(void *data, Evas_Object *obj, void *event __UNUSED__)
{ {
printf("Monitor Moved\n");
} }
/* callback received from the monitor object to let us know that it was
* deleted, and we should cleanup */
static void static void
_e_smart_cb_monitor_deleted(void *data __UNUSED__, Evas *evas __UNUSED__, Evas_Object *obj, void *event __UNUSED__) _e_smart_cb_monitor_deleted(void *data __UNUSED__, Evas *evas __UNUSED__, Evas_Object *obj, void *event __UNUSED__)
{ {