XQuartz: Workaround OSX VNC server bug for modifier key state
A better approach which ensures we have a L modifier key down if we are told neither are down and atleast one is down... =/ (cherry picked from commit bc13dda345f716bf4de9bfe4e1d85969263b60c2)
This commit is contained in:
parent
3ead9aa260
commit
f464b5a916
|
@ -921,6 +921,18 @@ void X11ApplicationMain (int argc, char **argv, char **envp) {
|
||||||
@implementation X11Application (Private)
|
@implementation X11Application (Private)
|
||||||
extern int darwin_modifier_flags; // darwinEvents.c
|
extern int darwin_modifier_flags; // darwinEvents.c
|
||||||
|
|
||||||
|
#ifdef NX_DEVICELCMDKEYMASK
|
||||||
|
/* This is to workaround a bug in the VNC server where we sometimes see the L
|
||||||
|
* modifier and sometimes see no "side"
|
||||||
|
*/
|
||||||
|
static inline int ensure_flag(int flags, int device_independent, int device_dependents, int device_dependent_default) {
|
||||||
|
if( (flags & device_independent) &&
|
||||||
|
!(flags & device_dependents))
|
||||||
|
flags |= device_dependent_default;
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
- (void) sendX11NSEvent:(NSEvent *)e {
|
- (void) sendX11NSEvent:(NSEvent *)e {
|
||||||
NSRect screen;
|
NSRect screen;
|
||||||
NSPoint location;
|
NSPoint location;
|
||||||
|
@ -928,6 +940,7 @@ extern int darwin_modifier_flags; // darwinEvents.c
|
||||||
int ev_button, ev_type;
|
int ev_button, ev_type;
|
||||||
float pointer_x, pointer_y, pressure, tilt_x, tilt_y;
|
float pointer_x, pointer_y, pressure, tilt_x, tilt_y;
|
||||||
DeviceIntPtr pDev;
|
DeviceIntPtr pDev;
|
||||||
|
int modifierFlags;
|
||||||
|
|
||||||
/* convert location to be relative to top-left of primary display */
|
/* convert location to be relative to top-left of primary display */
|
||||||
location = [e locationInWindow];
|
location = [e locationInWindow];
|
||||||
|
@ -949,12 +962,32 @@ extern int darwin_modifier_flags; // darwinEvents.c
|
||||||
tilt_x = 0;
|
tilt_x = 0;
|
||||||
tilt_y = 0;
|
tilt_y = 0;
|
||||||
|
|
||||||
|
modifierFlags = [e modifierFlags];
|
||||||
|
|
||||||
|
/* These are the "only" modifier keys we care about */
|
||||||
|
modifierFlags &= (NX_COMMANDMASK | NX_CONTROLMASK | NX_ALTERNATEMASK | NX_SHIFTMASK |
|
||||||
|
NX_SECONDARYFNMASK | NX_ALPHASHIFTMASK | NX_NUMERICPADMASK |
|
||||||
|
NX_HELPMASK | NX_DEVICELCTLKEYMASK | NX_DEVICELSHIFTKEYMASK |
|
||||||
|
NX_DEVICERSHIFTKEYMASK | NX_DEVICELCMDKEYMASK | NX_DEVICERCMDKEYMASK |
|
||||||
|
NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK | NX_DEVICERCTLKEYMASK);
|
||||||
|
|
||||||
|
#ifdef NX_DEVICELCMDKEYMASK
|
||||||
|
/* This is to workaround a bug in the VNC server where we sometimes see the L
|
||||||
|
* modifier and sometimes see no "side"
|
||||||
|
*/
|
||||||
|
modifierFlags = ensure_flag(modifierFlags, NX_CONTROLMASK, NX_DEVICELCTLKEYMASK | NX_DEVICERCTLKEYMASK, NX_DEVICELCTLKEYMASK);
|
||||||
|
modifierFlags = ensure_flag(modifierFlags, NX_SHIFTMASK, NX_DEVICELSHIFTKEYMASK | NX_DEVICERSHIFTKEYMASK, NX_DEVICELSHIFTKEYMASK);
|
||||||
|
modifierFlags = ensure_flag(modifierFlags, NX_COMMANDMASK, NX_DEVICELCMDKEYMASK | NX_DEVICERCMDKEYMASK, NX_DEVICELCMDKEYMASK);
|
||||||
|
modifierFlags = ensure_flag(modifierFlags, NX_ALTERNATEMASK, NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK, NX_DEVICELALTKEYMASK);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* We don't receive modifier key events while out of focus, and 3button
|
/* We don't receive modifier key events while out of focus, and 3button
|
||||||
* emulation mucks this up, so we need to check our modifier flag state
|
* emulation mucks this up, so we need to check our modifier flag state
|
||||||
* on every event... ugg
|
* on every event... ugg
|
||||||
*/
|
*/
|
||||||
if(darwin_modifier_flags != [e modifierFlags])
|
|
||||||
DarwinUpdateModKeys([e modifierFlags]);
|
if(darwin_modifier_flags != modifierFlags)
|
||||||
|
DarwinUpdateModKeys(modifierFlags);
|
||||||
|
|
||||||
switch ([e type]) {
|
switch ([e type]) {
|
||||||
case NSLeftMouseDown: ev_button=1; ev_type=ButtonPress; goto handle_mouse;
|
case NSLeftMouseDown: ev_button=1; ev_type=ButtonPress; goto handle_mouse;
|
||||||
|
|
Loading…
Reference in New Issue