summaryrefslogtreecommitdiff
path: root/src/modules/ecore_evas
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2017-06-09 11:06:05 -0400
committerChris Michael <cp.michael@samsung.com>2017-06-09 12:30:42 -0400
commitcb94befb9da6ab48195b8f0f535fb81bd83959be (patch)
tree6c370a6d2b8315028a9783106b43a94e7cc7ae42 /src/modules/ecore_evas
parentd47538dc0e0f839caae248aca60fbf191862c6cd (diff)
ecore-evas-wl: Add support for Window Manager rotations
This patch adds support to Ecore_Evas_Wayland for Window Manager Rotations so that window managers which do support rotations are able to rotate an EFL wayland application. @feature Signed-off-by: Chris Michael <cp.michael@samsung.com>
Diffstat (limited to 'src/modules/ecore_evas')
-rw-r--r--src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c201
-rw-r--r--src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_private.h11
2 files changed, 207 insertions, 5 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 30ddb30..362aef9 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
@@ -28,9 +28,10 @@ struct _EE_Wl_Device
28 28
29/* local variables */ 29/* local variables */
30static int _ecore_evas_wl_init_count = 0; 30static int _ecore_evas_wl_init_count = 0;
31static Ecore_Event_Handler *_ecore_evas_wl_event_hdls[13]; 31static Ecore_Event_Handler *_ecore_evas_wl_event_hdls[14];
32 32
33static void _ecore_evas_wayland_resize(Ecore_Evas *ee, int location); 33static void _ecore_evas_wayland_resize(Ecore_Evas *ee, int location);
34static void _ecore_evas_wl_common_rotation_set(Ecore_Evas *ee, int rotation, int resize);
34 35
35/* local functions */ 36/* local functions */
36static void 37static void
@@ -39,6 +40,17 @@ _ecore_evas_wl_common_state_update(Ecore_Evas *ee)
39 if (ee->func.fn_state_change) ee->func.fn_state_change(ee); 40 if (ee->func.fn_state_change) ee->func.fn_state_change(ee);
40} 41}
41 42
43static void
44_ecore_evas_wl_common_wm_rotation_protocol_set(Ecore_Evas *ee)
45{
46 Ecore_Evas_Engine_Wl_Data *wdata;
47
48 wdata = ee->engine.data;
49
50 ee->prop.wm_rot.supported =
51 ecore_wl2_window_wm_rotation_supported_get(wdata->win);
52}
53
42static Eina_Bool 54static Eina_Bool
43_ecore_evas_wl_common_cb_mouse_in(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) 55_ecore_evas_wl_common_cb_mouse_in(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
44{ 56{
@@ -344,6 +356,69 @@ _ecore_evas_wl_common_resize(Ecore_Evas *ee, int w, int h)
344 } 356 }
345} 357}
346 358
359static void
360_ecore_evas_wl_common_wm_rot_manual_rotation_done_job(void *data)
361{
362 Ecore_Evas *ee = (Ecore_Evas *)data;
363 Ecore_Evas_Engine_Wl_Data *wdata;
364
365 wdata = ee->engine.data;
366
367 wdata->wm_rot.manual_mode_job = NULL;
368 ee->prop.wm_rot.manual_mode.wait_for_done = EINA_FALSE;
369
370 ecore_wl2_window_rotation_change_done_send
371 (wdata->win, ee->rotation, ee->w, ee->h);
372
373 wdata->wm_rot.done = EINA_FALSE;
374}
375
376static void
377_ecore_evas_wl_common_wm_rot_manual_rotation_done(Ecore_Evas *ee)
378{
379 if ((ee->prop.wm_rot.supported) &&
380 (ee->prop.wm_rot.app_set) &&
381 (ee->prop.wm_rot.manual_mode.set))
382 {
383 if (ee->prop.wm_rot.manual_mode.wait_for_done)
384 {
385 Ecore_Evas_Engine_Wl_Data *wdata;
386
387 wdata = ee->engine.data;
388
389 if (ee->prop.wm_rot.manual_mode.timer)
390 ecore_timer_del(ee->prop.wm_rot.manual_mode.timer);
391 ee->prop.wm_rot.manual_mode.timer = NULL;
392
393 if (wdata->wm_rot.manual_mode_job)
394 ecore_job_del(wdata->wm_rot.manual_mode_job);
395
396 wdata->wm_rot.manual_mode_job = ecore_job_add
397 (_ecore_evas_wl_common_wm_rot_manual_rotation_done_job, ee);
398 }
399 }
400}
401
402static Eina_Bool
403_ecore_evas_wl_common_wm_rot_manual_rotation_done_timeout(void *data)
404{
405 Ecore_Evas *ee = data;
406
407 ee->prop.wm_rot.manual_mode.timer = NULL;
408 _ecore_evas_wl_common_wm_rot_manual_rotation_done(ee);
409 return ECORE_CALLBACK_CANCEL;
410}
411
412static void
413_ecore_evas_wl_common_wm_rot_manual_rotation_done_timeout_update(Ecore_Evas *ee)
414{
415 if (ee->prop.wm_rot.manual_mode.timer)
416 ecore_timer_del(ee->prop.wm_rot.manual_mode.timer);
417
418 ee->prop.wm_rot.manual_mode.timer = ecore_timer_add
419 (4.0f, _ecore_evas_wl_common_wm_rot_manual_rotation_done_timeout, ee);
420}
421
347static Eina_Bool 422static Eina_Bool
348_ecore_evas_wl_common_cb_window_configure(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) 423_ecore_evas_wl_common_cb_window_configure(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
349{ 424{
@@ -411,6 +486,38 @@ _ecore_evas_wl_common_cb_window_configure(void *data EINA_UNUSED, int type EINA_
411 if (ee->prop.fullscreen || (ee->req.w != nw) || (ee->req.h != nh)) 486 if (ee->prop.fullscreen || (ee->req.w != nw) || (ee->req.h != nh))
412 _ecore_evas_wl_common_resize(ee, nw, nh); 487 _ecore_evas_wl_common_resize(ee, nw, nh);
413 488
489 if (ee->prop.wm_rot.supported)
490 {
491 if (wdata->wm_rot.prepare)
492 {
493 if ((ee->prop.wm_rot.w == nw) &&
494 (ee->prop.wm_rot.h == nh))
495 {
496 ee->prop.wm_rot.win_resize = EINA_FALSE;
497 wdata->wm_rot.configure_coming = EINA_FALSE;
498 }
499 }
500 else if (wdata->wm_rot.request)
501 {
502 if ((wdata->wm_rot.configure_coming) &&
503 (ee->prop.wm_rot.w == nw) &&
504 (ee->prop.wm_rot.h == nh))
505 {
506 wdata->wm_rot.configure_coming = EINA_FALSE;
507
508 if (ee->prop.wm_rot.manual_mode.set)
509 {
510 ee->prop.wm_rot.manual_mode.wait_for_done = EINA_TRUE;
511 _ecore_evas_wl_common_wm_rot_manual_rotation_done_timeout_update(ee);
512 }
513
514 _ecore_evas_wl_common_rotation_set(ee,
515 ee->prop.wm_rot.angle,
516 EINA_TRUE);
517 }
518 }
519 }
520
414 return ECORE_CALLBACK_PASS_ON; 521 return ECORE_CALLBACK_PASS_ON;
415} 522}
416 523
@@ -439,6 +546,22 @@ _ecore_evas_wl_common_cb_window_configure_complete(void *data EINA_UNUSED, int t
439 return ECORE_CALLBACK_PASS_ON; 546 return ECORE_CALLBACK_PASS_ON;
440} 547}
441 548
549static Eina_Bool
550_ecore_evas_wl_common_cb_window_rotate(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
551{
552 Ecore_Evas *ee;
553 Ecore_Wl2_Event_Window_Rotation *ev;
554
555 LOGFN(__FILE__, __LINE__, __FUNCTION__);
556
557 ev = event;
558 ee = ecore_event_window_match(ev->win);
559 if (!ee) return ECORE_CALLBACK_PASS_ON;
560 if (ev->win != ee->prop.window) return ECORE_CALLBACK_PASS_ON;
561 _ecore_evas_wl_common_rotation_set(ee, ev->rotation, ev->resize);
562 return ECORE_CALLBACK_PASS_ON;
563}
564
442static void 565static void
443_mouse_move_dispatch(Ecore_Evas *ee) 566_mouse_move_dispatch(Ecore_Evas *ee)
444{ 567{
@@ -957,6 +1080,9 @@ _ecore_evas_wl_common_init(void)
957 ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE_COMPLETE, 1080 ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE_COMPLETE,
958 _ecore_evas_wl_common_cb_window_configure_complete, 1081 _ecore_evas_wl_common_cb_window_configure_complete,
959 NULL); 1082 NULL);
1083 _ecore_evas_wl_event_hdls[13] =
1084 ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ROTATE,
1085 _ecore_evas_wl_common_cb_window_rotate, NULL);
960 1086
961 ecore_event_evas_init(); 1087 ecore_event_evas_init();
962 1088
@@ -1109,6 +1235,67 @@ _ecore_evas_wl_common_pointer_xy_get(const Ecore_Evas *ee, Evas_Coord *x, Evas_C
1109} 1235}
1110 1236
1111static void 1237static void
1238_ecore_evas_wl_common_wm_rot_preferred_rotation_set(Ecore_Evas *ee, int rot)
1239{
1240 if (ee->prop.wm_rot.supported)
1241 {
1242 Ecore_Evas_Engine_Wl_Data *wdata;
1243
1244 wdata = ee->engine.data;
1245 if (!ee->prop.wm_rot.app_set)
1246 {
1247 ecore_wl2_window_rotation_app_set(wdata->win, EINA_TRUE);
1248 ee->prop.wm_rot.app_set = EINA_TRUE;
1249 }
1250
1251 ecore_wl2_window_preferred_rotation_set(wdata->win, rot);
1252 ee->prop.wm_rot.preferred_rot = rot;
1253 }
1254}
1255
1256static void
1257_ecore_evas_wl_common_wm_rot_available_rotations_set(Ecore_Evas *ee, const int *rots, unsigned int count)
1258{
1259 if (ee->prop.wm_rot.supported)
1260 {
1261 Ecore_Evas_Engine_Wl_Data *wdata;
1262
1263 wdata = ee->engine.data;
1264 if (!ee->prop.wm_rot.app_set)
1265 {
1266 ecore_wl2_window_rotation_app_set(wdata->win, EINA_TRUE);
1267 ee->prop.wm_rot.app_set = EINA_TRUE;
1268 }
1269
1270 if (ee->prop.wm_rot.available_rots)
1271 {
1272 free(ee->prop.wm_rot.available_rots);
1273 ee->prop.wm_rot.available_rots = NULL;
1274 }
1275
1276 ee->prop.wm_rot.count = 0;
1277
1278 if (count > 0)
1279 {
1280 ee->prop.wm_rot.available_rots = calloc(count, sizeof(int));
1281 if (!ee->prop.wm_rot.available_rots) return;
1282
1283 memcpy(ee->prop.wm_rot.available_rots, rots, sizeof(int) * count);
1284 }
1285
1286 ee->prop.wm_rot.count = count;
1287
1288 ecore_wl2_window_available_rotations_set(wdata->win, rots, count);
1289 }
1290}
1291
1292static void
1293_ecore_evas_wl_common_wm_rot_manual_rotation_done_set(Ecore_Evas *ee, Eina_Bool set)
1294{
1295 ee->prop.wm_rot.manual_mode.set = set;
1296}
1297
1298static void
1112_ecore_evas_wl_common_pointer_device_xy_get(const Ecore_Evas *ee, const Efl_Input_Device *pointer, Evas_Coord *x, Evas_Coord *y) 1299_ecore_evas_wl_common_pointer_device_xy_get(const Ecore_Evas *ee, const Efl_Input_Device *pointer, Evas_Coord *x, Evas_Coord *y)
1113{ 1300{
1114 Ecore_Evas_Engine_Wl_Data *wdata; 1301 Ecore_Evas_Engine_Wl_Data *wdata;
@@ -1433,6 +1620,8 @@ _ecore_evas_wayland_alpha_do(Ecore_Evas *ee, int alpha)
1433 1620
1434 if (wdata->win) ecore_wl2_window_alpha_set(wdata->win, ee->alpha); 1621 if (wdata->win) ecore_wl2_window_alpha_set(wdata->win, ee->alpha);
1435 1622
1623 _ecore_evas_wl_common_wm_rotation_protocol_set(ee);
1624
1436 evas_output_framespace_get(ee->evas, NULL, NULL, &fw, &fh); 1625 evas_output_framespace_get(ee->evas, NULL, NULL, &fw, &fh);
1437 1626
1438 if ((einfo = (Evas_Engine_Info_Wayland *)evas_engine_info_get(ee->evas))) 1627 if ((einfo = (Evas_Engine_Info_Wayland *)evas_engine_info_get(ee->evas)))
@@ -1960,10 +2149,10 @@ static Ecore_Evas_Engine_Func _ecore_wl_engine_func =
1960 _ecore_evas_wl_common_pointer_xy_get, 2149 _ecore_evas_wl_common_pointer_xy_get,
1961 NULL, // pointer_warp 2150 NULL, // pointer_warp
1962 2151
1963 NULL, // wm_rot_preferred_rotation_set 2152 _ecore_evas_wl_common_wm_rot_preferred_rotation_set,
1964 NULL, // wm_rot_available_rotations_set 2153 _ecore_evas_wl_common_wm_rot_available_rotations_set,
1965 NULL, // wm_rot_manual_rotation_done_set 2154 _ecore_evas_wl_common_wm_rot_manual_rotation_done_set,
1966 NULL, // wm_rot_manual_rotation_done 2155 _ecore_evas_wl_common_wm_rot_manual_rotation_done,
1967 2156
1968 NULL, // aux_hints_set 2157 NULL, // aux_hints_set
1969 2158
@@ -2126,6 +2315,8 @@ _ecore_evas_wl_common_new_internal(const char *disp_name, unsigned int parent, i
2126 goto eng_err; 2315 goto eng_err;
2127 } 2316 }
2128 2317
2318 _ecore_evas_wl_common_wm_rotation_protocol_set(ee);
2319
2129 _ecore_evas_register(ee); 2320 _ecore_evas_register(ee);
2130 ecore_evas_input_event_register(ee); 2321 ecore_evas_input_event_register(ee);
2131 2322
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 aed693b..e6e3f3e 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,17 @@ 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
50 struct
51 {
52 Eina_Bool supported : 1;
53 Eina_Bool prepare : 1;
54 Eina_Bool request : 1;
55 Eina_Bool done : 1;
56 Eina_Bool configure_coming : 1;
57 Ecore_Job *manual_mode_job;
58 } wm_rot;
59
49 Eina_Bool dragging : 1; 60 Eina_Bool dragging : 1;
50 Eina_Bool sync_done : 1; 61 Eina_Bool sync_done : 1;
51 Eina_Bool defer_show : 1; 62 Eina_Bool defer_show : 1;