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"
|
2016-09-23 13:14:37 -07:00
|
|
|
#include "xdg-shell-unstable-v5-server-protocol.h"
|
2014-05-09 02:56:05 -07:00
|
|
|
|
2015-06-08 09:23:40 -07:00
|
|
|
#define XDG_SERVER_VERSION 5
|
2014-05-09 02:56:05 -07:00
|
|
|
|
2016-04-05 12:05:10 -07:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
STATE_MAXIMIZED = (1 << 0),
|
|
|
|
STATE_UNMAXIMIZED = (1 << 1),
|
|
|
|
STATE_FULLSCREEN = (1 << 2),
|
|
|
|
STATE_UNFULLSCREEN = (1 << 3),
|
|
|
|
} State;
|
|
|
|
|
|
|
|
typedef struct Pending_State
|
|
|
|
{
|
|
|
|
State state;
|
|
|
|
uint32_t serial;
|
|
|
|
} Pending_State;
|
|
|
|
|
2015-12-10 10:24:55 -08:00
|
|
|
struct E_Shell_Data
|
|
|
|
{
|
|
|
|
uint32_t edges;
|
2015-12-15 07:20:33 -08:00
|
|
|
int32_t width;
|
|
|
|
int32_t height;
|
2016-04-05 12:05:10 -07:00
|
|
|
Eina_List *pending;
|
2015-12-10 10:24:55 -08:00
|
|
|
Eina_Bool fullscreen : 1;
|
|
|
|
Eina_Bool maximized : 1;
|
|
|
|
Eina_Bool activated : 1;
|
|
|
|
};
|
|
|
|
|
2016-04-18 12:37:22 -07:00
|
|
|
static Eina_Hash *shell_resources;
|
|
|
|
static Eina_Hash *xdg_shell_resources;
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-06-23 06:45:16 -07:00
|
|
|
_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;
|
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-05-09 02:56:05 -07:00
|
|
|
_e_shell_surface_mouse_down_helper(E_Client *ec, E_Binding_Event_Mouse_Button *ev, Eina_Bool move)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2014-09-08 05:14:38 -07:00
|
|
|
static void
|
|
|
|
_e_shell_surface_destroy(struct wl_resource *resource)
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
|
|
|
E_Client *ec;
|
|
|
|
|
2014-08-03 07:34:38 -07:00
|
|
|
/* DBG("Shell Surface Destroy: %d", wl_resource_get_id(resource)); */
|
2014-05-09 02:56:05 -07:00
|
|
|
|
|
|
|
/* get the client for this resource */
|
|
|
|
if ((ec = wl_resource_get_user_data(resource)))
|
|
|
|
{
|
2015-11-20 11:59:53 -08:00
|
|
|
if (!e_object_unref(E_OBJECT(ec))) return;
|
2014-06-23 09:57:19 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
|
|
|
|
2015-03-13 17:09:54 -07:00
|
|
|
if (ec->comp_data)
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
2016-04-05 12:05:10 -07:00
|
|
|
E_Shell_Data *shd = ec->comp_data->shell.data;
|
|
|
|
|
2016-06-15 13:19:32 -07:00
|
|
|
if (shd)
|
|
|
|
{
|
|
|
|
E_FREE_LIST(shd->pending, free);
|
|
|
|
E_FREE(ec->comp_data->shell.data);
|
|
|
|
}
|
|
|
|
|
2015-03-13 17:09:54 -07:00
|
|
|
if (ec->comp_data->mapped)
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
2015-03-13 17:09:54 -07:00
|
|
|
if ((ec->comp_data->shell.surface) &&
|
|
|
|
(ec->comp_data->shell.unmap))
|
|
|
|
ec->comp_data->shell.unmap(ec->comp_data->shell.surface);
|
2014-05-09 02:56:05 -07:00
|
|
|
}
|
2014-09-08 05:14:38 -07:00
|
|
|
if (ec->parent)
|
|
|
|
{
|
|
|
|
ec->parent->transients =
|
|
|
|
eina_list_remove(ec->parent->transients, ec);
|
|
|
|
}
|
2015-03-13 17:09:54 -07:00
|
|
|
/* wl_resource_destroy(ec->comp_data->shell.surface); */
|
|
|
|
ec->comp_data->shell.surface = NULL;
|
2014-05-09 02:56:05 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-08 05:14:38 -07:00
|
|
|
static void
|
|
|
|
_e_shell_surface_cb_destroy(struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
/* DBG("Shell Surface Destroy: %d", wl_resource_get_id(resource)); */
|
|
|
|
|
|
|
|
_e_shell_surface_destroy(resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-05-09 02:56:05 -07:00
|
|
|
_e_shell_surface_cb_pong(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t serial EINA_UNUSED)
|
|
|
|
{
|
|
|
|
E_Client *ec;
|
|
|
|
|
|
|
|
if ((ec = wl_resource_get_user_data(resource)))
|
2014-10-29 07:38:06 -07:00
|
|
|
{
|
|
|
|
ec->ping_ok = EINA_TRUE;
|
|
|
|
ec->hung = EINA_FALSE;
|
|
|
|
}
|
2014-05-09 02:56:05 -07:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2015-05-18 06:08:52 -07:00
|
|
|
_e_shell_surface_cb_move(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, struct wl_resource *seat_resource EINA_UNUSED, uint32_t serial EINA_UNUSED)
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
2014-06-05 09:39:27 -07:00
|
|
|
E_Client *ec;
|
|
|
|
E_Binding_Event_Mouse_Button ev;
|
|
|
|
|
|
|
|
/* get the client for this resource */
|
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2014-06-05 09:39:27 -07:00
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2014-06-05 09:39:27 -07:00
|
|
|
|
|
|
|
if ((ec->maximized) || (ec->fullscreen)) return;
|
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
switch (e_comp_wl->ptr.button)
|
2014-06-05 09:39:27 -07:00
|
|
|
{
|
|
|
|
case BTN_LEFT:
|
|
|
|
ev.button = 1;
|
|
|
|
break;
|
|
|
|
case BTN_MIDDLE:
|
|
|
|
ev.button = 2;
|
|
|
|
break;
|
|
|
|
case BTN_RIGHT:
|
|
|
|
ev.button = 3;
|
|
|
|
break;
|
|
|
|
default:
|
2015-08-13 13:05:57 -07:00
|
|
|
ev.button = e_comp_wl->ptr.button;
|
2014-06-05 09:39:27 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
e_comp_object_frame_xy_unadjust(ec->frame,
|
2015-08-13 13:05:57 -07:00
|
|
|
wl_fixed_to_int(e_comp_wl->ptr.x),
|
|
|
|
wl_fixed_to_int(e_comp_wl->ptr.y),
|
2014-06-05 09:39:27 -07:00
|
|
|
&ev.canvas.x, &ev.canvas.y);
|
|
|
|
|
|
|
|
_e_shell_surface_mouse_down_helper(ec, &ev, EINA_TRUE);
|
2014-05-09 02:56:05 -07:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2015-05-18 06:08:52 -07:00
|
|
|
_e_shell_surface_cb_resize(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, struct wl_resource *seat_resource EINA_UNUSED, uint32_t serial EINA_UNUSED, uint32_t edges)
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
2014-06-05 09:39:27 -07:00
|
|
|
E_Client *ec;
|
|
|
|
E_Binding_Event_Mouse_Button ev;
|
|
|
|
|
|
|
|
/* get the client for this resource */
|
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2014-06-05 09:39:27 -07:00
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2014-06-05 09:39:27 -07:00
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
if ((edges == 0) || (edges > 15) ||
|
2014-06-05 09:39:27 -07:00
|
|
|
((edges & 3) == 3) || ((edges & 12) == 12)) return;
|
|
|
|
|
|
|
|
if ((ec->maximized) || (ec->fullscreen)) return;
|
|
|
|
|
2014-10-22 08:47:53 -07:00
|
|
|
DBG("Comp Resize Edges Set: %d", edges);
|
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
e_comp_wl->resize.resource = resource;
|
|
|
|
e_comp_wl->resize.edges = edges;
|
|
|
|
e_comp_wl->ptr.grab_x = e_comp_wl->ptr.x - wl_fixed_from_int(ec->client.x);
|
|
|
|
e_comp_wl->ptr.grab_y = e_comp_wl->ptr.y - wl_fixed_from_int(ec->client.y);
|
2014-06-05 09:39:27 -07:00
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
switch (e_comp_wl->ptr.button)
|
2014-06-05 09:39:27 -07:00
|
|
|
{
|
|
|
|
case BTN_LEFT:
|
|
|
|
ev.button = 1;
|
|
|
|
break;
|
|
|
|
case BTN_MIDDLE:
|
|
|
|
ev.button = 2;
|
|
|
|
break;
|
|
|
|
case BTN_RIGHT:
|
|
|
|
ev.button = 3;
|
|
|
|
break;
|
|
|
|
default:
|
2015-08-13 13:05:57 -07:00
|
|
|
ev.button = e_comp_wl->ptr.button;
|
2014-06-05 09:39:27 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
e_comp_object_frame_xy_unadjust(ec->frame,
|
2015-08-13 13:05:57 -07:00
|
|
|
wl_fixed_to_int(e_comp_wl->ptr.x),
|
|
|
|
wl_fixed_to_int(e_comp_wl->ptr.y),
|
2014-06-05 09:39:27 -07:00
|
|
|
&ev.canvas.x, &ev.canvas.y);
|
|
|
|
|
|
|
|
_e_shell_surface_mouse_down_helper(ec, &ev, EINA_FALSE);
|
2014-05-09 02:56:05 -07:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-05-09 02:56:05 -07:00
|
|
|
_e_shell_surface_cb_toplevel_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
E_Client *ec;
|
|
|
|
|
|
|
|
/* get the client for this resource */
|
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2014-05-09 02:56:05 -07:00
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
|
|
|
/* set toplevel client properties */
|
2016-06-21 10:13:46 -07:00
|
|
|
ec->icccm.accepts_focus = 1;
|
2015-03-12 11:48:46 -07:00
|
|
|
if (!ec->internal)
|
|
|
|
ec->borderless = !ec->internal;
|
2015-01-09 09:47:08 -08:00
|
|
|
|
2015-01-23 13:30:28 -08:00
|
|
|
ec->lock_border = EINA_TRUE;
|
2016-06-21 10:13:46 -07:00
|
|
|
if ((!ec->internal) || (!ec->borderless))
|
2015-03-12 11:48:46 -07:00
|
|
|
ec->border.changed = ec->changes.border = !ec->borderless;
|
2014-05-09 02:56:05 -07:00
|
|
|
ec->netwm.type = E_WINDOW_TYPE_NORMAL;
|
2015-03-13 17:09:54 -07:00
|
|
|
ec->comp_data->set_win_type = EINA_TRUE;
|
2014-06-10 13:52:22 -07:00
|
|
|
if ((!ec->lock_user_maximize) && (ec->maximized))
|
|
|
|
e_client_unmaximize(ec, E_MAXIMIZE_BOTH);
|
|
|
|
if ((!ec->lock_user_fullscreen) && (ec->fullscreen))
|
|
|
|
e_client_unfullscreen(ec);
|
2014-05-09 02:56:05 -07:00
|
|
|
EC_CHANGED(ec);
|
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-06-18 11:47:06 -07:00
|
|
|
_e_shell_surface_cb_transient_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, struct wl_resource *parent_resource, int32_t x EINA_UNUSED, int32_t y EINA_UNUSED, uint32_t flags EINA_UNUSED)
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
2014-06-18 11:47:06 -07:00
|
|
|
E_Client *ec;
|
2014-06-23 06:45:16 -07:00
|
|
|
|
2014-06-18 11:47:06 -07:00
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
|
|
|
{
|
|
|
|
wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
|
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2014-06-18 11:47:06 -07:00
|
|
|
|
2014-06-23 06:45:16 -07:00
|
|
|
/* set this client as a transient for parent */
|
|
|
|
_e_shell_surface_parent_set(ec, parent_resource);
|
|
|
|
|
2016-06-29 09:22:59 -07:00
|
|
|
ec->icccm.accepts_focus = 1;
|
|
|
|
if (!ec->internal)
|
|
|
|
ec->borderless = !ec->internal;
|
|
|
|
|
|
|
|
ec->lock_border = EINA_TRUE;
|
|
|
|
if ((!ec->internal) || (!ec->borderless))
|
|
|
|
ec->border.changed = ec->changes.border = !ec->borderless;
|
|
|
|
ec->netwm.type = E_WINDOW_TYPE_DIALOG;
|
|
|
|
ec->dialog = EINA_TRUE;
|
|
|
|
ec->comp_data->set_win_type = EINA_TRUE;
|
|
|
|
if ((!ec->lock_user_maximize) && (ec->maximized))
|
|
|
|
e_client_unmaximize(ec, E_MAXIMIZE_BOTH);
|
|
|
|
if ((!ec->lock_user_fullscreen) && (ec->fullscreen))
|
|
|
|
e_client_unfullscreen(ec);
|
2014-06-18 11:47:06 -07:00
|
|
|
EC_CHANGED(ec);
|
2014-05-09 02:56:05 -07:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-06-09 10:48:22 -07:00
|
|
|
_e_shell_surface_cb_fullscreen_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t method EINA_UNUSED, uint32_t framerate EINA_UNUSED, struct wl_resource *output_resource EINA_UNUSED)
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
2014-06-09 10:49:09 -07:00
|
|
|
E_Client *ec;
|
|
|
|
|
2014-06-09 10:48:22 -07:00
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
|
|
|
{
|
2014-06-09 10:49:09 -07:00
|
|
|
wl_resource_post_error(resource,WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2014-06-09 10:48:22 -07:00
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2014-06-09 10:48:22 -07:00
|
|
|
|
|
|
|
if (!ec->lock_user_fullscreen)
|
|
|
|
e_client_fullscreen(ec, e_config->fullscreen_policy);
|
2014-05-09 02:56:05 -07:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-06-19 11:55:53 -07:00
|
|
|
_e_shell_surface_cb_popup_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, struct wl_resource *seat_resource EINA_UNUSED, uint32_t serial EINA_UNUSED, struct wl_resource *parent_resource, int32_t x, int32_t y, uint32_t flags EINA_UNUSED)
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
2014-06-19 11:55:53 -07:00
|
|
|
E_Client *ec;
|
2016-06-21 10:13:46 -07:00
|
|
|
E_Comp_Client_Data *cdata;
|
2014-06-19 11:55:53 -07:00
|
|
|
|
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
|
|
|
{
|
|
|
|
wl_resource_post_error(resource,WL_DISPLAY_ERROR_INVALID_OBJECT,
|
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2014-06-19 11:55:53 -07:00
|
|
|
|
2016-04-25 11:11:24 -07:00
|
|
|
ec->comp_data->popup.x = x;
|
|
|
|
ec->comp_data->popup.y = y;
|
2014-06-19 11:55:53 -07:00
|
|
|
|
2015-03-12 11:48:46 -07:00
|
|
|
if (!ec->internal)
|
|
|
|
ec->borderless = !ec->internal_elm_win;
|
2015-01-23 13:30:28 -08:00
|
|
|
ec->lock_border = EINA_TRUE;
|
2015-03-12 11:48:46 -07:00
|
|
|
if (!ec->internal)
|
|
|
|
ec->border.changed = ec->changes.border = !ec->borderless;
|
2014-06-19 11:55:53 -07:00
|
|
|
ec->changes.icon = !!ec->icccm.class;
|
|
|
|
ec->netwm.type = E_WINDOW_TYPE_POPUP_MENU;
|
2015-03-13 17:09:54 -07:00
|
|
|
ec->comp_data->set_win_type = EINA_TRUE;
|
2014-06-19 11:55:53 -07:00
|
|
|
|
2016-06-21 10:13:46 -07:00
|
|
|
cdata = ec->comp_data;
|
|
|
|
if (ec->parent)
|
|
|
|
{
|
|
|
|
cdata->popup.x = E_CLAMP(x, 0, ec->parent->client.w);
|
|
|
|
cdata->popup.y = E_CLAMP(y, 0, ec->parent->client.h);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cdata->popup.x = x;
|
|
|
|
cdata->popup.y = y;
|
|
|
|
}
|
|
|
|
|
2014-06-19 11:55:53 -07:00
|
|
|
/* set this client as a transient for parent */
|
2014-06-23 06:45:16 -07:00
|
|
|
_e_shell_surface_parent_set(ec, parent_resource);
|
2014-06-19 11:55:53 -07:00
|
|
|
|
|
|
|
EC_CHANGED(ec);
|
2014-05-09 02:56:05 -07:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-05-09 02:56:05 -07:00
|
|
|
_e_shell_surface_cb_maximized_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, struct wl_resource *output_resource EINA_UNUSED)
|
|
|
|
{
|
|
|
|
E_Client *ec;
|
|
|
|
|
|
|
|
/* DBG("WL_SHELL: Surface Maximize: %d", wl_resource_get_id(resource)); */
|
|
|
|
|
|
|
|
/* get the client for this resource */
|
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2014-05-09 02:56:05 -07:00
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
|
|
|
/* tell E to maximize this client */
|
|
|
|
if (!ec->lock_user_maximize)
|
|
|
|
{
|
|
|
|
unsigned int edges = 0;
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
e_client_maximize(ec, ((e_config->maximize_policy & E_MAXIMIZE_TYPE) |
|
2014-05-09 02:56:05 -07:00
|
|
|
E_MAXIMIZE_BOTH));
|
|
|
|
|
|
|
|
edges = (WL_SHELL_SURFACE_RESIZE_TOP | WL_SHELL_SURFACE_RESIZE_LEFT);
|
|
|
|
wl_shell_surface_send_configure(resource, edges, ec->w, ec->h);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-05-09 02:56:05 -07:00
|
|
|
_e_shell_surface_cb_title_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, const char *title)
|
|
|
|
{
|
|
|
|
E_Client *ec;
|
|
|
|
|
|
|
|
/* get the client for this resource */
|
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2014-05-09 02:56:05 -07:00
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
|
|
|
/* set title */
|
|
|
|
eina_stringshare_replace(&ec->icccm.title, title);
|
|
|
|
if (ec->frame) e_comp_object_frame_title_set(ec->frame, title);
|
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-05-09 02:56:05 -07:00
|
|
|
_e_shell_surface_cb_class_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, const char *clas)
|
|
|
|
{
|
|
|
|
E_Client *ec;
|
|
|
|
|
|
|
|
/* get the client for this resource */
|
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2014-05-09 02:56:05 -07:00
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
|
|
|
/* use the wl_client to get the pid * and set it in the netwm props */
|
2014-05-12 06:06:24 -07:00
|
|
|
wl_client_get_credentials(client, &ec->netwm.pid, NULL, NULL);
|
2014-05-09 02:56:05 -07:00
|
|
|
|
|
|
|
/* set class */
|
|
|
|
eina_stringshare_replace(&ec->icccm.class, clas);
|
|
|
|
ec->changes.icon = !!ec->icccm.class;
|
|
|
|
EC_CHANGED(ec);
|
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static const struct wl_shell_surface_interface _e_shell_surface_interface =
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
|
|
|
_e_shell_surface_cb_pong,
|
|
|
|
_e_shell_surface_cb_move,
|
|
|
|
_e_shell_surface_cb_resize,
|
|
|
|
_e_shell_surface_cb_toplevel_set,
|
|
|
|
_e_shell_surface_cb_transient_set,
|
|
|
|
_e_shell_surface_cb_fullscreen_set,
|
|
|
|
_e_shell_surface_cb_popup_set,
|
|
|
|
_e_shell_surface_cb_maximized_set,
|
|
|
|
_e_shell_surface_cb_title_set,
|
|
|
|
_e_shell_surface_cb_class_set,
|
|
|
|
};
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-05-09 02:56:05 -07:00
|
|
|
_e_shell_surface_configure_send(struct wl_resource *resource, uint32_t edges, int32_t width, int32_t height)
|
|
|
|
{
|
2016-06-23 09:26:57 -07:00
|
|
|
E_Client *ec;
|
|
|
|
|
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
|
|
|
{
|
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (e_client_util_is_popup(ec)) return;
|
|
|
|
|
2014-05-09 02:56:05 -07:00
|
|
|
wl_shell_surface_send_configure(resource, edges, width, height);
|
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-05-09 02:56:05 -07:00
|
|
|
_e_shell_surface_configure(struct wl_resource *resource, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
|
|
|
|
{
|
|
|
|
E_Client *ec;
|
|
|
|
|
|
|
|
/* DBG("WL_SHELL: Surface Configure: %d \t%d %d %d %d", */
|
|
|
|
/* wl_resource_get_id(resource), x, y, w, h); */
|
|
|
|
|
|
|
|
/* get the client for this resource */
|
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2014-05-09 02:56:05 -07:00
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
2014-06-19 11:55:53 -07:00
|
|
|
if (ec->parent)
|
|
|
|
{
|
2016-06-23 09:21:27 -07:00
|
|
|
if (e_client_util_is_popup(ec))
|
2014-06-19 11:55:53 -07:00
|
|
|
{
|
2015-03-13 17:09:54 -07:00
|
|
|
x = E_CLAMP(ec->parent->client.x + ec->comp_data->popup.x,
|
2015-06-25 06:30:59 -07:00
|
|
|
ec->parent->client.x,
|
|
|
|
ec->parent->client.x +
|
2016-06-15 14:39:08 -07:00
|
|
|
ec->parent->client.w);
|
2015-03-13 17:09:54 -07:00
|
|
|
y = E_CLAMP(ec->parent->client.y + ec->comp_data->popup.y,
|
2015-06-25 06:30:59 -07:00
|
|
|
ec->parent->client.y,
|
|
|
|
ec->parent->client.y +
|
2016-06-15 14:39:08 -07:00
|
|
|
ec->parent->client.h);
|
2014-06-19 11:55:53 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-22 20:43:42 -08:00
|
|
|
e_client_util_move_resize_without_frame(ec, x, y, w, h);
|
2014-05-09 02:56:05 -07:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-05-09 02:56:05 -07:00
|
|
|
_e_shell_surface_ping(struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
E_Client *ec;
|
|
|
|
uint32_t serial;
|
|
|
|
|
|
|
|
/* get the client for this resource */
|
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2014-05-09 02:56:05 -07:00
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
serial = wl_display_next_serial(e_comp_wl->wl.disp);
|
2015-03-13 17:09:54 -07:00
|
|
|
wl_shell_surface_send_ping(ec->comp_data->shell.surface, serial);
|
2014-05-09 02:56:05 -07:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-05-09 02:56:05 -07:00
|
|
|
_e_shell_surface_map(struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
E_Client *ec;
|
|
|
|
|
|
|
|
/* get the client for this resource */
|
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2014-05-09 02:56:05 -07:00
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
|
|
|
/* map this surface if needed */
|
2015-03-13 17:09:54 -07:00
|
|
|
if ((!ec->comp_data->mapped) && (e_pixmap_usable_get(ec->pixmap)))
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
|
|
|
ec->visible = EINA_TRUE;
|
|
|
|
evas_object_geometry_set(ec->frame, ec->x, ec->y, ec->w, ec->h);
|
2015-01-22 20:04:25 -08:00
|
|
|
evas_object_show(ec->frame);
|
2015-03-13 17:09:54 -07:00
|
|
|
ec->comp_data->mapped = EINA_TRUE;
|
2014-05-09 02:56:05 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-05-09 02:56:05 -07:00
|
|
|
_e_shell_surface_unmap(struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
E_Client *ec;
|
|
|
|
|
|
|
|
/* get the client for this resource */
|
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2014-05-09 02:56:05 -07:00
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
2015-03-13 17:09:54 -07:00
|
|
|
if (ec->comp_data->mapped)
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
|
|
|
ec->visible = EINA_FALSE;
|
|
|
|
evas_object_hide(ec->frame);
|
2015-03-13 17:09:54 -07:00
|
|
|
ec->comp_data->mapped = EINA_FALSE;
|
2014-05-09 02:56:05 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-05-09 02:56:05 -07:00
|
|
|
_e_shell_cb_shell_surface_get(struct wl_client *client, struct wl_resource *resource EINA_UNUSED, uint32_t id, struct wl_resource *surface_resource)
|
|
|
|
{
|
|
|
|
E_Client *ec;
|
2014-08-04 09:58:49 -07:00
|
|
|
E_Comp_Client_Data *cdata;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
2015-01-28 14:29:17 -08:00
|
|
|
/* get the pixmap from this surface so we can find the client */
|
2015-04-21 12:19:20 -07:00
|
|
|
if (!(ec = wl_resource_get_user_data(surface_resource)))
|
2015-01-28 14:29:17 -08:00
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(surface_resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2015-01-28 14:29:17 -08:00
|
|
|
"No Pixmap Set On Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
|
|
|
cdata = ec->comp_data;
|
2016-03-24 13:41:18 -07:00
|
|
|
ec->netwm.ping = 1;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
|
|
|
/* check for existing shell surface */
|
|
|
|
if (cdata->shell.surface)
|
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(surface_resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2014-05-09 02:56:05 -07:00
|
|
|
"Client already has shell surface");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* try to create a shell surface */
|
2015-02-24 14:34:20 -08:00
|
|
|
if (!(cdata->shell.surface =
|
2014-05-09 02:56:05 -07:00
|
|
|
wl_resource_create(client, &wl_shell_surface_interface, 1, id)))
|
|
|
|
{
|
2016-06-21 10:13:46 -07:00
|
|
|
ERR("Could not create wl_shell surface");
|
2014-05-09 02:56:05 -07:00
|
|
|
wl_resource_post_no_memory(surface_resource);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_set_implementation(cdata->shell.surface,
|
|
|
|
&_e_shell_surface_interface,
|
2014-05-09 02:56:05 -07:00
|
|
|
ec, _e_shell_surface_cb_destroy);
|
|
|
|
|
2015-11-20 11:59:53 -08:00
|
|
|
e_object_ref(E_OBJECT(ec));
|
|
|
|
|
2014-05-09 02:56:05 -07:00
|
|
|
cdata->shell.configure_send = _e_shell_surface_configure_send;
|
|
|
|
cdata->shell.configure = _e_shell_surface_configure;
|
|
|
|
cdata->shell.ping = _e_shell_surface_ping;
|
|
|
|
cdata->shell.map = _e_shell_surface_map;
|
|
|
|
cdata->shell.unmap = _e_shell_surface_unmap;
|
2016-04-18 12:37:22 -07:00
|
|
|
if (!ec->internal)
|
|
|
|
e_client_ping(ec);
|
2014-05-09 02:56:05 -07:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2015-02-24 11:47:56 -08:00
|
|
|
_e_xdg_surface_state_add(struct wl_resource *resource, struct wl_array *states, uint32_t state)
|
|
|
|
{
|
|
|
|
uint32_t *s;
|
2015-06-25 06:45:28 -07:00
|
|
|
|
|
|
|
s = wl_array_add(states, sizeof(*s));
|
2015-02-24 11:47:56 -08:00
|
|
|
if (s)
|
|
|
|
*s = state;
|
|
|
|
else
|
|
|
|
wl_resource_post_no_memory(resource);
|
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2016-04-27 08:26:38 -07:00
|
|
|
_xdg_shell_surface_send_configure(struct wl_resource *resource, Eina_Bool fullscreen, Eina_Bool maximized, uint32_t edges, int32_t width, int32_t height)
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
2014-10-01 13:14:28 -07:00
|
|
|
struct wl_array states;
|
|
|
|
uint32_t serial;
|
2016-04-27 08:26:38 -07:00
|
|
|
E_Client *focused, *ec;
|
2016-04-05 12:05:10 -07:00
|
|
|
E_Shell_Data *shd;
|
|
|
|
State pending = 0;
|
2016-04-27 08:26:38 -07:00
|
|
|
Eina_Bool activated = EINA_FALSE;
|
2014-10-01 13:14:28 -07:00
|
|
|
|
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2014-10-01 13:14:28 -07:00
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-06-23 09:21:27 -07:00
|
|
|
if (e_client_util_is_popup(ec)) return;
|
2016-04-27 08:26:38 -07:00
|
|
|
focused = e_client_focused_get();
|
|
|
|
if (ec == focused)
|
|
|
|
activated = 1;
|
|
|
|
else if (focused && focused->parent)
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (focused->parent != ec)
|
|
|
|
focused = focused->parent;
|
|
|
|
else
|
|
|
|
activated = 1;
|
|
|
|
} while (focused && (!activated));
|
|
|
|
}
|
2015-12-10 10:24:55 -08:00
|
|
|
shd = ec->comp_data->shell.data;
|
|
|
|
if ((shd->edges == edges) && (shd->width == width) && (shd->height == height) &&
|
2016-04-05 12:05:10 -07:00
|
|
|
(shd->fullscreen == fullscreen) &&
|
2016-04-05 13:54:04 -07:00
|
|
|
(shd->maximized == maximized) &&
|
2016-04-27 08:26:38 -07:00
|
|
|
(shd->activated == activated)) return;
|
2015-12-10 10:24:55 -08:00
|
|
|
shd->edges = edges;
|
|
|
|
shd->width = width;
|
|
|
|
shd->height = height;
|
2016-04-05 12:05:10 -07:00
|
|
|
if (shd->fullscreen != fullscreen)
|
|
|
|
{
|
|
|
|
if (fullscreen)
|
|
|
|
pending |= STATE_FULLSCREEN;
|
|
|
|
else
|
|
|
|
pending |= STATE_UNFULLSCREEN;
|
|
|
|
}
|
|
|
|
shd->fullscreen = fullscreen;
|
|
|
|
if (shd->maximized != maximized)
|
|
|
|
{
|
|
|
|
if (maximized)
|
|
|
|
pending |= STATE_MAXIMIZED;
|
|
|
|
else
|
|
|
|
pending |= STATE_UNMAXIMIZED;
|
|
|
|
}
|
|
|
|
shd->maximized = maximized;
|
2016-04-27 08:26:38 -07:00
|
|
|
shd->activated = activated;
|
2014-10-01 13:14:28 -07:00
|
|
|
wl_array_init(&states);
|
|
|
|
|
2016-04-05 12:05:10 -07:00
|
|
|
if (fullscreen)
|
2015-02-24 11:47:56 -08:00
|
|
|
_e_xdg_surface_state_add(resource, &states, XDG_SURFACE_STATE_FULLSCREEN);
|
2016-04-05 12:05:10 -07:00
|
|
|
else if (maximized)
|
2015-02-24 11:47:56 -08:00
|
|
|
_e_xdg_surface_state_add(resource, &states, XDG_SURFACE_STATE_MAXIMIZED);
|
2016-04-05 12:05:10 -07:00
|
|
|
if (edges)
|
2015-02-24 11:47:56 -08:00
|
|
|
_e_xdg_surface_state_add(resource, &states, XDG_SURFACE_STATE_RESIZING);
|
2016-04-27 08:26:38 -07:00
|
|
|
if (activated)
|
2015-02-24 11:47:56 -08:00
|
|
|
_e_xdg_surface_state_add(resource, &states, XDG_SURFACE_STATE_ACTIVATED);
|
2014-10-01 13:14:28 -07:00
|
|
|
|
2016-04-05 12:05:10 -07:00
|
|
|
serial = wl_display_next_serial(e_comp_wl->wl.disp);
|
|
|
|
xdg_surface_send_configure(resource, width, height, &states, serial);
|
|
|
|
{
|
|
|
|
Pending_State *ps;
|
|
|
|
|
|
|
|
ps = E_NEW(Pending_State, 1);
|
|
|
|
ps->state = pending;
|
|
|
|
ps->serial = serial;
|
|
|
|
shd->pending = eina_list_append(shd->pending, ps);
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_array_release(&states);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_xdg_shell_surface_configure_send(struct wl_resource *resource, uint32_t edges, int32_t width, int32_t height)
|
|
|
|
{
|
|
|
|
E_Client *ec;
|
|
|
|
|
|
|
|
/* get the client for this resource */
|
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
2015-03-10 12:52:31 -07:00
|
|
|
{
|
2016-04-05 12:05:10 -07:00
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
2015-03-10 12:52:31 -07:00
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2016-06-23 09:21:27 -07:00
|
|
|
if (e_client_util_is_popup(ec)) return;
|
2015-06-09 06:43:34 -07:00
|
|
|
|
2016-06-20 12:54:50 -07:00
|
|
|
_xdg_shell_surface_send_configure(resource, ec->fullscreen, !!ec->maximized || ec->comp_data->max, edges, width, height);
|
2014-10-01 13:14:28 -07:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-10-01 13:14:28 -07:00
|
|
|
_e_xdg_shell_surface_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
|
|
|
|
{
|
2016-02-17 17:12:52 -08:00
|
|
|
wl_resource_destroy(resource);
|
2014-05-09 02:56:05 -07:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-10-01 13:14:28 -07:00
|
|
|
_e_xdg_shell_surface_cb_parent_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, struct wl_resource *parent_resource)
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
2014-06-18 11:47:06 -07:00
|
|
|
E_Client *ec;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
2014-06-13 05:24:27 -07:00
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
|
|
|
{
|
|
|
|
wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
|
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2014-06-13 05:24:27 -07:00
|
|
|
|
2014-06-23 06:45:16 -07:00
|
|
|
/* set this client as a transient for parent */
|
|
|
|
_e_shell_surface_parent_set(ec, parent_resource);
|
2014-05-09 02:56:05 -07:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-05-09 02:56:05 -07:00
|
|
|
_e_xdg_shell_surface_cb_title_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, const char *title)
|
|
|
|
{
|
|
|
|
E_Client *ec;
|
|
|
|
|
|
|
|
/* get the client for this resource */
|
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2014-05-09 02:56:05 -07:00
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
|
|
|
/* set title */
|
|
|
|
eina_stringshare_replace(&ec->icccm.title, title);
|
|
|
|
if (ec->frame) e_comp_object_frame_title_set(ec->frame, title);
|
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-05-09 02:56:05 -07:00
|
|
|
_e_xdg_shell_surface_cb_app_id_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, const char *id)
|
|
|
|
{
|
|
|
|
E_Client *ec;
|
|
|
|
|
|
|
|
/* get the client for this resource */
|
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2014-05-09 02:56:05 -07:00
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
|
|
|
/* use the wl_client to get the pid * and set it in the netwm props */
|
2014-05-12 06:06:24 -07:00
|
|
|
wl_client_get_credentials(client, &ec->netwm.pid, NULL, NULL);
|
2014-05-09 02:56:05 -07:00
|
|
|
|
|
|
|
/* set class */
|
|
|
|
eina_stringshare_replace(&ec->icccm.class, id);
|
|
|
|
/* eina_stringshare_replace(&ec->netwm.name, id); */
|
2014-08-03 07:34:38 -07:00
|
|
|
ec->changes.icon = !!ec->icccm.class;
|
2014-05-09 02:56:05 -07:00
|
|
|
EC_CHANGED(ec);
|
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-10-29 06:51:28 -07:00
|
|
|
_e_xdg_shell_surface_cb_window_menu_show(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, struct wl_resource *seat_resource EINA_UNUSED, uint32_t serial EINA_UNUSED, int32_t x, int32_t y)
|
2014-10-01 13:14:28 -07:00
|
|
|
{
|
2014-10-29 06:51:28 -07:00
|
|
|
E_Client *ec;
|
|
|
|
double timestamp;
|
|
|
|
|
|
|
|
/* get the client for this resource */
|
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
|
|
|
{
|
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2014-10-29 06:51:28 -07:00
|
|
|
|
2015-06-09 06:43:34 -07:00
|
|
|
timestamp = ecore_loop_time_get();
|
2016-07-19 11:12:24 -07:00
|
|
|
e_int_client_menu_show(ec, ec->x + x, ec->y + y, 0, timestamp);
|
2014-10-01 13:14:28 -07:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2015-05-18 06:08:52 -07:00
|
|
|
_e_xdg_shell_surface_cb_move(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, struct wl_resource *seat_resource EINA_UNUSED, uint32_t serial EINA_UNUSED)
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
|
|
|
E_Client *ec;
|
|
|
|
E_Binding_Event_Mouse_Button ev;
|
|
|
|
|
|
|
|
/* get the client for this resource */
|
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2014-05-09 02:56:05 -07:00
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
|
|
|
if ((ec->maximized) || (ec->fullscreen)) return;
|
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
switch (e_comp_wl->ptr.button)
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
|
|
|
case BTN_LEFT:
|
|
|
|
ev.button = 1;
|
|
|
|
break;
|
|
|
|
case BTN_MIDDLE:
|
|
|
|
ev.button = 2;
|
|
|
|
break;
|
|
|
|
case BTN_RIGHT:
|
|
|
|
ev.button = 3;
|
|
|
|
break;
|
|
|
|
default:
|
2015-08-13 13:05:57 -07:00
|
|
|
ev.button = e_comp_wl->ptr.button;
|
2014-05-09 02:56:05 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
e_comp_object_frame_xy_unadjust(ec->frame,
|
2015-08-13 13:05:57 -07:00
|
|
|
wl_fixed_to_int(e_comp_wl->ptr.x),
|
|
|
|
wl_fixed_to_int(e_comp_wl->ptr.y),
|
2014-05-09 02:56:05 -07:00
|
|
|
&ev.canvas.x, &ev.canvas.y);
|
|
|
|
|
|
|
|
_e_shell_surface_mouse_down_helper(ec, &ev, EINA_TRUE);
|
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2015-05-18 06:08:52 -07:00
|
|
|
_e_xdg_shell_surface_cb_resize(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, struct wl_resource *seat_resource EINA_UNUSED, uint32_t serial EINA_UNUSED, uint32_t edges)
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
|
|
|
E_Client *ec;
|
|
|
|
E_Binding_Event_Mouse_Button ev;
|
|
|
|
|
2015-01-09 09:47:08 -08:00
|
|
|
/* DBG("XDG_SHELL: Surface Resize: %d\tEdges: %d", */
|
|
|
|
/* wl_resource_get_id(resource), edges); */
|
2014-05-12 06:06:24 -07:00
|
|
|
|
2014-05-09 02:56:05 -07:00
|
|
|
/* get the client for this resource */
|
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2014-05-09 02:56:05 -07:00
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
if ((edges == 0) || (edges > 15) ||
|
2014-05-09 02:56:05 -07:00
|
|
|
((edges & 3) == 3) || ((edges & 12) == 12)) return;
|
|
|
|
|
|
|
|
if ((ec->maximized) || (ec->fullscreen)) return;
|
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
e_comp_wl->resize.resource = resource;
|
|
|
|
e_comp_wl->resize.edges = edges;
|
|
|
|
e_comp_wl->ptr.grab_x = e_comp_wl->ptr.x - wl_fixed_from_int(ec->client.x);
|
|
|
|
e_comp_wl->ptr.grab_y = e_comp_wl->ptr.y - wl_fixed_from_int(ec->client.y);
|
2014-05-09 02:56:05 -07:00
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
switch (e_comp_wl->ptr.button)
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
|
|
|
case BTN_LEFT:
|
|
|
|
ev.button = 1;
|
|
|
|
break;
|
|
|
|
case BTN_MIDDLE:
|
|
|
|
ev.button = 2;
|
|
|
|
break;
|
|
|
|
case BTN_RIGHT:
|
|
|
|
ev.button = 3;
|
|
|
|
break;
|
|
|
|
default:
|
2015-08-13 13:05:57 -07:00
|
|
|
ev.button = e_comp_wl->ptr.button;
|
2014-05-09 02:56:05 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
e_comp_object_frame_xy_unadjust(ec->frame,
|
2015-08-13 13:05:57 -07:00
|
|
|
wl_fixed_to_int(e_comp_wl->ptr.x),
|
|
|
|
wl_fixed_to_int(e_comp_wl->ptr.y),
|
2014-05-09 02:56:05 -07:00
|
|
|
&ev.canvas.x, &ev.canvas.y);
|
|
|
|
|
|
|
|
_e_shell_surface_mouse_down_helper(ec, &ev, EINA_FALSE);
|
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2016-04-05 12:05:10 -07:00
|
|
|
_e_xdg_shell_surface_cb_ack_configure(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t serial)
|
2014-10-01 13:14:28 -07:00
|
|
|
{
|
2016-04-05 12:05:10 -07:00
|
|
|
E_Client *ec;
|
|
|
|
Pending_State *ps;
|
|
|
|
E_Shell_Data *shd;
|
2016-05-10 08:34:48 -07:00
|
|
|
Eina_List *l, *ll;
|
2016-04-05 12:05:10 -07:00
|
|
|
|
|
|
|
ec = wl_resource_get_user_data(resource);
|
|
|
|
if (!ec)
|
|
|
|
{
|
|
|
|
wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
|
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2016-04-05 12:05:10 -07:00
|
|
|
shd = ec->comp_data->shell.data;
|
2016-05-10 08:34:48 -07:00
|
|
|
EINA_LIST_FOREACH_SAFE(shd->pending, l, ll, ps)
|
2016-04-05 12:05:10 -07:00
|
|
|
{
|
|
|
|
if (ps->serial > serial) break;
|
|
|
|
if (ps->state & STATE_FULLSCREEN)
|
|
|
|
{
|
|
|
|
ec->comp_data->shell.set.fullscreen = 1;
|
|
|
|
ec->comp_data->shell.set.unfullscreen = 0;
|
|
|
|
}
|
|
|
|
if (ps->state & STATE_UNFULLSCREEN)
|
|
|
|
{
|
|
|
|
ec->comp_data->shell.set.unfullscreen = 1;
|
|
|
|
ec->comp_data->shell.set.fullscreen = 0;
|
|
|
|
}
|
|
|
|
if (ps->state & STATE_MAXIMIZED)
|
|
|
|
{
|
|
|
|
ec->comp_data->shell.set.maximize = 1;
|
|
|
|
ec->comp_data->shell.set.unmaximize = 0;
|
|
|
|
}
|
|
|
|
if (ps->state & STATE_UNMAXIMIZED)
|
|
|
|
{
|
|
|
|
ec->comp_data->shell.set.unmaximize = 1;
|
|
|
|
ec->comp_data->shell.set.maximize = 0;
|
|
|
|
}
|
2016-05-10 08:34:48 -07:00
|
|
|
shd->pending = eina_list_remove_list(shd->pending, l);
|
2016-04-05 12:05:10 -07:00
|
|
|
free(ps);
|
|
|
|
}
|
2014-10-01 13:14:28 -07:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2015-03-03 13:48:25 -08:00
|
|
|
_e_xdg_shell_surface_cb_window_geometry_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, int32_t x, int32_t y, int32_t w, int32_t h)
|
2014-10-01 13:14:28 -07:00
|
|
|
{
|
2015-03-03 13:48:25 -08:00
|
|
|
E_Client *ec;
|
2014-10-01 13:14:28 -07:00
|
|
|
|
2015-03-03 13:48:25 -08:00
|
|
|
ec = wl_resource_get_user_data(resource);
|
|
|
|
if (!ec)
|
|
|
|
{
|
|
|
|
wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
|
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2015-03-13 17:09:54 -07:00
|
|
|
EINA_RECTANGLE_SET(&ec->comp_data->shell.window, x, y, w, h);
|
2015-03-03 13:48:25 -08:00
|
|
|
//DBG("XDG_SHELL: Window Geom Set: %d \t%d %d, %d %d", wl_resource_get_id(resource), x, y, w, h);
|
2014-10-01 13:14:28 -07:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-10-01 13:14:28 -07:00
|
|
|
_e_xdg_shell_surface_cb_maximized_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
|
|
|
E_Client *ec;
|
2016-04-05 12:05:10 -07:00
|
|
|
int w, h;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
|
|
|
/* get the client for this resource */
|
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2014-05-09 02:56:05 -07:00
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
2016-04-05 12:05:10 -07:00
|
|
|
if (ec->lock_user_maximize) return;
|
2016-04-11 11:38:03 -07:00
|
|
|
if (e_config->window_maximize_animate && (!ec->maximize_anims_disabled))
|
2016-04-05 12:05:10 -07:00
|
|
|
w = ec->w, h = ec->h;
|
|
|
|
else
|
2014-10-06 12:57:36 -07:00
|
|
|
{
|
2016-04-05 12:05:10 -07:00
|
|
|
switch (e_config->maximize_policy & E_MAXIMIZE_TYPE)
|
|
|
|
{
|
|
|
|
case E_MAXIMIZE_FULLSCREEN:
|
|
|
|
w = ec->zone->w, h = ec->zone->h;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
e_zone_useful_geometry_get(ec->zone, NULL, NULL, &w, &h);
|
|
|
|
}
|
2014-10-06 12:57:36 -07:00
|
|
|
}
|
2016-04-27 08:26:38 -07:00
|
|
|
_xdg_shell_surface_send_configure(resource, ec->fullscreen, 1, 0, w, h);
|
2014-05-09 02:56:05 -07:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-10-01 13:14:28 -07:00
|
|
|
_e_xdg_shell_surface_cb_maximized_unset(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
|
|
|
E_Client *ec;
|
2016-04-05 13:54:04 -07:00
|
|
|
int w, h;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
|
|
|
/* get the client for this resource */
|
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2014-05-09 02:56:05 -07:00
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
2016-04-05 12:05:10 -07:00
|
|
|
if (ec->lock_user_maximize) return;
|
2016-07-13 08:26:16 -07:00
|
|
|
ec->comp_data->unmax = (e_config->maximize_policy & E_MAXIMIZE_TYPE) | E_MAXIMIZE_BOTH;
|
2016-04-11 11:38:03 -07:00
|
|
|
if (e_config->window_maximize_animate && (!ec->maximize_anims_disabled))
|
2016-04-05 13:54:04 -07:00
|
|
|
w = ec->w, h = ec->h;
|
|
|
|
else
|
|
|
|
w = ec->saved.w, h = ec->saved.h;
|
2016-04-27 08:26:38 -07:00
|
|
|
_xdg_shell_surface_send_configure(resource, ec->fullscreen, 0, 0, w, h);
|
2014-10-01 13:14:28 -07:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-10-01 13:14:28 -07:00
|
|
|
_e_xdg_shell_surface_cb_fullscreen_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, struct wl_resource *output_resource EINA_UNUSED)
|
|
|
|
{
|
|
|
|
E_Client *ec;
|
|
|
|
|
|
|
|
/* get the client for this resource */
|
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2014-10-01 13:14:28 -07:00
|
|
|
"No Client For Shell Surface");
|
2014-05-09 02:56:05 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-04-05 12:05:10 -07:00
|
|
|
if (ec->lock_user_fullscreen) return;
|
2016-06-20 12:54:50 -07:00
|
|
|
_xdg_shell_surface_send_configure(resource, 1, !!ec->maximized || ec->comp_data->max, 0, ec->zone->w, ec->zone->h);
|
2014-05-09 02:56:05 -07:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-10-01 13:14:28 -07:00
|
|
|
_e_xdg_shell_surface_cb_fullscreen_unset(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
|
|
|
E_Client *ec;
|
|
|
|
|
|
|
|
/* get the client for this resource */
|
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2014-05-09 02:56:05 -07:00
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
2016-04-05 12:05:10 -07:00
|
|
|
if (ec->lock_user_fullscreen) return;
|
2016-06-20 12:54:50 -07:00
|
|
|
_xdg_shell_surface_send_configure(resource, 0, !!ec->maximized || ec->comp_data->max, 0, ec->saved.w, ec->saved.h);
|
2014-10-01 13:14:28 -07:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-10-01 13:14:28 -07:00
|
|
|
_e_xdg_shell_surface_cb_minimized_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
E_Client *ec;
|
|
|
|
|
|
|
|
/* get the client for this resource */
|
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2014-10-01 13:14:28 -07:00
|
|
|
"No Client For Shell Surface");
|
2014-05-09 02:56:05 -07:00
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
2016-04-08 13:08:32 -07:00
|
|
|
if (ec->lock_user_iconify) return;
|
|
|
|
ec->comp_data->shell.set.minimize = 1;
|
|
|
|
ec->comp_data->max = (e_config->maximize_policy & E_MAXIMIZE_TYPE) | E_MAXIMIZE_BOTH;
|
2014-05-09 02:56:05 -07:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static const struct xdg_surface_interface _e_xdg_surface_interface =
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
|
|
|
_e_xdg_shell_surface_cb_destroy,
|
2014-10-01 13:14:28 -07:00
|
|
|
_e_xdg_shell_surface_cb_parent_set,
|
2014-05-09 02:56:05 -07:00
|
|
|
_e_xdg_shell_surface_cb_title_set,
|
|
|
|
_e_xdg_shell_surface_cb_app_id_set,
|
2014-10-01 13:14:28 -07:00
|
|
|
_e_xdg_shell_surface_cb_window_menu_show,
|
2014-05-09 02:56:05 -07:00
|
|
|
_e_xdg_shell_surface_cb_move,
|
|
|
|
_e_xdg_shell_surface_cb_resize,
|
2014-10-01 13:14:28 -07:00
|
|
|
_e_xdg_shell_surface_cb_ack_configure,
|
|
|
|
_e_xdg_shell_surface_cb_window_geometry_set,
|
|
|
|
_e_xdg_shell_surface_cb_maximized_set,
|
|
|
|
_e_xdg_shell_surface_cb_maximized_unset,
|
|
|
|
_e_xdg_shell_surface_cb_fullscreen_set,
|
|
|
|
_e_xdg_shell_surface_cb_fullscreen_unset,
|
|
|
|
_e_xdg_shell_surface_cb_minimized_set,
|
2014-05-09 02:56:05 -07:00
|
|
|
};
|
|
|
|
|
2015-06-08 09:23:40 -07:00
|
|
|
static void
|
|
|
|
_e_xdg_shell_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
wl_resource_destroy(resource);
|
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-05-09 02:56:05 -07:00
|
|
|
_e_xdg_shell_cb_unstable_version(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, int32_t version)
|
|
|
|
{
|
|
|
|
if (version > 1)
|
|
|
|
wl_resource_post_error(resource, 1, "XDG Version Not Implemented Yet");
|
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-05-09 02:56:05 -07:00
|
|
|
_e_xdg_shell_surface_configure(struct wl_resource *resource, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
|
|
|
|
{
|
|
|
|
E_Client *ec;
|
|
|
|
|
2015-01-09 09:47:08 -08:00
|
|
|
/* DBG("XDG_SHELL: Surface Configure: %d \t%d %d %d %d", */
|
|
|
|
/* wl_resource_get_id(resource), x, y, w, h); */
|
2014-05-09 02:56:05 -07:00
|
|
|
|
|
|
|
/* get the client for this resource */
|
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2014-05-09 02:56:05 -07:00
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
2014-06-19 11:55:53 -07:00
|
|
|
if (ec->parent)
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
2016-06-23 09:21:27 -07:00
|
|
|
if (e_client_util_is_popup(ec))
|
2014-06-19 11:55:53 -07:00
|
|
|
{
|
2016-03-31 11:58:55 -07:00
|
|
|
x = ec->parent->client.x + ec->comp_data->popup.x;
|
|
|
|
y = ec->parent->client.y + ec->comp_data->popup.y;
|
2014-06-19 11:55:53 -07:00
|
|
|
}
|
2014-05-09 02:56:05 -07:00
|
|
|
}
|
|
|
|
|
2015-01-22 20:43:42 -08:00
|
|
|
e_client_util_move_resize_without_frame(ec, x, y, w, h);
|
2014-05-09 02:56:05 -07:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-05-09 02:56:05 -07:00
|
|
|
_e_xdg_shell_surface_ping(struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
E_Client *ec;
|
|
|
|
uint32_t serial;
|
2016-04-18 12:37:22 -07:00
|
|
|
struct wl_client *client;
|
|
|
|
struct wl_resource *xdg_shell;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
|
|
|
/* get the client for this resource */
|
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2014-05-09 02:56:05 -07:00
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2016-04-18 12:37:22 -07:00
|
|
|
client = wl_resource_get_client(resource);
|
|
|
|
xdg_shell = eina_hash_find(xdg_shell_resources, &client);
|
2014-05-09 02:56:05 -07:00
|
|
|
|
2016-04-18 12:37:22 -07:00
|
|
|
if (!xdg_shell) return;
|
|
|
|
serial = wl_display_next_serial(e_comp_wl->wl.disp);
|
|
|
|
xdg_shell_send_ping(xdg_shell, serial);
|
2014-05-09 02:56:05 -07:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-05-09 02:56:05 -07:00
|
|
|
_e_xdg_shell_surface_map(struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
E_Client *ec;
|
|
|
|
|
2014-07-29 10:28:20 -07:00
|
|
|
/* DBG("XDG_SHELL: Map Surface: %d", wl_resource_get_id(resource)); */
|
2014-05-09 02:56:05 -07:00
|
|
|
|
|
|
|
/* get the client for this resource */
|
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2014-05-09 02:56:05 -07:00
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
2015-03-13 17:09:54 -07:00
|
|
|
if ((!ec->comp_data->mapped) && (e_pixmap_usable_get(ec->pixmap)))
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
|
|
|
/* map this surface if needed */
|
|
|
|
ec->visible = EINA_TRUE;
|
2015-01-22 20:04:25 -08:00
|
|
|
evas_object_show(ec->frame);
|
2015-03-13 17:09:54 -07:00
|
|
|
ec->comp_data->mapped = EINA_TRUE;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
/* FIXME: sometimes popup surfaces Do Not raise above their
|
2014-05-09 02:56:05 -07:00
|
|
|
* respective parents... */
|
2016-06-23 09:21:27 -07:00
|
|
|
/* if (e_client_util_is_popup(ec)) */
|
2014-05-09 02:56:05 -07:00
|
|
|
/* e_client_raise_latest_set(ec); */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-05-09 02:56:05 -07:00
|
|
|
_e_xdg_shell_surface_unmap(struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
E_Client *ec;
|
|
|
|
|
|
|
|
/* DBG("XDG_SHELL: Unmap Surface: %d", wl_resource_get_id(resource)); */
|
|
|
|
|
|
|
|
/* get the client for this resource */
|
|
|
|
if (!(ec = wl_resource_get_user_data(resource)))
|
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2014-05-09 02:56:05 -07:00
|
|
|
"No Client For Shell Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
2015-03-13 17:09:54 -07:00
|
|
|
if (ec->comp_data->mapped)
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
|
|
|
ec->visible = EINA_FALSE;
|
|
|
|
evas_object_hide(ec->frame);
|
2015-03-13 17:09:54 -07:00
|
|
|
ec->comp_data->mapped = EINA_FALSE;
|
2014-05-09 02:56:05 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-05-09 02:56:05 -07:00
|
|
|
_e_xdg_shell_cb_surface_get(struct wl_client *client, struct wl_resource *resource EINA_UNUSED, uint32_t id, struct wl_resource *surface_resource)
|
|
|
|
{
|
|
|
|
E_Client *ec;
|
2014-08-04 09:58:49 -07:00
|
|
|
E_Comp_Client_Data *cdata;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
2014-07-29 10:28:20 -07:00
|
|
|
/* DBG("XDG_SHELL: Surface Get %d", wl_resource_get_id(surface_resource)); */
|
2014-05-09 02:56:05 -07:00
|
|
|
|
2015-01-28 14:29:17 -08:00
|
|
|
/* get the pixmap from this surface so we can find the client */
|
2015-04-21 12:19:20 -07:00
|
|
|
if (!(ec = wl_resource_get_user_data(surface_resource)))
|
2015-01-28 14:29:17 -08:00
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(surface_resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2015-01-28 14:29:17 -08:00
|
|
|
"No Pixmap Set On Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2015-01-28 14:29:17 -08:00
|
|
|
|
2016-03-24 13:41:18 -07:00
|
|
|
ec->netwm.ping = 1;
|
2016-04-25 11:11:24 -07:00
|
|
|
cdata = ec->comp_data;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
|
|
|
/* check for existing shell surface */
|
|
|
|
if (cdata->shell.surface)
|
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(surface_resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2015-01-28 14:01:16 -08:00
|
|
|
"Client already has XDG shell surface");
|
2014-05-09 02:56:05 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* try to create a shell surface */
|
2015-02-24 14:34:20 -08:00
|
|
|
if (!(cdata->shell.surface =
|
2014-05-09 02:56:05 -07:00
|
|
|
wl_resource_create(client, &xdg_surface_interface, 1, id)))
|
|
|
|
{
|
|
|
|
ERR("Could not create xdg shell surface");
|
|
|
|
wl_resource_post_no_memory(surface_resource);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_set_implementation(cdata->shell.surface,
|
|
|
|
&_e_xdg_surface_interface, ec,
|
2014-05-09 02:56:05 -07:00
|
|
|
_e_shell_surface_cb_destroy);
|
|
|
|
|
2015-11-20 11:59:53 -08:00
|
|
|
e_object_ref(E_OBJECT(ec));
|
|
|
|
|
2014-05-09 02:56:05 -07:00
|
|
|
cdata->shell.configure_send = _e_xdg_shell_surface_configure_send;
|
|
|
|
cdata->shell.configure = _e_xdg_shell_surface_configure;
|
|
|
|
cdata->shell.ping = _e_xdg_shell_surface_ping;
|
|
|
|
cdata->shell.map = _e_xdg_shell_surface_map;
|
|
|
|
cdata->shell.unmap = _e_xdg_shell_surface_unmap;
|
2015-12-10 10:24:55 -08:00
|
|
|
cdata->shell.data = E_NEW(E_Shell_Data, 1);
|
2016-06-29 14:19:20 -07:00
|
|
|
cdata->is_xdg_surface = EINA_TRUE;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
|
|
|
/* set toplevel client properties */
|
2015-02-13 12:45:03 -08:00
|
|
|
ec->icccm.accepts_focus = 1;
|
2015-03-12 11:48:46 -07:00
|
|
|
if (!ec->internal)
|
2015-03-13 12:03:13 -07:00
|
|
|
ec->borderless = 1;
|
2015-01-23 13:30:28 -08:00
|
|
|
ec->lock_border = EINA_TRUE;
|
2015-03-13 12:03:13 -07:00
|
|
|
if ((!ec->internal) || (!ec->borderless))
|
2015-03-12 11:48:46 -07:00
|
|
|
ec->border.changed = ec->changes.border = !ec->borderless;
|
2014-05-09 02:56:05 -07:00
|
|
|
ec->netwm.type = E_WINDOW_TYPE_NORMAL;
|
2015-03-13 17:09:54 -07:00
|
|
|
ec->comp_data->set_win_type = EINA_TRUE;
|
2016-01-19 10:43:06 -08:00
|
|
|
|
|
|
|
if (ec->internal_elm_win && evas_object_visible_get(ec->internal_elm_win))
|
|
|
|
_e_xdg_shell_surface_map(surface_resource);
|
2016-04-18 12:37:22 -07:00
|
|
|
if (!ec->internal)
|
|
|
|
e_client_ping(ec);
|
2014-05-09 02:56:05 -07:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-05-09 02:56:05 -07:00
|
|
|
_e_xdg_shell_popup_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
|
|
|
|
{
|
2016-02-17 17:12:52 -08:00
|
|
|
wl_resource_destroy(resource);
|
2014-05-09 02:56:05 -07:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static const struct xdg_popup_interface _e_xdg_popup_interface =
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
|
|
|
_e_xdg_shell_popup_cb_destroy,
|
|
|
|
};
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2015-06-08 09:23:40 -07:00
|
|
|
_e_xdg_shell_cb_popup_get(struct wl_client *client, struct wl_resource *resource EINA_UNUSED, uint32_t id, struct wl_resource *surface_resource, struct wl_resource *parent_resource, struct wl_resource *seat_resource EINA_UNUSED, uint32_t serial EINA_UNUSED, int32_t x, int32_t y)
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
|
|
|
E_Client *ec;
|
2014-08-04 09:58:49 -07:00
|
|
|
E_Comp_Client_Data *cdata;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
|
|
|
/* DBG("XDG_SHELL: Popup Get"); */
|
|
|
|
/* DBG("\tSurface: %d", wl_resource_get_id(surface_resource)); */
|
|
|
|
/* DBG("\tParent Surface: %d", wl_resource_get_id(parent_resource)); */
|
|
|
|
/* DBG("\tLocation: %d %d", x, y); */
|
|
|
|
|
2015-01-28 14:29:17 -08:00
|
|
|
/* get the pixmap from this surface so we can find the client */
|
2015-04-21 12:19:20 -07:00
|
|
|
if (!(ec = wl_resource_get_user_data(surface_resource)))
|
2015-01-28 14:29:17 -08:00
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(surface_resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2015-01-28 14:29:17 -08:00
|
|
|
"No Pixmap Set On Surface");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-25 11:11:24 -07:00
|
|
|
if (e_object_is_del(E_OBJECT(ec))) return;
|
2015-01-28 14:29:17 -08:00
|
|
|
|
2016-04-25 11:11:24 -07:00
|
|
|
cdata = ec->comp_data;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
|
|
|
/* check for existing shell surface */
|
|
|
|
if (cdata->shell.surface)
|
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(surface_resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2015-01-28 14:01:16 -08:00
|
|
|
"Client already has shell popup surface");
|
2014-05-09 02:56:05 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-09-02 05:34:52 -07:00
|
|
|
/* check for the parent surface */
|
|
|
|
if (!parent_resource)
|
|
|
|
{
|
|
|
|
wl_resource_post_error(surface_resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2015-02-24 14:34:20 -08:00
|
|
|
"Popup requires a parent shell surface");
|
2014-09-02 05:34:52 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-05-09 02:56:05 -07:00
|
|
|
/* try to create a shell surface */
|
2015-02-24 14:34:20 -08:00
|
|
|
if (!(cdata->shell.surface =
|
2014-05-09 02:56:05 -07:00
|
|
|
wl_resource_create(client, &xdg_popup_interface, 1, id)))
|
|
|
|
{
|
|
|
|
ERR("Could not create xdg shell surface");
|
|
|
|
wl_resource_post_no_memory(surface_resource);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_set_implementation(cdata->shell.surface,
|
2016-03-31 11:04:47 -07:00
|
|
|
&_e_xdg_popup_interface, ec, _e_shell_surface_destroy);
|
2014-05-09 02:56:05 -07:00
|
|
|
|
2015-11-20 11:59:53 -08:00
|
|
|
e_object_ref(E_OBJECT(ec));
|
|
|
|
|
2014-05-09 02:56:05 -07:00
|
|
|
cdata->shell.configure_send = _e_xdg_shell_surface_configure_send;
|
|
|
|
cdata->shell.configure = _e_xdg_shell_surface_configure;
|
|
|
|
cdata->shell.ping = _e_xdg_shell_surface_ping;
|
|
|
|
cdata->shell.map = _e_xdg_shell_surface_map;
|
|
|
|
cdata->shell.unmap = _e_xdg_shell_surface_unmap;
|
2016-01-21 14:21:31 -08:00
|
|
|
cdata->shell.data = E_NEW(E_Shell_Data, 1);
|
2016-06-29 14:19:20 -07:00
|
|
|
cdata->is_xdg_surface = EINA_TRUE;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
2015-03-12 11:48:46 -07:00
|
|
|
if (!ec->internal)
|
|
|
|
ec->borderless = !ec->internal_elm_win;
|
2015-01-23 13:30:28 -08:00
|
|
|
ec->lock_border = EINA_TRUE;
|
2015-03-12 11:48:46 -07:00
|
|
|
if (!ec->internal)
|
|
|
|
ec->border.changed = ec->changes.border = !ec->borderless;
|
2014-05-09 02:56:05 -07:00
|
|
|
ec->changes.icon = !!ec->icccm.class;
|
|
|
|
ec->netwm.type = E_WINDOW_TYPE_POPUP_MENU;
|
2016-03-31 11:06:08 -07:00
|
|
|
ec->placed = ec->comp_data->set_win_type = EINA_TRUE;
|
2014-05-09 02:56:05 -07:00
|
|
|
|
|
|
|
/* set this client as a transient for parent */
|
2014-06-23 06:45:16 -07:00
|
|
|
_e_shell_surface_parent_set(ec, parent_resource);
|
2014-06-19 11:55:53 -07:00
|
|
|
|
2015-02-04 15:04:58 -08:00
|
|
|
if (ec->parent)
|
|
|
|
{
|
|
|
|
cdata->popup.x = E_CLAMP(x, 0, ec->parent->client.w);
|
2015-02-26 12:27:52 -08:00
|
|
|
cdata->popup.y = E_CLAMP(y, 0, ec->parent->client.h);
|
2015-02-04 15:04:58 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cdata->popup.x = x;
|
|
|
|
cdata->popup.y = y;
|
|
|
|
}
|
2016-01-19 10:43:06 -08:00
|
|
|
if (ec->internal_elm_win && evas_object_visible_get(ec->internal_elm_win))
|
|
|
|
_e_xdg_shell_surface_map(surface_resource);
|
2014-05-09 02:56:05 -07:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2014-05-09 02:56:05 -07:00
|
|
|
_e_xdg_shell_cb_pong(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t serial EINA_UNUSED)
|
|
|
|
{
|
|
|
|
E_Client *ec;
|
|
|
|
|
|
|
|
if ((ec = wl_resource_get_user_data(resource)))
|
2014-10-29 07:34:26 -07:00
|
|
|
{
|
|
|
|
ec->ping_ok = EINA_TRUE;
|
|
|
|
ec->hung = EINA_FALSE;
|
|
|
|
}
|
2014-05-09 02:56:05 -07:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static const struct wl_shell_interface _e_shell_interface =
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
|
|
|
_e_shell_cb_shell_surface_get
|
|
|
|
};
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static const struct xdg_shell_interface _e_xdg_shell_interface =
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
2015-06-08 09:23:40 -07:00
|
|
|
_e_xdg_shell_cb_destroy,
|
2014-05-09 02:56:05 -07:00
|
|
|
_e_xdg_shell_cb_unstable_version,
|
|
|
|
_e_xdg_shell_cb_surface_get,
|
|
|
|
_e_xdg_shell_cb_popup_get,
|
|
|
|
_e_xdg_shell_cb_pong
|
|
|
|
};
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2016-04-18 12:37:22 -07:00
|
|
|
_e_xdg_shell_cb_unbind(struct wl_resource *resource)
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
2016-04-18 12:37:22 -07:00
|
|
|
struct wl_client *client = wl_resource_get_client(resource);
|
|
|
|
eina_hash_set(shell_resources, &client, NULL);
|
2014-05-09 02:56:05 -07:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static int
|
2014-05-09 02:56:05 -07:00
|
|
|
_e_xdg_shell_cb_dispatch(const void *implementation EINA_UNUSED, void *target, uint32_t opcode, const struct wl_message *message EINA_UNUSED, union wl_argument *args)
|
|
|
|
{
|
|
|
|
struct wl_resource *res;
|
|
|
|
|
|
|
|
if (!(res = target)) return 0;
|
|
|
|
|
2015-06-08 09:23:40 -07:00
|
|
|
if (opcode != 1)
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(res, WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2014-05-09 02:56:05 -07:00
|
|
|
"Must call use_unstable_version first");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (args[0].i != XDG_SERVER_VERSION)
|
|
|
|
{
|
2015-02-24 14:34:20 -08:00
|
|
|
wl_resource_post_error(res, WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2014-05-09 02:56:05 -07:00
|
|
|
"Incompatible versions. "
|
2015-02-24 14:34:20 -08:00
|
|
|
"Server: %d, Client: %d",
|
2014-05-09 02:56:05 -07:00
|
|
|
XDG_SERVER_VERSION, args[0].i);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-05-18 06:08:52 -07:00
|
|
|
wl_resource_set_implementation(res, &_e_xdg_shell_interface,
|
2016-04-18 12:37:22 -07:00
|
|
|
NULL, _e_xdg_shell_cb_unbind);
|
2014-05-09 02:56:05 -07:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2016-04-18 12:37:22 -07:00
|
|
|
_e_shell_cb_unbind(struct wl_resource *resource)
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
2016-04-18 12:37:22 -07:00
|
|
|
struct wl_client *client = wl_resource_get_client(resource);
|
|
|
|
eina_hash_set(shell_resources, &client, NULL);
|
2014-05-09 02:56:05 -07:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2015-05-18 06:08:52 -07:00
|
|
|
_e_shell_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t version, uint32_t id)
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
|
|
|
struct wl_resource *res;
|
|
|
|
|
2015-11-26 17:12:47 -08:00
|
|
|
if (!(res = wl_resource_create(client, &wl_shell_interface, version, id)))
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
|
|
|
wl_client_post_no_memory(client);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-04-18 12:37:22 -07:00
|
|
|
eina_hash_set(shell_resources, &client, res);
|
2015-05-18 06:08:52 -07:00
|
|
|
wl_resource_set_implementation(res, &_e_shell_interface,
|
2016-04-18 12:30:03 -07:00
|
|
|
NULL, _e_shell_cb_unbind);
|
2014-05-09 02:56:05 -07:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:34:20 -08:00
|
|
|
static void
|
2015-05-18 06:20:16 -07:00
|
|
|
_e_xdg_shell_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t version, uint32_t id)
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
|
|
|
struct wl_resource *res;
|
|
|
|
|
2015-11-26 17:12:47 -08:00
|
|
|
if (!(res = wl_resource_create(client, &xdg_shell_interface, version, id)))
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
|
|
|
wl_client_post_no_memory(client);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-04-18 12:37:22 -07:00
|
|
|
eina_hash_set(xdg_shell_resources, &client, res);
|
2015-05-18 06:08:52 -07:00
|
|
|
wl_resource_set_dispatcher(res, _e_xdg_shell_cb_dispatch, NULL,
|
2016-04-18 12:30:03 -07:00
|
|
|
NULL, NULL);
|
2014-05-09 02:56:05 -07:00
|
|
|
}
|
|
|
|
|
2015-05-07 12:13:10 -07:00
|
|
|
E_API E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Wl_Desktop_Shell" };
|
2014-05-09 02:56:05 -07:00
|
|
|
|
2015-05-07 12:13:10 -07:00
|
|
|
E_API void *
|
2014-05-09 02:56:05 -07:00
|
|
|
e_modapi_init(E_Module *m)
|
|
|
|
{
|
|
|
|
/* try to create global shell interface */
|
2015-08-13 13:05:57 -07:00
|
|
|
if (!wl_global_create(e_comp_wl->wl.disp, &wl_shell_interface, 1,
|
2016-04-18 12:30:03 -07:00
|
|
|
NULL, _e_shell_cb_bind))
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
2016-01-14 09:41:47 -08:00
|
|
|
ERR("Could not create shell global");
|
2014-05-09 02:56:05 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* try to create global xdg_shell interface */
|
2015-08-13 13:05:57 -07:00
|
|
|
if (!wl_global_create(e_comp_wl->wl.disp, &xdg_shell_interface, 1,
|
2016-04-18 12:30:03 -07:00
|
|
|
NULL, _e_xdg_shell_cb_bind))
|
2014-05-09 02:56:05 -07:00
|
|
|
{
|
2016-01-14 09:41:47 -08:00
|
|
|
ERR("Could not create xdg_shell global");
|
2014-05-09 02:56:05 -07:00
|
|
|
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
|
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;
|
|
|
|
}
|