gardesk/garterm / bcc33bb

Browse files

add clipboard debug tracing for OSC 52 and selection transfer

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
bcc33bbcdc862c011ce4ddcfa7727bae5968b68c
Parents
7332fa6
Tree
66ec4da

3 changed files

StatusFile+-
M garterm/src/app.rs 1 0
M garterm/src/input/clipboard.rs 3 0
M garterm/src/terminal/mod.rs 9 2
garterm/src/app.rsmodified
@@ -284,6 +284,7 @@ impl App {
284284
                     for event in clipboard_events {
285285
                         match event {
286286
                             ClipboardEvent::Set(sel, data) => {
287
+                                tracing::debug!("OSC 52 event: Set({:?}, {} bytes)", sel, data.len());
287288
                                 if self.clipboard_write {
288289
                                     if let Ok(text) = String::from_utf8(data) {
289290
                                         let conn = self.window.connection();
garterm/src/input/clipboard.rsmodified
@@ -59,6 +59,7 @@ impl Clipboard {
5959
 
6060
     /// Copy text to CLIPBOARD (for Ctrl+Shift+C)
6161
     pub fn copy_clipboard(&mut self, conn: &Connection, text: String) -> Result<()> {
62
+        tracing::debug!("Clipboard: copy_clipboard called with {} bytes", text.len());
6263
         self.clipboard_content = Some(text);
6364
         conn.inner()
6465
             .set_selection_owner(self.window, self.atoms.clipboard, x11rb::CURRENT_TIME)?;
@@ -123,6 +124,7 @@ impl Clipboard {
123124
         } else if event.target == self.atoms.utf8_string {
124125
             // Client wants UTF-8 text
125126
             if let Some(text) = content {
127
+                tracing::debug!("Clipboard: serving {} bytes to requestor", text.len());
126128
                 conn.inner().change_property(
127129
                     xproto::PropMode::REPLACE,
128130
                     event.requestor,
@@ -134,6 +136,7 @@ impl Clipboard {
134136
                 )?;
135137
                 event.property
136138
             } else {
139
+                tracing::debug!("Clipboard: selection request but no content");
137140
                 0 // No data
138141
             }
139142
         } else {
garterm/src/terminal/mod.rsmodified
@@ -798,8 +798,15 @@ impl vte::Perform for Performer<'_> {
798798
                         data => {
799799
                             // Set clipboard (base64 encoded)
800800
                             use base64::Engine;
801
-                            if let Ok(decoded) = base64::engine::general_purpose::STANDARD.decode(data) {
802
-                                self.term.clipboard_events.push_back(ClipboardEvent::Set(selection, decoded));
801
+                            tracing::debug!("OSC 52: received base64 payload of {} bytes", data.len());
802
+                            match base64::engine::general_purpose::STANDARD.decode(data) {
803
+                                Ok(decoded) => {
804
+                                    tracing::debug!("OSC 52: decoded {} bytes of clipboard text", decoded.len());
805
+                                    self.term.clipboard_events.push_back(ClipboardEvent::Set(selection, decoded));
806
+                                }
807
+                                Err(e) => {
808
+                                    tracing::warn!("OSC 52: base64 decode failed ({} bytes payload): {}", data.len(), e);
809
+                                }
803810
                             }
804811
                         }
805812
                     }