Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam
2025-03-04 10:01:15 +00:00
17 changed files with 382 additions and 107 deletions

View File

@ -56,11 +56,11 @@ static void server_client_set_title(struct client *);
static void server_client_set_path(struct client *);
static void server_client_reset_state(struct client *);
static void server_client_update_latest(struct client *);
static void server_client_dispatch(struct imsg *, void *);
static void server_client_dispatch_command(struct client *, struct imsg *);
static void server_client_dispatch_identify(struct client *, struct imsg *);
static void server_client_dispatch_shell(struct client *);
static void server_client_report_theme(struct client *, enum client_theme);
/* Compare client windows. */
static int
@ -300,6 +300,7 @@ server_client_create(int fd)
c->tty.sx = 80;
c->tty.sy = 24;
c->theme = THEME_UNKNOWN;
status_init(c);
c->flags |= CLIENT_FOCUSED;
@ -401,6 +402,7 @@ server_client_set_session(struct client *c, struct session *s)
recalculate_sizes();
window_update_focus(s->curw->window);
session_update_activity(s, NULL);
session_theme_changed(s);
gettimeofday(&s->last_attached_time, NULL);
s->curw->flags &= ~WINLINK_ALERTFLAGS;
s->curw->window->latest = c;
@ -2384,6 +2386,16 @@ server_client_key_callback(struct cmdq_item *item, void *data)
event->key = key;
}
/* Handle theme reporting keys. */
if (key == KEYC_REPORT_LIGHT_THEME) {
server_client_report_theme(c, THEME_LIGHT);
goto out;
}
if (key == KEYC_REPORT_DARK_THEME) {
server_client_report_theme(c, THEME_DARK);
goto out;
}
/* Find affected pane. */
if (!KEYC_IS_MOUSE(key) || cmd_find_from_mouse(&fs, m, 0) != 0)
cmd_find_from_client(&fs, c, 0);
@ -2674,6 +2686,12 @@ server_client_loop(void)
}
check_window_name(w);
}
/* Send theme updates. */
RB_FOREACH(w, windows, &windows) {
TAILQ_FOREACH(wp, &w->panes, entry)
window_pane_send_theme_update(wp);
}
}
/* Check if window needs to be resized. */
@ -3910,3 +3928,21 @@ out:
if (!parse)
free(msg);
}
static void
server_client_report_theme(struct client *c, enum client_theme theme)
{
if (theme == THEME_LIGHT) {
c->theme = THEME_LIGHT;
notify_client("client-light-theme", c);
} else {
c->theme = THEME_DARK;
notify_client("client-dark-theme", c);
}
/*
* Request foreground and background colour again. Don't forward 2031 to
* panes until a response is received.
*/
tty_puts(&c->tty, "\033]10;?\033\\\033]11;?\033\\");
}