9fans/plan9port

devdraw: Modifier keys are not sent

Opened this issue · 1 comments

  • For keyboard inputs, only KeyCmd+'a'-style modifiers can be checked. Shift+special keys, Cmd+special keys, and Alt+any key all cannot be checked.
  • For mouse inputs, it's not possible to check which modifiers were pressed during a click event.

A simple solution that fixes both of the problems described above is to send each individual modifier keystroke as it happens, then the clients can maintain the modifier state and do whatever they want, including mouse presses with modifier.

This breaks existing clients, because they're not expecting these keys to come through, so they show up as unknown text in (e.g.: in acme), therefore it's not a proper solution, but maybe it helps for anyone else reading this who needs to access modifiers in their devdraw programs

From c85b5c92f6ba63ff3e2866c67108596ffb78124c Mon Sep 17 00:00:00 2001
From: zakkor <edward.partenie@gmail.com>
Date: Mon, 30 Jan 2023 09:55:27 +0200
Subject: [PATCH] devdraw: Forward individual modifier keypresses

---
 src/cmd/devdraw/mac-screen.m | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/cmd/devdraw/mac-screen.m b/src/cmd/devdraw/mac-screen.m
index f07054cf9..91ccb0171 100644
--- a/src/cmd/devdraw/mac-screen.m
+++ b/src/cmd/devdraw/mac-screen.m
@@ -640,6 +640,12 @@ - (void)flagsChanged:(NSEvent*)e
 		[self sendmouse:b];
 	}else if(m & ~omod & NSEventModifierFlagOption)
 		gfx_keystroke(self.client, Kalt);
+	else if(m & ~omod & NSEventModifierFlagCommand)
+		gfx_keystroke(self.client, Kcmd);
+	else if(m & ~omod & NSEventModifierFlagControl)
+		gfx_keystroke(self.client, Kctl);
+	else if(m & ~omod & NSEventModifierFlagShift)
+		gfx_keystroke(self.client, Kshift);
 
 	omod = m;
 }