diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-11 23:51:43 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-11 23:51:43 +0300 |
| commit | e813252e685d761235ad45e170d97c9375f51958 (patch) | |
| tree | e57bae545c0eb22aac4119a890b8344ee7cd09d2 /src/wayland/buffer.c | |
| parent | 608b49052178ea74f593c925cdeedf352aa1c357 (diff) | |
| parent | 6eac0a5f2c552728efca420b1129fae7d4fea773 (diff) | |
Merge branch 'backend-selection' into main
- Implement runtime backend selection (Wayland, X11, Cocoa)
- Add native X11 backend with clipboard, keyboard, mouse, and placement
- Integrate multi-backend integration tests running under Weston and Xwayland
- Retain zero-hole struct packing, branchless ALU/LUT primitives, and paced event loop
Diffstat (limited to 'src/wayland/buffer.c')
| -rw-r--r-- | src/wayland/buffer.c | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/src/wayland/buffer.c b/src/wayland/buffer.c index 0b6b028..76f6c0e 100644 --- a/src/wayland/buffer.c +++ b/src/wayland/buffer.c @@ -7,7 +7,7 @@ static long minor_faults(void) return getrusage(RUSAGE_SELF, &usage) == 0 ? usage.ru_minflt : 0; } -void surface_update_opaque_region(struct yasl_surface *w) +void surface_update_opaque_region(struct wayland_surface *w) { if (!w || !w->opaque || w->logical_width <= 0 || w->logical_height <= 0) return; @@ -55,7 +55,7 @@ static bool fd_truncate(int fd, size_t bytes) return rc == 0; } -int buffer_reserve(struct yasl_surface *w, struct buffer *b, size_t needed) +int buffer_reserve(struct wayland_surface *w, struct buffer *b, size_t needed) { if (needed <= b->capacity) return 0; if (b->busy || needed > INT32_MAX) return -1; @@ -87,7 +87,7 @@ int buffer_reserve(struct yasl_surface *w, struct buffer *b, size_t needed) return 0; } -int buffer_prepare(struct yasl_surface *w, struct buffer *b, int width, int height, +int buffer_prepare(struct wayland_surface *w, struct buffer *b, int width, int height, const struct wl_buffer_listener *listener) { if (b->proxy && !b->busy && b->width == width && b->height == height) return 0; @@ -113,7 +113,7 @@ int buffer_prepare(struct yasl_surface *w, struct buffer *b, int width, int heig return 0; } -static void publish_surface_scale(struct yasl_surface *w) +static void publish_surface_scale(struct wayland_surface *w) { if (w->viewport) { wp_viewport_set_destination(w->viewport, w->logical_width, w->logical_height); @@ -124,15 +124,15 @@ static void publish_surface_scale(struct yasl_surface *w) } } -static void surface_request_scale(struct yasl_surface *w, uint32_t scale_120) +static void surface_request_scale(struct wayland_surface *w, uint32_t scale_120) { if (!scale_120 || scale_120 == w->pending_scale_120) return; w->pending_scale_120 = scale_120; w->size_pending = true; - yasl_surface_schedule_redraw(w); + wayland_surface_schedule_redraw(w); } -int apply_pending_geometry(struct yasl_surface *w) +int apply_pending_geometry(struct wayland_surface *w) { if (!w->size_pending) return 0; if (w->parent && w->pending_scale_120 == w->scale_120) { @@ -183,7 +183,7 @@ int apply_pending_geometry(struct yasl_surface *w) } publish_surface_scale(w); if (w->cbs->configure && (resized || rescaled)) - w->cbs->configure(w, (struct yasl_geometry){ + w->cbs->configure(&w->base, (struct yasl_geometry){ .size = { .x = width, .y = height }, .scale_120 = w->scale_120, }, w->ud); return 0; @@ -200,7 +200,7 @@ static const struct wp_fractional_scale_v1_listener frac_scale_listener = { .preferred_scale = fractional_preferred_scale, }; -static void surface_follow_refresh(struct yasl_surface *w) +static void surface_follow_refresh(struct wayland_surface *w) { uint32_t refresh = 0; for (const struct wl_conn_output *o = w->conn->outputs; o; o = o->next) @@ -213,7 +213,7 @@ static void surface_follow_refresh(struct yasl_surface *w) w->clock.refresh_ns = refresh; } -void surface_follow_outputs(struct yasl_surface *w) +void surface_follow_outputs(struct wayland_surface *w) { surface_follow_refresh(w); if (!w->frac_scale && !surface_gets_preferred_scale(w->surface)) @@ -223,7 +223,7 @@ void surface_follow_outputs(struct yasl_surface *w) static void surface_enter(void *data, struct wl_surface *surface, struct wl_output *output) { (void)surface; - struct yasl_surface *w = data; + struct wayland_surface *w = data; w->outputs |= conn_output_mask(w->conn, output); surface_follow_outputs(w); } @@ -231,7 +231,7 @@ static void surface_enter(void *data, struct wl_surface *surface, struct wl_outp static void surface_leave(void *data, struct wl_surface *surface, struct wl_output *output) { (void)surface; - struct yasl_surface *w = data; + struct wayland_surface *w = data; w->outputs &= ~conn_output_mask(w->conn, output); surface_follow_outputs(w); } @@ -239,7 +239,7 @@ static void surface_leave(void *data, struct wl_surface *surface, struct wl_outp static void surface_preferred_scale(void *data, struct wl_surface *surface, int32_t factor) { (void)surface; - struct yasl_surface *w = data; + struct wayland_surface *w = data; if (w->frac_scale || w->parent || factor <= 0) return; surface_request_scale(w, (uint32_t)factor * YASL_SCALE_UNIT); @@ -264,7 +264,7 @@ static void buffer_release(void *data, struct wl_buffer *buffer) struct buffer *b = data; b->busy = false; if (b->owner && b->owner->want_draw) - yasl_surface_schedule_redraw(b->owner); + wayland_surface_schedule_redraw(b->owner); } static const struct wl_buffer_listener buffer_listener = { @@ -273,7 +273,7 @@ static const struct wl_buffer_listener buffer_listener = { static void frame_done(void *data, struct wl_callback *cb, uint32_t ms) { - struct yasl_surface *w = data; + struct wayland_surface *w = data; wl_callback_destroy(cb); w->frame_cb = NULL; @@ -282,14 +282,14 @@ static void frame_done(void *data, struct wl_callback *cb, uint32_t ms) yasl_clock_presented(&w->clock, yasl_clock_extend_ms(ms, now), w->sample_refresh); if (w->want_draw) - yasl_surface_schedule_redraw(w); + wayland_surface_schedule_redraw(w); } static const struct wl_callback_listener frame_listener = { .done = frame_done, }; -static void arm_frame(struct yasl_surface *w) +static void arm_frame(struct wayland_surface *w) { if (!w->configured || w->closed || w->frame_cb) return; @@ -321,7 +321,7 @@ int buffer_pick_free_index(const struct buffer *bufs, int cur) } struct latency_feedback { - struct yasl_surface *window; + struct wayland_surface *window; struct wp_presentation_feedback *proxy; struct latency_feedback *next; }; @@ -335,7 +335,7 @@ static void feedback_destroy(struct latency_feedback *feedback) free(feedback); } -void surface_feedback_destroy(struct yasl_surface *w) +void surface_feedback_destroy(struct wayland_surface *w) { while (w->latency_feedbacks) feedback_destroy(w->latency_feedbacks); } @@ -352,7 +352,7 @@ static void presented(void *data, struct wp_presentation_feedback *fb, { (void)seq_hi; (void)seq_lo; (void)flags; struct latency_feedback *feedback = data; - struct yasl_surface *w = feedback->window; + struct wayland_surface *w = feedback->window; if (w->conn->pres_clock_known) { uint64_t ns = conn_pres_to_mono(w->conn, (((uint64_t)tv_sec_hi << 32) | tv_sec_lo) * 1000000000ull + tv_nsec); @@ -377,7 +377,7 @@ static const struct wp_presentation_feedback_listener feedback_listener = { .discarded = discarded, }; -void surface_request_presentation_feedback(struct yasl_surface *w) +void surface_request_presentation_feedback(struct wayland_surface *w) { if (!w || !w->conn->presentation) return; @@ -395,7 +395,7 @@ void surface_request_presentation_feedback(struct yasl_surface *w) wp_presentation_feedback_add_listener(fb, &feedback_listener, feedback); } -static void commit_buffer(struct yasl_surface *w, int idx) +static void commit_buffer(struct wayland_surface *w, int idx) { wl_surface_attach(w->surface, w->buffers[idx].proxy, 0, 0); @@ -438,7 +438,7 @@ static void commit_buffer(struct yasl_surface *w, int idx) w->buffers[idx].presented = true; } -bool yasl_surface_present(struct yasl_surface *w, const struct yasl_framebuffer *fb, +bool wayland_surface_present(struct wayland_surface *w, const struct yasl_framebuffer *fb, const struct yasl_damage_list *damage) { if (!w || w->closed || !w->frame_active || w->frame_presented || !fb || @@ -456,7 +456,7 @@ bool yasl_surface_present(struct yasl_surface *w, const struct yasl_framebuffer return true; } -void surface_draw_frame(struct yasl_surface *w) +void surface_draw_frame(struct wayland_surface *w) { if (w->closed || !w->configured) return; @@ -483,7 +483,7 @@ void surface_draw_frame(struct yasl_surface *w) memset(w->buffers[idx].pixels, 0, (size_t)w->width * (size_t)w->height * sizeof(uint32_t)); w->damage = (struct yasl_damage_list){0}; w->frame = (struct yasl_frame){ - .surface = w, + .surface = &w->base, .target = { .pixels = w->buffers[idx].pixels, .size = { .x = w->width, .y = w->height }, @@ -496,13 +496,13 @@ void surface_draw_frame(struct yasl_surface *w) }; w->frame_active = true; w->frame_presented = false; - w->cbs->draw(w, &w->frame, w->ud); + w->cbs->draw(&w->base, &w->frame, w->ud); w->frame_active = false; if (!w->closed && !w->frame_presented) w->frames_skipped++; } -int surface_init_scaling(struct yasl_surface *w) +int surface_init_scaling(struct wayland_surface *w) { wl_surface_add_listener(w->surface, &surface_listener, w); if (w->conn->viewporter) { @@ -518,7 +518,7 @@ int surface_init_scaling(struct yasl_surface *w) return 0; } -void yasl_surface_set_title(struct yasl_surface *w, const char *title) +void wayland_surface_set_title(struct wayland_surface *w, const char *title) { if (!w || !w->toplevel || !title) return; char *copy = yasl_utf8_sanitize_dup(title); @@ -527,7 +527,7 @@ void yasl_surface_set_title(struct yasl_surface *w, const char *title) free(copy); } -uint32_t yasl_surface_state(const struct yasl_surface *w) +uint32_t wayland_surface_state(const struct wayland_surface *w) { if (unlikely(!w)) return 0; return ((uint32_t)w->fullscreen * YASL_STATE_FULLSCREEN) | @@ -537,7 +537,7 @@ uint32_t yasl_surface_state(const struct yasl_surface *w) ((uint32_t)!w->server_decorated * YASL_STATE_CSD); } -struct yasl_timing yasl_surface_timing(const struct yasl_surface *w) +struct yasl_timing wayland_surface_timing(const struct wayland_surface *w) { struct yasl_timing t = { .refresh_ns = w->clock.refresh_ns, @@ -549,7 +549,7 @@ struct yasl_timing yasl_surface_timing(const struct yasl_surface *w) return t; } -uint64_t yasl_surface_frame_time_ns(struct yasl_surface *w, uint64_t now) +uint64_t wayland_surface_frame_time_ns(struct wayland_surface *w, uint64_t now) { return yasl_clock_frame_timestamp_ns(&w->clock, now); } |
