forked from enlightenment/efl
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:
parent
87f02170e6
commit
648a11d100
|
@ -133,6 +133,11 @@ ecore_wl_window_free(Ecore_Wl_Window *win)
|
|||
if (win->ivi_surface) ivi_surface_destroy(win->ivi_surface);
|
||||
win->ivi_surface = NULL;
|
||||
#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);
|
||||
win->shell_surface = NULL;
|
||||
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);
|
||||
|
||||
if (win->shell_surface)
|
||||
{
|
||||
Ecore_Wl_Input *input;
|
||||
Ecore_Wl_Input *input = win->keyboard_device;
|
||||
|
||||
if (!(input = win->keyboard_device))
|
||||
{
|
||||
if (win->parent)
|
||||
if ((!input) && (win->parent))
|
||||
{
|
||||
input = win->parent->keyboard_device;
|
||||
if (!(input = win->parent->keyboard_device))
|
||||
input = win->parent->pointer_device;
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -184,22 +188,25 @@ ecore_wl_window_resize(Ecore_Wl_Window *win, int w, int h, int location)
|
|||
|
||||
ecore_wl_window_update_size(win, w, h);
|
||||
|
||||
if (win->shell_surface)
|
||||
{
|
||||
Ecore_Wl_Input *input;
|
||||
Ecore_Wl_Input *input = win->keyboard_device;
|
||||
|
||||
if (!(input = win->keyboard_device))
|
||||
{
|
||||
if (win->parent)
|
||||
if ((!input) && 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);
|
||||
|
||||
if (win->xdg_surface)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
@ -293,9 +300,22 @@ ecore_wl_window_show(Ecore_Wl_Window *win)
|
|||
ivi_application_surface_create(_ecore_wl_disp->wl.ivi_application,
|
||||
win->ivi_surface_id, win->surface);
|
||||
}
|
||||
if (!win->ivi_surface) {
|
||||
|
||||
if (!win->ivi_surface)
|
||||
{
|
||||
#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,
|
||||
|
@ -304,6 +324,7 @@ ecore_wl_window_show(Ecore_Wl_Window *win)
|
|||
|
||||
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);
|
||||
}
|
||||
|
@ -314,27 +335,56 @@ ecore_wl_window_show(Ecore_Wl_Window *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 */
|
||||
if (!win->shell_surface) return;
|
||||
if ((!win->xdg_surface) && (!win->shell_surface)) return;
|
||||
|
||||
switch (win->type)
|
||||
{
|
||||
case ECORE_WL_WINDOW_TYPE_FULLSCREEN:
|
||||
if (win->xdg_surface)
|
||||
xdg_surface_set_fullscreen(win->xdg_surface, NULL);
|
||||
else if (win->shell_surface)
|
||||
wl_shell_surface_set_fullscreen(win->shell_surface,
|
||||
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
|
||||
0, NULL);
|
||||
break;
|
||||
case ECORE_WL_WINDOW_TYPE_MAXIMIZED:
|
||||
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;
|
||||
case ECORE_WL_WINDOW_TYPE_TRANSIENT:
|
||||
if (win->xdg_surface)
|
||||
xdg_surface_set_parent(win->xdg_surface, win->parent->surface);
|
||||
else if (win->shell_surface)
|
||||
wl_shell_surface_set_transient(win->shell_surface,
|
||||
win->parent->surface,
|
||||
win->allocation.x, win->allocation.y, 0);
|
||||
win->allocation.x,
|
||||
win->allocation.y, 0);
|
||||
break;
|
||||
case ECORE_WL_WINDOW_TYPE_MENU:
|
||||
if (win->xdg_surface)
|
||||
{
|
||||
win->xdg_popup =
|
||||
xdg_shell_get_xdg_popup(_ecore_wl_disp->wl.xdg_shell,
|
||||
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,
|
||||
|
@ -342,6 +392,9 @@ ecore_wl_window_show(Ecore_Wl_Window *win)
|
|||
win->allocation.x, win->allocation.y, 0);
|
||||
break;
|
||||
case ECORE_WL_WINDOW_TYPE_TOPLEVEL:
|
||||
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;
|
||||
default:
|
||||
|
@ -355,8 +408,16 @@ ecore_wl_window_hide(Ecore_Wl_Window *win)
|
|||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
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);
|
||||
win->shell_surface = NULL;
|
||||
|
||||
if (win->surface) wl_surface_destroy(win->surface);
|
||||
win->surface = NULL;
|
||||
}
|
||||
|
@ -379,21 +440,38 @@ ecore_wl_window_maximized_set(Ecore_Wl_Window *win, Eina_Bool maximized)
|
|||
if (!win) return;
|
||||
|
||||
if ((win->type == ECORE_WL_WINDOW_TYPE_MAXIMIZED) == maximized) return;
|
||||
|
||||
if (win->type == ECORE_WL_WINDOW_TYPE_TOPLEVEL)
|
||||
{
|
||||
win->saved.w = win->allocation.w;
|
||||
win->saved.h = win->allocation.h;
|
||||
if (win->shell_surface)
|
||||
|
||||
if (win->xdg_surface)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (win->shell_surface)
|
||||
if (win->xdg_surface)
|
||||
{
|
||||
xdg_surface_unset_maximized(win->xdg_surface);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
|
@ -421,6 +499,10 @@ ecore_wl_window_fullscreen_set(Ecore_Wl_Window *win, Eina_Bool fullscreen)
|
|||
win->type = ECORE_WL_WINDOW_TYPE_FULLSCREEN;
|
||||
win->saved.w = win->allocation.w;
|
||||
win->saved.h = win->allocation.h;
|
||||
|
||||
if (win->xdg_surface)
|
||||
xdg_surface_set_fullscreen(win->xdg_surface, NULL);
|
||||
|
||||
if (win->shell_surface)
|
||||
wl_shell_surface_set_fullscreen(win->shell_surface,
|
||||
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
|
||||
|
@ -428,8 +510,11 @@ ecore_wl_window_fullscreen_set(Ecore_Wl_Window *win, Eina_Bool fullscreen)
|
|||
}
|
||||
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);
|
||||
|
||||
win->type = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
|
||||
_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;
|
||||
}
|
||||
|
||||
/* @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 *
|
||||
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;
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue