Rename wlr_primary_selection to wlr_gtk_primary_selection

This commit is contained in:
emersion 2018-11-23 11:58:56 +01:00
parent c70b8f64b7
commit 811a4d997b
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
15 changed files with 133 additions and 133 deletions

View File

@ -15,7 +15,7 @@
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_presentation_time.h>
#include <wlr/types/wlr_primary_selection.h>
#include <wlr/types/wlr_gtk_primary_selection.h>
#include <wlr/types/wlr_screencopy_v1.h>
#include <wlr/types/wlr_screenshooter.h>
#include <wlr/types/wlr_text_input_v3.h>
@ -51,7 +51,7 @@ struct roots_desktop {
struct wlr_export_dmabuf_manager_v1 *export_dmabuf_manager_v1;
struct wlr_server_decoration_manager *server_decoration_manager;
struct wlr_xdg_decoration_manager_v1 *xdg_decoration_manager;
struct wlr_primary_selection_device_manager *primary_selection_device_manager;
struct wlr_gtk_primary_selection_device_manager *primary_selection_device_manager;
struct wlr_idle *idle;
struct wlr_idle_inhibit_manager_v1 *idle_inhibit;
struct wlr_input_inhibit_manager *input_inhibit;

View File

@ -7,6 +7,7 @@ install_headers(
'wlr_export_dmabuf_v1.h',
'wlr_gamma_control_v1.h',
'wlr_gamma_control.h',
'wlr_gtk_primary_selection.h',
'wlr_idle_inhibit_v1.h',
'wlr_idle.h',
'wlr_input_device.h',
@ -22,7 +23,6 @@ install_headers(
'wlr_output.h',
'wlr_pointer.h',
'wlr_presentation_time.h',
'wlr_primary_selection.h',
'wlr_region.h',
'wlr_screencopy_v1.h',
'wlr_screenshooter.h',

View File

@ -0,0 +1,70 @@
/*
* This an unstable interface of wlroots. No guarantees are made regarding the
* future consistency of this API.
*/
#ifndef WLR_USE_UNSTABLE
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
#endif
#ifndef WLR_TYPES_WLR_GTK_PRIMARY_SELECTION_H
#define WLR_TYPES_WLR_GTK_PRIMARY_SELECTION_H
#include <wayland-server.h>
#include <wlr/types/wlr_seat.h>
struct wlr_gtk_primary_selection_device_manager {
struct wl_global *global;
struct wl_list resources;
struct wl_listener display_destroy;
struct {
struct wl_signal destroy;
} events;
void *data;
};
struct wlr_gtk_primary_selection_source {
// source metadata
struct wl_array mime_types;
// source implementation
void (*send)(struct wlr_gtk_primary_selection_source *source,
const char *mime_type, int32_t fd);
void (*cancel)(struct wlr_gtk_primary_selection_source *source);
// source status
struct wlr_seat_client *seat_client;
struct {
struct wl_signal destroy;
} events;
void *data;
};
struct wlr_gtk_primary_selection_offer {
struct wl_resource *resource;
struct wlr_gtk_primary_selection_source *source;
struct wl_listener source_destroy;
void *data;
};
struct wlr_gtk_primary_selection_device_manager *
wlr_gtk_primary_selection_device_manager_create(struct wl_display *display);
void wlr_gtk_primary_selection_device_manager_destroy(
struct wlr_gtk_primary_selection_device_manager *manager);
void wlr_seat_client_send_gtk_primary_selection(struct wlr_seat_client *seat_client);
void wlr_seat_set_gtk_primary_selection(struct wlr_seat *seat,
struct wlr_gtk_primary_selection_source *source, uint32_t serial);
void wlr_gtk_primary_selection_source_init(
struct wlr_gtk_primary_selection_source *source);
void wlr_gtk_primary_selection_source_finish(
struct wlr_gtk_primary_selection_source *source);
#endif

View File

@ -1,70 +0,0 @@
/*
* This an unstable interface of wlroots. No guarantees are made regarding the
* future consistency of this API.
*/
#ifndef WLR_USE_UNSTABLE
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
#endif
#ifndef WLR_TYPES_WLR_PRIMARY_SELECTION_H
#define WLR_TYPES_WLR_PRIMARY_SELECTION_H
#include <wayland-server.h>
#include <wlr/types/wlr_seat.h>
struct wlr_primary_selection_device_manager {
struct wl_global *global;
struct wl_list resources;
struct wl_listener display_destroy;
struct {
struct wl_signal destroy;
} events;
void *data;
};
struct wlr_primary_selection_source {
// source metadata
struct wl_array mime_types;
// source implementation
void (*send)(struct wlr_primary_selection_source *source,
const char *mime_type, int32_t fd);
void (*cancel)(struct wlr_primary_selection_source *source);
// source status
struct wlr_seat_client *seat_client;
struct {
struct wl_signal destroy;
} events;
void *data;
};
struct wlr_primary_selection_offer {
struct wl_resource *resource;
struct wlr_primary_selection_source *source;
struct wl_listener source_destroy;
void *data;
};
struct wlr_primary_selection_device_manager *
wlr_primary_selection_device_manager_create(struct wl_display *display);
void wlr_primary_selection_device_manager_destroy(
struct wlr_primary_selection_device_manager *manager);
void wlr_seat_client_send_primary_selection(struct wlr_seat_client *seat_client);
void wlr_seat_set_primary_selection(struct wlr_seat *seat,
struct wlr_primary_selection_source *source, uint32_t serial);
void wlr_primary_selection_source_init(
struct wlr_primary_selection_source *source);
void wlr_primary_selection_source_finish(
struct wlr_primary_selection_source *source);
#endif

View File

@ -194,7 +194,7 @@ struct wlr_seat {
struct wlr_data_source *selection_source;
uint32_t selection_serial;
struct wlr_primary_selection_source *primary_selection_source;
struct wlr_gtk_primary_selection_source *primary_selection_source;
uint32_t primary_selection_serial;
// `drag` goes away before `drag_source`, when the implicit grab ends

View File

@ -62,7 +62,7 @@ int xwm_handle_xfixes_selection_notify(struct wlr_xwm *xwm,
xcb_xfixes_selection_notify_event_t *event);
bool data_source_is_xwayland(struct wlr_data_source *wlr_source);
bool primary_selection_source_is_xwayland(
struct wlr_primary_selection_source *wlr_source);
struct wlr_gtk_primary_selection_source *wlr_source);
void xwm_seat_handle_start_drag(struct wlr_xwm *xwm, struct wlr_drag *drag);

View File

@ -16,7 +16,7 @@
#include <wlr/types/wlr_layer_shell_v1.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_pointer_constraints_v1.h>
#include <wlr/types/wlr_primary_selection.h>
#include <wlr/types/wlr_gtk_primary_selection.h>
#include <wlr/types/wlr_server_decoration.h>
#include <wlr/types/wlr_wl_shell.h>
#include <wlr/types/wlr_xcursor_manager.h>
@ -956,7 +956,7 @@ struct roots_desktop *desktop_create(struct roots_server *server,
desktop->server_decoration_manager,
WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT);
desktop->primary_selection_device_manager =
wlr_primary_selection_device_manager_create(server->wl_display);
wlr_gtk_primary_selection_device_manager_create(server->wl_display);
desktop->idle = wlr_idle_create(server->wl_display);
desktop->idle_inhibit = wlr_idle_inhibit_v1_create(server->wl_display);

View File

@ -46,7 +46,7 @@ lib_wlr_types = static_library(
'wlr_pointer_constraints_v1.c',
'wlr_pointer.c',
'wlr_presentation_time.c',
'wlr_primary_selection.c',
'wlr_gtk_primary_selection.c',
'wlr_region.c',
'wlr_screencopy_v1.c',
'wlr_screenshooter.c',

View File

@ -6,7 +6,7 @@
#include <wayland-server.h>
#include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_primary_selection.h>
#include <wlr/types/wlr_gtk_primary_selection.h>
#include <wlr/types/wlr_seat.h>
#include <wlr/util/log.h>
#include "types/wlr_seat.h"

View File

@ -8,7 +8,7 @@
#include <wayland-server.h>
#include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_primary_selection.h>
#include <wlr/types/wlr_gtk_primary_selection.h>
#include <wlr/util/log.h>
#include "types/wlr_seat.h"
#include "util/signal.h"
@ -273,7 +273,7 @@ void wlr_seat_keyboard_enter(struct wlr_seat *seat,
wl_array_release(&keys);
wlr_seat_client_send_selection(client);
wlr_seat_client_send_primary_selection(client);
wlr_seat_client_send_gtk_primary_selection(client);
}
// reinitialize the focus destroy events

View File

@ -3,7 +3,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <wlr/types/wlr_primary_selection.h>
#include <wlr/types/wlr_gtk_primary_selection.h>
#include <wlr/types/wlr_seat.h>
#include <wlr/util/log.h>
#include "gtk-primary-selection-protocol.h"
@ -13,7 +13,7 @@
static const struct gtk_primary_selection_offer_interface offer_impl;
static struct wlr_primary_selection_offer *offer_from_resource(
static struct wlr_gtk_primary_selection_offer *offer_from_resource(
struct wl_resource *resource) {
assert(wl_resource_instance_of(resource,
&gtk_primary_selection_offer_interface, &offer_impl));
@ -22,7 +22,7 @@ static struct wlr_primary_selection_offer *offer_from_resource(
static void offer_handle_receive(struct wl_client *client,
struct wl_resource *resource, const char *mime_type, int32_t fd) {
struct wlr_primary_selection_offer *offer = offer_from_resource(resource);
struct wlr_gtk_primary_selection_offer *offer = offer_from_resource(resource);
if (offer == NULL) {
close(fd);
return;
@ -41,7 +41,7 @@ static const struct gtk_primary_selection_offer_interface offer_impl = {
.destroy = offer_handle_destroy,
};
static void offer_destroy(struct wlr_primary_selection_offer *offer) {
static void offer_destroy(struct wlr_gtk_primary_selection_offer *offer) {
if (offer == NULL) {
return;
}
@ -52,24 +52,24 @@ static void offer_destroy(struct wlr_primary_selection_offer *offer) {
}
static void offer_handle_resource_destroy(struct wl_resource *resource) {
struct wlr_primary_selection_offer *offer = offer_from_resource(resource);
struct wlr_gtk_primary_selection_offer *offer = offer_from_resource(resource);
offer_destroy(offer);
}
static void offer_handle_source_destroy(struct wl_listener *listener,
void *data) {
struct wlr_primary_selection_offer *offer =
struct wlr_gtk_primary_selection_offer *offer =
wl_container_of(listener, offer, source_destroy);
offer_destroy(offer);
}
struct client_data_source {
struct wlr_primary_selection_source source;
struct wlr_gtk_primary_selection_source source;
struct wl_resource *resource;
};
static void client_source_send(struct wlr_primary_selection_source *wlr_source,
static void client_source_send(struct wlr_gtk_primary_selection_source *wlr_source,
const char *mime_type, int32_t fd) {
struct client_data_source *source = (struct client_data_source *)wlr_source;
gtk_primary_selection_source_send_send(source->resource, mime_type, fd);
@ -77,15 +77,15 @@ static void client_source_send(struct wlr_primary_selection_source *wlr_source,
}
static void client_source_cancel(
struct wlr_primary_selection_source *wlr_source) {
struct wlr_gtk_primary_selection_source *wlr_source) {
struct client_data_source *source = (struct client_data_source *)wlr_source;
gtk_primary_selection_source_send_cancelled(source->resource);
}
static void source_send_offer(struct wlr_primary_selection_source *source,
static void source_send_offer(struct wlr_gtk_primary_selection_source *source,
struct wl_resource *device_resource) {
struct wlr_primary_selection_offer *offer =
calloc(1, sizeof(struct wlr_primary_selection_offer));
struct wlr_gtk_primary_selection_offer *offer =
calloc(1, sizeof(struct wlr_gtk_primary_selection_offer));
if (offer == NULL) {
wl_resource_post_no_memory(device_resource);
return;
@ -159,18 +159,18 @@ static const struct gtk_primary_selection_source_interface source_impl = {
static void source_resource_handle_destroy(struct wl_resource *resource) {
struct client_data_source *source =
client_data_source_from_resource(resource);
wlr_primary_selection_source_finish(&source->source);
wlr_gtk_primary_selection_source_finish(&source->source);
free(source);
}
void wlr_seat_client_send_primary_selection(
void wlr_seat_client_send_gtk_primary_selection(
struct wlr_seat_client *seat_client) {
if (wl_list_empty(&seat_client->primary_selection_devices)) {
return;
}
struct wlr_primary_selection_source *source =
struct wlr_gtk_primary_selection_source *source =
seat_client->seat->primary_selection_source;
struct wl_resource *resource;
wl_resource_for_each(resource, &seat_client->primary_selection_devices) {
@ -200,8 +200,8 @@ static void seat_client_primary_selection_source_destroy(
wlr_signal_emit_safe(&seat->events.primary_selection, seat);
}
void wlr_seat_set_primary_selection(struct wlr_seat *seat,
struct wlr_primary_selection_source *source, uint32_t serial) {
void wlr_seat_set_gtk_primary_selection(struct wlr_seat *seat,
struct wlr_gtk_primary_selection_source *source, uint32_t serial) {
if (source) {
assert(source->send);
assert(source->cancel);
@ -225,7 +225,7 @@ void wlr_seat_set_primary_selection(struct wlr_seat *seat,
struct wlr_seat_client *focused_client =
seat->keyboard_state.focused_client;
if (focused_client) {
wlr_seat_client_send_primary_selection(focused_client);
wlr_seat_client_send_gtk_primary_selection(focused_client);
}
wlr_signal_emit_safe(&seat->events.primary_selection, seat);
@ -259,9 +259,9 @@ static void device_handle_set_selection(struct wl_client *client,
struct wlr_seat_client *seat_client =
seat_client_from_device_resource(resource);
struct wlr_primary_selection_source *wlr_source =
(struct wlr_primary_selection_source *)source;
wlr_seat_set_primary_selection(seat_client->seat, wlr_source, serial);
struct wlr_gtk_primary_selection_source *wlr_source =
(struct wlr_gtk_primary_selection_source *)source;
wlr_seat_set_gtk_primary_selection(seat_client->seat, wlr_source, serial);
}
static void device_handle_destroy(struct wl_client *client,
@ -279,14 +279,14 @@ static void device_resource_handle_destroy(struct wl_resource *resource) {
}
void wlr_primary_selection_source_init(
struct wlr_primary_selection_source *source) {
void wlr_gtk_primary_selection_source_init(
struct wlr_gtk_primary_selection_source *source) {
wl_array_init(&source->mime_types);
wl_signal_init(&source->events.destroy);
}
void wlr_primary_selection_source_finish(
struct wlr_primary_selection_source *source) {
void wlr_gtk_primary_selection_source_finish(
struct wlr_gtk_primary_selection_source *source) {
if (source == NULL) {
return;
}
@ -308,7 +308,7 @@ static void device_manager_handle_create_source(struct wl_client *client,
wl_client_post_no_memory(client);
return;
}
wlr_primary_selection_source_init(&source->source);
wlr_gtk_primary_selection_source_init(&source->source);
int version = wl_resource_get_version(manager_resource);
source->resource = wl_resource_create(client,
@ -364,7 +364,7 @@ static void device_manager_handle_resource_destroy(
static void primary_selection_device_manager_bind(struct wl_client *client,
void *data, uint32_t version, uint32_t id) {
struct wlr_primary_selection_device_manager *manager = data;
struct wlr_gtk_primary_selection_device_manager *manager = data;
struct wl_resource *resource = wl_resource_create(client,
&gtk_primary_selection_device_manager_interface, version, id);
@ -379,16 +379,16 @@ static void primary_selection_device_manager_bind(struct wl_client *client,
}
static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_primary_selection_device_manager *manager =
struct wlr_gtk_primary_selection_device_manager *manager =
wl_container_of(listener, manager, display_destroy);
wlr_primary_selection_device_manager_destroy(manager);
wlr_gtk_primary_selection_device_manager_destroy(manager);
}
struct wlr_primary_selection_device_manager *
wlr_primary_selection_device_manager_create(
struct wlr_gtk_primary_selection_device_manager *
wlr_gtk_primary_selection_device_manager_create(
struct wl_display *display) {
struct wlr_primary_selection_device_manager *manager =
calloc(1, sizeof(struct wlr_primary_selection_device_manager));
struct wlr_gtk_primary_selection_device_manager *manager =
calloc(1, sizeof(struct wlr_gtk_primary_selection_device_manager));
if (manager == NULL) {
return NULL;
}
@ -409,8 +409,8 @@ struct wlr_primary_selection_device_manager *
return manager;
}
void wlr_primary_selection_device_manager_destroy(
struct wlr_primary_selection_device_manager *manager) {
void wlr_gtk_primary_selection_device_manager_destroy(
struct wlr_gtk_primary_selection_device_manager *manager) {
if (manager == NULL) {
return;
}

View File

@ -4,7 +4,7 @@
#include <string.h>
#include <unistd.h>
#include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_primary_selection.h>
#include <wlr/types/wlr_gtk_primary_selection.h>
#include <wlr/util/log.h>
#include <xcb/xfixes.h>
#include "xwayland/xwm.h"

View File

@ -5,7 +5,7 @@
#include <string.h>
#include <unistd.h>
#include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_primary_selection.h>
#include <wlr/types/wlr_gtk_primary_selection.h>
#include <wlr/util/log.h>
#include <xcb/xfixes.h>
#include "xwayland/xwm.h"
@ -217,21 +217,21 @@ static const struct wlr_data_source_impl data_source_impl = {
};
struct x11_primary_selection_source {
struct wlr_primary_selection_source base;
struct wlr_gtk_primary_selection_source base;
struct wlr_xwm_selection *selection;
struct wl_array mime_types_atoms;
};
static void primary_selection_source_cancel(
struct wlr_primary_selection_source *wlr_source);
struct wlr_gtk_primary_selection_source *wlr_source);
bool primary_selection_source_is_xwayland(
struct wlr_primary_selection_source *wlr_source) {
struct wlr_gtk_primary_selection_source *wlr_source) {
return wlr_source->cancel == primary_selection_source_cancel;
}
static void primary_selection_source_send(
struct wlr_primary_selection_source *wlr_source, const char *mime_type,
struct wlr_gtk_primary_selection_source *wlr_source, const char *mime_type,
int32_t fd) {
struct x11_primary_selection_source *source =
(struct x11_primary_selection_source *)wlr_source;
@ -242,10 +242,10 @@ static void primary_selection_source_send(
}
static void primary_selection_source_cancel(
struct wlr_primary_selection_source *wlr_source) {
struct wlr_gtk_primary_selection_source *wlr_source) {
struct x11_primary_selection_source *source =
(struct x11_primary_selection_source *)wlr_source;
wlr_primary_selection_source_finish(&source->base);
wlr_gtk_primary_selection_source_finish(&source->base);
wl_array_release(&source->mime_types_atoms);
free(source);
}
@ -356,7 +356,7 @@ static void xwm_selection_get_targets(struct wlr_xwm_selection *selection) {
if (source == NULL) {
return;
}
wlr_primary_selection_source_init(&source->base);
wlr_gtk_primary_selection_source_init(&source->base);
source->base.send = primary_selection_source_send;
source->base.cancel = primary_selection_source_cancel;
@ -366,7 +366,7 @@ static void xwm_selection_get_targets(struct wlr_xwm_selection *selection) {
bool ok = source_get_targets(selection, &source->base.mime_types,
&source->mime_types_atoms);
if (ok) {
wlr_seat_set_primary_selection(xwm->seat, &source->base,
wlr_seat_set_gtk_primary_selection(xwm->seat, &source->base,
wl_display_next_serial(xwm->xwayland->wl_display));
} else {
source->base.cancel(&source->base);
@ -424,7 +424,7 @@ int xwm_handle_xfixes_selection_notify(struct wlr_xwm *xwm,
wlr_seat_set_selection(xwm->seat, NULL,
wl_display_next_serial(xwm->xwayland->wl_display));
} else if (selection == &xwm->primary_selection) {
wlr_seat_set_primary_selection(xwm->seat, NULL,
wlr_seat_set_gtk_primary_selection(xwm->seat, NULL,
wl_display_next_serial(xwm->xwayland->wl_display));
} else if (selection == &xwm->dnd_selection) {
// TODO: DND

View File

@ -4,7 +4,7 @@
#include <string.h>
#include <unistd.h>
#include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_primary_selection.h>
#include <wlr/types/wlr_gtk_primary_selection.h>
#include <wlr/util/log.h>
#include <xcb/xfixes.h>
#include "xwayland/xwm.h"
@ -195,7 +195,7 @@ static void xwm_selection_source_send(struct wlr_xwm_selection *selection,
return;
}
} else if (selection == &selection->xwm->primary_selection) {
struct wlr_primary_selection_source *source =
struct wlr_gtk_primary_selection_source *source =
selection->xwm->seat->primary_selection_source;
if (source != NULL) {
source->send(source, mime_type, fd);
@ -231,7 +231,7 @@ static struct wl_array *xwm_selection_source_get_mime_types(
return &source->mime_types;
}
} else if (selection == &selection->xwm->primary_selection) {
struct wlr_primary_selection_source *source =
struct wlr_gtk_primary_selection_source *source =
selection->xwm->seat->primary_selection_source;
if (source != NULL) {
return &source->mime_types;

View File

@ -5,7 +5,7 @@
#include <string.h>
#include <unistd.h>
#include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_primary_selection.h>
#include <wlr/types/wlr_gtk_primary_selection.h>
#include <wlr/util/log.h>
#include <xcb/xfixes.h>
#include "xwayland/xwm.h"
@ -231,7 +231,7 @@ void xwm_selection_finish(struct wlr_xwm *xwm) {
if (xwm->seat->primary_selection_source &&
primary_selection_source_is_xwayland(
xwm->seat->primary_selection_source)) {
wlr_seat_set_primary_selection(xwm->seat, NULL,
wlr_seat_set_gtk_primary_selection(xwm->seat, NULL,
wl_display_next_serial(xwm->xwayland->wl_display));
}
wlr_xwayland_set_seat(xwm->xwayland, NULL);
@ -274,7 +274,7 @@ static void seat_handle_primary_selection(struct wl_listener *listener,
struct wlr_seat *seat = data;
struct wlr_xwm *xwm =
wl_container_of(listener, xwm, seat_primary_selection);
struct wlr_primary_selection_source *source = seat->primary_selection_source;
struct wlr_gtk_primary_selection_source *source = seat->primary_selection_source;
if (source != NULL &&
primary_selection_source_is_xwayland(