summaryrefslogtreecommitdiff
path: root/src/lib/ecore_wl2
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2017-08-14 17:46:49 -0500
committerDerek Foreman <derekf@osg.samsung.com>2017-08-18 14:27:32 -0500
commit8f038b25914b9df738809a4150cf3aa5c6d0798e (patch)
treea86f7dad576e39b92d7a637a2164d91811639366 /src/lib/ecore_wl2
parentb599b1b90006f74979ae3c8527ed2c91082ef3be (diff)
ecore_wl2: Add new APIs ecore_wl2_window_frame_callback_add/del()
Abstract frame callbacks through ecore_wl2_window so we can add them in multiple places without having the wayland compositor generate more than one. Also allows us to keep a callback registered over hide/unhide of a window easily.
Diffstat (limited to 'src/lib/ecore_wl2')
-rw-r--r--src/lib/ecore_wl2/Ecore_Wl2.h23
-rw-r--r--src/lib/ecore_wl2/ecore_wl2_private.h8
-rw-r--r--src/lib/ecore_wl2/ecore_wl2_window.c53
3 files changed, 84 insertions, 0 deletions
diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h
index dad9652709..21b623e24a 100644
--- a/src/lib/ecore_wl2/Ecore_Wl2.h
+++ b/src/lib/ecore_wl2/Ecore_Wl2.h
@@ -361,6 +361,8 @@ typedef struct Ecore_Wl2_Event_Aux_Message
361 361
362typedef void (*Ecore_Wl2_Bind_Cb)(struct wl_client *client, void *data, uint32_t version, uint32_t id); 362typedef void (*Ecore_Wl2_Bind_Cb)(struct wl_client *client, void *data, uint32_t version, uint32_t id);
363typedef void (*Ecore_Wl2_Unbind_Cb)(struct wl_resource *resource); 363typedef void (*Ecore_Wl2_Unbind_Cb)(struct wl_resource *resource);
364typedef void (*Ecore_Wl2_Frame_Cb)(Ecore_Wl2_Window *win, uint32_t timestamp, void *data);
365typedef struct _Ecore_Wl2_Frame_Cb_Handle Ecore_Wl2_Frame_Cb_Handle;
364 366
365EAPI extern int ECORE_WL2_EVENT_DISCONNECT; /** @since 1.18 */ 367EAPI extern int ECORE_WL2_EVENT_DISCONNECT; /** @since 1.18 */
366EAPI extern int ECORE_WL2_EVENT_CONNECT; /** @since 1.18 */ 368EAPI extern int ECORE_WL2_EVENT_CONNECT; /** @since 1.18 */
@@ -1902,6 +1904,27 @@ EAPI void ecore_wl2_window_commit(Ecore_Wl2_Window *window, Eina_Bool flush);
1902 */ 1904 */
1903EAPI Eina_Bool ecore_wl2_window_pending_get(Ecore_Wl2_Window *window); 1905EAPI Eina_Bool ecore_wl2_window_pending_get(Ecore_Wl2_Window *window);
1904 1906
1907/**
1908 * Add a callback that fires when the window's surface_frame callback fires
1909 *
1910 * @window the window to add a callback on
1911 * @cb The callback
1912 * @data user data to provide to the callback handler
1913 *
1914 * @since 1.20
1915 */
1916EAPI Ecore_Wl2_Frame_Cb_Handle *ecore_wl2_window_frame_callback_add(Ecore_Wl2_Window *window, Ecore_Wl2_Frame_Cb cb, void *data);
1917
1918/**
1919 * delete a callback that fires when the window's surface_frame callback fires
1920 *
1921 * @window the window to add a callback on
1922 * @cb The callback handle
1923 *
1924 * @since 1.20
1925 */
1926EAPI void ecore_wl2_window_frame_callback_del(Ecore_Wl2_Frame_Cb_Handle *handle);
1927
1905# endif 1928# endif
1906 1929
1907# undef EAPI 1930# undef EAPI
diff --git a/src/lib/ecore_wl2/ecore_wl2_private.h b/src/lib/ecore_wl2/ecore_wl2_private.h
index 4ee29752e6..240e9062ad 100644
--- a/src/lib/ecore_wl2/ecore_wl2_private.h
+++ b/src/lib/ecore_wl2/ecore_wl2_private.h
@@ -140,6 +140,13 @@ struct _Ecore_Wl2_Aux_Hint
140 const char *hint, *val; 140 const char *hint, *val;
141}; 141};
142 142
143struct _Ecore_Wl2_Frame_Cb_Handle
144{
145 Ecore_Wl2_Window *win;
146 Ecore_Wl2_Frame_Cb cb;
147 void *data;
148};
149
143struct _Ecore_Wl2_Window 150struct _Ecore_Wl2_Window
144{ 151{
145 EINA_INLIST; 152 EINA_INLIST;
@@ -184,6 +191,7 @@ struct _Ecore_Wl2_Window
184 191
185 Eina_Inlist *subsurfs; 192 Eina_Inlist *subsurfs;
186 Eina_List *supported_aux_hints; 193 Eina_List *supported_aux_hints;
194 Eina_List *frame_callbacks;
187 195
188 Eina_Bool moving : 1; 196 Eina_Bool moving : 1;
189 Eina_Bool minimized : 1; 197 Eina_Bool minimized : 1;
diff --git a/src/lib/ecore_wl2/ecore_wl2_window.c b/src/lib/ecore_wl2/ecore_wl2_window.c
index 23eaafc960..c6d0ed4709 100644
--- a/src/lib/ecore_wl2/ecore_wl2_window.c
+++ b/src/lib/ecore_wl2/ecore_wl2_window.c
@@ -538,6 +538,12 @@ ecore_wl2_window_hide(Ecore_Wl2_Window *window)
538 window->commit_pending = EINA_FALSE; 538 window->commit_pending = EINA_FALSE;
539 } 539 }
540 540
541 if (window->callback)
542 {
543 wl_callback_destroy(window->callback);
544 window->callback = NULL;
545 }
546
541 window->configure_serial = 0; 547 window->configure_serial = 0;
542 window->zxdg_configure_ack = NULL; 548 window->zxdg_configure_ack = NULL;
543 window->zxdg_set_min_size = NULL; 549 window->zxdg_set_min_size = NULL;
@@ -573,6 +579,9 @@ ecore_wl2_window_free(Ecore_Wl2_Window *window)
573 579
574 _ecore_wl2_window_aux_hint_free(window); 580 _ecore_wl2_window_aux_hint_free(window);
575 581
582 if (window->callback) wl_callback_destroy(window->callback);
583 window->callback = NULL;
584
576 if (window->uuid && window->surface && window->display->wl.session_recovery) 585 if (window->uuid && window->surface && window->display->wl.session_recovery)
577 zwp_e_session_recovery_destroy_uuid(window->display->wl.session_recovery, 586 zwp_e_session_recovery_destroy_uuid(window->display->wl.session_recovery,
578 window->surface, window->uuid); 587 window->surface, window->uuid);
@@ -1344,6 +1353,26 @@ ecore_wl2_window_aspect_set(Ecore_Wl2_Window *window, int w, int h, unsigned int
1344 efl_hints_set_aspect(window->display->wl.efl_hints, window->zxdg_toplevel, w, h, aspect); 1353 efl_hints_set_aspect(window->display->wl.efl_hints, window->zxdg_toplevel, w, h, aspect);
1345} 1354}
1346 1355
1356static void
1357_frame_cb(void *data, struct wl_callback *callback, uint32_t timestamp)
1358{
1359 Ecore_Wl2_Frame_Cb_Handle *cb;
1360 Ecore_Wl2_Window *window;
1361 Eina_List *l, *ll;
1362
1363 window = data;
1364 window->commit_pending = EINA_FALSE;
1365 wl_callback_destroy(callback);
1366 window->callback = NULL;
1367 EINA_LIST_FOREACH_SAFE(window->frame_callbacks, l, ll, cb)
1368 cb->cb(window, timestamp, cb->data);
1369}
1370
1371static struct wl_callback_listener _frame_listener =
1372{
1373 _frame_cb
1374};
1375
1347EAPI void ecore_wl2_window_commit(Ecore_Wl2_Window *window, Eina_Bool flush) 1376EAPI void ecore_wl2_window_commit(Ecore_Wl2_Window *window, Eina_Bool flush)
1348{ 1377{
1349 EINA_SAFETY_ON_NULL_RETURN(window); 1378 EINA_SAFETY_ON_NULL_RETURN(window);
@@ -1364,3 +1393,27 @@ EAPI Eina_Bool ecore_wl2_window_pending_get(Ecore_Wl2_Window *window)
1364 1393
1365 return window->commit_pending; 1394 return window->commit_pending;
1366} 1395}
1396
1397EAPI Ecore_Wl2_Frame_Cb_Handle *ecore_wl2_window_frame_callback_add(Ecore_Wl2_Window *window, Ecore_Wl2_Frame_Cb cb, void *data)
1398{
1399 Ecore_Wl2_Frame_Cb_Handle *callback;
1400
1401 EINA_SAFETY_ON_NULL_RETURN_VAL(window, NULL);
1402 EINA_SAFETY_ON_NULL_RETURN_VAL(cb, NULL);
1403
1404 callback = malloc(sizeof(*callback));
1405 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, NULL);
1406 callback->cb = cb;
1407 callback->data = data;
1408 callback->win = window;
1409 window->frame_callbacks = eina_list_append(window->frame_callbacks, callback);
1410 return callback;
1411}
1412
1413EAPI void ecore_wl2_window_frame_callback_del(Ecore_Wl2_Frame_Cb_Handle *handle)
1414{
1415 EINA_SAFETY_ON_NULL_RETURN(handle);
1416
1417 handle->win->frame_callbacks = eina_list_remove(handle->win->frame_callbacks, handle);
1418 free(handle);
1419}