[digesting_libdecor] merge plugin_gtk's wl_registry instance with the main one
parent
30ece62d04
commit
54039259ad
|
|
@ -71,7 +71,6 @@ const struct xdg_wm_base_listener xdg_wm_base_listener;
|
||||||
const struct wl_callback_listener init_wl_display_callback_listener;
|
const struct wl_callback_listener init_wl_display_callback_listener;
|
||||||
const struct wl_buffer_listener buffer_listener;
|
const struct wl_buffer_listener buffer_listener;
|
||||||
const struct wl_callback_listener shm_callback_listener;
|
const struct wl_callback_listener shm_callback_listener;
|
||||||
const struct wl_registry_listener registry_listener;
|
|
||||||
const struct wl_callback_listener globals_callback_listener;
|
const struct wl_callback_listener globals_callback_listener;
|
||||||
|
|
||||||
struct libdecor_plugin_interface gtk_plugin_iface;
|
struct libdecor_plugin_interface gtk_plugin_iface;
|
||||||
|
|
@ -91,7 +90,7 @@ GL_FUNCS_XLIST(X)
|
||||||
static Ctx ctx = {0};
|
static Ctx ctx = {0};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
wlevent__wl_registry_global(void *data, struct wl_registry *registry,
|
wlevent__wl_registry_global(void *data, struct wl_registry *wl_registry,
|
||||||
uint32_t name, const char *interface,
|
uint32_t name, const char *interface,
|
||||||
uint32_t version){
|
uint32_t version){
|
||||||
/* (1) Appendix A: wl_registry::bind
|
/* (1) Appendix A: wl_registry::bind
|
||||||
|
|
@ -100,7 +99,8 @@ wlevent__wl_registry_global(void *data, struct wl_registry *registry,
|
||||||
|
|
||||||
if (strcmp(interface, "wl_compositor") == 0){
|
if (strcmp(interface, "wl_compositor") == 0){
|
||||||
ctx.wl_compositor = (struct wl_compositor*)
|
ctx.wl_compositor = (struct wl_compositor*)
|
||||||
wl_registry_bind(registry, name, &wl_compositor_interface, 1);
|
wl_registry_bind(wl_registry, name, &wl_compositor_interface,
|
||||||
|
MIN(version, 4));
|
||||||
}
|
}
|
||||||
else if (!strcmp(interface, xdg_wm_base_interface.name)){
|
else if (!strcmp(interface, xdg_wm_base_interface.name)){
|
||||||
init_xdg_wm_base(name, version);
|
init_xdg_wm_base(name, version);
|
||||||
|
|
@ -108,57 +108,31 @@ wlevent__wl_registry_global(void *data, struct wl_registry *registry,
|
||||||
else if (!strcmp(interface, zxdg_decoration_manager_v1_interface.name)){
|
else if (!strcmp(interface, zxdg_decoration_manager_v1_interface.name)){
|
||||||
const char *force_csd = getenv("LIBDECOR_FORCE_CSD");
|
const char *force_csd = getenv("LIBDECOR_FORCE_CSD");
|
||||||
if (!(force_csd && atoi(force_csd))){
|
if (!(force_csd && atoi(force_csd))){
|
||||||
ctx.decoration_manager = wl_registry_bind(ctx.wl_registry, name,
|
ctx.decoration_manager = wl_registry_bind(wl_registry, name,
|
||||||
&zxdg_decoration_manager_v1_interface,
|
&zxdg_decoration_manager_v1_interface,
|
||||||
MIN(version,2));
|
MIN(version,2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (strcmp(interface, "wl_subcompositor") == 0){
|
||||||
|
init_wl_subcompositor(name, version);
|
||||||
|
}
|
||||||
|
else if (strcmp(interface, "wl_shm") == 0){
|
||||||
|
init_wl_shm(name, version);
|
||||||
|
}
|
||||||
|
else if (strcmp(interface, "wl_seat") == 0){
|
||||||
|
init_wl_seat(name, version);
|
||||||
|
}
|
||||||
|
else if (strcmp(interface, "wl_output") == 0){
|
||||||
|
init_wl_output(name, version);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (1) Appendix A: wl_registry::global_remove */
|
/* (1) Appendix A: wl_registry::global_remove */
|
||||||
static void
|
static void
|
||||||
wlevent__wl_registry_global_remove(void *data, struct wl_registry *registry,
|
wlevent__wl_registry_global_remove(void *data, struct wl_registry *registry,
|
||||||
uint32_t name){}
|
uint32_t name){
|
||||||
|
|
||||||
const struct wl_registry_listener wl_registry_listener = {
|
|
||||||
wlevent__wl_registry_global,
|
|
||||||
wlevent__wl_registry_global_remove,
|
|
||||||
};
|
|
||||||
|
|
||||||
static void
|
|
||||||
registry_handle_global(void *user_data,
|
|
||||||
struct wl_registry *wl_registry,
|
|
||||||
uint32_t id,
|
|
||||||
const char *interface,
|
|
||||||
uint32_t version)
|
|
||||||
{
|
|
||||||
if (strcmp(interface, "wl_compositor") == 0){
|
|
||||||
init_wl_compositor(id, version);
|
|
||||||
}
|
|
||||||
else if (strcmp(interface, "wl_subcompositor") == 0){
|
|
||||||
init_wl_subcompositor(id, version);
|
|
||||||
}
|
|
||||||
else if (strcmp(interface, "wl_shm") == 0){
|
|
||||||
init_wl_shm(id, version);
|
|
||||||
}
|
|
||||||
else if (strcmp(interface, "wl_seat") == 0){
|
|
||||||
init_wl_seat(id, version);
|
|
||||||
}
|
|
||||||
else if (strcmp(interface, "wl_output") == 0){
|
|
||||||
init_wl_output(id, version);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
registry_handle_global_remove(void *user_data,
|
|
||||||
struct wl_registry *wl_registry,
|
|
||||||
uint32_t name)
|
|
||||||
{
|
|
||||||
struct libdecor_plugin_gtk *plugin_gtk = user_data;
|
|
||||||
struct output *output;
|
struct output *output;
|
||||||
|
wl_list_for_each(output, &ctx.plugin_gtk->output_list, link) {
|
||||||
wl_list_for_each(output, &plugin_gtk->output_list, link) {
|
|
||||||
if (output->id == name) {
|
if (output->id == name) {
|
||||||
output_removed(output);
|
output_removed(output);
|
||||||
break;
|
break;
|
||||||
|
|
@ -166,9 +140,9 @@ registry_handle_global_remove(void *user_data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct wl_registry_listener registry_listener = {
|
const struct wl_registry_listener wl_registry_listener = {
|
||||||
registry_handle_global,
|
wlevent__wl_registry_global,
|
||||||
registry_handle_global_remove
|
wlevent__wl_registry_global_remove,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* (libdecor.h) libdecor_interface::error " An error event " */
|
/* (libdecor.h) libdecor_interface::error " An error event " */
|
||||||
|
|
@ -317,18 +291,13 @@ int main(){
|
||||||
&init_wl_display_callback_listener,
|
&init_wl_display_callback_listener,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
ctx.plugin_gtk->wl_registry = wl_display_get_registry(ctx.wl_display);
|
|
||||||
wl_registry_add_listener(ctx.plugin_gtk->wl_registry,
|
|
||||||
®istry_listener, ctx.plugin_gtk);
|
|
||||||
|
|
||||||
ctx.plugin_gtk->globals_callback = wl_display_sync(ctx.wl_display);
|
ctx.plugin_gtk->globals_callback = wl_display_sync(ctx.wl_display);
|
||||||
wl_callback_add_listener(ctx.plugin_gtk->globals_callback,
|
wl_callback_add_listener(ctx.plugin_gtk->globals_callback,
|
||||||
&globals_callback_listener,
|
&globals_callback_listener,
|
||||||
ctx.plugin_gtk);
|
ctx.plugin_gtk);
|
||||||
wl_display_roundtrip(ctx.wl_display);
|
wl_display_roundtrip(ctx.wl_display);
|
||||||
|
|
||||||
if (ctx.plugin_gtk->wl_compositor != 0 &&
|
if (ctx.plugin_gtk->wl_subcompositor != 0 &&
|
||||||
ctx.plugin_gtk->wl_subcompositor != 0 &&
|
|
||||||
ctx.plugin_gtk->wl_shm != 0){
|
ctx.plugin_gtk->wl_shm != 0){
|
||||||
ctx.plugin = &ctx.plugin_gtk->plugin;
|
ctx.plugin = &ctx.plugin_gtk->plugin;
|
||||||
}
|
}
|
||||||
|
|
@ -2640,7 +2609,6 @@ libdecor_plugin_gtk_destroy(struct libdecor_plugin *plugin)
|
||||||
wl_callback_destroy(plugin_gtk->globals_callback_shm);
|
wl_callback_destroy(plugin_gtk->globals_callback_shm);
|
||||||
if (plugin_gtk->shm_callback)
|
if (plugin_gtk->shm_callback)
|
||||||
wl_callback_destroy(plugin_gtk->shm_callback);
|
wl_callback_destroy(plugin_gtk->shm_callback);
|
||||||
wl_registry_destroy(plugin_gtk->wl_registry);
|
|
||||||
|
|
||||||
wl_list_for_each_safe(seat, seat_tmp, &plugin_gtk->seat_list, link) {
|
wl_list_for_each_safe(seat, seat_tmp, &plugin_gtk->seat_list, link) {
|
||||||
struct cursor_output *cursor_output, *tmp;
|
struct cursor_output *cursor_output, *tmp;
|
||||||
|
|
@ -2682,8 +2650,6 @@ libdecor_plugin_gtk_destroy(struct libdecor_plugin *plugin)
|
||||||
if (plugin_gtk->wl_shm)
|
if (plugin_gtk->wl_shm)
|
||||||
wl_shm_destroy(plugin_gtk->wl_shm);
|
wl_shm_destroy(plugin_gtk->wl_shm);
|
||||||
|
|
||||||
if (plugin_gtk->wl_compositor)
|
|
||||||
wl_compositor_destroy(plugin_gtk->wl_compositor);
|
|
||||||
if (plugin_gtk->wl_subcompositor)
|
if (plugin_gtk->wl_subcompositor)
|
||||||
wl_subcompositor_destroy(plugin_gtk->wl_subcompositor);
|
wl_subcompositor_destroy(plugin_gtk->wl_subcompositor);
|
||||||
|
|
||||||
|
|
@ -3087,7 +3053,7 @@ create_surface_subsurface_pair(struct libdecor_frame_gtk *frame_gtk,
|
||||||
{
|
{
|
||||||
struct libdecor_plugin_gtk *plugin_gtk = frame_gtk->plugin_gtk;
|
struct libdecor_plugin_gtk *plugin_gtk = frame_gtk->plugin_gtk;
|
||||||
struct libdecor_frame *frame = &frame_gtk->frame;
|
struct libdecor_frame *frame = &frame_gtk->frame;
|
||||||
struct wl_compositor *wl_compositor = plugin_gtk->wl_compositor;
|
struct wl_compositor *wl_compositor = ctx.wl_compositor;
|
||||||
struct wl_subcompositor *wl_subcompositor = plugin_gtk->wl_subcompositor;
|
struct wl_subcompositor *wl_subcompositor = plugin_gtk->wl_subcompositor;
|
||||||
struct wl_surface *wl_surface;
|
struct wl_surface *wl_surface;
|
||||||
struct wl_surface *parent;
|
struct wl_surface *parent;
|
||||||
|
|
@ -3535,7 +3501,7 @@ set_component_input_region(struct libdecor_frame_gtk *frame_gtk,
|
||||||
* the input region is the outer surface size minus the inner
|
* the input region is the outer surface size minus the inner
|
||||||
* content size
|
* content size
|
||||||
*/
|
*/
|
||||||
input_region = wl_compositor_create_region(frame_gtk->plugin_gtk->wl_compositor);
|
input_region = wl_compositor_create_region(ctx.wl_compositor);
|
||||||
wl_region_add(input_region, 0, 0,
|
wl_region_add(input_region, 0, 0,
|
||||||
component_width, component_height);
|
component_width, component_height);
|
||||||
wl_region_subtract(input_region, -component_x, -component_y,
|
wl_region_subtract(input_region, -component_x, -component_y,
|
||||||
|
|
@ -4037,19 +4003,10 @@ struct libdecor_plugin_interface gtk_plugin_iface = {
|
||||||
.frame_get_border_size = libdecor_plugin_gtk_frame_get_border_size,
|
.frame_get_border_size = libdecor_plugin_gtk_frame_get_border_size,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
|
||||||
init_wl_compositor(uint32_t id, uint32_t version){
|
|
||||||
ctx.plugin_gtk->wl_compositor =
|
|
||||||
wl_registry_bind(ctx.plugin_gtk->wl_registry,
|
|
||||||
id, &wl_compositor_interface,
|
|
||||||
MIN(version, 4));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
init_wl_subcompositor(uint32_t id, uint32_t version){
|
init_wl_subcompositor(uint32_t id, uint32_t version){
|
||||||
ctx.plugin_gtk->wl_subcompositor =
|
ctx.plugin_gtk->wl_subcompositor =
|
||||||
wl_registry_bind(ctx.plugin_gtk->wl_registry,
|
wl_registry_bind(ctx.wl_registry, id, &wl_subcompositor_interface, 1);
|
||||||
id, &wl_subcompositor_interface, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -4089,8 +4046,7 @@ init_wl_shm(uint32_t id, uint32_t version){
|
||||||
struct wl_display *wl_display = ctx.wl_display;
|
struct wl_display *wl_display = ctx.wl_display;
|
||||||
|
|
||||||
ctx.plugin_gtk->wl_shm =
|
ctx.plugin_gtk->wl_shm =
|
||||||
wl_registry_bind(ctx.plugin_gtk->wl_registry,
|
wl_registry_bind(ctx.wl_registry, id, &wl_shm_interface, 1);
|
||||||
id, &wl_shm_interface, 1);
|
|
||||||
wl_shm_add_listener(ctx.plugin_gtk->wl_shm, &shm_listener, ctx.plugin_gtk);
|
wl_shm_add_listener(ctx.plugin_gtk->wl_shm, &shm_listener, ctx.plugin_gtk);
|
||||||
|
|
||||||
ctx.plugin_gtk->globals_callback_shm = wl_display_sync(wl_display);
|
ctx.plugin_gtk->globals_callback_shm = wl_display_sync(wl_display);
|
||||||
|
|
@ -4145,7 +4101,7 @@ static struct wl_surface_listener cursor_surface_listener = {
|
||||||
static void
|
static void
|
||||||
ensure_cursor_surface(struct seat *seat)
|
ensure_cursor_surface(struct seat *seat)
|
||||||
{
|
{
|
||||||
struct wl_compositor *wl_compositor = seat->plugin_gtk->wl_compositor;
|
struct wl_compositor *wl_compositor = ctx.wl_compositor;
|
||||||
|
|
||||||
if (seat->cursor_surface)
|
if (seat->cursor_surface)
|
||||||
return;
|
return;
|
||||||
|
|
@ -4918,9 +4874,7 @@ init_wl_seat(uint32_t id, uint32_t version){
|
||||||
seat->plugin_gtk = ctx.plugin_gtk;
|
seat->plugin_gtk = ctx.plugin_gtk;
|
||||||
wl_list_init(&seat->cursor_outputs);
|
wl_list_init(&seat->cursor_outputs);
|
||||||
wl_list_insert(&ctx.plugin_gtk->seat_list, &seat->link);
|
wl_list_insert(&ctx.plugin_gtk->seat_list, &seat->link);
|
||||||
seat->wl_seat =
|
seat->wl_seat = wl_registry_bind(ctx.wl_registry, id, &wl_seat_interface, 3);
|
||||||
wl_registry_bind(ctx.plugin_gtk->wl_registry,
|
|
||||||
id, &wl_seat_interface, 3);
|
|
||||||
wl_seat_add_listener(seat->wl_seat, &seat_listener, seat);
|
wl_seat_add_listener(seat->wl_seat, &seat_listener, seat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5002,7 +4956,7 @@ init_wl_output(uint32_t id, uint32_t version){
|
||||||
wl_list_insert(&ctx.plugin_gtk->output_list, &output->link);
|
wl_list_insert(&ctx.plugin_gtk->output_list, &output->link);
|
||||||
output->id = id;
|
output->id = id;
|
||||||
output->wl_output =
|
output->wl_output =
|
||||||
wl_registry_bind(ctx.plugin_gtk->wl_registry,
|
wl_registry_bind(ctx.wl_registry,
|
||||||
id, &wl_output_interface,
|
id, &wl_output_interface,
|
||||||
MIN (version, 3));
|
MIN (version, 3));
|
||||||
wl_proxy_set_tag((struct wl_proxy *) output->wl_output,
|
wl_proxy_set_tag((struct wl_proxy *) output->wl_output,
|
||||||
|
|
|
||||||
|
|
@ -438,9 +438,7 @@ struct libdecor_plugin_gtk {
|
||||||
struct wl_callback *globals_callback;
|
struct wl_callback *globals_callback;
|
||||||
struct wl_callback *globals_callback_shm;
|
struct wl_callback *globals_callback_shm;
|
||||||
|
|
||||||
struct wl_registry *wl_registry;
|
|
||||||
struct wl_subcompositor *wl_subcompositor;
|
struct wl_subcompositor *wl_subcompositor;
|
||||||
struct wl_compositor *wl_compositor;
|
|
||||||
|
|
||||||
struct wl_shm *wl_shm;
|
struct wl_shm *wl_shm;
|
||||||
struct wl_callback *shm_callback;
|
struct wl_callback *shm_callback;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue