use display protocol and add wayland supportdevs/devilhorns/ecore_drm2
parent
107872af91
commit
361bcd9bcd
8 changed files with 639 additions and 164 deletions
@ -0,0 +1,136 @@ |
||||
#define E_COMP_WL |
||||
#include "e_mod_main.h" |
||||
#include "wl_teamwork.h" |
||||
|
||||
static struct wl_resource *tw_resource; |
||||
static struct wl_global *tw_global; |
||||
|
||||
static void |
||||
tw_preload_uri(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED, |
||||
struct wl_resource *surface, const char *uri) |
||||
{ |
||||
E_Client *ec; |
||||
|
||||
ec = wl_resource_get_user_data(surface); |
||||
if (ec) |
||||
tw_link_detect(ec, uri); |
||||
} |
||||
|
||||
static void |
||||
tw_activate_uri(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED, |
||||
struct wl_resource *surface, const char *uri, wl_fixed_t x, wl_fixed_t y) |
||||
{ |
||||
E_Client *ec; |
||||
|
||||
ec = wl_resource_get_user_data(surface); |
||||
if (ec) |
||||
tw_link_show(ec, uri, wl_fixed_to_int(x), wl_fixed_to_int(y)); |
||||
} |
||||
|
||||
static void |
||||
tw_deactivate_uri(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED, |
||||
struct wl_resource *surface, const char *uri) |
||||
{ |
||||
E_Client *ec; |
||||
|
||||
ec = wl_resource_get_user_data(surface); |
||||
if (ec) |
||||
tw_link_hide(ec, uri); |
||||
} |
||||
|
||||
static void |
||||
tw_open_uri(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED, |
||||
struct wl_resource *surface, const char *uri) |
||||
{ |
||||
E_Client *ec; |
||||
|
||||
ec = wl_resource_get_user_data(surface); |
||||
if (ec) |
||||
tw_link_open(ec, uri); |
||||
} |
||||
|
||||
static const struct zwp_teamwork_interface tw_interface = |
||||
{ |
||||
tw_preload_uri, |
||||
tw_activate_uri, |
||||
tw_deactivate_uri, |
||||
tw_open_uri, |
||||
}; |
||||
|
||||
static void |
||||
wl_tw_cb_unbind(struct wl_resource *resource EINA_UNUSED) |
||||
{ |
||||
tw_resource = NULL; |
||||
} |
||||
|
||||
static void |
||||
wl_tw_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t version EINA_UNUSED, uint32_t id) |
||||
{ |
||||
struct wl_resource *res; |
||||
|
||||
if (!(res = wl_resource_create(client, &zwp_teamwork_interface, E_TW_VERSION, id))) |
||||
{ |
||||
ERR("Could not create zwp_teamwork_interface interface"); |
||||
wl_client_post_no_memory(client); |
||||
return; |
||||
} |
||||
|
||||
tw_resource = res; |
||||
wl_resource_set_implementation(res, &tw_interface, NULL, wl_tw_cb_unbind); |
||||
} |
||||
|
||||
static void |
||||
wl_tw_link_complete(E_Client *ec, const char *uri) |
||||
{ |
||||
if (e_object_is_del(E_OBJECT(ec))) return; |
||||
zwp_teamwork_send_completed_uri(tw_resource, ec->comp_data->surface, uri, 1); |
||||
} |
||||
|
||||
static void |
||||
wl_tw_link_invalid(E_Client *ec, const char *uri) |
||||
{ |
||||
if (e_object_is_del(E_OBJECT(ec))) return; |
||||
zwp_teamwork_send_completed_uri(tw_resource, ec->comp_data->surface, uri, 0); |
||||
} |
||||
|
||||
static void |
||||
wl_tw_link_progress(E_Client *ec, const char *uri, uint32_t pct) |
||||
{ |
||||
if (e_object_is_del(E_OBJECT(ec))) return; |
||||
zwp_teamwork_send_fetch_info(tw_resource, ec->comp_data->surface, uri, pct); |
||||
} |
||||
|
||||
static void |
||||
wl_tw_link_downloading(E_Client *ec, const char *uri) |
||||
{ |
||||
if (e_object_is_del(E_OBJECT(ec))) return; |
||||
zwp_teamwork_send_fetching_uri(tw_resource, ec->comp_data->surface, uri); |
||||
} |
||||
|
||||
EINTERN Eina_Bool |
||||
wl_tw_init(void) |
||||
{ |
||||
tw_global = wl_global_create(e_comp_wl->wl.disp, &zwp_teamwork_interface, E_TW_VERSION, |
||||
NULL, wl_tw_cb_bind); |
||||
if (!tw_global) |
||||
{ |
||||
ERR("Could not add zwp_teamwork to wayland globals"); |
||||
return EINA_FALSE; |
||||
} |
||||
tw_signal_link_complete[E_PIXMAP_TYPE_WL] = wl_tw_link_complete; |
||||
tw_signal_link_invalid[E_PIXMAP_TYPE_WL] = wl_tw_link_invalid; |
||||
tw_signal_link_progress[E_PIXMAP_TYPE_WL] = wl_tw_link_progress; |
||||
tw_signal_link_downloading[E_PIXMAP_TYPE_WL] = wl_tw_link_downloading; |
||||
return EINA_TRUE; |
||||
} |
||||
|
||||
EINTERN void |
||||
wl_tw_shutdown(void) |
||||
{ |
||||
E_FREE_FUNC(tw_resource, wl_resource_destroy); |
||||
E_FREE_FUNC(tw_global, wl_global_destroy); |
||||
tw_signal_link_complete[E_PIXMAP_TYPE_WL] = NULL; |
||||
tw_signal_link_invalid[E_PIXMAP_TYPE_WL] = NULL; |
||||
tw_signal_link_progress[E_PIXMAP_TYPE_WL] = NULL; |
||||
tw_signal_link_downloading[E_PIXMAP_TYPE_WL] = NULL; |
||||
} |
@ -0,0 +1,46 @@ |
||||
#include <stdlib.h> |
||||
#include <stdint.h> |
||||
#include "wayland-util.h" |
||||
|
||||
extern const struct wl_interface wl_surface_interface; |
||||
|
||||
static const struct wl_interface *types[] = { |
||||
&wl_surface_interface, |
||||
NULL, |
||||
&wl_surface_interface, |
||||
NULL, |
||||
NULL, |
||||
NULL, |
||||
&wl_surface_interface, |
||||
NULL, |
||||
&wl_surface_interface, |
||||
NULL, |
||||
&wl_surface_interface, |
||||
NULL, |
||||
&wl_surface_interface, |
||||
NULL, |
||||
NULL, |
||||
&wl_surface_interface, |
||||
NULL, |
||||
NULL, |
||||
}; |
||||
|
||||
static const struct wl_message zwp_teamwork_requests[] = { |
||||
{ "preload_uri", "os", types + 0 }, |
||||
{ "activate_uri", "osff", types + 2 }, |
||||
{ "deactivate_uri", "os", types + 6 }, |
||||
{ "open_uri", "os", types + 8 }, |
||||
}; |
||||
|
||||
static const struct wl_message zwp_teamwork_events[] = { |
||||
{ "fetching_uri", "os", types + 10 }, |
||||
{ "completed_uri", "osi", types + 12 }, |
||||
{ "fetch_info", "osu", types + 15 }, |
||||
}; |
||||
|
||||
WL_EXPORT const struct wl_interface zwp_teamwork_interface = { |
||||
"zwp_teamwork", 2, |
||||
4, zwp_teamwork_requests, |
||||
3, zwp_teamwork_events, |
||||
}; |
||||
|
@ -0,0 +1,93 @@ |
||||
#ifndef TEAMWORK_SERVER_PROTOCOL_H |
||||
#define TEAMWORK_SERVER_PROTOCOL_H |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
#include <stdint.h> |
||||
#include <stddef.h> |
||||
#include "wayland-server.h" |
||||
|
||||
struct wl_client; |
||||
struct wl_resource; |
||||
|
||||
struct wl_surface; |
||||
struct zwp_teamwork; |
||||
|
||||
extern const struct wl_interface zwp_teamwork_interface; |
||||
|
||||
struct zwp_teamwork_interface { |
||||
/**
|
||||
* preload_uri - (none) |
||||
* @surface: (none) |
||||
* @uri: (none) |
||||
*/ |
||||
void (*preload_uri)(struct wl_client *client, |
||||
struct wl_resource *resource, |
||||
struct wl_resource *surface, |
||||
const char *uri); |
||||
/**
|
||||
* activate_uri - (none) |
||||
* @surface: (none) |
||||
* @uri: (none) |
||||
* @x: surface local coords |
||||
* @y: surface local coords |
||||
*/ |
||||
void (*activate_uri)(struct wl_client *client, |
||||
struct wl_resource *resource, |
||||
struct wl_resource *surface, |
||||
const char *uri, |
||||
wl_fixed_t x, |
||||
wl_fixed_t y); |
||||
/**
|
||||
* deactivate_uri - (none) |
||||
* @surface: (none) |
||||
* @uri: (none) |
||||
*/ |
||||
void (*deactivate_uri)(struct wl_client *client, |
||||
struct wl_resource *resource, |
||||
struct wl_resource *surface, |
||||
const char *uri); |
||||
/**
|
||||
* open_uri - (none) |
||||
* @surface: (none) |
||||
* @uri: (none) |
||||
*/ |
||||
void (*open_uri)(struct wl_client *client, |
||||
struct wl_resource *resource, |
||||
struct wl_resource *surface, |
||||
const char *uri); |
||||
}; |
||||
|
||||
#define ZWP_TEAMWORK_FETCHING_URI 0 |
||||
#define ZWP_TEAMWORK_COMPLETED_URI 1 |
||||
#define ZWP_TEAMWORK_FETCH_INFO 2 |
||||
|
||||
#define ZWP_TEAMWORK_FETCHING_URI_SINCE_VERSION 1 |
||||
#define ZWP_TEAMWORK_COMPLETED_URI_SINCE_VERSION 1 |
||||
#define ZWP_TEAMWORK_FETCH_INFO_SINCE_VERSION 1 |
||||
|
||||
static inline void |
||||
zwp_teamwork_send_fetching_uri(struct wl_resource *resource_, struct wl_resource *surface, const char *uri) |
||||
{ |
||||
wl_resource_post_event(resource_, ZWP_TEAMWORK_FETCHING_URI, surface, uri); |
||||
} |
||||
|
||||
static inline void |
||||
zwp_teamwork_send_completed_uri(struct wl_resource *resource_, struct wl_resource *surface, const char *uri, int32_t valid) |
||||
{ |
||||
wl_resource_post_event(resource_, ZWP_TEAMWORK_COMPLETED_URI, surface, uri, valid); |
||||
} |
||||
|
||||
static inline void |
||||
zwp_teamwork_send_fetch_info(struct wl_resource *resource_, struct wl_resource *surface, const char *uri, uint32_t progress) |
||||
{ |
||||
wl_resource_post_event(resource_, ZWP_TEAMWORK_FETCH_INFO, surface, uri, progress); |
||||
} |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
#endif |
@ -0,0 +1,141 @@ |
||||
#define E_COMP_X |
||||
#include "e_mod_main.h" |
||||
|
||||
enum |
||||
{ |
||||
TEAMWORK_PRELOAD, |
||||
TEAMWORK_ACTIVATE, |
||||
TEAMWORK_DEACTIVATE, |
||||
TEAMWORK_OPEN, |
||||
TEAMWORK_NOPE, |
||||
}; |
||||
|
||||
enum |
||||
{ |
||||
TEAMWORK_COMPLETED, |
||||
TEAMWORK_PROGRESS, |
||||
TEAMWORK_STARTED, |
||||
}; |
||||
|
||||
static Ecore_Event_Handler *handler; |
||||
static Ecore_X_Atom atoms[4]; |
||||
static Ecore_X_Atom server_atoms[3]; |
||||
static Ecore_X_Atom prop; |
||||
|
||||
static Eina_Bool |
||||
x11_message_handler(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_X_Event_Client_Message *ev) |
||||
{ |
||||
E_Client *ec; |
||||
int i; |
||||
char *uri; |
||||
|
||||
ec = e_pixmap_find_client(E_PIXMAP_TYPE_X, ev->win); |
||||
if (!ec) return ECORE_CALLBACK_RENEW; |
||||
for (i = 0; i < TEAMWORK_NOPE; i++) |
||||
if (ev->message_type == atoms[i]) break; |
||||
if (i == TEAMWORK_NOPE) return ECORE_CALLBACK_RENEW; |
||||
|
||||
uri = ecore_x_window_prop_string_get(ev->win, prop); |
||||
if (!uri) return ECORE_CALLBACK_RENEW; |
||||
if (ev->message_type == atoms[TEAMWORK_PRELOAD]) |
||||
/*
|
||||
format = 32 |
||||
data.l[0] = version |
||||
*/ |
||||
tw_link_detect(ec, uri); |
||||
else if (ev->message_type == atoms[TEAMWORK_ACTIVATE]) |
||||
/*
|
||||
format = 32 |
||||
data.l[0] = version |
||||
data.l[1] = window_x |
||||
data.l[2] = window_y |
||||
*/ |
||||
tw_link_show(ec, uri, ev->data.l[1], ev->data.l[2]); |
||||
else if (ev->message_type == atoms[TEAMWORK_DEACTIVATE]) |
||||
/*
|
||||
format = 32 |
||||
data.l[0] = version |
||||
*/ |
||||
tw_link_hide(ec, uri); |
||||
else if (ev->message_type == atoms[TEAMWORK_OPEN]) |
||||
/*
|
||||
format = 32 |
||||
data.l[0] = version |
||||
*/ |
||||
tw_link_open(ec, uri); |
||||
free(uri); |
||||
return ECORE_CALLBACK_RENEW; |
||||
} |
||||
|
||||
static void |
||||
x11_tw_link_complete(E_Client *ec, const char *uri EINA_UNUSED) |
||||
{ |
||||
if (e_object_is_del(E_OBJECT(ec))) return; |
||||
ecore_x_client_message32_send(e_client_util_win_get(ec), server_atoms[TEAMWORK_COMPLETED], |
||||
ECORE_X_EVENT_MASK_WINDOW_MANAGE | ECORE_X_EVENT_MASK_WINDOW_CHILD_CONFIGURE, E_TW_VERSION, 1, 0, 0, 0); |
||||
} |
||||
|
||||
static void |
||||
x11_tw_link_invalid(E_Client *ec, const char *uri EINA_UNUSED) |
||||
{ |
||||
if (e_object_is_del(E_OBJECT(ec))) return; |
||||
ecore_x_client_message32_send(e_client_util_win_get(ec), server_atoms[TEAMWORK_COMPLETED], |
||||
ECORE_X_EVENT_MASK_WINDOW_MANAGE | ECORE_X_EVENT_MASK_WINDOW_CHILD_CONFIGURE, E_TW_VERSION, 0, 0, 0, 0); |
||||
} |
||||
|
||||
static void |
||||
x11_tw_link_progress(E_Client *ec, const char *uri EINA_UNUSED, uint32_t pct) |
||||
{ |
||||
if (e_object_is_del(E_OBJECT(ec))) return; |
||||
ecore_x_client_message32_send(e_client_util_win_get(ec), server_atoms[TEAMWORK_PROGRESS], |
||||
ECORE_X_EVENT_MASK_WINDOW_MANAGE | ECORE_X_EVENT_MASK_WINDOW_CHILD_CONFIGURE, E_TW_VERSION, pct, 0, 0, 0); |
||||
} |
||||
|
||||
static void |
||||
x11_tw_link_downloading(E_Client *ec, const char *uri EINA_UNUSED) |
||||
{ |
||||
if (e_object_is_del(E_OBJECT(ec))) return; |
||||
ecore_x_client_message32_send(e_client_util_win_get(ec), server_atoms[TEAMWORK_STARTED], |
||||
ECORE_X_EVENT_MASK_WINDOW_MANAGE | ECORE_X_EVENT_MASK_WINDOW_CHILD_CONFIGURE, E_TW_VERSION, 0, 0, 0, 0); |
||||
} |
||||
|
||||
EINTERN Eina_Bool |
||||
x11_tw_init(void) |
||||
{ |
||||
const char *atom_names[] = |
||||
{ |
||||
"_TEAMWORK_PRELOAD", |
||||
"_TEAMWORK_ACTIVATE", |
||||
"_TEAMWORK_DEACTIVATE", |
||||
"_TEAMWORK_OPEN", |
||||
"_TEAMWORK_COMPLETED", |
||||
"_TEAMWORK_PROGRESS", |
||||
"_TEAMWORK_STARTED", |
||||
"_TEAMWORK_PROP", |
||||
}; |
||||
Ecore_X_Atom at[EINA_C_ARRAY_LENGTH(atom_names)]; |
||||
int i; |
||||
|
||||
ecore_x_atoms_get(atom_names, EINA_C_ARRAY_LENGTH(atom_names), at); |
||||
for (i = 0; i < 4; i++) |
||||
atoms[i] = at[i]; |
||||
for (i = 4; i < 7; i++) |
||||
server_atoms[i] = at[i]; |
||||
prop = at[7]; |
||||
handler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, (Ecore_Event_Handler_Cb)x11_message_handler, NULL); |
||||
tw_signal_link_complete[E_PIXMAP_TYPE_X] = x11_tw_link_complete; |
||||
tw_signal_link_invalid[E_PIXMAP_TYPE_X] = x11_tw_link_invalid; |
||||
tw_signal_link_progress[E_PIXMAP_TYPE_X] = x11_tw_link_progress; |
||||
tw_signal_link_downloading[E_PIXMAP_TYPE_X] = x11_tw_link_downloading; |
||||
return EINA_TRUE; |
||||
} |
||||
|
||||
EINTERN void |
||||
x11_tw_shutdown(void) |
||||
{ |
||||
E_FREE_FUNC(handler, ecore_event_handler_del); |
||||
tw_signal_link_complete[E_PIXMAP_TYPE_X] = NULL; |
||||
tw_signal_link_invalid[E_PIXMAP_TYPE_X] = NULL; |
||||
tw_signal_link_progress[E_PIXMAP_TYPE_X] = NULL; |
||||
tw_signal_link_downloading[E_PIXMAP_TYPE_X] = NULL; |
||||
} |
@ -0,0 +1,39 @@ |
||||
<protocol name="teamwork"> |
||||
|
||||
<interface name="zwp_teamwork" version="2"> |
||||
<request name="preload_uri"> |
||||
<arg name="surface" type="object" interface="wl_surface"/> |
||||
<arg name="uri" type="string"/> |
||||
</request> |
||||
<request name="activate_uri"> |
||||
<arg name="surface" type="object" interface="wl_surface"/> |
||||
<arg name="uri" type="string"/> |
||||
<arg name="x" type="fixed" summary="surface local coords"/> |
||||
<arg name="y" type="fixed" summary="surface local coords"/> |
||||
</request> |
||||
<request name="deactivate_uri"> |
||||
<arg name="surface" type="object" interface="wl_surface"/> |
||||
<arg name="uri" type="string"/> |
||||
</request> |
||||
<request name="open_uri"> |
||||
<arg name="surface" type="object" interface="wl_surface"/> |
||||
<arg name="uri" type="string"/> |
||||
</request> |
||||
|
||||
<event name="fetching_uri"> |
||||
<arg name="surface" type="object" interface="wl_surface"/> |
||||
<arg name="uri" type="string"/> |
||||
</event> |
||||
<event name="completed_uri"> |
||||
<arg name="surface" type="object" interface="wl_surface"/> |
||||
<arg name="uri" type="string"/> |
||||
<arg name="valid" type="int" summary="1 if uri can be displayed, else 0"/> |
||||
</event> |
||||
<event name="fetch_info"> |
||||
<arg name="surface" type="object" interface="wl_surface"/> |
||||
<arg name="uri" type="string"/> |
||||
<arg name="progress" type="uint" summary="percentage of download"/> |
||||
</event> |
||||
</interface> |
||||
|
||||
</protocol> |
Loading…
Reference in new issue