diff options
| author | Berke Güzel <berke.guzel@gdh.digital> | 2026-10-14 09:38:31 +0300 |
|---|---|---|
| committer | Berke Güzel <berke.guzel@gdh.digital> | 2026-10-14 09:38:31 +0300 |
| commit | 5ef6ca21ab9e1cf4f69254234d190a634b777d52 (patch) | |
| tree | 974d3797a6d9487e54a811e224bf78a3f52dda85 /src | |
| parent | 563b23a33726289387193b85d90fb569631ee05f (diff) | |
Remove deprecated Cocoa OpenGL and private compatibility APIs
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/backend.c | 32 | ||||
| -rw-r--r-- | src/common/backend.h | 9 | ||||
| -rw-r--r-- | src/common/events.c | 56 | ||||
| -rw-r--r-- | src/common/surface.c | 6 | ||||
| -rw-r--r-- | src/common/types.h | 106 | ||||
| -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 |
16 files changed, 75 insertions, 598 deletions
diff --git a/src/common/backend.c b/src/common/backend.c index 8d20f67..939ec71 100644 --- a/src/common/backend.c +++ b/src/common/backend.c @@ -34,7 +34,6 @@ static struct yasl_private_display *open_backend(enum yasl_private_backend backe struct yasl_private_display *d = ops->display_open(loop, spec); if (!d && !errno) errno = ENODEV; if (d) { - d->callback_ud = spec ? spec->ud : NULL; if (!yasl_private_events_open(d)) { int error = errno; ops->display_close(d); @@ -132,26 +131,6 @@ int yasl_private_display_double_click_ms(const struct yasl_private_display *d) return ms > 0 && ms <= 10000 ? ms : YASL_PRIVATE_DOUBLE_CLICK_MS_DEFAULT; } -void yasl_private_display_copy(struct yasl_private_display *d, enum yasl_private_selection sel, const char *text) -{ - if (!d || !d->ops->display_copy || !text || - (sel != YASL_PRIVATE_CLIPBOARD && sel != YASL_PRIVATE_PRIMARY) || - (sel == YASL_PRIVATE_PRIMARY && !(yasl_private_display_caps(d) & YASL_PRIVATE_CAP_PRIMARY_SELECTION))) - return; - d->ops->display_copy(d, sel, text); -} - -void yasl_private_display_paste(struct yasl_private_display *d, enum yasl_private_selection sel, struct yasl_surface *target) -{ - if (!d || !d->ops->display_paste || - (sel != YASL_PRIVATE_CLIPBOARD && sel != YASL_PRIVATE_PRIMARY) || - (sel == YASL_PRIVATE_PRIMARY && !(yasl_private_display_caps(d) & YASL_PRIVATE_CAP_PRIMARY_SELECTION))) - return; - if (!target || target->display != d) - return; - d->ops->display_paste(d, sel, target); -} - bool yasl_private_display_drag_start(struct yasl_private_display *d, struct yasl_surface *origin, const struct yasl_private_drag_image *image, const struct yasl_private_drag_listener *l, void *ud) { if (!d || !d->ops->display_drag_start) @@ -336,17 +315,6 @@ bool yasl_private_surface_present(struct yasl_surface *s, const struct yasl_priv return s->display->ops->surface_present(s, fb, &clipped); } -bool yasl_private_surface_poll_event(struct yasl_surface *s, struct yasl_private_event *ev) -{ - if (!s || !ev) - return false; - if (s->display && s->display->events) - return yasl_private_events_poll_surface(s, ev); - if (s->display && s->display->ops && s->display->ops->surface_poll_event) - return s->display->ops->surface_poll_event(s, ev); - return input_queue_pop(&s->input, ev); -} - bool yasl_private_surface_read_pixels(struct yasl_surface *s, uint32_t *out, size_t cap, struct yasl_private_vector2i *size) { diff --git a/src/common/backend.h b/src/common/backend.h index bf6815a..6eefbb3 100644 --- a/src/common/backend.h +++ b/src/common/backend.h @@ -17,11 +17,9 @@ struct yasl_private_display { const struct yasl_private_backend_ops *ops; void *native_handle; bool offline; /* Connection lost; native handles are unusable until it is restored. */ - struct yasl_private_display_cbs callbacks; struct yasl_private_loop *loop; /* Backend's copy of yasl_private_display_spec.app_id, or NULL; for desktop services. */ const char *app_id; - void *callback_ud; struct yasl_private_event_state *events; struct yasl_surface *surfaces; }; @@ -82,7 +80,6 @@ bool yasl_private_events_register(struct yasl_surface *s); void yasl_private_events_unregister(struct yasl_surface *s); bool yasl_private_events_push(struct yasl_private_display *d, struct yasl_surface *queue_owner, const struct yasl_private_event *event); -bool yasl_private_events_poll_surface(struct yasl_surface *s, struct yasl_private_event *event); void yasl_private_surface_notify_configure(struct yasl_surface *s, struct yasl_private_geometry geometry); void yasl_private_surface_notify_refresh(struct yasl_surface *s); void yasl_private_surface_notify_close(struct yasl_surface *s); @@ -136,8 +133,6 @@ struct yasl_private_backend_ops { int (*display_modifiers)(const struct yasl_private_display *d); /* Optional; returns zero or less when the system reports no interval. */ int (*display_double_click_ms)(const struct yasl_private_display *d); - void (*display_copy)(struct yasl_private_display *d, enum yasl_private_selection sel, const char *text); - void (*display_paste)(struct yasl_private_display *d, enum yasl_private_selection sel, struct yasl_surface *target); bool (*display_copy_text)(struct yasl_private_display *d, enum yasl_private_selection sel, const char *text); bool (*display_request_paste)(struct yasl_private_display *d, enum yasl_private_selection sel, struct yasl_surface *target, uint64_t request_id); @@ -150,7 +145,7 @@ struct yasl_private_backend_ops { bool (*surface_popup_reposition)(struct yasl_surface *popup, const struct yasl_private_popup_spec *spec); void (*surface_destroy)(struct yasl_surface *s); struct input_queue *(*surface_input_queue)(struct yasl_surface *s); - bool (*surface_set_size)(struct yasl_surface *s, struct yasl_private_vector2i size_logical); + bool (*surface_set_size)(struct yasl_surface *s, struct yasl_private_vector2i size); bool (*surface_set_fullscreen)(struct yasl_surface *s, bool enabled); bool (*surface_set_maximized)(struct yasl_surface *s, bool enabled); bool (*surface_minimize)(struct yasl_surface *s); @@ -160,8 +155,6 @@ struct yasl_private_backend_ops { void (*surface_set_title)(struct yasl_surface *s, const char *title); void (*surface_schedule_redraw)(struct yasl_surface *s); bool (*surface_present)(struct yasl_surface *s, const struct yasl_private_framebuffer *fb, const struct yasl_private_damage_list *damage); - /* Optional; NULL means the common input queue is drained. */ - bool (*surface_poll_event)(struct yasl_surface *s, struct yasl_private_event *ev); /* Optional; NULL means only YASL_PRIVATE_POINTER_NORMAL is supported. Backends that * implement RELATIVE push POINTER_MOTION with delta set and pos frozen. */ bool (*surface_set_pointer_mode)(struct yasl_surface *s, enum yasl_private_pointer_mode mode); diff --git a/src/common/events.c b/src/common/events.c index ba78d77..9245050 100644 --- a/src/common/events.c +++ b/src/common/events.c @@ -228,46 +228,18 @@ bool yasl_private_display_post(struct yasl_private_display *d, const struct yasl return true; } -static bool poll_event(struct yasl_private_display *d, uint64_t queue_id, struct yasl_private_event *event) +bool yasl_private_display_poll_event(struct yasl_private_display *d, struct yasl_private_event *event) { if (!d || !d->events || !event) return false; struct yasl_private_event_state *state = d->events; yasl_private_mutex_lock(&state->mutex); - struct event_node *discarded = NULL; - struct event_node **entry = &state->head; - struct event_node *previous = NULL; - if (queue_id) { - /* The input-only migration adapter uses legacy callbacks for lifecycle. - * Retaining those notifications would keep dispatch permanently ready. - * Mixing this adapter with display polling is deliberately unsupported. */ - while (*entry) { - struct event_node *candidate = *entry; - if (candidate->event.type < YASL_PRIVATE_EVENT_KEY || - candidate->event.type > YASL_PRIVATE_EVENT_INPUT_RESET) { - *entry = candidate->next; - if (state->tail == candidate) state->tail = previous; - candidate->next = discarded; - discarded = candidate; - } else { - previous = candidate; - entry = &candidate->next; - } - } - entry = &state->head; - previous = NULL; - while (*entry && (*entry)->queue_id != queue_id) { - previous = *entry; - entry = &(*entry)->next; - } - } - struct event_node *node = *entry; + struct event_node *node = state->head; if (!node) { yasl_private_mutex_unlock(&state->mutex); - dispose_list(discarded); return false; } - *entry = node->next; - if (state->tail == node) state->tail = previous; + state->head = node->next; + if (state->tail == node) state->tail = NULL; node->next = NULL; if (node->event.surface_id) node->event.surface = yasl_private_events_find(d, node->event.surface_id); @@ -276,20 +248,9 @@ static bool poll_event(struct yasl_private_display *d, uint64_t queue_id, struct *event = node->event; yasl_private_mutex_unlock(&state->mutex); dispose(last); - dispose_list(discarded); return true; } -bool yasl_private_display_poll_event(struct yasl_private_display *d, struct yasl_private_event *event) -{ - return poll_event(d, 0, event); -} - -bool yasl_private_events_poll_surface(struct yasl_surface *s, struct yasl_private_event *event) -{ - return s && s->id ? poll_event(s->display, s->id, event) : false; -} - uint64_t yasl_private_events_request_id(struct yasl_private_display *d) { if (!d->events || d->events->request == UINT64_MAX) { errno = EOVERFLOW; return 0; } @@ -310,14 +271,12 @@ void yasl_private_surface_notify_configure(struct yasl_surface *s, struct yasl_p .resize = {.geometry = geometry, .scale_changed = previous_scale != geometry.scale_120}}; yasl_private_events_push(s->display, s, &event); if (s->display) yasl_private_surface_request_frame(s); - if (s->callbacks.configure) s->callbacks.configure(s, geometry, s->ud); } void yasl_private_surface_notify_close(struct yasl_surface *s) { struct yasl_private_event event = {.type = YASL_PRIVATE_EVENT_WINDOW_CLOSE, .surface = s}; yasl_private_events_push(s->display, s, &event); - if (s->callbacks.close) s->callbacks.close(s, s->ud); } void yasl_private_surface_notify_state(struct yasl_surface *s, uint32_t flags) @@ -325,21 +284,18 @@ void yasl_private_surface_notify_state(struct yasl_surface *s, uint32_t flags) s->state = flags; struct yasl_private_event event = {.type = YASL_PRIVATE_EVENT_WINDOW_STATE, .surface = s, .state.flags = flags}; yasl_private_events_push(s->display, s, &event); - if (s->callbacks.state) s->callbacks.state(s, flags, s->ud); } void yasl_private_surface_notify_drag(struct yasl_surface *s, enum yasl_private_drag_event action, struct yasl_private_vector2i pos) { struct yasl_private_event event = {.type = YASL_PRIVATE_EVENT_DRAG, .surface = s, .drag = {action, pos}}; yasl_private_events_push(s->display, s, &event); - if (s->callbacks.drag) s->callbacks.drag(s, action, pos, s->ud); } void yasl_private_surface_notify_drop(struct yasl_surface *s, enum yasl_private_drop_event action, struct yasl_private_vector2i pos) { struct yasl_private_event event = {.type = YASL_PRIVATE_EVENT_DROP_HOVER, .surface = s, .drop = {action, pos}}; yasl_private_events_push(s->display, s, &event); - if (s->callbacks.drop) s->callbacks.drop(s, action, pos, s->ud); } void yasl_private_surface_notify_composition(struct yasl_surface *s, const char *text, int begin, int end) @@ -367,8 +323,4 @@ void yasl_private_display_notify_event(struct yasl_private_display *d, enum yasl { struct yasl_private_event event = {.type = type}; yasl_private_events_push(d, NULL, &event); - void (*callback)(void *) = type == YASL_PRIVATE_EVENT_DISPLAY_QUIT ? d->callbacks.quit - : type == YASL_PRIVATE_EVENT_DISPLAY_REOPEN ? d->callbacks.reopen - : type == YASL_PRIVATE_EVENT_DISPLAY_LOST ? d->callbacks.lost : NULL; - if (callback) callback(d->callback_ud); } diff --git a/src/common/surface.c b/src/common/surface.c index 9b4a8ad..b47fea7 100644 --- a/src/common/surface.c +++ b/src/common/surface.c @@ -119,7 +119,7 @@ yasl_surface *yasl_surface_create(const char *title,int width,int height,unsigne if(!creation_valid(width,height,flags)) return NULL; bool fresh=!display; if(!initialize()) return NULL; - struct yasl_private_window_spec spec={.title=title,.size_logical={width,height}, + struct yasl_private_window_spec spec={.title=title,.size={width,height}, .flags=flags,.external_gpu=!(flags&YASL_SURFACE_CPU)}; yasl_surface *s=yasl_private_surface_create_toplevel(display,&spec); if(!s) { @@ -446,7 +446,7 @@ static bool trigger_valid(yasl_surface *s,const yasl_event *e) static bool popup_spec(yasl_surface *s,int w,int h,double x,double y,double aw,double ah,enum yasl_popup_edge anchor,enum yasl_popup_edge gravity,unsigned constraints,struct yasl_private_popup_spec *out) { if(w<=0||h<=0 || (unsigned)anchor>8 || (unsigned)gravity>8 || (constraints&~63u))return yasl_public_fail(EINVAL); - *out=(struct yasl_private_popup_spec){.size={yasl_private_scale_to_device(w,s->scale_120),yasl_private_scale_to_device(h,s->scale_120)},.anchor_edges=anchor,.gravity=gravity,.constraints=constraints,.positioner_explicit=true}; + *out=(struct yasl_private_popup_spec){.size={yasl_private_scale_to_device(w,s->scale_120),yasl_private_scale_to_device(h,s->scale_120)},.anchor_edges=anchor,.gravity=gravity,.constraints=constraints}; return logical_rect(s,x,y,aw,ah,&out->anchor); } yasl_surface *yasl_popup_create(yasl_surface *parent,int w,int h,double x,double y,double aw,double ah,enum yasl_popup_edge anchor,enum yasl_popup_edge gravity,unsigned constraints,const yasl_event *trigger) @@ -494,7 +494,7 @@ yasl_surface *yasl_gl_surface_create(const char *title,int w,int h,unsigned flag bool fresh=!display;if(!initialize())return NULL; if(share && (share->display!=display || share->presenter!=YASL_PRIVATE_PRESENTER_GL)) {yasl_public_fail(EINVAL);return NULL;} if(!display->ops->surface_create_gl) {if(fresh)yasl_shutdown();yasl_public_fail(ENOTSUP);return NULL;} - struct yasl_private_window_spec spec={.title=title,.size_logical={w,h},.flags=flags,.external_gpu=true}; + struct yasl_private_window_spec spec={.title=title,.size={w,h},.flags=flags,.external_gpu=true}; yasl_surface *s=display->ops->surface_create_gl(display,&spec,attrs,share); if(!s){int error=errno;if(fresh)yasl_shutdown();yasl_public_fail(error);return NULL;} if(!yasl_private_events_register(s)){int error=errno;display->ops->surface_destroy(s);if(fresh)yasl_shutdown();yasl_public_fail(error);return NULL;} diff --git a/src/common/types.h b/src/common/types.h index 40c502f..8b9bbba 100644 --- a/src/common/types.h +++ b/src/common/types.h @@ -22,7 +22,7 @@ * Coordinates have their origin at the upper left; x grows right and y grows down. * Scale is an integer ratio with YASL_PRIVATE_SCALE_UNIT (120) representing 1x. * See the application guide for the display-wide dispatch/poll/flush cycle - * and backend limits. Legacy surface polling is an input-only filtered adapter. + * and backend limits. */ #ifndef YASL_PRIVATE_H #define YASL_PRIVATE_H @@ -145,7 +145,7 @@ enum yasl_private_surface_state : uint32_t { YASL_PRIVATE_STATE_TILED = 1 << 5, /**< At least one edge is tiled; currently reported by Wayland. */ }; -/** System cursor shapes. HIDDEN preserves pointer input; NONE is its compatibility alias. */ +/** System cursor shapes. HIDDEN preserves pointer input. */ enum yasl_private_cursor { YASL_PRIVATE_CURSOR_ARROW, /**< Default arrow. */ YASL_PRIVATE_CURSOR_TEXT, /**< Text insertion. */ @@ -157,7 +157,6 @@ enum yasl_private_cursor { YASL_PRIVATE_CURSOR_RESIZE_EW, /**< Horizontal resize. */ YASL_PRIVATE_CURSOR_RESIZE_NS, /**< Vertical resize. */ YASL_PRIVATE_CURSOR_HIDDEN, /**< Hidden system cursor; pointer input continues. */ - YASL_PRIVATE_CURSOR_NONE = YASL_PRIVATE_CURSOR_HIDDEN, /**< Compatibility alias for HIDDEN. */ }; /** Valid interactive resize edges; combinations are restricted to the named values. */ @@ -328,7 +327,7 @@ struct yasl_private_pointer_pen { enum yasl_private_event_type { YASL_PRIVATE_EVENT_NONE = 0, - /* Input: produced by backends, returned by yasl_private_surface_poll_event(). */ + /* Input: produced by backends and consumed from the display FIFO. */ YASL_PRIVATE_EVENT_KEY, /**< .key */ YASL_PRIVATE_EVENT_TEXT, /**< .text — committed UTF-8; insert this, not key codepoints. */ YASL_PRIVATE_EVENT_POINTER_DOWN, /**< .pointer — button/tip pressed; button valid. */ @@ -337,12 +336,11 @@ enum yasl_private_event_type { YASL_PRIVATE_EVENT_POINTER_SCROLL, /**< .pointer — scroll valid. */ YASL_PRIVATE_EVENT_POINTER_LEAVE, /**< .pointer — last known pos/device; cancel hover state. */ YASL_PRIVATE_EVENT_FOCUS, /**< .focus — keyboard focus changed; cancel held state on loss. */ - YASL_PRIVATE_EVENT_PASTE, /**< .text — UTF-8 from yasl_private_display_paste(). */ + YASL_PRIVATE_EVENT_PASTE, /**< .paste — clipboard request completion. */ YASL_PRIVATE_EVENT_DROP, /**< .text — dropped text/uri-list: CRLF-separated file URLs, not paths. */ YASL_PRIVATE_EVENT_INPUT_RESET, /**< No payload. Input stream interrupted; clear held keys, buttons, strokes, IME. */ - /* Window and application: part of the display FIFO, as well as runner delivery. - * Legacy window callbacks also receive matching native notifications. */ + /* Window and application notifications in the display FIFO. */ YASL_PRIVATE_EVENT_WINDOW_RESIZE, /**< .resize — size and/or scale changed; reallocate and redraw. */ YASL_PRIVATE_EVENT_WINDOW_CLOSE, /**< No payload. User asked to close the window. */ YASL_PRIVATE_EVENT_USER, /**< .user — posted application message. */ @@ -414,7 +412,7 @@ struct yasl_private_pointer_event { /** Borrowed NUL-terminated UTF-8, shared by TEXT, PASTE and DROP. */ struct yasl_private_text_event { - /** Borrowed NUL-terminated bytes; see yasl_private_surface_poll_event() for lifetime. */ + /** Borrowed NUL-terminated bytes; valid until the next successful display poll or display close. */ const char *data; /** Length in bytes excluding the terminating NUL. */ size_t len; @@ -427,11 +425,11 @@ enum yasl_private_transfer_status { YASL_PRIVATE_TRANSFER_FAILED, /**< Transfer or decoding failed. */ }; -/** Clipboard completion; data/len alias the legacy text payload. */ +/** Clipboard completion; data/len share the text payload layout. */ struct yasl_private_paste_event { const char *data; /**< Borrowed NUL-terminated UTF-8; empty on failure. */ size_t len; /**< Byte length excluding NUL. */ - uint64_t request_id; /**< Zero for a legacy paste request. */ + uint64_t request_id; /**< Nonzero clipboard request identity. */ enum yasl_private_transfer_status status; /**< Completion outcome. */ }; @@ -511,7 +509,7 @@ struct yasl_private_event { struct { const char *data; size_t len; uint64_t revision, generation; size_t begin, end; } text_edit; struct yasl_private_key_event key; /**< KEY */ struct yasl_private_pointer_event pointer; /**< POINTER_* */ - struct yasl_private_text_event text; /**< TEXT, legacy PASTE, DROP */ + struct yasl_private_text_event text; /**< TEXT, DROP */ struct yasl_private_paste_event paste; /**< PASTE */ struct yasl_private_composition_event composition; /**< COMPOSITION */ struct yasl_private_state_event state; /**< WINDOW_STATE */ @@ -534,35 +532,9 @@ struct yasl_private_event { */ /* Callbacks */ -/** Optional display notifications. NULL callback members are ignored. */ -struct yasl_private_display_cbs { - /** Application quit request; arrange orderly shutdown after dispatch returns. */ - void (*quit)(void *ud); - /** Application reopen/activation request, currently Cocoa. */ - void (*reopen)(void *ud); - /** Display connection lost; arrange cleanup after dispatch returns. */ - void (*lost)(void *ud); -}; - -/** Optional window/popup notifications, copied from yasl_private_window_spec.cbs or by -yasl_private_surface_set_callbacks(). -Callbacks may destroy their surface. They must then return without further use -of the surface or draw target. NULL members are ignored. */ +/** Internal CPU presenter callback, copied on installation. */ struct yasl_private_window_cbs { - /** Initialize the entire target and optionally present. Requested through schedule_redraw/flush. */ void (*draw)(struct yasl_surface *s, struct yasl_private_frame *frame, void *ud); - /** Configured size/scale changed; reallocate application content and request a redraw. */ - void (*configure)(struct yasl_surface *s, struct yasl_private_geometry geometry, void *ud); - /** Window/popup close request; application is responsible for destruction. */ - void (*close)(struct yasl_surface *s, void *ud); - /** Reported yasl_private_surface_state bitmask changed; matches yasl_private_surface_state(s). */ - void (*state)(struct yasl_surface *s, uint32_t state, void *ud); - /** YASL surface-drag target hover, leave, or drop; pos is in device pixels. */ - void (*drag)(struct yasl_surface *s, enum yasl_private_drag_event ev, - struct yasl_private_vector2i pos, void *ud); - /** External data-drag hover or leave; pos is in device pixels. */ - void (*drop)(struct yasl_surface *s, enum yasl_private_drop_event ev, - struct yasl_private_vector2i pos, void *ud); }; /* Display Lifecycle */ @@ -578,10 +550,6 @@ enum yasl_private_backend { struct yasl_private_display_spec { /** Copied application identifier, conventionally a reverse-domain UTF-8 string; NULL uses backend defaults. */ const char *app_id; - /** Copied optional display callbacks; NULL disables them. */ - const struct yasl_private_display_cbs *cbs; - /** Borrowed display callback userdata. */ - void *ud; /** Zero/AUTO chooses native backend; explicit choices never fall back. */ enum yasl_private_backend backend; @@ -661,26 +629,6 @@ int yasl_private_display_modifiers(const struct yasl_private_display *d); * rather than on every click. */ int yasl_private_display_double_click_ms(const struct yasl_private_display *d); -/* Unsupported/invalid selections are no-ops, never clipboard aliases. */ -/** - * Offer a copy of a NUL-terminated UTF-8 string as a selection. - * @param d Display, or NULL for no action. - * @param sel YASL_PRIVATE_CLIPBOARD or YASL_PRIVATE_PRIMARY. - * @param text Text copied during this call; NULL does nothing. - * Unsupported selections do nothing. The void return does not confirm that the - * system accepted the offer; Wayland may require a recent input serial. - */ -void yasl_private_display_copy(struct yasl_private_display *d, enum yasl_private_selection sel, const char *text); -/** - * Request text delivery to a particular surface. - * @param d Display that owns target. - * @param sel YASL_PRIVATE_CLIPBOARD or YASL_PRIVATE_PRIMARY. - * @param target Destination surface; NULL or a surface on another display does nothing. - * Results arrive as YASL_PRIVATE_EVENT_PASTE, possibly during a later dispatch. No result - * is promised for unavailable data or a failed transfer. Destroying target cancels - * delivery. Unsupported selections do nothing. - */ -void yasl_private_display_paste(struct yasl_private_display *d, enum yasl_private_selection sel, struct yasl_surface *target); /* A successful drag invokes the copied listener's non-NULL end once, including * cancel and display close. Failed starts do not invoke it. */ @@ -714,19 +662,16 @@ struct yasl_private_window_spec { /** Copied UTF-8 title; NULL uses backend defaults. */ const char *title; /** Requested logical-pixel width and height; both must be positive. */ - union { - struct yasl_private_vector2i size_logical; /**< Requested logical-pixel extent. */ - struct yasl_private_vector2i size; /**< Migration alias for size_logical. */ - }; + struct yasl_private_vector2i size; /** Request initial fullscreen; actual state is reported asynchronously. */ bool fullscreen; /** Permit unpaced presentation where supported; a hint, not a guarantee. */ bool tearing; /** Copied optional window callbacks; NULL disables them. */ const struct yasl_private_window_cbs *cbs; - /** Borrowed window callback userdata; ignored by the runner. */ + /** Borrowed CPU presenter userdata. */ void *ud; - /** Borrowed application data, independent of callbacks and available in either loop style. */ + /** Borrowed application data, independent of the CPU presenter. */ void *userdata; }; @@ -738,13 +683,10 @@ Dimensions must be positive, at most 32767, and fit an INT32_MAX-byte buffer; backends may impose further limits after scaling or resolving placement. */ struct yasl_private_popup_spec { unsigned anchor_edges, gravity, constraints; - bool positioner_explicit; /** Full popup framebuffer extent in device pixels, including transparent margins. */ struct yasl_private_vector2i size; /** Rectangle in parent framebuffer coordinates, in device pixels. */ struct yasl_private_rect2i anchor; - /** true prefers right of anchor; false prefers below. Placement may flip/slide. */ - bool beside; /** Top-left content offset within the popup, in device pixels. */ struct yasl_private_vector2i content_offset; /** Content extent; zero per axis extends to the corresponding size edge. */ @@ -761,10 +703,8 @@ struct yasl_private_popup_spec { * size may differ from the request. The callback table in spec->cbs is copied; * spec->ud stays borrowed until callbacks are replaced or the surface is destroyed. * This window's callbacks cannot run before creation returns. Use - * yasl_private_surface_geometry() for initial geometry; an initial configure callback - * is not guaranteed. Schedule an initial redraw after setting up application state. - * On a display owned by yasl_private_run(), the runner installs its own callbacks instead; - * use yasl_private_app_desc.event and yasl_private_app_desc.frame for application notifications. + * yasl_private_surface_geometry() for initial geometry. Schedule an initial redraw + * after setting up the CPU presenter. Lifecycle notifications arrive in the display FIFO. */ struct yasl_surface *yasl_private_surface_create_toplevel(struct yasl_private_display *d, const struct yasl_private_window_spec *spec); @@ -809,7 +749,7 @@ struct yasl_private_display *yasl_private_surface_display(const struct yasl_surf * @param s Surface. * @param cbs Table copied by value; NULL removes all callbacks. NULL members are ignored. * @param ud Borrowed userdata passed to the installed callbacks. - * @return true if replaced; false with EINVAL for NULL, EBUSY on a runner-owned surface. + * @return true if replaced; false with EINVAL for NULL. * This call only replaces callbacks; it does not invoke them. * Use yasl_private_surface_geometry() to read current geometry; do not rely on receiving * an initial configure callback when registering. @@ -849,18 +789,6 @@ void yasl_private_surface_schedule_redraw(struct yasl_surface *s); bool yasl_private_surface_present(struct yasl_surface *s, const struct yasl_private_framebuffer *fb, const struct yasl_private_damage_list *damage); /** - * Migration adapter: consume one input event for a surface from the display FIFO. - * Popup input can belong to the root queue; inspect ev->surface. Returns false - * for empty/invalid arguments, leaving ev unchanged. Strings remain borrowed - * until the next successful display or surface poll, or display close. Pending - * recipient events are canceled on destruction. Prefer yasl_private_display_poll_event() - * to receive window, composition, and display events as well as input. This - * input-only adapter discards pending non-input events across the display - * (legacy callbacks already delivered lifecycle changes). Do not mix - * the two polling styles in one application. Use the display thread. - */ -bool yasl_private_surface_poll_event(struct yasl_surface *s, struct yasl_private_event *ev); -/** * Decode the next local file path from a YASL_PRIVATE_EVENT_DROP payload. * @param cursor Required in/out position in the NUL-terminated list. Start it * at event.text.data; a NULL *cursor returns zero. @@ -958,7 +886,7 @@ void yasl_private_surface_request_frame(struct yasl_surface *s); bool yasl_private_surface_set_pacing(struct yasl_surface *s, yasl_private_pacing_mode mode); /** Request a positive logical-pixel size. Success means issued, not configured. */ -bool yasl_private_surface_set_size(struct yasl_surface *s, struct yasl_private_vector2i size_logical); +bool yasl_private_surface_set_size(struct yasl_surface *s, struct yasl_private_vector2i size); /** Request fullscreen state; returns acceptance, not confirmation. */ bool yasl_private_surface_set_fullscreen(struct yasl_surface *s, bool enabled); /** Request maximized state; returns acceptance, not confirmation. */ 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, |
