summaryrefslogtreecommitdiff
path: root/src/modules/ecore_evas
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2017-08-04 16:17:53 -0400
committerMike Blumenkrantz <zmike@osg.samsung.com>2017-08-04 16:17:33 -0400
commit64754b682eba484dff1f520d3bd329c299b4bac0 (patch)
treef3901496efd9810c4413e3159b5d2ff224305aeb /src/modules/ecore_evas
parentbaf511a47e8ab5e08c21638a36c5125743b82765 (diff)
ecore-evas-wayland: rework window hint calcs to be more accurate
this is still pretty broken for some directions, client-side aspect fml
Diffstat (limited to 'src/modules/ecore_evas')
-rw-r--r--src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c141
-rw-r--r--src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_private.h2
2 files changed, 74 insertions, 69 deletions
diff --git a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
index b97487a..1ee934d 100644
--- a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
+++ b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
@@ -174,7 +174,7 @@ static void
174_ecore_evas_wl_common_resize(Ecore_Evas *ee, int w, int h) 174_ecore_evas_wl_common_resize(Ecore_Evas *ee, int w, int h)
175{ 175{
176 Ecore_Evas_Engine_Wl_Data *wdata; 176 Ecore_Evas_Engine_Wl_Data *wdata;
177 int ow, oh; 177 int ow, oh, ew, eh;
178 int diff = 0; 178 int diff = 0;
179 179
180 LOGFN(__FILE__, __LINE__, __FUNCTION__); 180 LOGFN(__FILE__, __LINE__, __FUNCTION__);
@@ -189,6 +189,8 @@ _ecore_evas_wl_common_resize(Ecore_Evas *ee, int w, int h)
189 189
190 /* TODO: wayland client can resize the ecore_evas directly. 190 /* TODO: wayland client can resize the ecore_evas directly.
191 * In the future, we will remove ee->req value in wayland backend */ 191 * In the future, we will remove ee->req value in wayland backend */
192 ew = ee->w;
193 eh = ee->h;
192 ee->w = w; 194 ee->w = w;
193 ee->h = h; 195 ee->h = h;
194 196
@@ -197,7 +199,6 @@ _ecore_evas_wl_common_resize(Ecore_Evas *ee, int w, int h)
197 int fw = 0, fh = 0; 199 int fw = 0, fh = 0;
198 int maxw = 0, maxh = 0; 200 int maxw = 0, maxh = 0;
199 int minw = 0, minh = 0; 201 int minw = 0, minh = 0;
200 double a = 0.0;
201 202
202 evas_output_framespace_get(ee->evas, NULL, NULL, &fw, &fh); 203 evas_output_framespace_get(ee->evas, NULL, NULL, &fw, &fh);
203 204
@@ -224,84 +225,73 @@ _ecore_evas_wl_common_resize(Ecore_Evas *ee, int w, int h)
224 maxh = (ee->prop.max.h + fw); 225 maxh = (ee->prop.max.h + fw);
225 } 226 }
226 227
227 /* adjust size using aspect */ 228 if ((maxw > 0) && (w > maxw))
228 if ((ee->prop.base.w >= 0) && (ee->prop.base.h >= 0)) 229 w = maxw;
229 { 230 else if (w < minw)
230 int bw, bh; 231 w = minw;
231
232 bw = (w - ee->prop.base.w);
233 bh = (h - ee->prop.base.h);
234 if (bw < 1) bw = 1;
235 if (bh < 1) bh = 1;
236 a = ((double)bw / (double)bh);
237
238 if ((!EINA_FLT_EQ(ee->prop.aspect, 0.0) &&
239 (a < ee->prop.aspect)))
240 {
241 if ((h < ee->h) > 0)
242 bw = bh * ee->prop.aspect;
243 else
244 bw = bw / ee->prop.aspect;
245 232
246 w = bw + ee->prop.base.w; 233 if ((maxh > 0) && (h > maxh))
247 h = bh + ee->prop.base.h; 234 h = maxh;
248 } 235 else if (h < minh)
249 else if ((!EINA_FLT_EQ(ee->prop.aspect, 0.0)) && 236 h = minh;
250 (a > ee->prop.aspect))
251 {
252 bw = bh * ee->prop.aspect;
253 w = bw + ee->prop.base.w;
254 }
255 }
256 else
257 {
258 a = ((double)w / (double)h);
259 if ((!EINA_FLT_EQ(ee->prop.aspect, 0.0)) &&
260 (a < ee->prop.aspect))
261 {
262 if ((h < ee->h) > 0)
263 w = h * ee->prop.aspect;
264 else
265 h = w / ee->prop.aspect;
266 }
267 else if ((!EINA_FLT_EQ(ee->prop.aspect, 0.0)) &&
268 (a > ee->prop.aspect))
269 w = h * ee->prop.aspect;
270 }
271 237
272 if (!ee->prop.maximized) 238 if (!ee->prop.maximized)
273 { 239 {
274 /* calc new size using base size & step size */ 240 /* calc new size using base size & step size */
275 if (ee->prop.step.w > 0) 241 if (ee->prop.step.w > 1)
276 { 242 {
277 if (ee->prop.base.w >= 0) 243 int bw = ee->prop.base.w ?: minw;
278 w = (ee->prop.base.w + 244 w = (bw + (((w - bw) / ee->prop.step.w) * ee->prop.step.w));
279 (((w - ee->prop.base.w) / ee->prop.step.w) *
280 ee->prop.step.w));
281 else
282 w = (minw + (((w - minw) / ee->prop.step.w) * ee->prop.step.w));
283 } 245 }
284 246
285 if (ee->prop.step.h > 0) 247 if (ee->prop.step.h > 1)
286 { 248 {
287 if (ee->prop.base.h >= 0) 249 int bh = ee->prop.base.h ?: minh;
288 h = (ee->prop.base.h + 250 h = (bh + (((h - bh) / ee->prop.step.h) * ee->prop.step.h));
289 (((h - ee->prop.base.h) / ee->prop.step.h) *
290 ee->prop.step.h));
291 else
292 h = (minh + (((h - minh) / ee->prop.step.h) * ee->prop.step.h));
293 } 251 }
294 }
295 252
296 if ((maxw > 0) && (w > maxw)) 253 if (!wdata->win->display->wl.efl_hints && EINA_DBL_NONZERO(ee->prop.aspect))
297 w = maxw; 254 {
298 else if (w < minw) 255 /* copied from e_client.c */
299 w = minw; 256 Evas_Aspect_Control aspect;
257 int aw, ah;
258 double val, a = (double)w / h;
300 259
301 if ((maxh > 0) && (h > maxh)) 260 if (fabs(a - ee->prop.aspect) > 0.001)
302 h = maxh; 261 {
303 else if (h < minh) 262 int step_w = ee->prop.step.w ?: 1, step_h = ee->prop.step.h ?: 1;
304 h = minh; 263 if (wdata->resizing || wdata->win->resizing)
264 ew = wdata->cw, eh = wdata->ch;
265 if (abs(w - ew) > abs(h - eh))
266 aspect = EVAS_ASPECT_CONTROL_HORIZONTAL;
267 else
268 aspect = EVAS_ASPECT_CONTROL_VERTICAL;
269 switch (aspect)
270 {
271 case EVAS_ASPECT_CONTROL_HORIZONTAL:
272 val = ((h - (w / ee->prop.aspect)) * step_h) / step_h;
273 if (val > 0)
274 ah = ceil(val);
275 else
276 ah = floor(val);
277 if ((h - ah > minh) || (minh < 1))
278 {
279 h -= ah;
280 break;
281 }
282 default:
283 val = (((h * ee->prop.aspect) - w) * step_w) / step_w;
284 if (val > 0)
285 aw = ceil(val);
286 else
287 aw = floor(val);
288 if ((w + aw < maxw) || (maxw < 1))
289 w += aw;
290 break;
291 }
292 }
293 }
294 }
305 295
306 ee->w = w; 296 ee->w = w;
307 ee->h = h; 297 ee->h = h;
@@ -435,6 +425,9 @@ _ecore_evas_wl_common_cb_window_configure(void *data EINA_UNUSED, int type EINA_
435 wdata = ee->engine.data; 425 wdata = ee->engine.data;
436 if (!wdata) return ECORE_CALLBACK_PASS_ON; 426 if (!wdata) return ECORE_CALLBACK_PASS_ON;
437 427
428 if ((!wdata->win->resizing) && (!wdata->resizing))
429 wdata->cw = wdata->ch = 0;
430
438 prev_max = ee->prop.maximized; 431 prev_max = ee->prop.maximized;
439 prev_full = ee->prop.fullscreen; 432 prev_full = ee->prop.fullscreen;
440 ee->prop.maximized = 433 ee->prop.maximized =
@@ -481,7 +474,17 @@ _ecore_evas_wl_common_cb_window_configure(void *data EINA_UNUSED, int type EINA_
481 nh -= fh; 474 nh -= fh;
482 475
483 if (ee->prop.fullscreen || (ee->req.w != nw) || (ee->req.h != nh)) 476 if (ee->prop.fullscreen || (ee->req.w != nw) || (ee->req.h != nh))
484 _ecore_evas_wl_common_resize(ee, nw, nh); 477 {
478 if (wdata->win->resizing || wdata->resizing)
479 {
480 if ((wdata->cw != nw) || (wdata->ch != nh))
481 _ecore_evas_wl_common_resize(ee, nw, nh);
482 wdata->cw = nw, wdata->ch = nh;
483 }
484 else
485 _ecore_evas_wl_common_resize(ee, nw, nh);
486 }
487 wdata->resizing = wdata->win->resizing;
485 488
486 if (ee->prop.wm_rot.supported) 489 if (ee->prop.wm_rot.supported)
487 { 490 {
diff --git a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_private.h b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_private.h
index e6e3f3e..76ca2d9 100644
--- a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_private.h
+++ b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_private.h
@@ -46,6 +46,7 @@ struct _Ecore_Evas_Engine_Wl_Data
46 int y_rel; 46 int y_rel;
47 uint32_t timestamp; 47 uint32_t timestamp;
48 Eina_List *devices_list; 48 Eina_List *devices_list;
49 int cw, ch;
49 50
50 struct 51 struct
51 { 52 {
@@ -57,6 +58,7 @@ struct _Ecore_Evas_Engine_Wl_Data
57 Ecore_Job *manual_mode_job; 58 Ecore_Job *manual_mode_job;
58 } wm_rot; 59 } wm_rot;
59 60
61 Eina_Bool resizing : 1;
60 Eina_Bool dragging : 1; 62 Eina_Bool dragging : 1;
61 Eina_Bool sync_done : 1; 63 Eina_Bool sync_done : 1;
62 Eina_Bool defer_show : 1; 64 Eina_Bool defer_show : 1;