2014-08-04 09:58:49 -07:00
|
|
|
#define E_COMP_WL
|
2014-05-09 02:56:05 -07:00
|
|
|
#include "e.h"
|
2015-08-20 11:55:14 -07:00
|
|
|
#include "e_mod_main.h"
|
2014-05-09 02:56:05 -07:00
|
|
|
|
2016-10-10 08:30:52 -07:00
|
|
|
EINTERN Eina_Hash *shell_resources;
|
|
|
|
EINTERN Eina_Hash *xdg_shell_resources;
|
2017-03-10 12:57:15 -08:00
|
|
|
EINTERN Eina_List *hooks;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
2016-10-10 08:30:52 -07:00
|
|
|
EINTERN void
|
|
|
|
e_shell_surface_destroy(struct wl_resource *resource)
|
2016-04-05 12:05:10 -07:00
|
|
|
{
|
2016-10-10 08:30:52 -07:00
|
|
|
E_Client *ec;
|
|
|
|
E_Shell_Data *shd;
|
2016-04-05 12:05:10 -07:00
|
|
|
|
2016-10-10 08:30:52 -07:00
|
|
|
/* DBG("Shell Surface Destroy: %d", wl_resource_get_id(resource)); */
|
|
|
|
|
|
|
|
/* get the client for this resource */
|
|
|
|
ec = wl_resource_get_user_data(resource);
|
|
|
|
if (!ec) return;
|
2017-03-22 13:15:15 -07:00
|
|
|
wl_resource_set_user_data(resource, NULL);
|
2016-12-01 09:11:38 -08:00
|
|
|
/* client may be passed here during DEL hook */
|
|
|
|
if (!ec->comp_data) return;
|
2016-10-10 08:30:52 -07:00
|
|
|
|
2016-11-11 09:28:49 -08:00
|
|
|
if (ec->comp_data->grab)
|
|
|
|
{
|
|
|
|
e_comp_wl_grab_client_del(ec, 0);
|
|
|
|
ec->comp_data->grab = 0;
|
|
|
|
}
|
|
|
|
|
2016-10-10 08:30:52 -07:00
|
|
|
|
2016-11-29 08:08:46 -08:00
|
|
|
if (resource == ec->comp_data->shell.surface)
|
|
|
|
ec->comp_data->shell.surface = NULL;
|
|
|
|
shd = ec->comp_data->shell.data;
|
2016-10-10 08:30:52 -07:00
|
|
|
if (shd)
|
|
|
|
{
|
|
|
|
E_FREE_LIST(shd->pending, free);
|
2016-12-01 09:13:57 -08:00
|
|
|
if ((resource == shd->surface) || (!shd->surface))
|
2016-11-29 08:08:46 -08:00
|
|
|
E_FREE(ec->comp_data->shell.data);
|
2016-10-10 08:30:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ec->comp_data->mapped)
|
|
|
|
{
|
|
|
|
if ((ec->comp_data->shell.surface) &&
|
|
|
|
(ec->comp_data->shell.unmap))
|
|
|
|
ec->comp_data->shell.unmap(ec->comp_data->shell.surface);
|
|
|
|
}
|
|
|
|
if (ec->parent)
|
|
|
|
{
|
|
|
|
ec->parent->transients =
|
|
|
|
eina_list_remove(ec->parent->transients, ec);
|
|
|
|
}
|
2016-11-11 09:28:49 -08:00
|
|
|
|
|
|
|
e_object_unref(E_OBJECT(ec));
|
2016-10-10 08:30:52 -07:00
|
|
|
}
|
2016-04-05 12:05:10 -07:00
|
|
|
|
2016-10-10 08:30:52 -07:00
|
|
|
EINTERN void
|
|
|
|
e_shell_surface_cb_destroy(struct wl_resource *resource)
|
2015-12-10 10:24:55 -08:00
|
|
|
{
|
2016-10-10 08:30:52 -07:00
|
|
|
/* DBG("Shell Surface Destroy: %d", wl_resource_get_id(resource)); */
|
2015-12-10 10:24:55 -08:00
|
|
|
|
2016-10-10 08:30:52 -07:00
|
|
|
e_shell_surface_destroy(resource);
|
|
|
|
}
|
2016-04-18 12:37:22 -07:00
|
|
|
|
2016-10-10 08:30:52 -07:00
|
|
|
EINTERN void
|
|
|
|
e_shell_surface_parent_set(E_Client *ec, struct wl_resource *parent_resource)
|
2014-06-19 11:55:53 -07:00
|
|
|
{
|
|
|
|
E_Client *pc;
|
2014-07-21 08:10:16 -07:00
|
|
|
uint64_t pwin = 0;
|
2014-06-19 11:55:53 -07:00
|
|
|
|
2014-07-24 11:34:36 -07:00
|
|
|
if (!parent_resource)
|
|
|
|
{
|
|
|
|
ec->icccm.fetch.transient_for = EINA_FALSE;
|
|
|
|
ec->icccm.transient_for = 0;
|
2014-07-26 07:13:02 -07:00
|
|
|
if (ec->parent)
|
|
|
|
{
|
|
|
|
ec->parent->transients =
|
|
|
|
eina_list_remove(ec->parent->transients, ec);
|
|
|
|
if (ec->parent->modal == ec) ec->parent->modal = NULL;
|
|
|
|
ec->parent = NULL;
|
|
|
|
}
|
2014-07-24 11:34:36 -07:00
|
|
|
return;
|
|
|
|
}
|
2015-06-25 09:05:05 -07:00
|
|
|
|
|
|
|
pc = wl_resource_get_user_data(parent_resource);
|
|
|
|
if (!pc)
|
2014-06-19 11:55:53 -07:00
|
|
|
{
|
2015-04-22 11:54:49 -07:00
|
|
|
ERR("Could not get parent resource client");
|
2014-06-19 11:55:53 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-04-22 11:54:49 -07:00
|
|
|
pwin = e_pixmap_window_get(pc->pixmap);
|
2014-06-19 11:55:53 -07:00
|
|
|
|
|
|
|
e_pixmap_parent_window_set(ec->pixmap, pwin);
|
2017-04-07 13:07:25 -07:00
|
|
|
e_client_parent_set(ec, pc);
|
2014-07-11 06:15:22 -07:00
|
|
|
|
2014-06-19 11:55:53 -07:00
|
|
|
ec->icccm.fetch.transient_for = EINA_TRUE;
|
|
|
|
ec->icccm.transient_for = pwin;
|
|
|
|
}
|
|
|
|
|
2016-10-10 08:30:52 -07:00
|
|
|
EINTERN void
|
|
|
|
e_shell_surface_mouse_down_helper(E_Client *ec, E_Binding_Event_Mouse_Button *ev, Eina_Bool move)
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
|
|
|
if (move)
|
|
|
|
{
|
|
|
|
/* tell E to start moving the client */
|
|
|
|
e_client_act_move_begin(ec, ev);
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
/* we have to get a reference to the window_move action here, or else
|
2014-05-09 02:56:05 -07:00
|
|
|
* when e_client stops the move we will never get notified */
|
|
|
|
ec->cur_mouse_action = e_action_find("window_move");
|
|
|
|
if (ec->cur_mouse_action)
|
|
|
|
e_object_ref(E_OBJECT(ec->cur_mouse_action));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* tell E to start resizing the client */
|
|
|
|
e_client_act_resize_begin(ec, ev);
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
/* we have to get a reference to the window_resize action here,
|
2014-05-09 02:56:05 -07:00
|
|
|
* or else when e_client stops the resize we will never get notified */
|
|
|
|
ec->cur_mouse_action = e_action_find("window_resize");
|
|
|
|
if (ec->cur_mouse_action)
|
|
|
|
e_object_ref(E_OBJECT(ec->cur_mouse_action));
|
|
|
|
}
|
|
|
|
|
|
|
|
e_focus_event_mouse_down(ec);
|
|
|
|
}
|
|
|
|
|
2016-12-01 09:11:38 -08:00
|
|
|
EINTERN E_Shell_Data *
|
|
|
|
e_shell_data_new(unsigned int version)
|
|
|
|
{
|
|
|
|
E_Shell_Data *shd;
|
|
|
|
|
|
|
|
shd = E_NEW(E_Shell_Data, 1);
|
|
|
|
shd->version = version;
|
|
|
|
return shd;
|
|
|
|
}
|
|
|
|
|
2017-10-06 08:37:50 -07:00
|
|
|
static Eina_Bool
|
|
|
|
desktop_xwayland_startup()
|
|
|
|
{
|
|
|
|
e_startup();
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
desktop_startup()
|
|
|
|
{
|
|
|
|
if (e_module_find("xwayland"))
|
|
|
|
ecore_event_handler_add(E_EVENT_COMPOSITOR_XWAYLAND_INIT, desktop_xwayland_startup, NULL);
|
|
|
|
else
|
|
|
|
e_startup();
|
|
|
|
}
|
|
|
|
|
2016-10-10 08:30:52 -07:00
|
|
|
E_API E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Wl_Desktop_Shell" };
|
2014-05-09 02:56:05 -07:00
|
|
|
|
2016-10-10 08:30:52 -07:00
|
|
|
E_API void *
|
|
|
|
e_modapi_init(E_Module *m)
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
2016-11-11 09:28:49 -08:00
|
|
|
Eina_Bool have_shell;
|
|
|
|
|
2017-02-28 08:36:23 -08:00
|
|
|
/* try to create global shell interface */
|
|
|
|
if (!wl_global_create(e_comp_wl->wl.disp, &wl_shell_interface, 1,
|
|
|
|
NULL, wl_shell_cb_bind))
|
2015-01-28 14:29:17 -08:00
|
|
|
{
|
2017-02-28 08:36:23 -08:00
|
|
|
ERR("Could not create shell global");
|
|
|
|
return NULL;
|
2015-01-28 14:29:17 -08:00
|
|
|
}
|
2014-05-09 02:56:05 -07:00
|
|
|
|
2018-01-08 09:03:03 -08:00
|
|
|
have_shell = e_xdg_shell_v5_init() | e_xdg_shell_v6_init() | e_xdg_shell_init();
|
2017-02-28 08:36:23 -08:00
|
|
|
if (!have_shell) return NULL;
|
|
|
|
|
2015-08-20 11:55:14 -07:00
|
|
|
#ifdef HAVE_WL_TEXT_INPUT
|
|
|
|
if (!e_input_panel_init())
|
|
|
|
{
|
|
|
|
ERR("Could not init input panel");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#endif
|
2017-10-06 08:37:50 -07:00
|
|
|
ecore_job_add(desktop_startup, NULL);
|
2016-04-18 12:27:47 -07:00
|
|
|
|
2016-04-18 12:37:22 -07:00
|
|
|
shell_resources = eina_hash_pointer_new(NULL);
|
|
|
|
xdg_shell_resources = eina_hash_pointer_new(NULL);
|
2015-08-20 11:55:14 -07:00
|
|
|
|
2014-05-09 02:56:05 -07:00
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
2015-05-07 12:13:10 -07:00
|
|
|
E_API int
|
2014-05-09 02:56:05 -07:00
|
|
|
e_modapi_shutdown(E_Module *m EINA_UNUSED)
|
|
|
|
{
|
2015-08-20 11:55:14 -07:00
|
|
|
e_input_panel_shutdown();
|
2016-04-18 12:37:22 -07:00
|
|
|
eina_hash_free(shell_resources);
|
|
|
|
eina_hash_free(xdg_shell_resources);
|
2017-03-10 12:57:15 -08:00
|
|
|
E_FREE_LIST(hooks, e_client_hook_del);
|
2014-05-09 02:56:05 -07:00
|
|
|
return 1;
|
|
|
|
}
|