]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ptyfwd: Add transparent flag
authorDaan De Meyer <daan@amutable.com>
Fri, 27 Mar 2026 13:23:34 +0000 (14:23 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 2 Apr 2026 13:12:52 +0000 (15:12 +0200)
src/shared/ptyfwd.c
src/shared/ptyfwd.h

index 2e8d77dee1c4325ce63aa2fc1ed9968b545f137a..88cfd596d050828d78135c039c94a95fc1b1077c 100644 (file)
@@ -669,19 +669,22 @@ static int do_shovel(PTYForward *f) {
 
                                 f->stdin_event_source = sd_event_source_unref(f->stdin_event_source);
                         } else {
-                                /* Check if ^] has been pressed three times within one second. If we get this we quite
-                                 * immediately. */
-                                RequestOperation q = look_for_escape(f, f->in_buffer + f->in_buffer_full, k);
-                                f->in_buffer_full += (size_t) k;
-                                if (q < 0)
-                                        return q;
-                                if (q == REQUEST_EXIT)
-                                        return -ECANCELED;
-                                if (q >= REQUEST_HOTKEY_A && q <= REQUEST_HOTKEY_Z && f->hotkey_handler) {
-                                        r = f->hotkey_handler(f, q - REQUEST_HOTKEY_BASE, f->hotkey_userdata);
-                                        if (r < 0)
-                                                return r;
-                                }
+                                if (!FLAGS_SET(f->flags, PTY_FORWARD_TRANSPARENT)) {
+                                        /* Check if ^] has been pressed three times within one second. If we get this we quit
+                                         * immediately. */
+                                        RequestOperation q = look_for_escape(f, f->in_buffer + f->in_buffer_full, k);
+                                        f->in_buffer_full += (size_t) k;
+                                        if (q < 0)
+                                                return q;
+                                        if (q == REQUEST_EXIT)
+                                                return -ECANCELED;
+                                        if (q >= REQUEST_HOTKEY_A && q <= REQUEST_HOTKEY_Z && f->hotkey_handler) {
+                                                r = f->hotkey_handler(f, q - REQUEST_HOTKEY_BASE, f->hotkey_userdata);
+                                                if (r < 0)
+                                                        return r;
+                                        }
+                                } else
+                                        f->in_buffer_full += (size_t) k;
                         }
 
                         did_something = true;
index 1c1246f37f163e0734771a0f7dcde47829ced0f7..f92676dabe3e89ab8f370134dbff0819227ada9e 100644 (file)
@@ -17,6 +17,9 @@ typedef enum PTYForwardFlags {
 
         /* Don't tint the background, or set window title */
         PTY_FORWARD_DUMB_TERMINAL          = 1 << 3,
+
+        /* Don't interpret escape sequences (^] exit, hotkeys), just forward everything as-is */
+        PTY_FORWARD_TRANSPARENT            = 1 << 4,
 } PTYForwardFlags;
 
 typedef int (*PTYForwardHangupHandler)(PTYForward *f, int rcode, void *userdata);