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;
|
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;
|
|
|
|
if (!e_object_unref(E_OBJECT(ec))) return;
|
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
|
|
|
|
|
|
|
shd = ec->comp_data->shell.data;
|
|
|
|
|
|
|
|
if (shd)
|
|
|
|
{
|
|
|
|
E_FREE_LIST(shd->pending, free);
|
|
|
|
E_FREE(ec->comp_data->shell.data);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
/* wl_resource_destroy(ec->comp_data->shell.surface); */
|
|
|
|
ec->comp_data->shell.surface = NULL;
|
|
|
|
}
|
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);
|
|
|
|
|
2014-07-11 06:15:22 -07:00
|
|
|
/* If we already have a parent, remove it */
|
|
|
|
if (ec->parent)
|
|
|
|
{
|
|
|
|
if (pc != ec->parent)
|
|
|
|
{
|
|
|
|
ec->parent->transients =
|
|
|
|
eina_list_remove(ec->parent->transients, ec);
|
|
|
|
if (ec->parent->modal == ec) ec->parent->modal = NULL;
|
|
|
|
ec->parent = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-22 11:54:49 -07:00
|
|
|
if ((pc != ec) &&
|
2014-07-11 06:15:22 -07:00
|
|
|
(eina_list_data_find(pc->transients, ec) != ec))
|
|
|
|
{
|
|
|
|
pc->transients = eina_list_append(pc->transients, ec);
|
|
|
|
ec->parent = pc;
|
2016-03-31 11:05:47 -07:00
|
|
|
evas_object_layer_set(ec->frame, evas_object_layer_get(pc->frame));
|
|
|
|
evas_object_stack_above(ec->frame, pc->frame);
|
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-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-10-10 08:30:52 -07: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
|
|
|
{
|
2016-10-10 08:30:52 -07: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
|
|
|
|
2016-10-10 08:30:52 -07:00
|
|
|
if (!e_xdg_shell_init()) return NULL;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
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
|
2016-04-18 12:27:47 -07:00
|
|
|
e_startup();
|
|
|
|
|
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);
|
2015-08-20 11:55:14 -07:00
|
|
|
|
2014-05-09 02:56:05 -07:00
|
|
|
return 1;
|
|
|
|
}
|