* Accept mouse events according to the forward parameter on macOS.

* Update BrowserWindow docs: mouse forward is available on macOS
This commit is contained in:
Andreas 2018-04-09 12:35:05 +02:00 коммит произвёл Cheng Zhao
Родитель 0e5aaab0b5
Коммит 6b5e09478c
3 изменённых файлов: 17 добавлений и 5 удалений

Просмотреть файл

@ -89,7 +89,7 @@ class NativeWindowMac : public NativeWindow {
std::string GetRepresentedFilename() override;
void SetDocumentEdited(bool edited) override;
bool IsDocumentEdited() override;
void SetIgnoreMouseEvents(bool ignore, bool) override;
void SetIgnoreMouseEvents(bool ignore, bool forward) override;
void SetContentProtection(bool enable) override;
void SetBrowserView(NativeBrowserView* browser_view) override;
void SetParentWindow(NativeWindow* parent) override;
@ -143,6 +143,8 @@ class NativeWindowMac : public NativeWindow {
void InstallView(NSView* view);
void SetForwardMouseMessages(bool forward);
base::scoped_nsobject<AtomNSWindow> window_;
base::scoped_nsobject<AtomNSWindowDelegate> window_delegate_;

Просмотреть файл

@ -1485,8 +1485,14 @@ bool NativeWindowMac::IsDocumentEdited() {
return [window_ isDocumentEdited];
}
void NativeWindowMac::SetIgnoreMouseEvents(bool ignore, bool) {
void NativeWindowMac::SetIgnoreMouseEvents(bool ignore, bool forward) {
[window_ setIgnoresMouseEvents:ignore];
if (!ignore) {
SetForwardMouseMessages(NO);
} else {
SetForwardMouseMessages(forward);
}
}
void NativeWindowMac::SetContentProtection(bool enable) {
@ -1823,6 +1829,10 @@ void NativeWindowMac::InstallView(NSView* view) {
}
}
void NativeWindowMac::SetForwardMouseMessages(bool forward) {
[window_ setAcceptsMouseMovedEvents:forward];
}
void NativeWindowMac::SetStyleMask(bool on, NSUInteger flag) {
// Changing the styleMask of a frameless windows causes it to change size so
// we explicitly disable resizing while setting it.

Просмотреть файл

@ -1382,10 +1382,10 @@ Returns `Boolean` - Whether the window is visible on all workspaces.
* `ignore` Boolean
* `options` Object (optional)
* `forward` Boolean (optional) _Windows_ - If true, forwards mouse move
* `forward` Boolean (optional) _macOS_ _Windows_ - If true, forwards mouse move
messages to Chromium, enabling mouse related events such as `mouseleave`.
Only used when `ignore` is true. If `ignore` is false, forwarding is always
disabled regardless of this value.
Only used when `ignore` is true. If `ignore` is false, forwarding is always
disabled regardless of this value.
Makes the window ignore all mouse events.