XQuartz: Send a MotionNotify event for the mouse cursor when activating X11.app
Otherwise if X11.app was activated with a mouse click, the location of the even is the last location of the cursor before X11 was deactivated
(cherry picked from commit c7457d7b31
)
This commit is contained in:
parent
e1338d2714
commit
67621f3b39
|
@ -80,6 +80,11 @@ static KeyboardLayoutRef last_key_layout;
|
||||||
|
|
||||||
extern int darwinFakeButtons;
|
extern int darwinFakeButtons;
|
||||||
|
|
||||||
|
/* Store the mouse location while in the background, and update X11's pointer
|
||||||
|
* location when we become the foreground application
|
||||||
|
*/
|
||||||
|
static NSPoint bgMouseLocation;
|
||||||
|
|
||||||
X11Application *X11App;
|
X11Application *X11App;
|
||||||
|
|
||||||
CFStringRef app_prefs_domain_cfstr = NULL;
|
CFStringRef app_prefs_domain_cfstr = NULL;
|
||||||
|
@ -188,6 +193,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
|
||||||
size_t i;
|
size_t i;
|
||||||
DEBUG_LOG("state=%d, _x_active=%d, \n", state, _x_active)
|
DEBUG_LOG("state=%d, _x_active=%d, \n", state, _x_active)
|
||||||
if (state) {
|
if (state) {
|
||||||
|
DarwinSendPointerEvents(darwinPointer, MotionNotify, 0, bgMouseLocation.x, bgMouseLocation.y, 0.0, 0.0, 0.0);
|
||||||
DarwinSendDDXEvent(kXquartzActivate, 0);
|
DarwinSendDDXEvent(kXquartzActivate, 0);
|
||||||
|
|
||||||
if (!_x_active) {
|
if (!_x_active) {
|
||||||
|
@ -954,10 +960,10 @@ static inline int ensure_flag(int flags, int device_independent, int device_depe
|
||||||
|
|
||||||
- (void) sendX11NSEvent:(NSEvent *)e {
|
- (void) sendX11NSEvent:(NSEvent *)e {
|
||||||
NSRect screen;
|
NSRect screen;
|
||||||
NSPoint location;
|
NSPoint location, tilt;
|
||||||
NSWindow *window;
|
NSWindow *window;
|
||||||
int ev_button, ev_type;
|
int ev_button, ev_type;
|
||||||
float pointer_x, pointer_y, pressure, tilt_x, tilt_y;
|
float pressure;
|
||||||
DeviceIntPtr pDev;
|
DeviceIntPtr pDev;
|
||||||
int modifierFlags;
|
int modifierFlags;
|
||||||
|
|
||||||
|
@ -984,10 +990,8 @@ static inline int ensure_flag(int flags, int device_independent, int device_depe
|
||||||
|
|
||||||
/* Setup our valuators. These will range from 0 to 1 */
|
/* Setup our valuators. These will range from 0 to 1 */
|
||||||
pressure = 0;
|
pressure = 0;
|
||||||
tilt_x = 0;
|
tilt.x = 0.0;
|
||||||
tilt_y = 0;
|
tilt.y = 0.0;
|
||||||
pointer_x = location.x;
|
|
||||||
pointer_y = location.y;
|
|
||||||
|
|
||||||
modifierFlags = [e modifierFlags];
|
modifierFlags = [e modifierFlags];
|
||||||
|
|
||||||
|
@ -1055,14 +1059,13 @@ static inline int ensure_flag(int flags, int device_independent, int device_depe
|
||||||
pDev = darwinTabletCurrent;
|
pDev = darwinTabletCurrent;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DarwinSendProximityEvents([e isEnteringProximity]?ProximityIn:ProximityOut,
|
DarwinSendProximityEvents([e isEnteringProximity] ? ProximityIn : ProximityOut,
|
||||||
pointer_x, pointer_y);
|
location.x, location.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([e type] == NSTabletPoint || [e subtype] == NSTabletPointEventSubtype) {
|
if ([e type] == NSTabletPoint || [e subtype] == NSTabletPointEventSubtype) {
|
||||||
pressure = [e pressure];
|
pressure = [e pressure];
|
||||||
tilt_x = [e tilt].x;
|
tilt = [e tilt];
|
||||||
tilt_y = [e tilt].y;
|
|
||||||
|
|
||||||
pDev = darwinTabletCurrent;
|
pDev = darwinTabletCurrent;
|
||||||
}
|
}
|
||||||
|
@ -1076,6 +1079,7 @@ static inline int ensure_flag(int flags, int device_independent, int device_depe
|
||||||
//#if defined(XPLUGIN_VERSION) && XPLUGIN_VERSION > 0
|
//#if defined(XPLUGIN_VERSION) && XPLUGIN_VERSION > 0
|
||||||
/* Older libXplugin (Tiger/"Stock" Leopard) aren't thread safe, so we can't call xp_find_window from the Appkit thread */
|
/* Older libXplugin (Tiger/"Stock" Leopard) aren't thread safe, so we can't call xp_find_window from the Appkit thread */
|
||||||
xp_window_id wid;
|
xp_window_id wid;
|
||||||
|
xp_error e;
|
||||||
|
|
||||||
/* Sigh. Need to check that we're really over one of
|
/* Sigh. Need to check that we're really over one of
|
||||||
* our windows. (We need to receive pointer events while
|
* our windows. (We need to receive pointer events while
|
||||||
|
@ -1084,15 +1088,20 @@ static inline int ensure_flag(int flags, int device_independent, int device_depe
|
||||||
*/
|
*/
|
||||||
|
|
||||||
wid = 0;
|
wid = 0;
|
||||||
|
e = xp_find_window(location.x, location.y, 0, &wid);
|
||||||
|
|
||||||
if (xp_find_window(pointer_x, pointer_y, 0, &wid) == XP_Success &&
|
if (e == XP_Success && wid == 0) {
|
||||||
wid == 0)
|
bgMouseLocation = location;
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
bgMouseLocation = location;
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
DarwinSendPointerEvents(pDev, ev_type, ev_button, pointer_x, pointer_y,
|
DarwinSendPointerEvents(pDev, ev_type, ev_button, location.x, location.y,
|
||||||
pressure, tilt_x, tilt_y);
|
pressure, tilt.x, tilt.y);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1111,13 +1120,13 @@ static inline int ensure_flag(int flags, int device_independent, int device_depe
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
DarwinSendProximityEvents([e isEnteringProximity]?ProximityIn:ProximityOut,
|
DarwinSendProximityEvents([e isEnteringProximity] ? ProximityIn : ProximityOut,
|
||||||
pointer_x, pointer_y);
|
location.x, location.y);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NSScrollWheel:
|
case NSScrollWheel:
|
||||||
DarwinSendScrollEvents([e deltaX], [e deltaY], pointer_x, pointer_y,
|
DarwinSendScrollEvents([e deltaX], [e deltaY], location.x, location.y,
|
||||||
pressure, tilt_x, tilt_y);
|
pressure, tilt.x, tilt.y);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NSKeyDown: case NSKeyUp:
|
case NSKeyDown: case NSKeyUp:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user