From 6c56b04b3f312be8dcee307e29515f3c83b3ae87 Mon Sep 17 00:00:00 2001 From: delthas Date: Mon, 4 Sep 2023 14:02:05 +0200 Subject: osc: add support for osc 176 (app ID) This adds support for a new OSC escape sequence: OSC 176, that lets terminal programs tell the terminal the name of the app that is running. foot then sets the app ID of the toplevel to that ID, which lets the compositor know which app is running, and typically sets the appropriate icon, window grouping, ... See: https://gist.github.com/delthas/d451e2cc1573bb2364839849c7117239 --- render.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'render.c') diff --git a/render.c b/render.c index 13d348f3..f82e54f0 100644 --- a/render.c +++ b/render.c @@ -4529,6 +4529,28 @@ render_refresh_title(struct terminal *term) render_refresh_csd(term); } +void +render_refresh_app_id(struct terminal *term) +{ + struct timespec now; + if (clock_gettime(CLOCK_MONOTONIC, &now) < 0) + return; + + struct timespec diff; + timespec_sub(&now, &term->render.app_id.last_update, &diff); + + if (diff.tv_sec == 0 && diff.tv_nsec < 8333 * 1000) { + const struct itimerspec timeout = { + .it_value = {.tv_nsec = 8333 * 1000 - diff.tv_nsec}, + }; + + timerfd_settime(term->render.app_id.timer_fd, 0, &timeout, NULL); + } else { + term->render.app_id.last_update = now; + xdg_toplevel_set_app_id(term->window->xdg_toplevel, term->app_id ? term->app_id : term->conf->app_id); + } +} + void render_refresh(struct terminal *term) { -- cgit v1.3