ecore/wayland: Add window state changed callback to Ecore_Wl_Window.

This will allow it to report to Ecore_Evas that the window has changed
its state. Elementary uses this to update its maximized/fullscreen/other
window states internal information.

The code that uses this callback is also added to Ecore_Evas.

SVN revision: 83625
This commit is contained in:
Rafael Antognolli 2013-02-05 12:19:40 +00:00
parent 562b278b52
commit 74cb944f25
6 changed files with 69 additions and 0 deletions

View File

@ -211,8 +211,12 @@ struct _Ecore_Wl_Window
Ecore_Wl_Input *pointer_device;
Ecore_Wl_Input *keyboard_device;
/* FIXME: Shouldn't these attributes be private to the Ecore_Wl_Window? */
Eina_Bool frame_pending;
struct wl_callback *frame_callback;
void (*state_changed_cb)(void *);
void *state_changed_cb_data;
Ecore_Job *state_changed_job;
/* FIXME: Ideally we should record the cursor name for this window
* so we can compare and avoid unnecessary cursor set calls to wayland */
@ -596,6 +600,7 @@ EAPI void ecore_wl_window_pointer_set(Ecore_Wl_Window *win, struct wl_surface *s
EAPI void ecore_wl_window_cursor_from_name_set(Ecore_Wl_Window *win, const char *cursor_name);
EAPI void ecore_wl_window_cursor_default_restore(Ecore_Wl_Window *win);
EAPI void ecore_wl_window_parent_set(Ecore_Wl_Window *win, Ecore_Wl_Window *parent);
EAPI void ecore_wl_window_state_changed_cb_set(Ecore_Wl_Window *win, void (*cb)(void *), void *cb_data);
/** @since 1.7 */
EAPI Eina_Bool ecore_wl_dnd_set_selection(Ecore_Wl_Dnd *dnd, const char **types_offered);

View File

@ -12,6 +12,7 @@ static void _ecore_wl_window_cb_surface_enter(void *data, struct wl_surface *sur
static void _ecore_wl_window_cb_surface_leave(void *data, struct wl_surface *surface, struct wl_output *output EINA_UNUSED);
static void _ecore_wl_window_configure_send(Ecore_Wl_Window *win, int w, int h);
static char *_ecore_wl_window_id_str_get(unsigned int win_id);
static void _ecore_wl_window_state_changed(Ecore_Wl_Window *win);
/* local variables */
static Eina_Hash *_windows = NULL;
@ -107,6 +108,12 @@ ecore_wl_window_free(Ecore_Wl_Window *win)
if (win->surface) wl_surface_destroy(win->surface);
win->surface = NULL;
if (win->state_changed_job)
{
ecore_job_del(win->state_changed_job);
win->state_changed_job = NULL;
}
/* HMMM, why was this disabled ? */
free(win);
}
@ -307,6 +314,8 @@ ecore_wl_window_show(Ecore_Wl_Window *win)
break;
}
_ecore_wl_window_state_changed(win);
/* if (win->type != ECORE_WL_WINDOW_TYPE_FULLSCREEN) */
/* { */
/* win->region.input = */
@ -334,6 +343,7 @@ ecore_wl_window_hide(Ecore_Wl_Window *win)
win->shell_surface = NULL;
if (win->surface) wl_surface_destroy(win->surface);
win->surface = NULL;
_ecore_wl_window_state_changed(win);
}
EAPI void
@ -344,6 +354,7 @@ ecore_wl_window_raise(Ecore_Wl_Window *win)
if (!win) return;
if (win->shell_surface)
wl_shell_surface_set_toplevel(win->shell_surface);
_ecore_wl_window_state_changed(win);
}
EAPI void
@ -369,6 +380,7 @@ ecore_wl_window_maximized_set(Ecore_Wl_Window *win, Eina_Bool maximized)
_ecore_wl_window_configure_send(win, win->saved_allocation.w,
win->saved_allocation.h);
}
_ecore_wl_window_state_changed(win);
}
EAPI void
@ -395,6 +407,7 @@ ecore_wl_window_fullscreen_set(Ecore_Wl_Window *win, Eina_Bool fullscreen)
_ecore_wl_window_configure_send(win, win->saved_allocation.w,
win->saved_allocation.h);
}
_ecore_wl_window_state_changed(win);
}
EAPI void
@ -413,6 +426,7 @@ ecore_wl_window_transparent_set(Ecore_Wl_Window *win, Eina_Bool transparent)
wl_region_add(win->region.opaque, win->allocation.x, win->allocation.y,
win->allocation.w, win->allocation.h);
}
_ecore_wl_window_state_changed(win);
}
EAPI void
@ -529,6 +543,21 @@ ecore_wl_window_parent_set(Ecore_Wl_Window *win, Ecore_Wl_Window *parent)
win->parent = parent;
}
/* @since 1.8 */
EAPI void
ecore_wl_window_state_changed_cb_set(Ecore_Wl_Window *win, void (*cb)(void *), void *cb_data)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (!win) return;
win->state_changed_cb = cb;
if (cb)
win->state_changed_cb_data = cb_data;
else
win->state_changed_cb_data = NULL;
}
/* local functions */
static void
_ecore_wl_window_cb_ping(void *data EINA_UNUSED, struct wl_shell_surface *shell_surface, unsigned int serial)
@ -631,3 +660,26 @@ _ecore_wl_window_id_str_get(unsigned int win_id)
return id;
}
static void
_ecore_wl_window_state_changed_job(void *data)
{
Ecore_Wl_Window *win = data;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (win->state_changed_cb)
win->state_changed_cb(win->state_changed_cb_data);
win->state_changed_job = NULL;
}
static void
_ecore_wl_window_state_changed(Ecore_Wl_Window *win)
{
if (win->state_changed_job)
return;
win->state_changed_job =
ecore_job_add(_ecore_wl_window_state_changed_job, win);
}

View File

@ -933,3 +933,12 @@ _ecore_evas_wl_interface_new(void)
return iface;
}
void
_ecore_evas_wl_common_state_change(void *data)
{
Ecore_Evas *ee = data;
if (ee->func.fn_state_change)
ee->func.fn_state_change(ee);
}

View File

@ -180,6 +180,7 @@ ecore_evas_wayland_egl_new_internal(const char *disp_name, unsigned int parent,
wdata->win =
ecore_wl_window_new(p, x, y, w, h, ECORE_WL_WINDOW_BUFFER_TYPE_EGL_WINDOW);
ee->prop.window = wdata->win->id;
ecore_wl_window_state_changed_cb_set(wdata->win, _ecore_evas_wl_common_state_change, ee);
if ((einfo = (Evas_Engine_Info_Wayland_Egl *)evas_engine_info_get(ee->evas)))
{

View File

@ -67,6 +67,7 @@ void _ecore_evas_wl_common_post_render(Ecore_Evas *ee);
int _ecore_evas_wl_common_render(Ecore_Evas *ee);
void _ecore_evas_wl_common_screen_geometry_get(const Ecore_Evas *ee, int *x, int *y, int *w, int *h);
void _ecore_evas_wl_common_screen_dpi_get(const Ecore_Evas *ee, int *xdpi, int *ydpi);
void _ecore_evas_wl_common_state_change(void *data);
Evas_Object * _ecore_evas_wl_common_frame_add(Evas *evas);

View File

@ -179,6 +179,7 @@ ecore_evas_wayland_shm_new_internal(const char *disp_name, unsigned int parent,
wdata->win =
ecore_wl_window_new(p, x, y, w, h, ECORE_WL_WINDOW_BUFFER_TYPE_SHM);
ee->prop.window = wdata->win->id;
ecore_wl_window_state_changed_cb_set(wdata->win, _ecore_evas_wl_common_state_change, ee);
if ((einfo = (Evas_Engine_Info_Wayland_Shm *)evas_engine_info_get(ee->evas)))
{