Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devdraw: Modifier keys are not sent #600

Open
zakkor opened this issue Jan 29, 2023 · 1 comment
Open

devdraw: Modifier keys are not sent #600

zakkor opened this issue Jan 29, 2023 · 1 comment

Comments

@zakkor
Copy link
Contributor

zakkor commented Jan 29, 2023

  • 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.
@zakkor
Copy link
Contributor Author

zakkor commented Jan 30, 2023

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;
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant