diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2024-06-30 17:44:17 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2024-07-19 04:54:32 +0000 |
| commit | 38461eef6f3b612277bf48e49b9cc6c3b79e25bb (patch) | |
| tree | f73114e3853bbd55c717b0555724d353f6839b16 /terminal.c | |
| parent | wayland: #ifdef guard code related to wl_shm_release() (diff) | |
csi: in-band window resize notifications, private mode 2048
This implements
https://gist.github.com/rockorager/e695fb2924d36b2bcf1fff4a3704bd83,
in-band window resize notifications.
When user enables private mode 2048 (in-band resize
notifications), *always* send current size, even if the mode is
already active.
This ensures applications can rely on getting a reply from the
terminal.
Diffstat (limited to 'terminal.c')
| -rw-r--r-- | terminal.c | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -44,6 +44,7 @@ #include "util.h" #include "vt.h" #include "xmalloc.h" +#include "xsnprintf.h" #define PTMX_TIMING 0 @@ -4240,3 +4241,37 @@ term_set_user_mouse_cursor(struct terminal *term, const char *cursor) : NULL; term_xcursor_update(term); } + +void +term_enable_size_notifications(struct terminal *term) +{ + /* Note: always send current size upon activation, regardless of + previous state */ + term->size_notifications = true; + term_send_size_notification(term); +} + +void +term_disable_size_notifications(struct terminal *term) +{ + if (!term->size_notifications) + return; + + term->size_notifications = false; +} + +void +term_send_size_notification(struct terminal *term) +{ + if (!term->size_notifications) + return; + + const int height = term->height - term->margins.top - term->margins.bottom; + const int width = term->width - term->margins.left - term->margins.right; + + char buf[128]; + const int n = xsnprintf( + buf, sizeof(buf), "\033[48;%d;%d;%d;%dt", + term->rows, term->cols, height, width); + term_to_slave(term, buf, n); +} |
