diff options
Diffstat (limited to 'src/platform/wayland/backend.c')
| -rw-r--r-- | src/platform/wayland/backend.c | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/src/platform/wayland/backend.c b/src/platform/wayland/backend.c index 4585cd6..7026a8c 100644 --- a/src/platform/wayland/backend.c +++ b/src/platform/wayland/backend.c @@ -1,5 +1,6 @@ #include "platform/wayland/internal.h" #include "platform/freedesktop/dbus.h" +#include <errno.h> static struct yasl_display *impl_display_open(struct yasl_loop *loop, const struct yasl_display_spec *spec) { @@ -44,11 +45,28 @@ static void impl_display_copy(struct yasl_display *d, enum yasl_selection sel, c wayland_display_copy((struct wayland_display *)d, sel, text); } +static bool impl_display_copy_text(struct yasl_display *d, enum yasl_selection sel, + const char *text) +{ + bool ok = wayland_display_copy_text((struct wayland_display *)d, sel, text); + if (!ok && errno == 0) errno = ENOTSUP; + return ok; +} + static void impl_display_paste(struct yasl_display *d, enum yasl_selection sel, struct yasl_surface *target) { wayland_display_paste((struct wayland_display *)d, sel, (struct wayland_surface *)target); } +static bool impl_display_request_paste(struct yasl_display *d, enum yasl_selection sel, + struct yasl_surface *target, uint64_t request_id) +{ + bool ok = wayland_display_request_paste((struct wayland_display *)d, sel, + (struct wayland_surface *)target, request_id); + if (!ok && errno == 0) errno = ENOTSUP; + return ok; +} + static bool impl_display_drag_start(struct yasl_display *d, struct yasl_surface *origin, const struct yasl_drag_image *image, const struct yasl_drag_listener *l, void *ud) { return wayland_display_drag_start((struct wayland_display *)d, (struct wayland_surface *)origin, image, l, ud); @@ -82,6 +100,59 @@ static void impl_surface_destroy(struct yasl_surface *s) wayland_surface_destroy((struct wayland_surface *)s); } +static struct input_queue *impl_surface_input_queue(struct yasl_surface *s) +{ + struct wayland_surface *w = (struct wayland_surface *)s; + return w ? &w->input : NULL; +} + +static bool impl_surface_set_size(struct yasl_surface *s, struct yasl_vector2i size) +{ + struct wayland_surface *w = (struct wayland_surface *)s; + if (!w || w->closed || w->destroyed || !w->toplevel || + size.x <= 0 || size.y <= 0) { + errno = EINVAL; + return false; + } + errno = ENOTSUP; + return false; +} + +static bool impl_surface_set_fullscreen(struct yasl_surface *s, bool enabled) +{ + struct wayland_surface *w = (struct wayland_surface *)s; + if (!w || w->closed || w->destroyed || !w->toplevel) { + errno = EINVAL; + return false; + } + if (enabled) xdg_toplevel_set_fullscreen(w->toplevel, NULL); + else xdg_toplevel_unset_fullscreen(w->toplevel); + return true; +} + +static bool impl_surface_set_maximized(struct yasl_surface *s, bool enabled) +{ + struct wayland_surface *w = (struct wayland_surface *)s; + if (!w || w->closed || w->destroyed || !w->toplevel) { + errno = EINVAL; + return false; + } + if (enabled) xdg_toplevel_set_maximized(w->toplevel); + else xdg_toplevel_unset_maximized(w->toplevel); + return true; +} + +static bool impl_surface_minimize(struct yasl_surface *s) +{ + struct wayland_surface *w = (struct wayland_surface *)s; + if (!w || w->closed || w->destroyed || !w->toplevel) { + errno = EINVAL; + return false; + } + xdg_toplevel_set_minimized(w->toplevel); + return true; +} + static struct yasl_display *impl_surface_display(const struct yasl_surface *s) { const struct wayland_surface *w = (const struct wayland_surface *)s; @@ -219,12 +290,19 @@ const struct yasl_backend_ops yasl_wayland_backend = { .display_double_click_ms = impl_display_double_click_ms, .display_copy = impl_display_copy, .display_paste = impl_display_paste, + .display_copy_text = impl_display_copy_text, + .display_request_paste = impl_display_request_paste, .display_drag_start = impl_display_drag_start, .display_drag_cancel = impl_display_drag_cancel, .surface_create_toplevel = impl_surface_create_toplevel, .surface_create_popup = impl_surface_create_popup, .surface_popup_reposition = impl_surface_popup_reposition, .surface_destroy = impl_surface_destroy, + .surface_input_queue = impl_surface_input_queue, + .surface_set_size = impl_surface_set_size, + .surface_set_fullscreen = impl_surface_set_fullscreen, + .surface_set_maximized = impl_surface_set_maximized, + .surface_minimize = impl_surface_minimize, .surface_display = impl_surface_display, .surface_set_callbacks = impl_surface_set_callbacks, .surface_set_title = impl_surface_set_title, |
