mirror of
https://github.com/labwc/labwc.git
synced 2026-04-16 08:21:26 -04:00
implement permissions_context_clone()
This commit is contained in:
parent
f0a9875da6
commit
2285c5e77c
2 changed files with 31 additions and 9 deletions
|
|
@ -6,6 +6,7 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
int permissions_context_create(struct wl_display *display, uint32_t permissions);
|
int permissions_context_create(struct wl_display *display, uint32_t permissions);
|
||||||
|
bool permissions_context_clone(struct wl_client *client, int fd);
|
||||||
bool permissions_check(const struct wl_client *client, const struct wl_interface *iface);
|
bool permissions_check(const struct wl_client *client, const struct wl_interface *iface);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,24 @@ permissions_get(const struct wl_client *client)
|
||||||
return context->permissions;
|
return context->permissions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
context_create(struct wl_display *display, uint32_t permissions, int fd)
|
||||||
|
{
|
||||||
|
struct wl_client *client = wl_client_create(display, fd);
|
||||||
|
if (!client) {
|
||||||
|
wlr_log(WLR_ERROR, "failed to create client");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct permissions_context *context = znew(*context);
|
||||||
|
context->permissions = permissions;
|
||||||
|
context->fd = fd;
|
||||||
|
context->destroy.notify = permissions_context_handle_destroy;
|
||||||
|
wl_client_add_destroy_listener(client, &context->destroy);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
permissions_context_create(struct wl_display *display, uint32_t permissions)
|
permissions_context_create(struct wl_display *display, uint32_t permissions)
|
||||||
{
|
{
|
||||||
|
|
@ -55,23 +73,26 @@ permissions_context_create(struct wl_display *display, uint32_t permissions)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wl_client *client = wl_client_create(display, sv[0]);
|
if (!context_create(display, permissions, sv[0])) {
|
||||||
if (!client) {
|
|
||||||
wlr_log(WLR_ERROR, "failed to create client");
|
|
||||||
close(sv[0]);
|
close(sv[0]);
|
||||||
close(sv[1]);
|
close(sv[1]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct permissions_context *context = znew(*context);
|
|
||||||
context->permissions = permissions;
|
|
||||||
context->fd = sv[0];
|
|
||||||
context->destroy.notify = permissions_context_handle_destroy;
|
|
||||||
wl_client_add_destroy_listener(client, &context->destroy);
|
|
||||||
|
|
||||||
return sv[1];
|
return sv[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
permissions_context_clone(struct wl_client *client, int fd)
|
||||||
|
{
|
||||||
|
struct wl_display *display = wl_client_get_display(client);
|
||||||
|
uint32_t permissions = permissions_get(client);
|
||||||
|
if (permissions == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return context_create(display, permissions, fd);
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
permissions_check(const struct wl_client *client, const struct wl_interface *iface)
|
permissions_check(const struct wl_client *client, const struct wl_interface *iface)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue