diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 14:14:28 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 14:14:28 +0300 |
| commit | 339e1ad7adb8340732ee856d0f6f0d2c7f1455d1 (patch) | |
| tree | 55d2735987f240e5eaacf6581ed3ce5db2c0e3a8 /src/platform/cocoa | |
| parent | e185a9d719d469a0fd7edcf09a6342f7b10cbb8e (diff) | |
Inline trivial internal helpers at their call sites
Diffstat (limited to 'src/platform/cocoa')
| -rw-r--r-- | src/platform/cocoa/api.h | 7 | ||||
| -rw-r--r-- | src/platform/cocoa/window.m | 56 |
2 files changed, 11 insertions, 52 deletions
diff --git a/src/platform/cocoa/api.h b/src/platform/cocoa/api.h index 802a039..89b71f3 100644 --- a/src/platform/cocoa/api.h +++ b/src/platform/cocoa/api.h @@ -15,25 +15,20 @@ int cocoa_display_modifiers(const struct cocoa_display *d); void cocoa_display_copy(struct cocoa_display *d, enum yasl_selection sel, const char *text); void cocoa_display_paste(struct cocoa_display *d, enum yasl_selection sel, struct cocoa_surface *target); bool cocoa_display_drag_start(struct cocoa_display *d, struct cocoa_surface *origin, const struct yasl_drag_image *image, const struct yasl_drag_listener *l, void *ud); -void cocoa_display_drag_cancel(struct cocoa_display *d); struct cocoa_surface *cocoa_surface_create_toplevel(struct cocoa_display *d, const struct yasl_window_spec *spec, void *graphics_device); struct cocoa_surface *cocoa_surface_create_popup(struct cocoa_surface *parent, const struct yasl_popup_spec *spec); bool cocoa_surface_popup_reposition(struct cocoa_surface *popup, const struct yasl_popup_spec *spec); void cocoa_surface_destroy(struct cocoa_surface *s); -struct cocoa_display *cocoa_surface_display(const struct cocoa_surface *s); void cocoa_surface_set_callbacks(struct cocoa_surface *s, const struct yasl_window_cbs *cbs, void *ud); 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_framebuffer *fb, const struct yasl_damage_list *damage); bool cocoa_surface_input_poll(struct cocoa_surface *s, struct yasl_input_event *ev); struct yasl_geometry cocoa_surface_geometry(const struct cocoa_surface *s); -uint32_t cocoa_surface_state(const struct cocoa_surface *s); struct yasl_timing cocoa_surface_timing(const struct cocoa_surface *s); -uint64_t cocoa_surface_frame_time_ns(struct cocoa_surface *s, uint64_t now); void cocoa_surface_set_cursor(struct cocoa_surface *s, enum yasl_cursor cursor); void cocoa_surface_set_background_color(struct cocoa_surface *s, uint32_t bg); -const char *cocoa_surface_ime_preedit(const struct cocoa_surface *s); bool cocoa_surface_ime_preedit_cursor(const struct cocoa_surface *s, int *begin, int *end); void cocoa_surface_set_ime_caret(struct cocoa_surface *s, struct yasl_rect2i caret); bool cocoa_surface_start_interactive_move(struct cocoa_surface *s); @@ -41,7 +36,5 @@ bool cocoa_surface_start_interactive_resize(struct cocoa_surface *s, enum yasl_r bool cocoa_surface_show_window_menu(struct cocoa_surface *s, struct yasl_vector2i pos); bool cocoa_surface_drag_carry(struct cocoa_surface *s, struct yasl_vector2i offset); bool cocoa_surface_place_under_pointer(struct cocoa_surface *s, struct yasl_vector2i at); -void *cocoa_display_get_native_handle(struct cocoa_display *d); -void *cocoa_surface_get_native_handle(struct cocoa_surface *s); #endif diff --git a/src/platform/cocoa/window.m b/src/platform/cocoa/window.m index 3c8519a..dc6175d 100644 --- a/src/platform/cocoa/window.m +++ b/src/platform/cocoa/window.m @@ -1487,11 +1487,6 @@ void cocoa_surface_destroy(struct cocoa_surface *w) yasl_loop_kick(darwin_ctx.loop); } -struct cocoa_display *cocoa_surface_display(const struct cocoa_surface *w) -{ - return w ? &darwin_ctx : NULL; -} - void cocoa_surface_set_title(struct cocoa_surface *w, const char *title) { if (!w || w->closed || !title) return; @@ -1540,11 +1535,6 @@ void cocoa_surface_set_ime_caret(struct cocoa_surface *w, struct yasl_rect2i car if (w) w->ime_caret = caret; } -const char *cocoa_surface_ime_preedit(const struct cocoa_surface *w) -{ - return w ? w->preedit : NULL; -} - bool cocoa_surface_ime_preedit_cursor(const struct cocoa_surface *w, int *begin, int *end) { (void)w; (void)begin; (void)end; @@ -1878,11 +1868,6 @@ bool cocoa_display_drag_start(struct cocoa_display *d, struct cocoa_surface *ori return true; } -void cocoa_display_drag_cancel(struct cocoa_display *d) -{ - drag_end(d, YASL_DRAG_CANCELLED); -} - bool cocoa_surface_drag_carry(struct cocoa_surface *w, struct yasl_vector2i offset) { if (!w || w->closed || !darwin_ctx.drag.active) @@ -1909,18 +1894,6 @@ bool cocoa_surface_show_window_menu(struct cocoa_surface *s, struct yasl_vector2 return false; } -void *cocoa_display_get_native_handle(struct cocoa_display *d) -{ - return d ? (void *)NSApp : NULL; -} - -void *cocoa_surface_get_native_handle(struct cocoa_surface *s) -{ - return s ? (void *)s->window : NULL; -} - - - void cocoa_surface_set_callbacks(struct cocoa_surface *w, const struct yasl_window_cbs *cbs, void *ud) { @@ -1946,11 +1919,6 @@ bool cocoa_surface_input_poll(struct cocoa_surface *w, struct yasl_input_event * return true; } -uint32_t cocoa_surface_state(const struct cocoa_surface *w) -{ - return w ? w->state : 0; -} - struct yasl_timing cocoa_surface_timing(const struct cocoa_surface *w) { struct yasl_timing timing = {0}; @@ -1965,11 +1933,6 @@ struct yasl_timing cocoa_surface_timing(const struct cocoa_surface *w) return timing; } -uint64_t cocoa_surface_frame_time_ns(struct cocoa_surface *w, uint64_t now) -{ - return w ? yasl_clock_frame_timestamp_ns(&w->clock, now) : now; -} - static struct yasl_display *impl_display_open(struct yasl_loop *loop, const struct yasl_display_spec *spec) { struct cocoa_display *result = cocoa_display_open(loop, spec); @@ -2018,7 +1981,7 @@ static bool impl_display_drag_start(struct yasl_display *d, struct yasl_surface static void impl_display_drag_cancel(struct yasl_display *d) { - cocoa_display_drag_cancel((struct cocoa_display *)d); + drag_end((struct cocoa_display *)d, YASL_DRAG_CANCELLED); } static struct yasl_surface *impl_surface_create_toplevel(struct yasl_display *d, @@ -2046,8 +2009,7 @@ static void impl_surface_destroy(struct yasl_surface *s) static struct yasl_display *impl_surface_display(const struct yasl_surface *s) { - struct cocoa_display *result = cocoa_surface_display((const struct cocoa_surface *)s); - return result ? &result->base : NULL; + return s ? &darwin_ctx.base : NULL; } static void impl_surface_set_callbacks(struct yasl_surface *s, const struct yasl_window_cbs *cbs, void *ud) @@ -2082,7 +2044,8 @@ static struct yasl_geometry impl_surface_geometry(const struct yasl_surface *s) static uint32_t impl_surface_state(const struct yasl_surface *s) { - return cocoa_surface_state((const struct cocoa_surface *)s); + const struct cocoa_surface *w = (const struct cocoa_surface *)s; + return w ? w->state : 0; } static struct yasl_timing impl_surface_timing(const struct yasl_surface *s) @@ -2092,7 +2055,8 @@ static struct yasl_timing impl_surface_timing(const struct yasl_surface *s) static uint64_t impl_surface_frame_time_ns(struct yasl_surface *s, uint64_t now) { - return cocoa_surface_frame_time_ns((struct cocoa_surface *)s, now); + struct cocoa_surface *w = (struct cocoa_surface *)s; + return w ? yasl_clock_frame_timestamp_ns(&w->clock, now) : now; } static void impl_surface_set_cursor(struct yasl_surface *s, enum yasl_cursor cursor) @@ -2107,7 +2071,8 @@ static void impl_surface_set_background_color(struct yasl_surface *s, uint32_t b static const char *impl_surface_ime_preedit(const struct yasl_surface *s) { - return cocoa_surface_ime_preedit((const struct cocoa_surface *)s); + const struct cocoa_surface *w = (const struct cocoa_surface *)s; + return w ? w->preedit : NULL; } static bool impl_surface_ime_preedit_cursor(const struct yasl_surface *s, int *begin, int *end) @@ -2147,12 +2112,13 @@ static bool impl_surface_place_under_pointer(struct yasl_surface *s, struct yasl static void *impl_display_get_native_handle(struct yasl_display *d) { - return cocoa_display_get_native_handle((struct cocoa_display *)d); + return d ? (void *)NSApp : NULL; } static void *impl_surface_get_native_handle(struct yasl_surface *s) { - return cocoa_surface_get_native_handle((struct cocoa_surface *)s); + struct cocoa_surface *w = (struct cocoa_surface *)s; + return w ? (void *)w->window : NULL; } static bool impl_surface_get_native_frame(struct yasl_surface *s, |
