struct _E_Desktop_Shell
{
+ struct wl_display *display;
struct wl_global *wl_shell;
struct wl_global *xdg_shell_v5;
+ E_Desktop_Xdg_Shell_V6 *xdg_shell_v6;
E_Comp_Wl_Shell *e_comp_wl_shell;
struct wl_listener display_destroy;
} events;
};
+static void _shell_destroy(E_Desktop_Shell *shell);
+
static void
_shell_cb_display_destroy(struct wl_listener *listener, void *data)
{
E_Desktop_Shell *shell = wl_container_of(listener, shell, display_destroy);
wl_signal_emit(&shell->events.destroy, shell);
+ _shell_destroy(shell);
+}
+
+static E_Desktop_Shell *
+_shell_create(struct wl_display *display)
+{
+ E_Desktop_Shell *shell;
+
+ shell = calloc(1, sizeof(*shell));
+ if (!shell)
+ return NULL;
+
+ wl_signal_init(&shell->events.destroy);
+ wl_signal_init(&shell->events.new_toplevel);
+
+ shell->display = display;
+
+ shell->display_destroy.notify = _shell_cb_display_destroy;
+ wl_display_add_destroy_listener(display, &shell->display_destroy);
+
+ return shell;
+}
+
+static void
+_shell_destroy(E_Desktop_Shell *shell)
+{
+ if (shell->e_comp_wl_shell)
+ e_comp_wl_shell_destroy(shell->e_comp_wl_shell);
+
+ if (shell->xdg_shell_v6)
+ e_desktop_shell_xdg_shell_v6_destroy(shell->xdg_shell_v6);
+
+ if (shell->xdg_shell_v5)
+ wl_global_destroy(shell->xdg_shell_v5);
+
+ if (shell->wl_shell)
+ wl_global_destroy(shell->wl_shell);
- e_comp_wl_shell_destroy(shell->e_comp_wl_shell);
- wl_global_destroy(shell->wl_shell);
- wl_global_destroy(shell->xdg_shell_v5);
wl_list_remove(&shell->display_destroy.link);
free(shell);
}
{
E_Desktop_Shell *shell;
- shell = calloc(1, sizeof(*shell));
+ shell = _shell_create(display);
if (!shell)
return NULL;
- wl_signal_init(&shell->events.destroy);
- wl_signal_init(&shell->events.new_toplevel);
-
shell->wl_shell = e_desktop_wl_shell_create(display);
if (!shell->wl_shell)
- goto err_wl_shell;
+ goto err;
shell->xdg_shell_v5 = e_desktop_xdg_shell_v5_create(display);
if (!shell->xdg_shell_v5)
- goto err_xdg_shell_v5;
+ goto err;
- if (!e_desktop_xdg_shell_v6_init(display, shell))
- goto err_xdg_shell_v6;
+ shell->xdg_shell_v6 = e_desktop_xdg_shell_v6_create(shell);
+ if (!shell->xdg_shell_v6)
+ goto err;
shell->e_comp_wl_shell = e_comp_wl_shell_create(shell);
if (!shell->e_comp_wl_shell)
- goto err_xdg_shell_v6;
-
- shell->display_destroy.notify = _shell_cb_display_destroy;
- wl_display_add_destroy_listener(display, &shell->display_destroy);
+ goto err;
return shell;
-
-err_xdg_shell_v6:
- wl_global_destroy(shell->xdg_shell_v5);
-err_xdg_shell_v5:
- wl_global_destroy(shell->wl_shell);
-err_wl_shell:
- free(shell);
+err:
+ _shell_destroy(shell);
return NULL;
}
+EINTERN struct wl_display *
+e_desktop_shell_display_get(E_Desktop_Shell *shell)
+{
+ return shell->display;
+}
+
EINTERN void
e_desktop_shell_toplevel_add(E_Desktop_Shell *shell, E_Desktop_Toplevel *toplevel)
{
E_Desktop_Surface surface;
};
+struct wl_display *e_desktop_shell_display_get(E_Desktop_Shell *shell);
void e_desktop_shell_toplevel_add(E_Desktop_Shell *shell, E_Desktop_Toplevel *toplevel);
void e_desktop_toplevel_init(E_Desktop_Toplevel *toplevel, E_Desktop_Surface_Interface *iface, E_Surface *e_surface, struct wl_resource *shell_surface_resource);
#define LOG(f, x...) INF("XDG6 <LOG> " f, ##x)
-typedef struct _E_Desktop_Xdg_Shell_V6 E_Desktop_Xdg_Shell_V6;
-
struct _E_Desktop_Xdg_Shell_V6
{
E_Desktop_Shell *desktop_shell;
struct wl_listener surface_commit;
} E_Desktop_Xdg_Toplevel_V6;
-static void _shell_cb_destroy(struct wl_listener *listener, void *data);
static void _shell_cb_new_surface(struct wl_listener *listener, void *data);
static void _toplevel_add(E_Desktop_Xdg_Shell_V6 *shell, struct ds_xdg_surface_v6 *ds_xdg_surface);
static void _toplevel_cb_xdg_surface_destroy(struct wl_listener *listener, void *data);
static E_Desktop_Xdg_Toplevel_V6 *_toplevel_from_shell_surface_resource(struct wl_resource *shsurface_resource);
-EINTERN Eina_Bool
-e_desktop_xdg_shell_v6_init(struct wl_display *display, E_Desktop_Shell *desktop_shell)
+EINTERN E_Desktop_Xdg_Shell_V6 *
+e_desktop_xdg_shell_v6_create(E_Desktop_Shell *desktop_shell)
{
- static E_Desktop_Xdg_Shell_V6 shell = { .ds_xdg_shell = NULL };
-
- LOG("Initializing Xdg_Shell_V6");
-
- if (shell.ds_xdg_shell)
- {
- LOG("Xdg_Shell_V6 already initialized");
- return EINA_TRUE;
- }
+ E_Desktop_Xdg_Shell_V6 *shell;
+ shell = calloc(1, sizeof(*shell));
+ if (!shell)
+ return NULL;
- shell.ds_xdg_shell = ds_xdg_shell_v6_create(display);
- if (!shell.ds_xdg_shell)
+ shell->ds_xdg_shell = ds_xdg_shell_v6_create(e_desktop_shell_display_get(desktop_shell));
+ if (!shell->ds_xdg_shell)
{
ERR("Could not create ds_xdg_shell_v6");
- return EINA_FALSE;
+ free(shell);
+ return NULL;
}
- shell.desktop_shell = desktop_shell;
+ shell->desktop_shell = desktop_shell;
+
+ shell->new_surface.notify = _shell_cb_new_surface;
+ ds_xdg_shell_v6_add_new_surface_listener(shell->ds_xdg_shell, &shell->new_surface);
- shell.destroy.notify = _shell_cb_destroy;
- ds_xdg_shell_v6_add_destroy_listener(shell.ds_xdg_shell, &shell.destroy);
- shell.new_surface.notify = _shell_cb_new_surface;
- ds_xdg_shell_v6_add_new_surface_listener(shell.ds_xdg_shell, &shell.new_surface);
+ LOG("Create Xdg_Shell_V6");
- return EINA_TRUE;
+ return shell;
}
-static void
-_shell_cb_destroy(struct wl_listener *listener, void *data)
+EINTERN void
+e_desktop_shell_xdg_shell_v6_destroy(E_Desktop_Xdg_Shell_V6 *shell)
{
- E_Desktop_Xdg_Shell_V6 *shell;
-
LOG("Destroy Xdg_Shell_V6");
- shell = wl_container_of(listener, shell, destroy);
- wl_list_remove(&shell->destroy.link);
wl_list_remove(&shell->new_surface.link);
- shell->ds_xdg_shell = NULL;
+ free(shell);
}
static void
#include "e_intern.h"
#include "e_desktop_shell_intern.h"
+typedef struct _E_Desktop_Xdg_Shell_V6 E_Desktop_Xdg_Shell_V6;
-EINTERN Eina_Bool e_desktop_xdg_shell_v6_init(struct wl_display *display, E_Desktop_Shell *desktop_shell);
+E_Desktop_Xdg_Shell_V6 *e_desktop_xdg_shell_v6_create(E_Desktop_Shell *desktop_shell);
+void e_desktop_shell_xdg_shell_v6_destroy(E_Desktop_Xdg_Shell_V6 *shell);
#endif