diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-12 08:41:51 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-12 08:41:51 +0300 |
| commit | 3b8af02be94a510e385f44d58c35c86bb89424a6 (patch) | |
| tree | 2573fb5ac41700d458109ee1cea4bfd875ecf1a2 /src/wayland/popup.c | |
| parent | f7fa0930cb46046f995fa1ab927aef62466e995e (diff) | |
refactor: simplify public API and isolate native extensions
Separate loop/timer and native interoperability APIs from the portable surface header. Unify dispatch, geometry queries, and timer callbacks; keep framebuffer bookkeeping and frame clocks private, and hide implementation symbols.
Update backends, documentation, examples, and API/integration coverage. Verify exports, strict C/C++ installed consumers, and normal plus ASan/UBSan suites.
Diffstat (limited to 'src/wayland/popup.c')
| -rw-r--r-- | src/wayland/popup.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/wayland/popup.c b/src/wayland/popup.c index f0ef305..63bcba6 100644 --- a/src/wayland/popup.c +++ b/src/wayland/popup.c @@ -23,13 +23,18 @@ static const struct xdg_popup_listener popup_listener = { .repositioned = popup_repositioned, }; -static bool popup_spec_valid(const struct yasl_popup_spec *spec) +static bool popup_spec_valid(const struct wayland_surface *parent, + const struct yasl_popup_spec *spec) { - return spec && spec->size.x > 0 && spec->size.y > 0 && + if (!parent || !spec) return false; + int64_t x = (int64_t)spec->anchor.x - parent->content.x; + int64_t y = (int64_t)spec->anchor.y - parent->content.y; + return x >= INT_MIN && x <= INT_MAX && y >= INT_MIN && y <= INT_MAX && + spec->size.x > 0 && spec->size.y > 0 && spec->content_offset.x >= 0 && spec->content_offset.y >= 0 && spec->content_size.x >= 0 && spec->content_size.y >= 0 && - spec->content_offset.x + spec->content_size.x <= spec->size.x && - spec->content_offset.y + spec->content_size.y <= spec->size.y; + (int64_t)spec->content_offset.x + spec->content_size.x <= spec->size.x && + (int64_t)spec->content_offset.y + spec->content_size.y <= spec->size.y; } static bool popup_apply_spec(struct wayland_surface *w, const struct yasl_popup_spec *spec) @@ -125,7 +130,7 @@ struct wayland_surface *wayland_surface_create_popup(struct wayland_surface *par struct wayland_display *c = parent ? parent->conn : NULL; struct seat *seat = c ? conn_active_seat(c) : NULL; if (!c || c->lost || parent->closed || !parent->xdg_surface || !seat || - !seat->input_serial || !popup_spec_valid(spec)) + !seat->input_serial || !popup_spec_valid(parent, spec)) return NULL; struct wayland_surface *w = calloc(1, sizeof(*w)); @@ -170,7 +175,7 @@ err: bool wayland_surface_popup_reposition(struct wayland_surface *w, const struct yasl_popup_spec *spec) { if (!w || !w->popup || w->closed || !w->conn || w->conn->lost || - !popup_spec_valid(spec) || + !popup_spec_valid(w->parent, spec) || xdg_popup_get_version(w->popup) < XDG_POPUP_REPOSITION_SINCE_VERSION) return false; struct yasl_popup_spec old = { |
