Actually propagate setAcceptsMouseMovedEvents to XSelectInput()

X11Display already has the code to drop mouse moved events in case
the window does not want them; but we weren't getting the events in
the first place because they were filtered out on the server side.

Fixes, among other things, NSMenu not reacting to clicks properly,
because it was assuming the clicked item was not the selected one
as it could not see the mouse hovering over it.
This commit is contained in:
Sergey Bugaev 2018-12-17 00:05:01 +03:00
parent 1403e9700b
commit c95aecf2a3
4 changed files with 22 additions and 2 deletions

View File

@ -976,6 +976,7 @@ NSString * const NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification
-(void)setAcceptsMouseMovedEvents:(BOOL)flag {
_acceptsMouseMovedEvents=flag;
[_platformWindow syncDelegateProperties];
}
-(void)setExcludedFromWindowsMenu:(BOOL)value {

View File

@ -95,8 +95,7 @@
(_visualInfo==NULL)?CopyFromParent:_visualInfo->visual,
xattr_mask, &xattr);
XSelectInput(_display, _window, ExposureMask | KeyPressMask | KeyReleaseMask | StructureNotifyMask |
ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | VisibilityChangeMask | FocusChangeMask | SubstructureRedirectMask );
[self syncDelegateProperties];
Atom atm=XInternAtom(_display, "WM_DELETE_WINDOW", False);
XSetWMProtocols(_display, _window, &atm , 1);
@ -157,12 +156,27 @@
-(void)setDelegate:delegate {
_delegate=delegate;
[self syncDelegateProperties];
}
-delegate {
return _delegate;
}
- (void) syncDelegateProperties {
long mask = KeyPressMask | KeyReleaseMask |
ExposureMask | StructureNotifyMask |
ButtonPressMask | ButtonReleaseMask | ButtonMotionMask |
VisibilityChangeMask | FocusChangeMask | SubstructureRedirectMask;
if ([_delegate acceptsMouseMovedEvents]) {
mask |= PointerMotionMask;
}
XSelectInput(_display, _window, mask);
// TODO: background color
}
-(void) invalidate {
// This is essentially dealloc; we release our contexts
// and windows, but unlike dealloc, this method can be called

View File

@ -23,6 +23,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
O2InvalidAbstractInvocation();
}
- (void) syncDelegateProperties {
O2InvalidAbstractInvocation();
}
-(O2Context *)cgContext {
O2InvalidAbstractInvocation();

View File

@ -25,6 +25,7 @@ typedef enum {
- delegate;
- (void)invalidate;
- (void)syncDelegateProperties;
- (O2Context *)cgContext;