diff options
Diffstat (limited to 'src/platform')
| -rw-r--r-- | src/platform/cocoa/api.h | 3 | ||||
| -rw-r--r-- | src/platform/cocoa/window.m | 239 | ||||
| -rw-r--r-- | src/platform/wayland/api.h | 3 | ||||
| -rw-r--r-- | src/platform/wayland/backend.c | 23 | ||||
| -rw-r--r-- | src/platform/wayland/clipboard.c | 12 | ||||
| -rw-r--r-- | src/platform/wayland/clipboard.h | 2 | ||||
| -rw-r--r-- | src/platform/wayland/internal.h | 2 | ||||
| -rw-r--r-- | src/platform/wayland/keyboard.c | 25 | ||||
| -rw-r--r-- | src/platform/wayland/popup.c | 17 | ||||
| -rw-r--r-- | src/platform/wayland/surface.c | 3 | ||||
| -rw-r--r-- | src/platform/x11/window.c | 135 |
11 files changed, 50 insertions, 414 deletions
diff --git a/src/platform/cocoa/api.h b/src/platform/cocoa/api.h index 4a22410..006954c 100644 --- a/src/platform/cocoa/api.h +++ b/src/platform/cocoa/api.h @@ -12,8 +12,6 @@ uint32_t cocoa_display_caps(const struct cocoa_display *d); int cocoa_display_dispatch_timeout(struct cocoa_display *d, int timeout_ms); void cocoa_display_flush(struct cocoa_display *d); int cocoa_display_modifiers(const struct cocoa_display *d); -void cocoa_display_copy(struct cocoa_display *d, enum yasl_private_selection sel, const char *text); -void cocoa_display_paste(struct cocoa_display *d, enum yasl_private_selection sel, struct cocoa_surface *target); bool cocoa_display_drag_start(struct cocoa_display *d, struct cocoa_surface *origin, const struct yasl_private_drag_image *image, const struct yasl_private_drag_listener *l, void *ud); struct cocoa_surface *cocoa_surface_create_toplevel(struct cocoa_display *d, const struct yasl_private_window_spec *spec, void *graphics_device); @@ -24,7 +22,6 @@ void cocoa_surface_set_callbacks(struct cocoa_surface *s, const struct yasl_priv void cocoa_surface_set_title(struct cocoa_surface *s, const char *title); void cocoa_surface_schedule_redraw(struct cocoa_surface *s); bool cocoa_surface_present(struct cocoa_surface *s, const struct yasl_private_framebuffer *fb, const struct yasl_private_damage_list *damage); -bool cocoa_surface_poll_event(struct cocoa_surface *s, struct yasl_private_event *ev); struct yasl_private_geometry cocoa_surface_geometry(const struct cocoa_surface *s); struct yasl_private_timing cocoa_surface_timing(const struct cocoa_surface *s); void cocoa_surface_set_cursor(struct cocoa_surface *s, enum yasl_private_cursor cursor); diff --git a/src/platform/cocoa/window.m b/src/platform/cocoa/window.m index 7be78fd..4b97ce1 100644 --- a/src/platform/cocoa/window.m +++ b/src/platform/cocoa/window.m @@ -1,7 +1,6 @@ #import <AppKit/AppKit.h> #import <Metal/Metal.h> #import <QuartzCore/QuartzCore.h> -#import <OpenGL/OpenGL.h> #include "platform/cocoa/api.h" #include "common/backend.h" @@ -20,7 +19,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <dlfcn.h> #include <sys/event.h> #include <unistd.h> #include <objc/message.h> @@ -68,7 +66,6 @@ struct cocoa_surface { YaslWindowController *controller; YaslView *view; CAMetalLayer *layer; - NSOpenGLContext *gl_context; id<MTLCommandQueue> software_queue; id<MTLBuffer> software_buffer; NSUInteger software_buffer_capacity; @@ -130,8 +127,6 @@ struct cocoa_display { struct cocoa_surface **windows; int count; int capacity; - const struct yasl_private_display_cbs *cbs; - void *ud; char *app_id; struct yasl_private_loop *loop; id key_up_monitor; @@ -275,11 +270,7 @@ static void sync_size(struct cocoa_surface *w, bool force) w->layer.contentsScale = scale; w->layer.drawableSize = CGSizeMake(size.x, size.y); } - if (w->gl_context) - [w->gl_context update]; - /* Common configure notification already requests a frame before invoking - * the legacy callback. Finish local bookkeeping before that callback can - * destroy this surface. */ + /* Finish local bookkeeping before publishing geometry and requesting a frame. */ yasl_private_clock_note_resize(&w->clock, yasl_private_loop_now_ns() - start); yasl_private_surface_notify_configure(&w->base, (struct yasl_private_geometry){ .size = size, .scale_120 = scale_120, @@ -1642,10 +1633,6 @@ struct cocoa_display *cocoa_display_open(struct yasl_private_loop *loop, const s } darwin_ctx.base.loop = darwin_ctx.loop; if (spec) { - darwin_ctx.base.callbacks = spec->cbs ? *spec->cbs : (struct yasl_private_display_cbs){0}; - darwin_ctx.cbs = &darwin_ctx.base.callbacks; - darwin_ctx.ud = spec->ud; - darwin_ctx.base.callback_ud = spec->ud; if (spec->app_id) darwin_ctx.app_id = strdup(spec->app_id); darwin_ctx.base.app_id = darwin_ctx.app_id; } @@ -1789,7 +1776,6 @@ struct cocoa_surface *cocoa_surface_create_toplevel(struct cocoa_display *d, static void surface_free(struct cocoa_surface *w) { [w->link release]; - [w->gl_context release]; [w->software_buffer release]; [w->software_queue release]; [w->view release]; @@ -1987,11 +1973,6 @@ static NSPasteboard *pasteboard_for_selection(enum yasl_private_selection sel) static bool cocoa_display_copy_text(struct cocoa_display *d, enum yasl_private_selection sel, const char *text); -void cocoa_display_copy(struct cocoa_display *d, enum yasl_private_selection sel, const char *text) -{ - (void)cocoa_display_copy_text(d, sel, text); -} - static bool cocoa_display_copy_text(struct cocoa_display *d, enum yasl_private_selection sel, const char *text) { assert([NSThread isMainThread]); @@ -2030,11 +2011,6 @@ static bool cocoa_display_request_paste(struct cocoa_display *d, enum yasl_priva return true; } -void cocoa_display_paste(struct cocoa_display *d, enum yasl_private_selection sel, struct cocoa_surface *target) -{ - (void)cocoa_display_request_paste(d, sel, target, 0); -} - int cocoa_display_modifiers(const struct cocoa_display *d) { (void)d; @@ -2053,8 +2029,8 @@ static bool popup_spec_valid(const struct cocoa_surface *parent, const struct yasl_private_popup_spec *spec) { if (!parent || !spec) return false; - if (spec->positioner_explicit && (spec->anchor_edges > 8 || spec->gravity > 8 || - (spec->constraints & ~63u))) return false; + if (spec->anchor_edges > 8 || spec->gravity > 8 || + (spec->constraints & ~63u)) return false; int parent_cx = parent->is_popup ? parent->content_offset.x : 0; int parent_cy = parent->is_popup ? parent->content_offset.y : 0; int64_t x = (int64_t)spec->anchor.x - parent_cx; @@ -2069,70 +2045,6 @@ static bool popup_spec_valid(const struct cocoa_surface *parent, (int64_t)spec->content_offset.y + spec->content_size.y <= spec->size.y; } -static NSRect popup_calc_frame_legacy(struct cocoa_surface *parent, const struct yasl_private_popup_spec *spec) -{ - CGFloat scale = parent->window ? parent->window.backingScaleFactor : 1.0; - if (scale < 1.0) scale = 1.0; - - CGFloat pcx = (parent->is_popup ? parent->content_offset.x : 0) / scale; - CGFloat pcy = (parent->is_popup ? parent->content_offset.y : 0) / scale; - - CGFloat pw = spec->size.x / scale; - CGFloat ph = spec->size.y / scale; - CGFloat ax = (spec->anchor.x / scale) - pcx; - CGFloat ay = (spec->anchor.y / scale) - pcy; - CGFloat aw = spec->anchor.width / scale; - CGFloat ah = spec->anchor.height / scale; - CGFloat ox = spec->content_offset.x / scale; - CGFloat oy = spec->content_offset.y / scale; - - CGFloat top_left_x = spec->beside ? (ax + aw - ox) : (ax - ox); - CGFloat top_left_y = spec->beside ? (ay - oy) : (ay + ah - oy); - - CGFloat view_h = parent->view.bounds.size.height; - CGFloat view_y = view_h - top_left_y; - - NSPoint ptInView = NSMakePoint(top_left_x, view_y); - NSPoint ptInWin = [parent->view convertPoint:ptInView toView:nil]; - NSPoint screen_tl = [parent->window convertPointToScreen:ptInWin]; - - NSRect frame = NSMakeRect(screen_tl.x, screen_tl.y - ph, pw, ph); - - NSScreen *screen = parent->window.screen ?: [NSScreen mainScreen]; - if (screen) { - NSRect visible = screen.visibleFrame; - if (NSMaxX(frame) > NSMaxX(visible)) { - if (spec->beside) { - CGFloat flip_tl_x = ax - pw + ox; - NSPoint flip_v = NSMakePoint(flip_tl_x, view_y); - NSPoint flip_w = [parent->view convertPoint:flip_v toView:nil]; - NSPoint flip_s = [parent->window convertPointToScreen:flip_w]; - frame.origin.x = flip_s.x; - } - if (NSMaxX(frame) > NSMaxX(visible)) - frame.origin.x = NSMaxX(visible) - frame.size.width; - } - if (NSMinX(frame) < NSMinX(visible)) - frame.origin.x = NSMinX(visible); - - if (NSMinY(frame) < NSMinY(visible)) { - if (!spec->beside) { - CGFloat flip_top_y = ay - ph + oy; - CGFloat flip_vy = view_h - flip_top_y; - NSPoint flip_v = NSMakePoint(top_left_x, flip_vy); - NSPoint flip_w = [parent->view convertPoint:flip_v toView:nil]; - NSPoint flip_s = [parent->window convertPointToScreen:flip_w]; - frame.origin.y = flip_s.y - ph; - } - if (NSMinY(frame) < NSMinY(visible)) - frame.origin.y = NSMinY(visible); - } - if (NSMaxY(frame) > NSMaxY(visible)) - frame.origin.y = NSMaxY(visible) - frame.size.height; - } - return frame; -} - enum { POPUP_EDGE_TOP = 1, POPUP_EDGE_BOTTOM = 2, @@ -2227,8 +2139,6 @@ static NSRect popup_frame_explicit(struct cocoa_surface *parent, static NSRect popup_calc_frame(struct cocoa_surface *parent, const struct yasl_private_popup_spec *spec) { - if (!spec->positioner_explicit) - return popup_calc_frame_legacy(parent, spec); NSRect frame = popup_frame_explicit(parent, spec, spec->anchor_edges, spec->gravity); NSScreen *screen = parent->window.screen ?: [NSScreen mainScreen]; @@ -2505,22 +2415,6 @@ void cocoa_surface_set_callbacks(struct cocoa_surface *w, w->ud = ud; } -bool cocoa_surface_poll_event(struct cocoa_surface *w, struct yasl_private_event *ev) -{ - if (!w || !ev || !input_queue_pop(&w->input, ev)) - return false; - if (ev->type == YASL_PRIVATE_EVENT_INPUT_RESET) { - w->buttons = 0; - w->tablet_down = false; - w->mods = 0; - if (w->preedit) { - free(w->preedit); - w->preedit = NULL; - } - } - return true; -} - struct yasl_private_timing cocoa_surface_timing(const struct cocoa_surface *w) { struct yasl_private_timing timing = {0}; @@ -2572,16 +2466,6 @@ static int impl_display_modifiers(const struct yasl_private_display *d) return cocoa_display_modifiers((const struct cocoa_display *)d); } -static void impl_display_copy(struct yasl_private_display *d, enum yasl_private_selection sel, const char *text) -{ - cocoa_display_copy((struct cocoa_display *)d, sel, text); -} - -static void impl_display_paste(struct yasl_private_display *d, enum yasl_private_selection sel, struct yasl_surface *target) -{ - cocoa_display_paste((struct cocoa_display *)d, sel, (struct cocoa_surface *)target); -} - static bool impl_display_copy_text(struct yasl_private_display *d, enum yasl_private_selection sel, const char *text) { return cocoa_display_copy_text((struct cocoa_display *)d, sel, text); @@ -2725,116 +2609,6 @@ static bool impl_surface_place_under_pointer(struct yasl_surface *s, struct yasl return cocoa_surface_place_under_pointer((struct cocoa_surface *)s, at); } -static struct yasl_surface *impl_surface_create_gl(struct yasl_private_display *display, - const struct yasl_private_window_spec *spec, const int *attrs, struct yasl_surface *share) -{ - struct yasl_private_gl_options options; - if (!spec || !yasl_private_gl_parse_options(attrs, &options) || - options.api != YASL_PRIVATE_GL_OPENGL || options.debug || (share && - (share->display != display || share->presenter != YASL_PRIVATE_PRESENTER_GL))) - return NULL; - int profile = options.profile; - if (profile == YASL_PRIVATE_GL_ANY) - profile = options.major >= 3 ? YASL_PRIVATE_GL_CORE : YASL_PRIVATE_GL_COMPATIBILITY; - if (options.forward_compat && profile != YASL_PRIVATE_GL_CORE) - return NULL; - if ((profile == YASL_PRIVATE_GL_CORE && - (options.major != 3 || options.minor != 2)) || - (profile == YASL_PRIVATE_GL_COMPATIBILITY && - (options.major > 2 || (options.major == 2 && options.minor > 1)))) - return NULL; - - struct yasl_private_window_spec gl_spec = *spec; - gl_spec.external_gpu = true; - struct cocoa_surface *w = cocoa_surface_create_toplevel((struct cocoa_display *)display, &gl_spec, NULL); - if (!w) return NULL; - - NSOpenGLPixelFormatAttribute pixel_attrs[32]; - NSUInteger n = 0; - pixel_attrs[n++] = NSOpenGLPFAAccelerated; - pixel_attrs[n++] = NSOpenGLPFADoubleBuffer; - pixel_attrs[n++] = NSOpenGLPFAColorSize; - pixel_attrs[n++] = options.red_bits + options.green_bits + options.blue_bits + options.alpha_bits; - pixel_attrs[n++] = NSOpenGLPFAAlphaSize; - pixel_attrs[n++] = options.alpha_bits; - pixel_attrs[n++] = NSOpenGLPFADepthSize; - pixel_attrs[n++] = options.depth_bits; - pixel_attrs[n++] = NSOpenGLPFAStencilSize; - pixel_attrs[n++] = options.stencil_bits; - if (options.samples > 0) { - pixel_attrs[n++] = NSOpenGLPFASampleBuffers; - pixel_attrs[n++] = 1; - pixel_attrs[n++] = NSOpenGLPFASamples; - pixel_attrs[n++] = options.samples; - } - if (options.srgb) pixel_attrs[n++] = NSOpenGLPFASRGB; - if (profile == YASL_PRIVATE_GL_CORE) { - pixel_attrs[n++] = NSOpenGLPFAOpenGLProfile; - pixel_attrs[n++] = NSOpenGLProfileVersion3_2Core; - } else if (profile == YASL_PRIVATE_GL_COMPATIBILITY) { - pixel_attrs[n++] = NSOpenGLPFAOpenGLProfile; - pixel_attrs[n++] = NSOpenGLProfileVersionLegacy; - } - pixel_attrs[n++] = 0; - - NSOpenGLPixelFormat *format = [[NSOpenGLPixelFormat alloc] initWithAttributes:pixel_attrs]; - NSOpenGLContext *shared = share ? ((struct cocoa_surface *)share)->gl_context : nil; - if (format) - w->gl_context = [[NSOpenGLContext alloc] initWithFormat:format shareContext:shared]; - [format release]; - if (!w->gl_context) { - cocoa_surface_destroy(w); - reap_dead((struct cocoa_display *)display); - return NULL; - } - [w->view setLayer:[CALayer layer]]; - w->layer = nil; - [w->gl_context setView:w->view]; - w->base.presenter = YASL_PRIVATE_PRESENTER_GL; - return &w->base; -} - -static bool impl_gl_make_current(struct yasl_private_display *display, struct yasl_surface *surface) -{ - (void)display; - if (!surface) { - [NSOpenGLContext clearCurrentContext]; - return true; - } - struct cocoa_surface *w = (struct cocoa_surface *)surface; - if (w->base.presenter != YASL_PRIVATE_PRESENTER_GL || !w->gl_context || w->closed) - return false; - [w->gl_context makeCurrentContext]; - return [NSOpenGLContext currentContext] == w->gl_context; -} - -static yasl_private_gl_proc impl_gl_get_proc_address(struct yasl_private_display *display, const char *name) -{ - (void)display; - return name ? (yasl_private_gl_proc)dlsym(RTLD_DEFAULT, name) : NULL; -} - -static bool impl_gl_swap_interval(struct yasl_private_display *display, struct yasl_surface *surface, int interval) -{ - (void)display; - struct cocoa_surface *w = (struct cocoa_surface *)surface; - if (!w || w->base.presenter != YASL_PRIVATE_PRESENTER_GL || !w->gl_context || w->closed) - return false; - [w->gl_context setValues:&interval forParameter:NSOpenGLCPSwapInterval]; - return true; -} - -static bool impl_gl_swap_buffers(struct yasl_private_display *display, struct yasl_surface *surface) -{ - (void)display; - struct cocoa_surface *w = (struct cocoa_surface *)surface; - if (!w || w->base.presenter != YASL_PRIVATE_PRESENTER_GL || !w->gl_context || w->closed) - return false; - [w->gl_context flushBuffer]; - yasl_private_clock_presented(&w->clock, yasl_private_loop_now_ns(), false); - return true; -} - static void *impl_surface_get_metal_layer(struct yasl_surface *surface) { struct cocoa_surface *w = (struct cocoa_surface *)surface; @@ -2899,11 +2673,6 @@ static bool impl_surface_get_native_frame(struct yasl_surface *s, const struct yasl_private_backend_ops yasl_private_cocoa_backend = { .type = YASL_PRIVATE_BACKEND_COCOA, - .surface_create_gl = impl_surface_create_gl, - .gl_make_current = impl_gl_make_current, - .gl_get_proc_address = impl_gl_get_proc_address, - .gl_swap_interval = impl_gl_swap_interval, - .gl_swap_buffers = impl_gl_swap_buffers, .surface_get_metal_layer = impl_surface_get_metal_layer, .surface_update_text_input = impl_surface_update_text_input, .display_open = impl_display_open, @@ -2913,8 +2682,6 @@ const struct yasl_private_backend_ops yasl_private_cocoa_backend = { .display_flush = impl_display_flush, .display_modifiers = impl_display_modifiers, .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, diff --git a/src/platform/wayland/api.h b/src/platform/wayland/api.h index 9670af1..69f61b1 100644 --- a/src/platform/wayland/api.h +++ b/src/platform/wayland/api.h @@ -12,8 +12,6 @@ uint32_t wayland_display_caps(const struct wayland_display *d); int wayland_display_dispatch_timeout(struct wayland_display *d, int timeout_ms); void wayland_display_flush(struct wayland_display *d); int wayland_display_modifiers(const struct wayland_display *d); -void wayland_display_copy(struct wayland_display *d, enum yasl_private_selection sel, const char *text); -void wayland_display_paste(struct wayland_display *d, enum yasl_private_selection sel, struct wayland_surface *target); bool wayland_display_copy_text(struct wayland_display *d, enum yasl_private_selection sel, const char *text); bool wayland_display_request_paste(struct wayland_display *d, enum yasl_private_selection sel, struct wayland_surface *target, uint64_t request_id); @@ -28,7 +26,6 @@ void wayland_surface_set_callbacks(struct wayland_surface *s, const struct yasl_ void wayland_surface_set_title(struct wayland_surface *s, const char *title); void wayland_surface_schedule_redraw(struct wayland_surface *s); bool wayland_surface_present(struct wayland_surface *s, const struct yasl_private_framebuffer *fb, const struct yasl_private_damage_list *damage); -bool wayland_surface_poll_event(struct wayland_surface *s, struct yasl_private_event *ev); struct yasl_private_geometry wayland_surface_geometry(const struct wayland_surface *s); struct yasl_private_timing wayland_surface_timing(const struct wayland_surface *s); void wayland_surface_set_cursor(struct wayland_surface *s, enum yasl_private_cursor cursor); diff --git a/src/platform/wayland/backend.c b/src/platform/wayland/backend.c index b3337cc..7ac1c65 100644 --- a/src/platform/wayland/backend.c +++ b/src/platform/wayland/backend.c @@ -40,11 +40,6 @@ static int impl_display_double_click_ms(const struct yasl_private_display *d) return portal_double_click_ms(); } -static void impl_display_copy(struct yasl_private_display *d, enum yasl_private_selection sel, const char *text) -{ - wayland_display_copy((struct wayland_display *)d, sel, text); -} - static bool impl_display_copy_text(struct yasl_private_display *d, enum yasl_private_selection sel, const char *text) { @@ -53,11 +48,6 @@ static bool impl_display_copy_text(struct yasl_private_display *d, enum yasl_pri return ok; } -static void impl_display_paste(struct yasl_private_display *d, enum yasl_private_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_private_display *d, enum yasl_private_selection sel, struct yasl_surface *target, uint64_t request_id) { @@ -348,11 +338,6 @@ static bool impl_surface_present(struct yasl_surface *s, const struct yasl_priva return wayland_surface_present((struct wayland_surface *)s, fb, damage); } -static bool impl_surface_poll_event(struct yasl_surface *s, struct yasl_private_event *ev) -{ - return wayland_surface_poll_event((struct wayland_surface *)s, ev); -} - static struct yasl_private_geometry impl_surface_geometry(const struct yasl_surface *s) { return wayland_surface_geometry((const struct wayland_surface *)s); @@ -449,11 +434,6 @@ static void *impl_surface_get_native_handle(struct yasl_surface *s) const struct yasl_private_backend_ops yasl_private_wayland_backend = { #if YASL_HAS_EGL - .surface_create_gl = impl_surface_create_gl, - .gl_make_current = impl_gl_make_current, - .gl_get_proc_address = impl_gl_get_proc_address, - .gl_swap_interval = impl_gl_swap_interval, - .gl_swap_buffers = impl_gl_swap_buffers, #endif .surface_update_text_input = impl_surface_update_text_input, .type = YASL_PRIVATE_BACKEND_WAYLAND, @@ -464,8 +444,6 @@ const struct yasl_private_backend_ops yasl_private_wayland_backend = { .display_flush = impl_display_flush, .display_modifiers = impl_display_modifiers, .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, @@ -484,7 +462,6 @@ const struct yasl_private_backend_ops yasl_private_wayland_backend = { .surface_set_title = impl_surface_set_title, .surface_schedule_redraw = impl_surface_schedule_redraw, .surface_present = impl_surface_present, - .surface_poll_event = impl_surface_poll_event, .surface_set_pointer_mode = impl_surface_set_pointer_mode, .surface_geometry = impl_surface_geometry, .surface_timing = impl_surface_timing, diff --git a/src/platform/wayland/clipboard.c b/src/platform/wayland/clipboard.c index cf39b6c..9a75953 100644 --- a/src/platform/wayland/clipboard.c +++ b/src/platform/wayland/clipboard.c @@ -600,12 +600,6 @@ bool clipboard_copy(struct clipboard *c, const char *text, uint32_t serial) return true; } -void clipboard_paste(struct clipboard *c, struct wl_surface *target) -{ - if (c && target) - (void)clipboard_request_paste(c, YASL_PRIVATE_CLIPBOARD, target, 0); -} - bool clipboard_copy_primary(struct clipboard *c, const char *text, uint32_t serial) { if (!c || !c->primary_device || !c->primary_manager) { errno = ENOTSUP; return false; } @@ -627,12 +621,6 @@ bool clipboard_copy_primary(struct clipboard *c, const char *text, uint32_t seri return true; } -void clipboard_paste_primary(struct clipboard *c, struct wl_surface *target) -{ - if (c && target) - (void)clipboard_request_paste(c, YASL_PRIVATE_PRIMARY, target, 0); -} - bool clipboard_request_paste(struct clipboard *c, enum yasl_private_selection selection, struct wl_surface *target, uint64_t request_id) { diff --git a/src/platform/wayland/clipboard.h b/src/platform/wayland/clipboard.h index d03df17..7ab1719 100644 --- a/src/platform/wayland/clipboard.h +++ b/src/platform/wayland/clipboard.h @@ -25,12 +25,10 @@ void clipboard_destroy(struct clipboard *); bool clipboard_set_seat(struct clipboard *, struct wl_seat *); void clipboard_set_primary_manager(struct clipboard *, struct zwp_primary_selection_device_manager_v1 *); bool clipboard_copy(struct clipboard *, const char *, uint32_t); -void clipboard_paste(struct clipboard *, struct wl_surface *target); bool clipboard_request_paste(struct clipboard *, enum yasl_private_selection, struct wl_surface *target, uint64_t request_id); void clipboard_forget_surface(struct clipboard *, struct wl_surface *); bool clipboard_copy_primary(struct clipboard *, const char *, uint32_t); -void clipboard_paste_primary(struct clipboard *, struct wl_surface *target); typedef void (*clipboard_drag_fn)(enum yasl_private_drag_event, struct wl_surface *on, double x, double y, void *); diff --git a/src/platform/wayland/internal.h b/src/platform/wayland/internal.h index 92108c1..ff1b18f 100644 --- a/src/platform/wayland/internal.h +++ b/src/platform/wayland/internal.h @@ -244,8 +244,6 @@ struct wayland_display { struct wp_commit_timing_manager_v1 *commit_timing_mgr; struct xkb_context *xkb_ctx; struct yasl_private_loop *loop; - const struct yasl_private_display_cbs *cbs; - void *ud; char *app_id; struct xdg_toplevel_drag_manager_v1 *toplevel_drag_mgr; struct conn_drag drag; diff --git a/src/platform/wayland/keyboard.c b/src/platform/wayland/keyboard.c index 6f9dec9..9637341 100644 --- a/src/platform/wayland/keyboard.c +++ b/src/platform/wayland/keyboard.c @@ -425,11 +425,6 @@ int wayland_display_modifiers(const struct wayland_display *c) return c ? seat_modifiers(c->active_seat ? c->active_seat : c->seats) : 0; } -void wayland_display_copy(struct wayland_display *c, enum yasl_private_selection sel, const char *text) -{ - (void)wayland_display_copy_text(c, sel, text); -} - bool wayland_display_copy_text(struct wayland_display *c, enum yasl_private_selection sel, const char *text) { @@ -453,21 +448,6 @@ bool wayland_display_copy_text(struct wayland_display *c, enum yasl_private_sele return ok; } -void wayland_display_paste(struct wayland_display *c, enum yasl_private_selection sel, struct wayland_surface *target) -{ - struct seat *s = c ? (c->active_seat ? c->active_seat : c->seats) : NULL; - if (!target || target->closed || target->destroyed) return; - if (!s || !s->clipboard) { - yasl_private_surface_complete_paste(&target->base, 0, - YASL_PRIVATE_TRANSFER_UNAVAILABLE, NULL, 0); - return; - } - if (sel == YASL_PRIVATE_PRIMARY) - clipboard_paste_primary(s->clipboard, target->surface); - else - clipboard_paste(s->clipboard, target->surface); -} - bool wayland_display_request_paste(struct wayland_display *c, enum yasl_private_selection sel, struct wayland_surface *target, uint64_t request_id) { @@ -485,8 +465,3 @@ bool wayland_display_request_paste(struct wayland_display *c, enum yasl_private_ if (!ok) errno = ENOMEM; return ok; } - -bool wayland_surface_poll_event(struct wayland_surface *w, struct yasl_private_event *ev) -{ - return w && ev && input_queue_pop(&w->input, ev); -} diff --git a/src/platform/wayland/popup.c b/src/platform/wayland/popup.c index c563eb4..1ae4805 100644 --- a/src/platform/wayland/popup.c +++ b/src/platform/wayland/popup.c @@ -27,15 +27,14 @@ static bool popup_spec_valid(const struct wayland_surface *parent, const struct yasl_private_popup_spec *spec) { if (!parent || !spec) return false; - if (spec->positioner_explicit && - (spec->anchor_edges > XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT || + if (spec->anchor_edges > XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT || spec->gravity > XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT || (spec->constraints & ~(unsigned)(XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X | XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_Y | XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_X | XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_Y | XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_X | - XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_Y)))) + XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_Y))) return false; int64_t x = (int64_t)spec->anchor.x - parent->content.x; int64_t y = (int64_t)spec->anchor.y - parent->content.y; @@ -121,15 +120,9 @@ static struct xdg_positioner *popup_positioner(struct wayland_surface *w, yasl_private_scale_to_logical(at.x, scale), yasl_private_scale_to_logical(at.y, scale), aw > 0 ? aw : 1, ah > 0 ? ah : 1); - uint32_t anchor = spec->positioner_explicit ? spec->anchor_edges : - (spec->beside ? XDG_POSITIONER_ANCHOR_TOP_RIGHT : XDG_POSITIONER_ANCHOR_TOP_LEFT); - uint32_t gravity = spec->positioner_explicit ? spec->gravity : - XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT; - uint32_t constraints = spec->positioner_explicit ? spec->constraints : - XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_X | - XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_Y | - XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X | - XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_Y; + uint32_t anchor = spec->anchor_edges; + uint32_t gravity = spec->gravity; + uint32_t constraints = spec->constraints; xdg_positioner_set_anchor(pos, anchor); xdg_positioner_set_gravity(pos, gravity); xdg_positioner_set_constraint_adjustment(pos, constraints); diff --git a/src/platform/wayland/surface.c b/src/platform/wayland/surface.c index e04a594..635c905 100644 --- a/src/platform/wayland/surface.c +++ b/src/platform/wayland/surface.c @@ -347,9 +347,6 @@ struct wayland_display *wayland_display_open(struct yasl_private_loop *loop, con c->base.loop = c->loop; if (!c->loop) goto err; if (spec) { - c->base.callbacks = spec->cbs ? *spec->cbs : (struct yasl_private_display_cbs){0}; - c->cbs = &c->base.callbacks; - c->ud = spec->ud; if (spec->app_id) c->app_id = strdup(spec->app_id); c->base.app_id = c->app_id; } diff --git a/src/platform/x11/window.c b/src/platform/x11/window.c index ef13afe..43e2109 100644 --- a/src/platform/x11/window.c +++ b/src/platform/x11/window.c @@ -1384,8 +1384,8 @@ static bool popup_spec_valid(const struct x11_surface *parent, const struct yasl_private_popup_spec *spec) { if (!parent || !spec) return false; - if (spec->positioner_explicit && (spec->anchor_edges > 8 || spec->gravity > 8 || - (spec->constraints & ~63u))) return false; + if (spec->anchor_edges > 8 || spec->gravity > 8 || + (spec->constraints & ~63u)) return false; int parent_cx = parent->is_popup ? parent->content_offset.x : 0; int parent_cy = parent->is_popup ? parent->content_offset.y : 0; int64_t x = (int64_t)spec->anchor.x - parent_cx; @@ -1494,22 +1494,10 @@ static void popup_calculate_position(struct x11_display *d, struct yasl_private_vector2i size = spec->size; int anchor_x, anchor_y, root_x, root_y; - if (spec->positioner_explicit) { - popup_anchor_point(spec, &anchor_x, &anchor_y); - anchor_x += parent_rx - parent_cx; - anchor_y += parent_ry - parent_cy; - popup_position_at(spec, anchor_x, anchor_y, spec->gravity, size, &root_x, &root_y); - } else { - anchor_x = parent_rx + (spec->anchor.x - parent_cx); - anchor_y = parent_ry + (spec->anchor.y - parent_cy); - if (spec->beside) { - root_x = anchor_x + spec->anchor.width - spec->content_offset.x; - root_y = anchor_y - spec->content_offset.y; - } else { - root_x = anchor_x - spec->content_offset.x; - root_y = anchor_y + spec->anchor.height - spec->content_offset.y; - } - } + popup_anchor_point(spec, &anchor_x, &anchor_y); + anchor_x += parent_rx - parent_cx; + anchor_y += parent_ry - parent_cy; + popup_position_at(spec, anchor_x, anchor_y, spec->gravity, size, &root_x, &root_y); int mon_x = 0, mon_y = 0; int mon_w = d->native ? DisplayWidth(d->native, d->screen) : 1920; @@ -1535,60 +1523,44 @@ static void popup_calculate_position(struct x11_display *d, } #endif - if (spec->positioner_explicit) { - if (spec->constraints & X11_CONSTRAINT_FLIP_X) { - int flip_x, flip_y; - /* Reflect the selected anchor edge across the anchor rectangle center. */ - int anchor_origin_x = parent_rx - parent_cx + spec->anchor.x; - int flipped_anchor_x = 2 * anchor_origin_x + spec->anchor.width - anchor_x; - popup_position_at(spec, flipped_anchor_x, anchor_y, popup_flip_x(spec->gravity), size, &flip_x, &flip_y); - if (popup_overflow(flip_x, size.x, mon_x, mon_x + mon_w) < - popup_overflow(root_x, size.x, mon_x, mon_x + mon_w)) root_x = flip_x; - } - if (spec->constraints & X11_CONSTRAINT_FLIP_Y) { - int flip_x, flip_y; - int anchor_origin_y = parent_ry - parent_cy + spec->anchor.y; - int flipped_anchor_y = 2 * anchor_origin_y + spec->anchor.height - anchor_y; - popup_position_at(spec, anchor_x, flipped_anchor_y, popup_flip_y(spec->gravity), size, &flip_x, &flip_y); - if (popup_overflow(flip_y, size.y, mon_y, mon_y + mon_h) < - popup_overflow(root_y, size.y, mon_y, mon_y + mon_h)) root_y = flip_y; - } - if (spec->constraints & X11_CONSTRAINT_SLIDE_X) { - if (root_x < mon_x) root_x = mon_x; - if (root_x + size.x > mon_x + mon_w) root_x = mon_x + mon_w - size.x; - } - if (spec->constraints & X11_CONSTRAINT_SLIDE_Y) { - if (root_y < mon_y) root_y = mon_y; - if (root_y + size.y > mon_y + mon_h) root_y = mon_y + mon_h - size.y; - } - if ((spec->constraints & X11_CONSTRAINT_RESIZE_X) && - popup_overflow(root_x, size.x, mon_x, mon_x + mon_w)) { - if (root_x >= mon_x + mon_w) root_x = mon_x + mon_w - 1; - if (root_x < mon_x) { size.x -= mon_x - root_x; root_x = mon_x; } - if (root_x + size.x > mon_x + mon_w) size.x = mon_x + mon_w - root_x; - if (size.x < 1) size.x = 1; - } - if ((spec->constraints & X11_CONSTRAINT_RESIZE_Y) && - popup_overflow(root_y, size.y, mon_y, mon_y + mon_h)) { - if (root_y >= mon_y + mon_h) root_y = mon_y + mon_h - 1; - if (root_y < mon_y) { size.y -= mon_y - root_y; root_y = mon_y; } - if (root_y + size.y > mon_y + mon_h) size.y = mon_y + mon_h - root_y; - if (size.y < 1) size.y = 1; - } - } else { - if (spec->beside) { - if (root_x + size.x > mon_x + mon_w) { - int flipped_x = anchor_x - size.x + spec->content_offset.x; - if (flipped_x >= mon_x) root_x = flipped_x; - } - } else if (root_y + size.y > mon_y + mon_h) { - int flipped_y = anchor_y - size.y + spec->content_offset.y; - if (flipped_y >= mon_y) root_y = flipped_y; - } - if (root_x + size.x > mon_x + mon_w) root_x = mon_x + mon_w - size.x; + if (spec->constraints & X11_CONSTRAINT_FLIP_X) { + int flip_x, flip_y; + /* Reflect the selected anchor edge across the anchor rectangle center. */ + int anchor_origin_x = parent_rx - parent_cx + spec->anchor.x; + int flipped_anchor_x = 2 * anchor_origin_x + spec->anchor.width - anchor_x; + popup_position_at(spec, flipped_anchor_x, anchor_y, popup_flip_x(spec->gravity), size, &flip_x, &flip_y); + if (popup_overflow(flip_x, size.x, mon_x, mon_x + mon_w) < + popup_overflow(root_x, size.x, mon_x, mon_x + mon_w)) root_x = flip_x; + } + if (spec->constraints & X11_CONSTRAINT_FLIP_Y) { + int flip_x, flip_y; + int anchor_origin_y = parent_ry - parent_cy + spec->anchor.y; + int flipped_anchor_y = 2 * anchor_origin_y + spec->anchor.height - anchor_y; + popup_position_at(spec, anchor_x, flipped_anchor_y, popup_flip_y(spec->gravity), size, &flip_x, &flip_y); + if (popup_overflow(flip_y, size.y, mon_y, mon_y + mon_h) < + popup_overflow(root_y, size.y, mon_y, mon_y + mon_h)) root_y = flip_y; + } + if (spec->constraints & X11_CONSTRAINT_SLIDE_X) { if (root_x < mon_x) root_x = mon_x; - if (root_y + size.y > mon_y + mon_h) root_y = mon_y + mon_h - size.y; + if (root_x + size.x > mon_x + mon_w) root_x = mon_x + mon_w - size.x; + } + if (spec->constraints & X11_CONSTRAINT_SLIDE_Y) { if (root_y < mon_y) root_y = mon_y; + if (root_y + size.y > mon_y + mon_h) root_y = mon_y + mon_h - size.y; + } + if ((spec->constraints & X11_CONSTRAINT_RESIZE_X) && + popup_overflow(root_x, size.x, mon_x, mon_x + mon_w)) { + if (root_x >= mon_x + mon_w) root_x = mon_x + mon_w - 1; + if (root_x < mon_x) { size.x -= mon_x - root_x; root_x = mon_x; } + if (root_x + size.x > mon_x + mon_w) size.x = mon_x + mon_w - root_x; + if (size.x < 1) size.x = 1; + } + if ((spec->constraints & X11_CONSTRAINT_RESIZE_Y) && + popup_overflow(root_y, size.y, mon_y, mon_y + mon_h)) { + if (root_y >= mon_y + mon_h) root_y = mon_y + mon_h - 1; + if (root_y < mon_y) { size.y -= mon_y - root_y; root_y = mon_y; } + if (root_y + size.y > mon_y + mon_h) size.y = mon_y + mon_h - root_y; + if (size.y < 1) size.y = 1; } *out_x = root_x; @@ -2434,7 +2406,6 @@ static struct yasl_private_display *display_open(struct yasl_private_loop *loop, struct x11_display *d = calloc(1, sizeof(*d)); if (!d) return NULL; d->base.ops = &yasl_private_x11_backend; - d->base.callbacks = spec && spec->cbs ? *spec->cbs : (struct yasl_private_display_cbs){0}; d->native = XOpenDisplay(NULL); if (!d->native) { free(d); errno = ENODEV; return NULL; } XSetErrorHandler(yasl_private_x11_error_handler); @@ -2590,11 +2561,6 @@ static bool copy_text(struct yasl_private_display *base, enum yasl_private_selec return true; } -static void copy(struct yasl_private_display *base, enum yasl_private_selection sel, const char *text) -{ - (void)copy_text(base, sel, text); -} - static bool request_paste(struct yasl_private_display *base, enum yasl_private_selection sel, struct yasl_surface *target, uint64_t id) { @@ -2646,20 +2612,6 @@ static bool request_paste(struct yasl_private_display *base, enum yasl_private_s } } -static void paste(struct yasl_private_display *base, enum yasl_private_selection sel, - struct yasl_surface *target) -{ - (void)request_paste(base, sel, target, 0); -} - -static bool input_poll(struct yasl_surface *base, struct yasl_private_event *event) -{ - struct x11_surface *s = (struct x11_surface *)base; - if (s->destroyed) return false; - if (base->display->events) return yasl_private_events_poll_surface(base, event); - return input_queue_pop(&s->input, event); -} - static struct input_queue *surface_input_queue(struct yasl_surface *base) { return &((struct x11_surface *)base)->input; @@ -3077,8 +3029,6 @@ const struct yasl_private_backend_ops yasl_private_x11_backend = { .display_dispatch_timeout = dispatch_timeout, .display_flush = flush, .display_modifiers = mods, - .display_copy = copy, - .display_paste = paste, .display_copy_text = copy_text, .display_request_paste = request_paste, .display_drag_start = drag_start, @@ -3097,7 +3047,6 @@ const struct yasl_private_backend_ops yasl_private_x11_backend = { .surface_set_title = set_title, .surface_schedule_redraw = schedule_redraw, .surface_present = present, - .surface_poll_event = input_poll, .surface_geometry = geometry, .surface_timing = timing, .surface_frame_time_ns = frame_time, |
