Make mouse forward option of setIgnoreMouseMessages and update documentation.
This commit is contained in:
parent
60c0bf1636
commit
3d33da7696
7 changed files with 28 additions and 31 deletions
|
@ -651,8 +651,11 @@ bool Window::IsDocumentEdited() {
|
|||
return window_->IsDocumentEdited();
|
||||
}
|
||||
|
||||
void Window::SetIgnoreMouseEvents(bool ignore) {
|
||||
return window_->SetIgnoreMouseEvents(ignore);
|
||||
void Window::SetIgnoreMouseEvents(bool ignore, mate::Arguments* args) {
|
||||
mate::Dictionary options;
|
||||
bool forward = false;
|
||||
args->GetNext(&options) && options.Get("forward", &forward);
|
||||
return window_->SetIgnoreMouseEvents(ignore, forward);
|
||||
}
|
||||
|
||||
void Window::SetContentProtection(bool enable) {
|
||||
|
@ -787,10 +790,6 @@ void Window::SetAppDetails(const mate::Dictionary& options) {
|
|||
relaunch_command, relaunch_display_name,
|
||||
window_->GetAcceleratedWidget());
|
||||
}
|
||||
|
||||
void Window::SetForwardMouseMessages(bool forward) {
|
||||
window_->SetForwardMouseMessages(forward);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
|
@ -1064,7 +1063,6 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
|||
.SetMethod("setThumbnailClip", &Window::SetThumbnailClip)
|
||||
.SetMethod("setThumbnailToolTip", &Window::SetThumbnailToolTip)
|
||||
.SetMethod("setAppDetails", &Window::SetAppDetails)
|
||||
.SetMethod("setForwardMouseMessages", &Window::SetForwardMouseMessages)
|
||||
#endif
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
.SetMethod("setIcon", &Window::SetIcon)
|
||||
|
|
|
@ -166,7 +166,7 @@ class Window : public mate::TrackableObject<Window>,
|
|||
std::string GetRepresentedFilename();
|
||||
void SetDocumentEdited(bool edited);
|
||||
bool IsDocumentEdited();
|
||||
void SetIgnoreMouseEvents(bool ignore);
|
||||
void SetIgnoreMouseEvents(bool ignore, mate::Arguments* args);
|
||||
void SetContentProtection(bool enable);
|
||||
void SetFocusable(bool focusable);
|
||||
void SetProgressBar(double progress, mate::Arguments* args);
|
||||
|
@ -201,7 +201,6 @@ class Window : public mate::TrackableObject<Window>,
|
|||
bool SetThumbnailClip(const gfx::Rect& region);
|
||||
bool SetThumbnailToolTip(const std::string& tooltip);
|
||||
void SetAppDetails(const mate::Dictionary& options);
|
||||
void SetForwardMouseMessages(bool forward);
|
||||
#endif
|
||||
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
|
|
|
@ -143,7 +143,7 @@ class NativeWindow : public base::SupportsUserData,
|
|||
virtual std::string GetRepresentedFilename();
|
||||
virtual void SetDocumentEdited(bool edited);
|
||||
virtual bool IsDocumentEdited();
|
||||
virtual void SetIgnoreMouseEvents(bool ignore) = 0;
|
||||
virtual void SetIgnoreMouseEvents(bool ignore, bool forward) = 0;
|
||||
virtual void SetContentProtection(bool enable) = 0;
|
||||
virtual void SetFocusable(bool focusable);
|
||||
virtual void SetMenu(AtomMenuModel* menu);
|
||||
|
@ -152,9 +152,6 @@ class NativeWindow : public base::SupportsUserData,
|
|||
virtual gfx::NativeView GetNativeView() const = 0;
|
||||
virtual gfx::NativeWindow GetNativeWindow() const = 0;
|
||||
virtual gfx::AcceleratedWidget GetAcceleratedWidget() const = 0;
|
||||
#if defined(OS_WIN)
|
||||
virtual void SetForwardMouseMessages(bool forward) = 0;
|
||||
#endif
|
||||
|
||||
// Taskbar/Dock APIs.
|
||||
enum ProgressState {
|
||||
|
|
|
@ -790,7 +790,7 @@ bool NativeWindowViews::HasShadow() {
|
|||
!= wm::ShadowElevation::NONE;
|
||||
}
|
||||
|
||||
void NativeWindowViews::SetIgnoreMouseEvents(bool ignore) {
|
||||
void NativeWindowViews::SetIgnoreMouseEvents(bool ignore, bool forward) {
|
||||
#if defined(OS_WIN)
|
||||
LONG ex_style = ::GetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE);
|
||||
if (ignore)
|
||||
|
@ -798,6 +798,13 @@ void NativeWindowViews::SetIgnoreMouseEvents(bool ignore) {
|
|||
else
|
||||
ex_style &= ~(WS_EX_TRANSPARENT | WS_EX_LAYERED);
|
||||
::SetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE, ex_style);
|
||||
|
||||
// Forwarding is always disabled when not ignoring mouse messages.
|
||||
if (!ignore) {
|
||||
SetForwardMouseMessages(false);
|
||||
} else {
|
||||
SetForwardMouseMessages(forward);
|
||||
}
|
||||
#elif defined(USE_X11)
|
||||
if (ignore) {
|
||||
XRectangle r = {0, 0, 1, 1};
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include "atom/browser/native_window.h"
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -102,7 +102,7 @@ class NativeWindowViews : public NativeWindow,
|
|||
void SetBackgroundColor(const std::string& color_name) override;
|
||||
void SetHasShadow(bool has_shadow) override;
|
||||
bool HasShadow() override;
|
||||
void SetIgnoreMouseEvents(bool ignore) override;
|
||||
void SetIgnoreMouseEvents(bool ignore, bool forward) override;
|
||||
void SetContentProtection(bool enable) override;
|
||||
void SetFocusable(bool focusable) override;
|
||||
void SetMenu(AtomMenuModel* menu_model) override;
|
||||
|
@ -134,7 +134,6 @@ class NativeWindowViews : public NativeWindow,
|
|||
|
||||
#if defined(OS_WIN)
|
||||
TaskbarHost& taskbar_host() { return taskbar_host_; }
|
||||
void SetForwardMouseMessages(bool forward) override;
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
@ -171,6 +170,7 @@ class NativeWindowViews : public NativeWindow,
|
|||
bool PreHandleMSG(
|
||||
UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) override;
|
||||
void HandleSizeEvent(WPARAM w_param, LPARAM l_param);
|
||||
void SetForwardMouseMessages(bool forward);
|
||||
static LRESULT CALLBACK SubclassProc(
|
||||
HWND hwnd, UINT msg, WPARAM w_param, LPARAM l_param, UINT_PTR subclass_id,
|
||||
DWORD_PTR ref_data);
|
||||
|
|
|
@ -221,10 +221,8 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) {
|
|||
}
|
||||
|
||||
void NativeWindowViews::SetForwardMouseMessages(bool forward) {
|
||||
forwarding_mouse_messages_ = forward;
|
||||
SetIgnoreMouseEvents(forward);
|
||||
|
||||
if (forward) {
|
||||
if (forward && !forwarding_mouse_messages_) {
|
||||
forwarding_mouse_messages_ = true;
|
||||
forwarding_windows_.insert(this);
|
||||
|
||||
// Subclassing is used to fix some issues when forwarding mouse messages;
|
||||
|
@ -235,7 +233,8 @@ void NativeWindowViews::SetForwardMouseMessages(bool forward) {
|
|||
if (!mouse_hook_) {
|
||||
mouse_hook_ = SetWindowsHookEx(WH_MOUSE_LL, MouseHookProc, NULL, 0);
|
||||
}
|
||||
} else {
|
||||
} else if (!forward && forwarding_mouse_messages_) {
|
||||
forwarding_mouse_messages_ = false;
|
||||
forwarding_windows_.erase(this);
|
||||
|
||||
RemoveWindowSubclass(legacy_window_, SubclassProc, 1);
|
||||
|
|
|
@ -1283,9 +1283,14 @@ Returns `Boolean` - Whether the window is visible on all workspaces.
|
|||
|
||||
**Note:** This API always returns false on Windows.
|
||||
|
||||
#### `win.setIgnoreMouseEvents(ignore)`
|
||||
#### `win.setIgnoreMouseEvents(ignore[, options])`
|
||||
|
||||
* `ignore` Boolean
|
||||
* `options` Object (optional)
|
||||
* `forward` Boolean (optional) _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.
|
||||
|
||||
Makes the window ignore all mouse events.
|
||||
|
||||
|
@ -1356,14 +1361,6 @@ removed in future Electron releases.
|
|||
**Note:** The BrowserView API is currently experimental and may change or be
|
||||
removed in future Electron releases.
|
||||
|
||||
#### `win.setForwardMouseMessages(forward)` _Windows_
|
||||
|
||||
* `forward` Boolean
|
||||
|
||||
Forward mouse messages to the window below this one. This is similar to
|
||||
`setIgnoreMouseEvents`, but additionally allows users to listen to events
|
||||
related to mouse movement such as `mouseleave`.
|
||||
|
||||
[blink-feature-string]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.json5?l=62
|
||||
[page-visibility-api]: https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API
|
||||
[quick-look]: https://en.wikipedia.org/wiki/Quick_Look
|
||||
|
|
Loading…
Reference in a new issue