2015-08-20 09:39:39 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "ecore_wl2_private.h"
|
|
|
|
|
2015-09-30 09:03:50 -07:00
|
|
|
static void
|
|
|
|
_ecore_wl2_window_configure_send(Ecore_Wl2_Window *window, int w, int h, unsigned int edges)
|
|
|
|
{
|
|
|
|
Ecore_Wl2_Event_Window_Configure *ev;
|
|
|
|
|
|
|
|
ev = calloc(1, sizeof(Ecore_Wl2_Event_Window_Configure));
|
|
|
|
if (!ev) return;
|
|
|
|
|
|
|
|
ev->win = window->id;
|
|
|
|
ev->event_win = window->id;
|
|
|
|
ev->x = window->geometry.x;
|
|
|
|
ev->y = window->geometry.y;
|
|
|
|
ev->w = w;
|
|
|
|
ev->h = h;
|
|
|
|
ev->edges = edges;
|
|
|
|
|
|
|
|
ecore_event_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE, ev, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2015-09-09 08:19:24 -07:00
|
|
|
static void
|
|
|
|
_wl_shell_surface_cb_ping(void *data EINA_UNUSED, struct wl_shell_surface *shell_surface, unsigned int serial)
|
|
|
|
{
|
|
|
|
wl_shell_surface_pong(shell_surface, serial);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_wl_shell_surface_cb_configure(void *data, struct wl_shell_surface *shell_surface EINA_UNUSED, unsigned int edges, int w, int h)
|
|
|
|
{
|
|
|
|
Ecore_Wl2_Window *win;
|
|
|
|
|
|
|
|
win = data;
|
|
|
|
if (!win) return;
|
|
|
|
|
|
|
|
if ((w <= 0) || (h <= 0)) return;
|
2015-11-09 08:57:42 -08:00
|
|
|
if ((w > 0) && (h > 0))
|
2015-09-30 09:03:50 -07:00
|
|
|
_ecore_wl2_window_configure_send(win, w, h, edges);
|
2015-09-09 08:19:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_wl_shell_surface_cb_popup_done(void *data EINA_UNUSED, struct wl_shell_surface *shell_surface EINA_UNUSED)
|
|
|
|
{
|
2015-09-23 09:13:44 -07:00
|
|
|
Ecore_Wl2_Window *win;
|
|
|
|
|
|
|
|
win = data;
|
|
|
|
if (!win) return;
|
|
|
|
|
|
|
|
_ecore_wl2_input_ungrab(win->input);
|
2015-09-09 08:19:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_shell_surface_listener _wl_shell_surface_listener =
|
|
|
|
{
|
|
|
|
_wl_shell_surface_cb_ping,
|
|
|
|
_wl_shell_surface_cb_configure,
|
|
|
|
_wl_shell_surface_cb_popup_done
|
|
|
|
};
|
|
|
|
|
2015-09-24 08:45:10 -07:00
|
|
|
static void
|
|
|
|
_xdg_popup_cb_done(void *data, struct xdg_popup *xdg_popup EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Ecore_Wl2_Window *win;
|
|
|
|
|
|
|
|
win = data;
|
|
|
|
if (!win) return;
|
|
|
|
|
|
|
|
_ecore_wl2_input_ungrab(win->input);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct xdg_popup_listener _xdg_popup_listener =
|
|
|
|
{
|
|
|
|
_xdg_popup_cb_done,
|
|
|
|
};
|
|
|
|
|
2015-09-09 08:19:24 -07:00
|
|
|
static void
|
|
|
|
_xdg_surface_cb_configure(void *data, struct xdg_surface *xdg_surface EINA_UNUSED, int32_t w, int32_t h, struct wl_array *states, uint32_t serial)
|
|
|
|
{
|
|
|
|
Ecore_Wl2_Window *win;
|
|
|
|
uint32_t *s;
|
|
|
|
|
|
|
|
win = data;
|
|
|
|
if (!win) return;
|
|
|
|
|
|
|
|
win->minimized = EINA_FALSE;
|
|
|
|
win->maximized = EINA_FALSE;
|
|
|
|
win->fullscreen = EINA_FALSE;
|
|
|
|
win->focused = EINA_FALSE;
|
|
|
|
win->resizing = EINA_FALSE;
|
|
|
|
|
|
|
|
wl_array_for_each(s, states)
|
|
|
|
{
|
|
|
|
switch (*s)
|
|
|
|
{
|
|
|
|
case XDG_SURFACE_STATE_MAXIMIZED:
|
|
|
|
win->maximized = EINA_TRUE;
|
|
|
|
break;
|
|
|
|
case XDG_SURFACE_STATE_FULLSCREEN:
|
|
|
|
win->fullscreen = EINA_TRUE;
|
|
|
|
break;
|
|
|
|
case XDG_SURFACE_STATE_RESIZING:
|
|
|
|
win->resizing = EINA_TRUE;
|
|
|
|
break;
|
|
|
|
case XDG_SURFACE_STATE_ACTIVATED:
|
|
|
|
win->focused = EINA_TRUE;
|
|
|
|
win->minimized = EINA_FALSE;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((w > 0) && (h > 0))
|
2015-09-30 09:03:50 -07:00
|
|
|
_ecore_wl2_window_configure_send(win, w, h, 0);
|
2015-09-09 08:19:24 -07:00
|
|
|
|
|
|
|
xdg_surface_ack_configure(win->xdg_surface, serial);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_xdg_surface_cb_delete(void *data, struct xdg_surface *xdg_surface EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Ecore_Wl2_Window *win;
|
|
|
|
|
|
|
|
win = data;
|
|
|
|
if (!win) return;
|
|
|
|
|
2015-09-09 10:23:39 -07:00
|
|
|
ecore_wl2_window_free(win);
|
2015-09-09 08:19:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct xdg_surface_listener _xdg_surface_listener =
|
|
|
|
{
|
|
|
|
_xdg_surface_cb_configure,
|
|
|
|
_xdg_surface_cb_delete,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
_ecore_wl2_window_type_set(Ecore_Wl2_Window *win)
|
|
|
|
{
|
|
|
|
switch (win->type)
|
|
|
|
{
|
|
|
|
case ECORE_WL2_WINDOW_TYPE_FULLSCREEN:
|
|
|
|
if (win->xdg_surface)
|
|
|
|
xdg_surface_set_fullscreen(win->xdg_surface, NULL);
|
|
|
|
else if (win->wl_shell_surface)
|
|
|
|
wl_shell_surface_set_fullscreen(win->wl_shell_surface,
|
|
|
|
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
|
|
|
|
0, NULL);
|
|
|
|
break;
|
|
|
|
case ECORE_WL2_WINDOW_TYPE_MAXIMIZED:
|
|
|
|
if (win->xdg_surface)
|
|
|
|
xdg_surface_set_maximized(win->xdg_surface);
|
|
|
|
else if (win->wl_shell_surface)
|
|
|
|
wl_shell_surface_set_maximized(win->wl_shell_surface, NULL);
|
|
|
|
break;
|
|
|
|
case ECORE_WL2_WINDOW_TYPE_TRANSIENT:
|
|
|
|
if (win->xdg_surface)
|
|
|
|
xdg_surface_set_parent(win->xdg_surface, win->parent->xdg_surface);
|
|
|
|
else if (win->wl_shell_surface)
|
|
|
|
wl_shell_surface_set_transient(win->wl_shell_surface,
|
|
|
|
win->parent->surface,
|
|
|
|
win->geometry.x, win->geometry.y, 0);
|
|
|
|
break;
|
|
|
|
case ECORE_WL2_WINDOW_TYPE_MENU:
|
|
|
|
{
|
2015-09-24 08:54:19 -07:00
|
|
|
Ecore_Wl2_Input *input;
|
|
|
|
|
|
|
|
input = win->input;
|
|
|
|
if ((!input) && (win->parent))
|
2015-09-24 08:45:10 -07:00
|
|
|
{
|
2015-09-24 08:54:19 -07:00
|
|
|
input = win->parent->input;
|
2015-09-24 08:45:10 -07:00
|
|
|
}
|
|
|
|
|
2015-09-24 08:54:19 -07:00
|
|
|
if ((!input) || (!input->wl.seat)) return;
|
|
|
|
|
|
|
|
if (win->xdg_surface)
|
|
|
|
{
|
|
|
|
win->xdg_popup =
|
|
|
|
xdg_shell_get_xdg_popup(win->display->wl.xdg_shell,
|
|
|
|
win->surface, win->parent->surface,
|
|
|
|
input->wl.seat,
|
|
|
|
win->display->serial,
|
|
|
|
win->geometry.x, win->geometry.y);
|
|
|
|
if (!win->xdg_popup)
|
|
|
|
{
|
|
|
|
ERR("Could not create xdg popup: %m");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
xdg_popup_set_user_data(win->xdg_popup, win);
|
|
|
|
xdg_popup_add_listener(win->xdg_popup,
|
|
|
|
&_xdg_popup_listener, win);
|
|
|
|
}
|
|
|
|
else if (win->wl_shell_surface)
|
|
|
|
{
|
|
|
|
wl_shell_surface_set_popup(win->wl_shell_surface,
|
|
|
|
input->wl.seat,
|
|
|
|
win->display->serial,
|
|
|
|
win->parent->surface,
|
|
|
|
win->geometry.x,
|
|
|
|
win->geometry.y, 0);
|
|
|
|
}
|
2015-09-09 08:19:24 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ECORE_WL2_WINDOW_TYPE_TOPLEVEL:
|
|
|
|
if (win->xdg_surface)
|
|
|
|
xdg_surface_set_parent(win->xdg_surface, NULL);
|
|
|
|
else if (win->wl_shell_surface)
|
|
|
|
wl_shell_surface_set_toplevel(win->wl_shell_surface);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-20 09:39:39 -07:00
|
|
|
EAPI Ecore_Wl2_Window *
|
|
|
|
ecore_wl2_window_new(Ecore_Wl2_Display *display, Ecore_Wl2_Window *parent, int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
Ecore_Wl2_Window *win;
|
|
|
|
static int _win_id = 1;
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(display, NULL);
|
|
|
|
|
|
|
|
/* try to allocate space for window structure */
|
|
|
|
win = calloc(1, sizeof(Ecore_Wl2_Window));
|
|
|
|
if (!win) return NULL;
|
|
|
|
|
|
|
|
win->display = display;
|
|
|
|
win->parent = parent;
|
|
|
|
win->id = _win_id++;
|
|
|
|
|
|
|
|
win->geometry.x = x;
|
|
|
|
win->geometry.y = y;
|
|
|
|
win->geometry.w = w;
|
|
|
|
win->geometry.h = h;
|
|
|
|
|
2015-09-28 06:36:34 -07:00
|
|
|
win->opaque.x = x;
|
|
|
|
win->opaque.y = y;
|
|
|
|
win->opaque.w = w;
|
|
|
|
win->opaque.h = h;
|
|
|
|
|
2015-08-20 09:54:27 -07:00
|
|
|
win->type = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
|
|
|
|
|
2015-09-10 10:21:02 -07:00
|
|
|
display->windows =
|
|
|
|
eina_inlist_append(display->windows, EINA_INLIST_GET(win));
|
|
|
|
|
2015-08-20 09:39:39 -07:00
|
|
|
return win;
|
|
|
|
}
|
2015-08-20 09:44:17 -07:00
|
|
|
|
|
|
|
EAPI int
|
|
|
|
ecore_wl2_window_id_get(Ecore_Wl2_Window *window)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(window, -1);
|
2015-08-20 11:12:18 -07:00
|
|
|
return window->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI struct wl_surface *
|
|
|
|
ecore_wl2_window_surface_get(Ecore_Wl2_Window *window)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(window, NULL);
|
|
|
|
|
|
|
|
if (!window->surface)
|
|
|
|
{
|
2015-10-20 08:04:31 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(window->display->wl.compositor, NULL);
|
|
|
|
|
2015-08-20 11:12:18 -07:00
|
|
|
window->surface =
|
|
|
|
wl_compositor_create_surface(window->display->wl.compositor);
|
2015-09-29 08:00:32 -07:00
|
|
|
|
|
|
|
window->surface_id =
|
|
|
|
wl_proxy_get_id((struct wl_proxy *)window->surface);
|
2015-08-20 11:12:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return window->surface;
|
2015-08-20 09:44:17 -07:00
|
|
|
}
|
2015-09-09 08:19:24 -07:00
|
|
|
|
2015-09-29 08:00:32 -07:00
|
|
|
EAPI int
|
|
|
|
ecore_wl2_window_surface_id_get(Ecore_Wl2_Window *window)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(window, -1);
|
|
|
|
return window->surface_id;
|
|
|
|
}
|
|
|
|
|
2015-09-09 08:19:24 -07:00
|
|
|
EAPI void
|
|
|
|
ecore_wl2_window_show(Ecore_Wl2_Window *window)
|
|
|
|
{
|
|
|
|
Ecore_Wl2_Display *disp;
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(window);
|
|
|
|
|
|
|
|
disp = window->display;
|
|
|
|
|
|
|
|
if (!window->surface)
|
|
|
|
{
|
|
|
|
window->surface =
|
|
|
|
wl_compositor_create_surface(window->display->wl.compositor);
|
|
|
|
}
|
|
|
|
|
2015-10-09 08:56:56 -07:00
|
|
|
if ((window->type == ECORE_WL2_WINDOW_TYPE_DND) ||
|
|
|
|
(window->type == ECORE_WL2_WINDOW_TYPE_NONE))
|
|
|
|
goto type_set;
|
|
|
|
|
2015-09-09 08:19:24 -07:00
|
|
|
if ((disp->wl.xdg_shell) && (!window->xdg_surface))
|
|
|
|
{
|
|
|
|
window->xdg_surface =
|
|
|
|
xdg_shell_get_xdg_surface(disp->wl.xdg_shell, window->surface);
|
|
|
|
if (!window->xdg_surface) goto surf_err;
|
|
|
|
|
|
|
|
if (window->title)
|
|
|
|
xdg_surface_set_title(window->xdg_surface, window->title);
|
|
|
|
if (window->class)
|
|
|
|
xdg_surface_set_app_id(window->xdg_surface, window->class);
|
|
|
|
|
|
|
|
xdg_surface_set_user_data(window->xdg_surface, window);
|
|
|
|
xdg_surface_add_listener(window->xdg_surface,
|
|
|
|
&_xdg_surface_listener, window);
|
|
|
|
}
|
|
|
|
else if ((disp->wl.wl_shell) && (!window->wl_shell_surface))
|
|
|
|
{
|
|
|
|
window->wl_shell_surface =
|
|
|
|
wl_shell_get_shell_surface(disp->wl.wl_shell, window->surface);
|
|
|
|
if (!window->wl_shell_surface) goto surf_err;
|
|
|
|
|
|
|
|
if (window->title)
|
|
|
|
wl_shell_surface_set_title(window->wl_shell_surface, window->title);
|
|
|
|
if (window->class)
|
|
|
|
wl_shell_surface_set_class(window->wl_shell_surface, window->class);
|
|
|
|
|
|
|
|
wl_shell_surface_add_listener(window->wl_shell_surface,
|
|
|
|
&_wl_shell_surface_listener, window);
|
|
|
|
}
|
|
|
|
|
2015-10-09 08:56:56 -07:00
|
|
|
type_set:
|
2015-09-09 08:19:24 -07:00
|
|
|
_ecore_wl2_window_type_set(window);
|
|
|
|
return;
|
|
|
|
|
|
|
|
surf_err:
|
|
|
|
ERR("Failed to create surface for window: %m");
|
|
|
|
}
|
2015-09-09 09:08:26 -07:00
|
|
|
|
|
|
|
EAPI void
|
|
|
|
ecore_wl2_window_hide(Ecore_Wl2_Window *window)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(window);
|
|
|
|
|
|
|
|
if (window->xdg_surface) xdg_surface_destroy(window->xdg_surface);
|
|
|
|
window->xdg_surface = NULL;
|
|
|
|
|
|
|
|
if (window->xdg_popup) xdg_popup_destroy(window->xdg_popup);
|
|
|
|
window->xdg_popup = NULL;
|
|
|
|
|
|
|
|
if (window->wl_shell_surface)
|
|
|
|
wl_shell_surface_destroy(window->wl_shell_surface);
|
|
|
|
window->wl_shell_surface = NULL;
|
|
|
|
|
|
|
|
if (window->surface) wl_surface_destroy(window->surface);
|
|
|
|
window->surface = NULL;
|
|
|
|
}
|
2015-09-09 09:12:53 -07:00
|
|
|
|
|
|
|
EAPI void
|
|
|
|
ecore_wl2_window_free(Ecore_Wl2_Window *window)
|
|
|
|
{
|
2015-09-10 10:21:02 -07:00
|
|
|
Ecore_Wl2_Display *display;
|
2015-09-23 09:25:10 -07:00
|
|
|
Ecore_Wl2_Input *input;
|
2015-10-01 09:22:32 -07:00
|
|
|
Ecore_Wl2_Subsurface *subsurf;
|
|
|
|
Eina_Inlist *tmp;
|
2015-09-10 10:21:02 -07:00
|
|
|
|
2015-09-09 09:12:53 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(window);
|
|
|
|
|
2015-09-10 10:21:02 -07:00
|
|
|
display = window->display;
|
|
|
|
|
2015-09-23 09:25:10 -07:00
|
|
|
EINA_INLIST_FOREACH(display->inputs, input)
|
|
|
|
{
|
|
|
|
if ((input->focus.pointer) &&
|
|
|
|
(input->focus.pointer == window))
|
|
|
|
input->focus.pointer = NULL;
|
|
|
|
if ((input->focus.keyboard) &&
|
|
|
|
(input->focus.keyboard == window))
|
|
|
|
{
|
|
|
|
input->focus.keyboard = NULL;
|
|
|
|
ecore_timer_del(input->repeat.timer);
|
|
|
|
input->repeat.timer = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-01 09:22:32 -07:00
|
|
|
EINA_INLIST_FOREACH_SAFE(window->subsurfs, tmp, subsurf)
|
|
|
|
_ecore_wl2_subsurf_free(subsurf);
|
2015-09-09 09:12:53 -07:00
|
|
|
|
|
|
|
ecore_wl2_window_hide(window);
|
|
|
|
|
|
|
|
if (window->title) eina_stringshare_del(window->title);
|
|
|
|
if (window->class) eina_stringshare_del(window->class);
|
|
|
|
|
2015-09-10 10:21:02 -07:00
|
|
|
display->windows =
|
|
|
|
eina_inlist_remove(display->windows, EINA_INLIST_GET(window));
|
|
|
|
|
2015-09-09 09:12:53 -07:00
|
|
|
free(window);
|
|
|
|
}
|
2015-09-09 09:24:30 -07:00
|
|
|
|
|
|
|
EAPI void
|
2015-11-10 06:37:07 -08:00
|
|
|
ecore_wl2_window_move(Ecore_Wl2_Window *window, int x EINA_UNUSED, int y EINA_UNUSED)
|
2015-09-09 09:24:30 -07:00
|
|
|
{
|
2015-09-24 08:50:36 -07:00
|
|
|
Ecore_Wl2_Input *input;
|
|
|
|
|
2015-09-09 09:24:30 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(window);
|
|
|
|
|
2015-09-24 08:50:36 -07:00
|
|
|
input = window->input;
|
|
|
|
if ((!input) && (window->parent))
|
|
|
|
{
|
|
|
|
input = window->parent->input;
|
|
|
|
}
|
2015-09-09 09:24:30 -07:00
|
|
|
|
2015-09-24 08:50:36 -07:00
|
|
|
if ((!input) || (!input->wl.seat)) return;
|
|
|
|
|
2015-11-09 12:49:18 -08:00
|
|
|
window->moving = EINA_TRUE;
|
2015-09-24 08:50:36 -07:00
|
|
|
|
|
|
|
if (window->xdg_surface)
|
|
|
|
xdg_surface_move(window->xdg_surface, input->wl.seat,
|
|
|
|
window->display->serial);
|
|
|
|
else if (window->wl_shell_surface)
|
|
|
|
wl_shell_surface_move(window->wl_shell_surface, input->wl.seat,
|
|
|
|
window->display->serial);
|
2015-09-09 09:24:30 -07:00
|
|
|
}
|
2015-09-09 09:27:23 -07:00
|
|
|
|
|
|
|
EAPI void
|
2015-11-10 06:37:07 -08:00
|
|
|
ecore_wl2_window_resize(Ecore_Wl2_Window *window, int w EINA_UNUSED, int h EINA_UNUSED, int location)
|
2015-09-09 09:27:23 -07:00
|
|
|
{
|
2015-09-24 08:56:45 -07:00
|
|
|
Ecore_Wl2_Input *input;
|
|
|
|
|
2015-09-09 09:27:23 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(window);
|
|
|
|
|
2015-09-24 08:56:45 -07:00
|
|
|
input = window->input;
|
|
|
|
if ((!input) && (window->parent))
|
|
|
|
{
|
|
|
|
input = window->parent->input;
|
|
|
|
}
|
2015-09-09 09:27:23 -07:00
|
|
|
|
2015-09-24 08:56:45 -07:00
|
|
|
if ((!input) || (!input->wl.seat)) return;
|
|
|
|
|
|
|
|
if (window->xdg_surface)
|
|
|
|
xdg_surface_resize(window->xdg_surface, input->wl.seat,
|
2015-09-30 09:03:50 -07:00
|
|
|
input->display->serial, location);
|
2015-09-24 08:56:45 -07:00
|
|
|
else if (window->wl_shell_surface)
|
|
|
|
wl_shell_surface_resize(window->wl_shell_surface, input->wl.seat,
|
2015-09-30 09:03:50 -07:00
|
|
|
input->display->serial, location);
|
2015-09-09 09:27:23 -07:00
|
|
|
}
|
2015-09-09 10:06:54 -07:00
|
|
|
|
|
|
|
EAPI void
|
|
|
|
ecore_wl2_window_raise(Ecore_Wl2_Window *window)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(window);
|
|
|
|
|
2015-09-28 09:09:32 -07:00
|
|
|
if (window->xdg_surface)
|
|
|
|
{
|
|
|
|
struct wl_array states;
|
|
|
|
uint32_t *s;
|
|
|
|
|
|
|
|
wl_array_init(&states);
|
|
|
|
s = wl_array_add(&states, sizeof(*s));
|
|
|
|
*s = XDG_SURFACE_STATE_ACTIVATED;
|
|
|
|
_xdg_surface_cb_configure(window, window->xdg_surface,
|
|
|
|
window->geometry.w, window->geometry.h,
|
|
|
|
&states, 0);
|
|
|
|
wl_array_release(&states);
|
|
|
|
}
|
|
|
|
else if (window->wl_shell_surface)
|
2015-09-24 08:58:42 -07:00
|
|
|
wl_shell_surface_set_toplevel(window->wl_shell_surface);
|
2015-09-09 10:06:54 -07:00
|
|
|
}
|
2015-09-28 06:12:36 -07:00
|
|
|
|
2015-09-28 06:15:49 -07:00
|
|
|
EAPI Eina_Bool
|
|
|
|
ecore_wl2_window_alpha_get(Ecore_Wl2_Window *window)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(window, EINA_FALSE);
|
|
|
|
|
|
|
|
return window->alpha;
|
|
|
|
}
|
2015-09-28 06:19:21 -07:00
|
|
|
|
|
|
|
EAPI void
|
|
|
|
ecore_wl2_window_alpha_set(Ecore_Wl2_Window *window, Eina_Bool alpha)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(window);
|
|
|
|
|
2015-09-28 06:25:52 -07:00
|
|
|
if (window->alpha == alpha) return;
|
2015-09-28 06:19:21 -07:00
|
|
|
|
2015-09-28 06:25:52 -07:00
|
|
|
window->alpha = alpha;
|
|
|
|
|
|
|
|
if (!window->alpha)
|
|
|
|
ecore_wl2_window_opaque_region_set(window, window->opaque.x,
|
|
|
|
window->opaque.y, window->opaque.w,
|
|
|
|
window->opaque.h);
|
2015-09-28 06:36:34 -07:00
|
|
|
else
|
|
|
|
ecore_wl2_window_opaque_region_set(window, 0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
ecore_wl2_window_transparent_set(Ecore_Wl2_Window *window, Eina_Bool transparent)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(window);
|
|
|
|
|
|
|
|
if (window->transparent == transparent) return;
|
|
|
|
|
|
|
|
window->transparent = transparent;
|
|
|
|
|
|
|
|
if (!window->transparent)
|
|
|
|
ecore_wl2_window_opaque_region_set(window, window->opaque.x,
|
|
|
|
window->opaque.y, window->opaque.w,
|
|
|
|
window->opaque.h);
|
2015-09-28 06:25:52 -07:00
|
|
|
else
|
|
|
|
ecore_wl2_window_opaque_region_set(window, 0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
ecore_wl2_window_opaque_region_set(Ecore_Wl2_Window *window, int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
struct wl_region *region;
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(window);
|
|
|
|
|
|
|
|
window->opaque.x = x;
|
|
|
|
window->opaque.y = y;
|
|
|
|
window->opaque.w = w;
|
|
|
|
window->opaque.h = h;
|
|
|
|
|
2015-09-30 10:02:54 -07:00
|
|
|
if ((window->transparent) || (window->alpha)) return;
|
2015-09-28 06:25:52 -07:00
|
|
|
|
|
|
|
region = wl_compositor_create_region(window->display->wl.compositor);
|
|
|
|
if (!region)
|
|
|
|
{
|
|
|
|
ERR("Failed to create opaque region: %m");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (window->rotation)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
wl_region_add(region, x, y, w, h);
|
|
|
|
break;
|
|
|
|
case 180:
|
|
|
|
wl_region_add(region, x, x + y, w, h);
|
|
|
|
break;
|
|
|
|
case 90:
|
|
|
|
wl_region_add(region, y, x, h, w);
|
|
|
|
break;
|
|
|
|
case 270:
|
|
|
|
wl_region_add(region, x + y, x, h, w);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_surface_set_opaque_region(window->surface, region);
|
|
|
|
wl_region_destroy(region);
|
2015-09-28 06:19:21 -07:00
|
|
|
}
|
2015-09-28 06:39:07 -07:00
|
|
|
|
2015-10-01 07:06:35 -07:00
|
|
|
EAPI void
|
|
|
|
ecore_wl2_window_input_region_set(Ecore_Wl2_Window *window, int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
struct wl_region *region;
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(window);
|
|
|
|
|
2015-10-01 09:22:32 -07:00
|
|
|
window->input_rect.x = x;
|
|
|
|
window->input_rect.y = y;
|
|
|
|
window->input_rect.w = w;
|
|
|
|
window->input_rect.h = h;
|
2015-10-01 07:06:35 -07:00
|
|
|
|
|
|
|
if (window->type == ECORE_WL2_WINDOW_TYPE_DND) return;
|
|
|
|
|
|
|
|
region = wl_compositor_create_region(window->display->wl.compositor);
|
|
|
|
if (!region)
|
|
|
|
{
|
|
|
|
ERR("Failed to create opaque region: %m");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (window->rotation)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
wl_region_add(region, x, y, w, h);
|
|
|
|
break;
|
|
|
|
case 180:
|
|
|
|
wl_region_add(region, x, x + y, w, h);
|
|
|
|
break;
|
|
|
|
case 90:
|
|
|
|
wl_region_add(region, y, x, h, w);
|
|
|
|
break;
|
|
|
|
case 270:
|
|
|
|
wl_region_add(region, x + y, x, h, w);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_surface_set_input_region(window->surface, region);
|
|
|
|
wl_region_destroy(region);
|
|
|
|
}
|
|
|
|
|
2015-09-28 06:39:07 -07:00
|
|
|
EAPI Eina_Bool
|
|
|
|
ecore_wl2_window_maximized_get(Ecore_Wl2_Window *window)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(window, EINA_FALSE);
|
|
|
|
|
|
|
|
if (window->type == ECORE_WL2_WINDOW_TYPE_MAXIMIZED)
|
|
|
|
return EINA_TRUE;
|
|
|
|
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
2015-09-28 06:40:39 -07:00
|
|
|
|
2015-09-28 08:28:23 -07:00
|
|
|
EAPI void
|
|
|
|
ecore_wl2_window_maximized_set(Ecore_Wl2_Window *window, Eina_Bool maximized)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(window);
|
|
|
|
|
|
|
|
if ((window->type == ECORE_WL2_WINDOW_TYPE_MAXIMIZED) == maximized)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (window->type == ECORE_WL2_WINDOW_TYPE_TOPLEVEL)
|
|
|
|
{
|
2015-11-09 08:57:42 -08:00
|
|
|
window->saved = window->geometry;
|
|
|
|
|
2015-09-28 08:28:23 -07:00
|
|
|
if (window->xdg_surface)
|
|
|
|
xdg_surface_set_maximized(window->xdg_surface);
|
|
|
|
else if (window->wl_shell_surface)
|
|
|
|
wl_shell_surface_set_maximized(window->wl_shell_surface, NULL);
|
|
|
|
|
|
|
|
window->type = ECORE_WL2_WINDOW_TYPE_MAXIMIZED;
|
|
|
|
}
|
|
|
|
else if (window->type == ECORE_WL2_WINDOW_TYPE_MAXIMIZED)
|
|
|
|
{
|
|
|
|
if (window->xdg_surface)
|
|
|
|
xdg_surface_unset_maximized(window->xdg_surface);
|
|
|
|
else if (window->wl_shell_surface)
|
|
|
|
wl_shell_surface_set_toplevel(window->wl_shell_surface);
|
|
|
|
|
|
|
|
window->type = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
|
|
|
|
|
2015-11-09 08:57:42 -08:00
|
|
|
_ecore_wl2_window_configure_send(window, window->saved.w,
|
|
|
|
window->saved.h, 0);
|
2015-09-30 09:59:26 -07:00
|
|
|
}
|
2015-09-28 08:28:23 -07:00
|
|
|
}
|
|
|
|
|
2015-09-28 06:40:39 -07:00
|
|
|
EAPI Eina_Bool
|
|
|
|
ecore_wl2_window_fullscreen_get(Ecore_Wl2_Window *window)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(window, EINA_FALSE);
|
|
|
|
|
|
|
|
if (window->type == ECORE_WL2_WINDOW_TYPE_FULLSCREEN)
|
|
|
|
return EINA_TRUE;
|
|
|
|
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
2015-09-28 06:42:21 -07:00
|
|
|
|
2015-09-28 08:31:43 -07:00
|
|
|
EAPI void
|
|
|
|
ecore_wl2_window_fullscreen_set(Ecore_Wl2_Window *window, Eina_Bool fullscreen)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(window);
|
|
|
|
|
|
|
|
if ((window->type == ECORE_WL2_WINDOW_TYPE_FULLSCREEN) == fullscreen)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (fullscreen)
|
|
|
|
{
|
2015-11-09 08:57:42 -08:00
|
|
|
window->saved = window->geometry;
|
|
|
|
|
2015-09-28 08:31:43 -07:00
|
|
|
if (window->xdg_surface)
|
|
|
|
xdg_surface_set_fullscreen(window->xdg_surface, NULL);
|
|
|
|
else if (window->wl_shell_surface)
|
|
|
|
wl_shell_surface_set_fullscreen(window->wl_shell_surface,
|
|
|
|
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
|
|
|
|
0, NULL);
|
|
|
|
|
|
|
|
window->type = ECORE_WL2_WINDOW_TYPE_FULLSCREEN;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (window->xdg_surface)
|
|
|
|
xdg_surface_unset_fullscreen(window->xdg_surface);
|
|
|
|
else if (window->wl_shell_surface)
|
|
|
|
wl_shell_surface_set_toplevel(window->wl_shell_surface);
|
|
|
|
|
|
|
|
window->type = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
|
|
|
|
|
2015-11-09 08:57:42 -08:00
|
|
|
_ecore_wl2_window_configure_send(window, window->saved.w,
|
|
|
|
window->saved.h, 0);
|
2015-09-30 09:59:26 -07:00
|
|
|
}
|
2015-09-28 08:31:43 -07:00
|
|
|
}
|
|
|
|
|
2015-11-10 06:35:25 -08:00
|
|
|
EAPI int
|
|
|
|
ecore_wl2_window_rotation_get(Ecore_Wl2_Window *window)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(window, -1);
|
|
|
|
|
|
|
|
return window->rotation;
|
|
|
|
}
|
|
|
|
|
2015-09-28 06:42:21 -07:00
|
|
|
EAPI void
|
|
|
|
ecore_wl2_window_rotation_set(Ecore_Wl2_Window *window, int rotation)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(window);
|
|
|
|
|
|
|
|
window->rotation = rotation;
|
|
|
|
}
|
2015-09-28 06:47:59 -07:00
|
|
|
|
|
|
|
EAPI void
|
|
|
|
ecore_wl2_window_title_set(Ecore_Wl2_Window *window, const char *title)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(window);
|
|
|
|
|
|
|
|
eina_stringshare_replace(&window->title, title);
|
|
|
|
if (!window->title) return;
|
|
|
|
|
|
|
|
if (window->xdg_surface)
|
|
|
|
xdg_surface_set_title(window->xdg_surface, window->title);
|
|
|
|
else if (window->wl_shell_surface)
|
|
|
|
wl_shell_surface_set_title(window->wl_shell_surface, window->title);
|
|
|
|
}
|
2015-09-28 06:51:00 -07:00
|
|
|
|
|
|
|
EAPI void
|
2015-11-10 06:50:19 -08:00
|
|
|
ecore_wl2_window_class_set(Ecore_Wl2_Window *window, const char *clas)
|
2015-09-28 06:51:00 -07:00
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(window);
|
|
|
|
|
2015-11-10 06:50:19 -08:00
|
|
|
eina_stringshare_replace(&window->class, clas);
|
2015-09-28 06:51:00 -07:00
|
|
|
if (!window->class) return;
|
|
|
|
|
|
|
|
if (window->xdg_surface)
|
|
|
|
xdg_surface_set_app_id(window->xdg_surface, window->class);
|
|
|
|
else if (window->wl_shell_surface)
|
|
|
|
wl_shell_surface_set_class(window->wl_shell_surface, window->class);
|
|
|
|
}
|
2015-09-28 08:16:03 -07:00
|
|
|
|
|
|
|
EAPI void
|
|
|
|
ecore_wl2_window_geometry_get(Ecore_Wl2_Window *window, int *x, int *y, int *w, int *h)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(window);
|
|
|
|
|
|
|
|
if (x) *x = window->geometry.x;
|
|
|
|
if (y) *y = window->geometry.y;
|
|
|
|
if (w) *w = window->geometry.w;
|
|
|
|
if (h) *h = window->geometry.h;
|
|
|
|
}
|
2015-09-28 08:18:23 -07:00
|
|
|
|
|
|
|
EAPI void
|
|
|
|
ecore_wl2_window_geometry_set(Ecore_Wl2_Window *window, int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(window);
|
|
|
|
|
|
|
|
if ((window->geometry.x == x) && (window->geometry.y == y) &&
|
|
|
|
(window->geometry.w == w) && (window->geometry.h == h))
|
|
|
|
return;
|
|
|
|
|
|
|
|
window->geometry.x = x;
|
|
|
|
window->geometry.y = y;
|
|
|
|
window->geometry.w = w;
|
|
|
|
window->geometry.h = h;
|
|
|
|
|
|
|
|
if (window->xdg_surface)
|
|
|
|
xdg_surface_set_window_geometry(window->xdg_surface, x, y, w, h);
|
|
|
|
}
|
2015-09-28 08:37:11 -07:00
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
ecore_wl2_window_iconified_get(Ecore_Wl2_Window *window)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(window, EINA_FALSE);
|
|
|
|
|
|
|
|
return window->minimized;
|
|
|
|
}
|
2015-09-28 08:43:20 -07:00
|
|
|
|
|
|
|
EAPI void
|
|
|
|
ecore_wl2_window_iconified_set(Ecore_Wl2_Window *window, Eina_Bool iconified)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(window);
|
|
|
|
|
|
|
|
if (window->minimized == iconified) return;
|
|
|
|
|
|
|
|
if (iconified)
|
|
|
|
{
|
|
|
|
if (window->xdg_surface)
|
|
|
|
xdg_surface_set_minimized(window->xdg_surface);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (window->xdg_surface)
|
|
|
|
{
|
|
|
|
struct wl_array states;
|
|
|
|
uint32_t *s;
|
|
|
|
|
|
|
|
wl_array_init(&states);
|
|
|
|
s = wl_array_add(&states, sizeof(*s));
|
|
|
|
*s = XDG_SURFACE_STATE_ACTIVATED;
|
|
|
|
_xdg_surface_cb_configure(window, window->xdg_surface,
|
|
|
|
window->geometry.w, window->geometry.h,
|
|
|
|
&states, 0);
|
|
|
|
wl_array_release(&states);
|
|
|
|
}
|
|
|
|
|
|
|
|
window->type = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
|
|
|
|
}
|
|
|
|
|
|
|
|
window->minimized = iconified;
|
|
|
|
}
|
2015-09-28 09:07:39 -07:00
|
|
|
|
|
|
|
EAPI void
|
|
|
|
ecore_wl2_window_pointer_xy_get(Ecore_Wl2_Window *window, int *x, int *y)
|
|
|
|
{
|
2015-11-09 12:49:18 -08:00
|
|
|
Ecore_Wl2_Input *input;
|
|
|
|
|
2015-09-28 09:07:39 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(window);
|
|
|
|
|
|
|
|
if (x) *x = 0;
|
|
|
|
if (y) *y = 0;
|
|
|
|
|
2015-11-09 12:49:18 -08:00
|
|
|
input = ecore_wl2_window_input_get(window);
|
|
|
|
if (!input) return;
|
2015-09-28 09:07:39 -07:00
|
|
|
|
2015-11-09 12:49:18 -08:00
|
|
|
if (x) *x = input->pointer.sx;
|
|
|
|
if (y) *y = input->pointer.sy;
|
2015-09-28 09:07:39 -07:00
|
|
|
}
|
2015-09-28 09:15:51 -07:00
|
|
|
|
|
|
|
EAPI void
|
|
|
|
ecore_wl2_window_pointer_set(Ecore_Wl2_Window *window, struct wl_surface *surface, int hot_x, int hot_y)
|
|
|
|
{
|
2015-11-09 12:49:18 -08:00
|
|
|
Ecore_Wl2_Input *input;
|
|
|
|
|
2015-09-28 09:15:51 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(window);
|
2015-09-30 07:28:17 -07:00
|
|
|
|
2015-11-09 12:49:18 -08:00
|
|
|
input = ecore_wl2_window_input_get(window);
|
|
|
|
if (!input) return;
|
2015-09-28 09:15:51 -07:00
|
|
|
|
2015-11-09 12:49:18 -08:00
|
|
|
_ecore_wl2_input_cursor_update_stop(input);
|
2015-09-30 09:41:50 -07:00
|
|
|
|
2015-11-09 12:49:18 -08:00
|
|
|
if (input->wl.pointer)
|
|
|
|
wl_pointer_set_cursor(input->wl.pointer,
|
|
|
|
input->pointer.enter_serial,
|
2015-09-28 09:15:51 -07:00
|
|
|
surface, hot_x, hot_y);
|
|
|
|
}
|
2015-09-29 07:54:13 -07:00
|
|
|
|
|
|
|
EAPI void
|
|
|
|
ecore_wl2_window_cursor_from_name_set(Ecore_Wl2_Window *window, const char *cursor)
|
|
|
|
{
|
2015-11-09 12:49:18 -08:00
|
|
|
Ecore_Wl2_Input *input;
|
|
|
|
|
2015-09-29 07:54:13 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(window);
|
|
|
|
|
|
|
|
eina_stringshare_replace(&window->cursor, cursor);
|
|
|
|
|
2015-11-09 12:49:18 -08:00
|
|
|
input = ecore_wl2_window_input_get(window);
|
|
|
|
if (!input) return;
|
2015-09-30 09:41:50 -07:00
|
|
|
|
2015-11-09 12:49:18 -08:00
|
|
|
_ecore_wl2_input_cursor_update_stop(input);
|
|
|
|
_ecore_wl2_input_cursor_set(input, cursor);
|
2015-09-29 07:54:13 -07:00
|
|
|
}
|
2015-09-29 08:17:33 -07:00
|
|
|
|
|
|
|
EAPI void
|
|
|
|
ecore_wl2_window_type_set(Ecore_Wl2_Window *window, Ecore_Wl2_Window_Type type)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(window);
|
|
|
|
window->type = type;
|
|
|
|
}
|
2015-09-29 08:19:54 -07:00
|
|
|
|
|
|
|
EAPI Ecore_Wl2_Input *
|
|
|
|
ecore_wl2_window_input_get(Ecore_Wl2_Window *window)
|
|
|
|
{
|
2015-10-09 08:56:56 -07:00
|
|
|
Ecore_Wl2_Input *input;
|
|
|
|
|
2015-09-29 08:19:54 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(window, NULL);
|
2015-10-09 08:56:56 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(window->display, NULL);
|
2015-09-29 08:19:54 -07:00
|
|
|
|
2015-10-09 08:56:56 -07:00
|
|
|
if (window->input) return window->input;
|
|
|
|
|
|
|
|
EINA_INLIST_FOREACH(window->display->inputs, input)
|
|
|
|
{
|
|
|
|
if (input->focus.pointer) return input;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
2015-09-29 08:19:54 -07:00
|
|
|
}
|