summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-11-14 15:10:36 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-11-14 15:10:36 +0900
commitfdc9b5229917b7febfcbf6465a365c279d3d5e62 (patch)
treee6071c23079bad19604e8ec2da3def1f52d32118
parent4b856da2dbf439378319f593c2bebf2ff1f7b857 (diff)
randr dialog - fix badly broken screen resizing logic. now it works reliably.
-rw-r--r--src/modules/conf_randr/e_smart_monitor.c70
1 files changed, 37 insertions, 33 deletions
diff --git a/src/modules/conf_randr/e_smart_monitor.c b/src/modules/conf_randr/e_smart_monitor.c
index 131963c0c..977608b19 100644
--- a/src/modules/conf_randr/e_smart_monitor.c
+++ b/src/modules/conf_randr/e_smart_monitor.c
@@ -82,6 +82,9 @@ struct _E_Smart_Data
82 /* coordinates where the user clicked to start resizing */ 82 /* coordinates where the user clicked to start resizing */
83 Evas_Coord rx, ry; 83 Evas_Coord rx, ry;
84 84
85 /* size when user clicked for resize */
86 Evas_Coord rw, rh;
87
85 /* coordinates where the user clicked to start moving */ 88 /* coordinates where the user clicked to start moving */
86 Evas_Coord mx, my; 89 Evas_Coord mx, my;
87 90
@@ -1295,7 +1298,7 @@ _e_smart_monitor_modes_fill(E_Smart_Data *sd)
1295 { 1298 {
1296 Ecore_X_Randr_Mode_Info *mode; 1299 Ecore_X_Randr_Mode_Info *mode;
1297 1300
1298 /* try to get the mode info */ 1301 /* try to get the mode info */
1299 if (!(mode = ecore_x_randr_mode_info_get(root, modes[i]))) 1302 if (!(mode = ecore_x_randr_mode_info_get(root, modes[i])))
1300 continue; 1303 continue;
1301 1304
@@ -1308,7 +1311,8 @@ _e_smart_monitor_modes_fill(E_Smart_Data *sd)
1308 1311
1309 /* sort the list of modes (smallest to largest) */ 1312 /* sort the list of modes (smallest to largest) */
1310 if (sd->modes) 1313 if (sd->modes)
1311 sd->modes = eina_list_sort(sd->modes, 0, _e_smart_monitor_modes_sort); 1314 sd->modes = eina_list_sort(sd->modes, eina_list_count(sd->modes),
1315 _e_smart_monitor_modes_sort);
1312} 1316}
1313 1317
1314static int 1318static int
@@ -1472,36 +1476,42 @@ _e_smart_monitor_coord_canvas_to_virtual(E_Smart_Data *sd, Evas_Coord cx, Evas_C
1472static Ecore_X_Randr_Mode_Info * 1476static Ecore_X_Randr_Mode_Info *
1473_e_smart_monitor_mode_find(E_Smart_Data *sd, Evas_Coord w, Evas_Coord h, Eina_Bool skip_refresh) 1477_e_smart_monitor_mode_find(E_Smart_Data *sd, Evas_Coord w, Evas_Coord h, Eina_Bool skip_refresh)
1474{ 1478{
1475 Ecore_X_Randr_Mode_Info *mode = NULL; 1479 Ecore_X_Randr_Mode_Info *mode = NULL, *chosen = NULL;
1476 Eina_List *l = NULL; 1480 Eina_List *l = NULL;
1481 int maxdiff = 0x7fffffff, a1, a2, diff;
1477 1482
1478 /* loop the modes */ 1483 /* loop the modes */
1484 if (w < 0) h = 0;
1485 if (h < 0) h = 0;
1486 a1 = w * h;
1479 EINA_LIST_REVERSE_FOREACH(sd->modes, l, mode) 1487 EINA_LIST_REVERSE_FOREACH(sd->modes, l, mode)
1480 { 1488 {
1481 if ((((int)mode->width - RESIZE_FUZZ) <= w) || 1489 a2 = mode->width * mode->height;
1482 (((int)mode->width + RESIZE_FUZZ) <= w)) 1490 diff = abs(a2 - a1);
1491 if (diff < maxdiff)
1483 { 1492 {
1484 if ((((int)mode->height - RESIZE_FUZZ) <= h) || 1493 if (!skip_refresh)
1485 (((int)mode->height + RESIZE_FUZZ) <= h))
1486 { 1494 {
1487 if (!skip_refresh) 1495 double rate = 0.0;
1496
1497 /* get the refresh rate for this mode */
1498 rate = _e_smart_monitor_mode_refresh_rate_get(mode);
1499
1500 /* compare mode rate to "current" rate */
1501 if ((int)rate == sd->current.refresh_rate)
1488 { 1502 {
1489 double rate = 0.0; 1503 maxdiff = diff;
1490 1504 chosen = mode;
1491 /* get the refresh rate for this mode */
1492 rate = _e_smart_monitor_mode_refresh_rate_get(mode);
1493
1494 /* compare mode rate to "current" rate */
1495 if ((int)rate == sd->current.refresh_rate)
1496 return mode;
1497 } 1505 }
1498 else 1506 }
1499 return mode; 1507 else
1508 {
1509 maxdiff = diff;
1510 chosen = mode;
1500 } 1511 }
1501 } 1512 }
1502 } 1513 }
1503 1514 return chosen;
1504 return NULL;
1505} 1515}
1506 1516
1507static inline double 1517static inline double
@@ -1850,6 +1860,9 @@ _e_smart_monitor_frame_cb_resize_start(void *data, Evas_Object *obj EINA_UNUSED,
1850 1860
1851 /* record current position of mouse */ 1861 /* record current position of mouse */
1852 evas_pointer_canvas_xy_get(sd->evas, &sd->rx, &sd->ry); 1862 evas_pointer_canvas_xy_get(sd->evas, &sd->rx, &sd->ry);
1863
1864 sd->rw = sd->current.w;
1865 sd->rh = sd->current.h;
1853 1866
1854 /* record current size of monitor */ 1867 /* record current size of monitor */
1855 evas_object_grid_pack_get(sd->grid.obj, mon, 1868 evas_object_grid_pack_get(sd->grid.obj, mon,
@@ -2174,25 +2187,16 @@ _e_smart_monitor_resize_event(E_Smart_Data *sd, Evas_Object *mon, void *event)
2174 return; 2187 return;
2175 2188
2176 /* calculate difference in mouse movement */ 2189 /* calculate difference in mouse movement */
2177 dx = (sd->rx - ev->cur.canvas.x); 2190 dx = (ev->cur.canvas.x - sd->rx);
2178 dy = (sd->ry - ev->cur.canvas.y); 2191 dy = (ev->cur.canvas.y - sd->ry);
2179 2192
2180 /* factor in drag resistance to measure movement */ 2193 /* factor in drag resistance to measure movement */
2181 if (((dx * dx) + (dy * dy)) < 2194 if (((dx * dx) + (dy * dy)) <
2182 (e_config->drag_resist * e_config->drag_resist)) 2195 (e_config->drag_resist * e_config->drag_resist))
2183 return; 2196 return;
2184 2197
2185 if ((ev->cur.output.x > (sd->x + sd->w + (RESIZE_FUZZ / 2))) ||
2186 (ev->cur.output.x < sd->x)) return;
2187
2188 if ((ev->cur.output.y > (sd->y + sd->h + (RESIZE_FUZZ / 2))) ||
2189 (ev->cur.output.y < sd->y)) return;
2190
2191 dx = (ev->cur.canvas.x - ev->prev.canvas.x);
2192 dy = (ev->cur.canvas.y - ev->prev.canvas.y);
2193
2194 /* convert monitor size to canvas size */ 2198 /* convert monitor size to canvas size */
2195 _e_smart_monitor_coord_virtual_to_canvas(sd, sd->current.w, sd->current.h, 2199 _e_smart_monitor_coord_virtual_to_canvas(sd, sd->rw, sd->rh,
2196 &cw, &ch); 2200 &cw, &ch);
2197 2201
2198 /* factor in resize difference and convert to virtual */ 2202 /* factor in resize difference and convert to virtual */