From a2567fcac9851e5cc965a236679f568b0e79cff2 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 17 Jun 2024 09:28:40 -0400 Subject: [PATCH] devdraw: handle shift of real mouse buttons correctly --- src/cmd/devdraw/mac-screen.m | 10 +++++----- src/cmd/devdraw/x11-screen.c | 23 ++++++++++++++++++----- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/cmd/devdraw/mac-screen.m b/src/cmd/devdraw/mac-screen.m index 04c807b7a..6abdee113 100644 --- a/src/cmd/devdraw/mac-screen.m +++ b/src/cmd/devdraw/mac-screen.m @@ -639,9 +639,9 @@ - (void)flagsChanged:(NSEvent*)e x = 2; if(m & ~omod & NSEventModifierFlagCommand) x = 4; - if(m & NSEventModifierFlagShift) - x <<= 5; b |= x; + if(m & NSEventModifierFlagShift) + b <<= 5; [self sendmouse:b]; }else if(m & ~omod & NSEventModifierFlagOption) gfx_keystroke(self.client, Kalt); @@ -698,17 +698,17 @@ - (void)getmouse:(NSEvent *)e b = b&~6 | (b&4)>>1 | (b&2)<<1; b = mouseswap(b); + m = [e modifierFlags]; if(b == 1){ - m = [e modifierFlags]; if(m & NSEventModifierFlagOption){ gfx_abortcompose(self.client); b = 2; }else if(m & NSEventModifierFlagCommand) b = 4; - if(m & NSEventModifierFlagShift) - b <<= 5; } + if(m & NSEventModifierFlagShift) + b <<= 5; [self sendmouse:b]; } diff --git a/src/cmd/devdraw/x11-screen.c b/src/cmd/devdraw/x11-screen.c index 9490ab8f2..f4aa1ce9e 100644 --- a/src/cmd/devdraw/x11-screen.c +++ b/src/cmd/devdraw/x11-screen.c @@ -376,6 +376,7 @@ runxevent(XEvent *xev) if(w == nil) w = _x.windows; + int shift; switch(xev->type){ case Expose: _xexpose(w, xev); @@ -406,7 +407,10 @@ runxevent(XEvent *xev) case MotionNotify: if(_xtoplan9mouse(w, xev, &m) < 0) return; - gfx_mousetrack(w->client, m.xy.x, m.xy.y, m.buttons|_x.kbuttons, m.msec); + shift = 0; + if(_x.kstate & ShiftMask) + shift = 5; + gfx_mousetrack(w->client, m.xy.x, m.xy.y, (m.buttons|_x.kbuttons)<keycode; - // fall through + c |= Mod1Mask; + modp = 1; + break; case XK_Shift_L: case XK_Shift_R: kcodeshift = ke->keycode; - c |= Mod1Mask; + c |= ShiftMask; modp = 1; + break; } else { if(ke->keycode == kcodecontrol){ c &= ~ControlMask; modp = 1; - } else if(ke->keycode == kcodealt || ke->keycode == kcodeshift){ + } else if(ke->keycode == kcodealt){ c &= ~Mod1Mask; modp = 1; + } else if(ke->keycode == kcodeshift) { + c &= ~ShiftMask; + modp = 1; } } if(modp){ _x.kstate = c; if(m.buttons || _x.kbuttons) { + int shift = 0; _x.altdown = 0; // used alt _x.kbuttons = 0; if(c & ControlMask) _x.kbuttons |= 2; if(c & Mod1Mask) _x.kbuttons |= 4; - gfx_mousetrack(w->client, m.xy.x, m.xy.y, m.buttons|_x.kbuttons, m.msec); + if(c & ShiftMask) + shift = 5; + gfx_mousetrack(w->client, m.xy.x, m.xy.y, (m.buttons|_x.kbuttons)<