Added support for xdg-shell protocol in ecore-wayland.

Summary: Signed-off-by: Srivardhan Hebbar <sri.hebbar@samsung.com>

Reviewers: devilhorns

Reviewed By: devilhorns

Subscribers: cedric

Projects: #efl

Differential Revision: https://phab.enlightenment.org/D1328
This commit is contained in:
Chris Michael 2014-08-13 10:44:19 -04:00
parent 87f02170e6
commit 648a11d100
1 changed files with 169 additions and 72 deletions

View File

@ -133,6 +133,11 @@ ecore_wl_window_free(Ecore_Wl_Window *win)
if (win->ivi_surface) ivi_surface_destroy(win->ivi_surface); if (win->ivi_surface) ivi_surface_destroy(win->ivi_surface);
win->ivi_surface = NULL; win->ivi_surface = NULL;
#endif #endif
if (win->xdg_surface) xdg_surface_destroy(win->xdg_surface);
win->xdg_surface = NULL;
if (win->xdg_popup) xdg_popup_destroy(win->xdg_popup);
win->xdg_popup = NULL;
if (win->shell_surface) wl_shell_surface_destroy(win->shell_surface); if (win->shell_surface) wl_shell_surface_destroy(win->shell_surface);
win->shell_surface = NULL; win->shell_surface = NULL;
if (win->surface) wl_surface_destroy(win->surface); if (win->surface) wl_surface_destroy(win->surface);
@ -154,25 +159,24 @@ ecore_wl_window_move(Ecore_Wl_Window *win, int x, int y)
ecore_wl_window_update_location(win, x, y); ecore_wl_window_update_location(win, x, y);
if (win->shell_surface) Ecore_Wl_Input *input = win->keyboard_device;
if ((!input) && (win->parent))
{ {
Ecore_Wl_Input *input; input = win->parent->keyboard_device;
if (!(input = win->parent->keyboard_device))
if (!(input = win->keyboard_device)) input = win->parent->pointer_device;
{
if (win->parent)
{
if (!(input = win->parent->keyboard_device))
input = win->parent->pointer_device;
}
}
if ((!input) || (!input->seat)) return;
_ecore_wl_input_grab_release(input, win);
wl_shell_surface_move(win->shell_surface, input->seat,
input->display->serial);
} }
if ((!input) || (!input->seat)) return;
_ecore_wl_input_grab_release(input, win);
if (win->xdg_surface)
xdg_surface_move(win->xdg_surface, input->seat, input->display->serial);
else if (win->shell_surface)
wl_shell_surface_move(win->shell_surface, input->seat,
input->display->serial);
} }
EAPI void EAPI void
@ -184,23 +188,26 @@ ecore_wl_window_resize(Ecore_Wl_Window *win, int w, int h, int location)
ecore_wl_window_update_size(win, w, h); ecore_wl_window_update_size(win, w, h);
if (win->shell_surface) Ecore_Wl_Input *input = win->keyboard_device;
if ((!input) && win->parent)
{ {
Ecore_Wl_Input *input; if (!(input = win->parent->keyboard_device))
input = win->parent->pointer_device;
}
if (!(input = win->keyboard_device)) if ((!input) || (!input->seat)) return;
{
if (win->parent)
{
if (!(input = win->parent->keyboard_device))
input = win->parent->pointer_device;
}
}
if ((!input) || (!input->seat)) return; _ecore_wl_input_grab_release(input, win);
_ecore_wl_input_grab_release(input, win); if (win->xdg_surface)
wl_shell_surface_resize(win->shell_surface, input->seat, {
xdg_surface_resize(win->xdg_surface, input->seat,
input->display->serial, location);
}
else if (win->shell_surface)
{
wl_shell_surface_resize(win->shell_surface, input->seat,
input->display->serial, location); input->display->serial, location);
} }
} }
@ -293,56 +300,102 @@ ecore_wl_window_show(Ecore_Wl_Window *win)
ivi_application_surface_create(_ecore_wl_disp->wl.ivi_application, ivi_application_surface_create(_ecore_wl_disp->wl.ivi_application,
win->ivi_surface_id, win->surface); win->ivi_surface_id, win->surface);
} }
if (!win->ivi_surface) {
#endif if (!win->ivi_surface)
if ((!win->shell_surface) && (_ecore_wl_disp->wl.shell))
{ {
win->shell_surface =
wl_shell_get_shell_surface(_ecore_wl_disp->wl.shell,
win->surface);
if (!win->shell_surface) return;
if (win->title)
wl_shell_surface_set_title(win->shell_surface, win->title);
if (win->class_name)
wl_shell_surface_set_class(win->shell_surface, win->class_name);
}
if (win->shell_surface)
wl_shell_surface_add_listener(win->shell_surface,
&_ecore_wl_shell_surface_listener, win);
#ifdef USE_IVI_SHELL
}
#endif #endif
if ((!win->shell_surface) && (_ecore_wl_disp->wl.shell))
if ((!win->xdg_surface) && (_ecore_wl_disp->wl.xdg_shell))
{
win->xdg_surface =
xdg_shell_get_xdg_surface(_ecore_wl_disp->wl.xdg_shell,
win->surface);
if (!win->xdg_surface) return;
xdg_surface_set_user_data(win->xdg_surface, win);
xdg_surface_add_listener(win->xdg_surface,
&_ecore_xdg_surface_listener, win);
}
else if ((!win->shell_surface) && (_ecore_wl_disp->wl.shell))
{
win->shell_surface =
wl_shell_get_shell_surface(_ecore_wl_disp->wl.shell,
win->surface);
if (!win->shell_surface) return;
if (win->title)
wl_shell_surface_set_title(win->shell_surface, win->title);
if (win->class_name)
wl_shell_surface_set_class(win->shell_surface, win->class_name);
}
if (win->shell_surface)
wl_shell_surface_add_listener(win->shell_surface,
&_ecore_wl_shell_surface_listener, win);
#ifdef USE_IVI_SHELL
}
#endif
if (win->shell_surface)
wl_shell_surface_add_listener(win->shell_surface,
&_ecore_wl_shell_surface_listener,
win);
} }
/* trap for valid shell surface */ /* trap for valid shell surface */
if (!win->shell_surface) return; if ((!win->xdg_surface) && (!win->shell_surface)) return;
switch (win->type) switch (win->type)
{ {
case ECORE_WL_WINDOW_TYPE_FULLSCREEN: case ECORE_WL_WINDOW_TYPE_FULLSCREEN:
wl_shell_surface_set_fullscreen(win->shell_surface, if (win->xdg_surface)
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, xdg_surface_set_fullscreen(win->xdg_surface, NULL);
0, NULL); else if (win->shell_surface)
wl_shell_surface_set_fullscreen(win->shell_surface,
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
0, NULL);
break; break;
case ECORE_WL_WINDOW_TYPE_MAXIMIZED: case ECORE_WL_WINDOW_TYPE_MAXIMIZED:
wl_shell_surface_set_maximized(win->shell_surface, NULL); if (win->xdg_surface)
xdg_surface_set_maximized(win->xdg_surface);
else if (win->shell_surface)
wl_shell_surface_set_maximized(win->shell_surface, NULL);
break; break;
case ECORE_WL_WINDOW_TYPE_TRANSIENT: case ECORE_WL_WINDOW_TYPE_TRANSIENT:
wl_shell_surface_set_transient(win->shell_surface, if (win->xdg_surface)
win->parent->surface, xdg_surface_set_parent(win->xdg_surface, win->parent->surface);
win->allocation.x, win->allocation.y, 0); else if (win->shell_surface)
wl_shell_surface_set_transient(win->shell_surface,
win->parent->surface,
win->allocation.x,
win->allocation.y, 0);
break; break;
case ECORE_WL_WINDOW_TYPE_MENU: case ECORE_WL_WINDOW_TYPE_MENU:
wl_shell_surface_set_popup(win->shell_surface, if (win->xdg_surface)
_ecore_wl_disp->input->seat, {
_ecore_wl_disp->serial, win->xdg_popup =
win->parent->surface, xdg_shell_get_xdg_popup(_ecore_wl_disp->wl.xdg_shell,
win->allocation.x, win->allocation.y, 0); win->surface,
win->parent->surface,
_ecore_wl_disp->input->seat,
_ecore_wl_disp->serial,
win->allocation.x,
win->allocation.y, 0);
xdg_popup_set_user_data(win->xdg_popup, win);
xdg_popup_add_listener(win->xdg_popup,
&_ecore_xdg_popup_listener, win);
}
else if (win->shell_surface)
wl_shell_surface_set_popup(win->shell_surface,
_ecore_wl_disp->input->seat,
_ecore_wl_disp->serial,
win->parent->surface,
win->allocation.x, win->allocation.y, 0);
break; break;
case ECORE_WL_WINDOW_TYPE_TOPLEVEL: case ECORE_WL_WINDOW_TYPE_TOPLEVEL:
wl_shell_surface_set_toplevel(win->shell_surface); if (win->xdg_surface)
xdg_surface_set_parent(win->xdg_surface, NULL);
else if (win->shell_surface)
wl_shell_surface_set_toplevel(win->shell_surface);
break; break;
default: default:
break; break;
@ -355,8 +408,16 @@ ecore_wl_window_hide(Ecore_Wl_Window *win)
LOGFN(__FILE__, __LINE__, __FUNCTION__); LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (!win) return; if (!win) return;
if (win->xdg_surface) xdg_surface_destroy(win->xdg_surface);
win->xdg_surface = NULL;
if (win->xdg_popup) xdg_popup_destroy(win->xdg_popup);
win->xdg_popup = NULL;
if (win->shell_surface) wl_shell_surface_destroy(win->shell_surface); if (win->shell_surface) wl_shell_surface_destroy(win->shell_surface);
win->shell_surface = NULL; win->shell_surface = NULL;
if (win->surface) wl_surface_destroy(win->surface); if (win->surface) wl_surface_destroy(win->surface);
win->surface = NULL; win->surface = NULL;
} }
@ -379,20 +440,37 @@ ecore_wl_window_maximized_set(Ecore_Wl_Window *win, Eina_Bool maximized)
if (!win) return; if (!win) return;
if ((win->type == ECORE_WL_WINDOW_TYPE_MAXIMIZED) == maximized) return; if ((win->type == ECORE_WL_WINDOW_TYPE_MAXIMIZED) == maximized) return;
if (win->type == ECORE_WL_WINDOW_TYPE_TOPLEVEL) if (win->type == ECORE_WL_WINDOW_TYPE_TOPLEVEL)
{ {
win->saved.w = win->allocation.w; win->saved.w = win->allocation.w;
win->saved.h = win->allocation.h; win->saved.h = win->allocation.h;
if (win->shell_surface)
wl_shell_surface_set_maximized(win->shell_surface, NULL); if (win->xdg_surface)
win->type = ECORE_WL_WINDOW_TYPE_MAXIMIZED; {
xdg_surface_set_maximized(win->xdg_surface);
win->type = ECORE_WL_WINDOW_TYPE_MAXIMIZED;
}
else if (win->shell_surface)
{
wl_shell_surface_set_maximized(win->shell_surface, NULL);
win->type = ECORE_WL_WINDOW_TYPE_MAXIMIZED;
}
} }
else if (win->type == ECORE_WL_WINDOW_TYPE_MAXIMIZED) else if (win->type == ECORE_WL_WINDOW_TYPE_MAXIMIZED)
{ {
if (win->shell_surface) if (win->xdg_surface)
wl_shell_surface_set_toplevel(win->shell_surface); {
win->type = ECORE_WL_WINDOW_TYPE_TOPLEVEL; xdg_surface_unset_maximized(win->xdg_surface);
_ecore_wl_window_configure_send(win, win->saved.w, win->saved.h, 0); win->type = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
_ecore_wl_window_configure_send(win, win->saved.w, win->saved.h, 0);
}
else if (win->shell_surface)
{
wl_shell_surface_set_toplevel(win->shell_surface);
win->type = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
_ecore_wl_window_configure_send(win, win->saved.w, win->saved.h, 0);
}
} }
} }
@ -421,6 +499,10 @@ ecore_wl_window_fullscreen_set(Ecore_Wl_Window *win, Eina_Bool fullscreen)
win->type = ECORE_WL_WINDOW_TYPE_FULLSCREEN; win->type = ECORE_WL_WINDOW_TYPE_FULLSCREEN;
win->saved.w = win->allocation.w; win->saved.w = win->allocation.w;
win->saved.h = win->allocation.h; win->saved.h = win->allocation.h;
if (win->xdg_surface)
xdg_surface_set_fullscreen(win->xdg_surface, NULL);
if (win->shell_surface) if (win->shell_surface)
wl_shell_surface_set_fullscreen(win->shell_surface, wl_shell_surface_set_fullscreen(win->shell_surface,
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
@ -428,8 +510,11 @@ ecore_wl_window_fullscreen_set(Ecore_Wl_Window *win, Eina_Bool fullscreen)
} }
else else
{ {
if (win->shell_surface) if (win->xdg_surface)
xdg_surface_unset_fullscreen(win->xdg_surface);
else if (win->shell_surface)
wl_shell_surface_set_toplevel(win->shell_surface); wl_shell_surface_set_toplevel(win->shell_surface);
win->type = ECORE_WL_WINDOW_TYPE_TOPLEVEL; win->type = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
_ecore_wl_window_configure_send(win, win->saved.w, win->saved.h, 0); _ecore_wl_window_configure_send(win, win->saved.w, win->saved.h, 0);
} }
@ -535,6 +620,16 @@ ecore_wl_window_shell_surface_get(Ecore_Wl_Window *win)
return win->shell_surface; return win->shell_surface;
} }
/* @since 1.11 */
EAPI struct xdg_surface *
ecore_wl_window_xdg_surface_get(Ecore_Wl_Window *win)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (!win) return NULL;
return win->xdg_surface;
}
EAPI Ecore_Wl_Window * EAPI Ecore_Wl_Window *
ecore_wl_window_find(unsigned int id) ecore_wl_window_find(unsigned int id)
{ {
@ -772,7 +867,9 @@ ecore_wl_window_title_set(Ecore_Wl_Window *win, const char *title)
if (!win) return; if (!win) return;
eina_stringshare_replace(&win->title, title); eina_stringshare_replace(&win->title, title);
if ((win->shell_surface) && (win->title)) if ((win->xdg_surface) && (win->title))
xdg_surface_set_title(win->xdg_surface, win->title);
else if ((win->shell_surface) && (win->title))
wl_shell_surface_set_title(win->shell_surface, win->title); wl_shell_surface_set_title(win->shell_surface, win->title);
} }