mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
devdraw: handle shift of real mouse buttons correctly
This commit is contained in:
parent
e9cbe46fe6
commit
a2567fcac9
2 changed files with 23 additions and 10 deletions
|
@ -639,9 +639,9 @@ rpc_resizewindow(Client *c, Rectangle r)
|
||||||
x = 2;
|
x = 2;
|
||||||
if(m & ~omod & NSEventModifierFlagCommand)
|
if(m & ~omod & NSEventModifierFlagCommand)
|
||||||
x = 4;
|
x = 4;
|
||||||
if(m & NSEventModifierFlagShift)
|
|
||||||
x <<= 5;
|
|
||||||
b |= x;
|
b |= x;
|
||||||
|
if(m & NSEventModifierFlagShift)
|
||||||
|
b <<= 5;
|
||||||
[self sendmouse:b];
|
[self sendmouse:b];
|
||||||
}else if(m & ~omod & NSEventModifierFlagOption)
|
}else if(m & ~omod & NSEventModifierFlagOption)
|
||||||
gfx_keystroke(self.client, Kalt);
|
gfx_keystroke(self.client, Kalt);
|
||||||
|
@ -698,17 +698,17 @@ rpc_resizewindow(Client *c, Rectangle r)
|
||||||
b = b&~6 | (b&4)>>1 | (b&2)<<1;
|
b = b&~6 | (b&4)>>1 | (b&2)<<1;
|
||||||
b = mouseswap(b);
|
b = mouseswap(b);
|
||||||
|
|
||||||
if(b == 1){
|
|
||||||
m = [e modifierFlags];
|
m = [e modifierFlags];
|
||||||
|
if(b == 1){
|
||||||
if(m & NSEventModifierFlagOption){
|
if(m & NSEventModifierFlagOption){
|
||||||
gfx_abortcompose(self.client);
|
gfx_abortcompose(self.client);
|
||||||
b = 2;
|
b = 2;
|
||||||
}else
|
}else
|
||||||
if(m & NSEventModifierFlagCommand)
|
if(m & NSEventModifierFlagCommand)
|
||||||
b = 4;
|
b = 4;
|
||||||
|
}
|
||||||
if(m & NSEventModifierFlagShift)
|
if(m & NSEventModifierFlagShift)
|
||||||
b <<= 5;
|
b <<= 5;
|
||||||
}
|
|
||||||
[self sendmouse:b];
|
[self sendmouse:b];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -376,6 +376,7 @@ runxevent(XEvent *xev)
|
||||||
if(w == nil)
|
if(w == nil)
|
||||||
w = _x.windows;
|
w = _x.windows;
|
||||||
|
|
||||||
|
int shift;
|
||||||
switch(xev->type){
|
switch(xev->type){
|
||||||
case Expose:
|
case Expose:
|
||||||
_xexpose(w, xev);
|
_xexpose(w, xev);
|
||||||
|
@ -406,7 +407,10 @@ runxevent(XEvent *xev)
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
if(_xtoplan9mouse(w, xev, &m) < 0)
|
if(_xtoplan9mouse(w, xev, &m) < 0)
|
||||||
return;
|
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)<<shift, m.msec);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KeyRelease:
|
case KeyRelease:
|
||||||
|
@ -440,32 +444,41 @@ runxevent(XEvent *xev)
|
||||||
case XK_Alt_L:
|
case XK_Alt_L:
|
||||||
case XK_Alt_R:
|
case XK_Alt_R:
|
||||||
kcodealt = ke->keycode;
|
kcodealt = ke->keycode;
|
||||||
// fall through
|
c |= Mod1Mask;
|
||||||
|
modp = 1;
|
||||||
|
break;
|
||||||
case XK_Shift_L:
|
case XK_Shift_L:
|
||||||
case XK_Shift_R:
|
case XK_Shift_R:
|
||||||
kcodeshift = ke->keycode;
|
kcodeshift = ke->keycode;
|
||||||
c |= Mod1Mask;
|
c |= ShiftMask;
|
||||||
modp = 1;
|
modp = 1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(ke->keycode == kcodecontrol){
|
if(ke->keycode == kcodecontrol){
|
||||||
c &= ~ControlMask;
|
c &= ~ControlMask;
|
||||||
modp = 1;
|
modp = 1;
|
||||||
} else if(ke->keycode == kcodealt || ke->keycode == kcodeshift){
|
} else if(ke->keycode == kcodealt){
|
||||||
c &= ~Mod1Mask;
|
c &= ~Mod1Mask;
|
||||||
modp = 1;
|
modp = 1;
|
||||||
|
} else if(ke->keycode == kcodeshift) {
|
||||||
|
c &= ~ShiftMask;
|
||||||
|
modp = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(modp){
|
if(modp){
|
||||||
_x.kstate = c;
|
_x.kstate = c;
|
||||||
if(m.buttons || _x.kbuttons) {
|
if(m.buttons || _x.kbuttons) {
|
||||||
|
int shift = 0;
|
||||||
_x.altdown = 0; // used alt
|
_x.altdown = 0; // used alt
|
||||||
_x.kbuttons = 0;
|
_x.kbuttons = 0;
|
||||||
if(c & ControlMask)
|
if(c & ControlMask)
|
||||||
_x.kbuttons |= 2;
|
_x.kbuttons |= 2;
|
||||||
if(c & Mod1Mask)
|
if(c & Mod1Mask)
|
||||||
_x.kbuttons |= 4;
|
_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)<<shift, m.msec);
|
||||||
}
|
}
|
||||||
modp = 0;
|
modp = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue