Fix scroll conflict
This commit is contained in:
parent
5eeadb0ad4
commit
1aedccaeeb
2 changed files with 55 additions and 7 deletions
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
#include "base/mac/scoped_nsobject.h"
|
#include "base/mac/scoped_nsobject.h"
|
||||||
#include "atom/browser/native_window.h"
|
#include "atom/browser/native_window.h"
|
||||||
|
#include "content/public/browser/render_widget_host.h"
|
||||||
|
|
||||||
@class AtomNSWindow;
|
@class AtomNSWindow;
|
||||||
@class AtomNSWindowDelegate;
|
@class AtomNSWindowDelegate;
|
||||||
|
@ -19,7 +20,8 @@
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
class NativeWindowMac : public NativeWindow {
|
class NativeWindowMac : public NativeWindow,
|
||||||
|
public content::RenderWidgetHost::InputEventObserver {
|
||||||
public:
|
public:
|
||||||
NativeWindowMac(brightray::InspectableWebContents* inspectable_web_contents,
|
NativeWindowMac(brightray::InspectableWebContents* inspectable_web_contents,
|
||||||
const mate::Dictionary& options,
|
const mate::Dictionary& options,
|
||||||
|
@ -90,6 +92,8 @@ class NativeWindowMac : public NativeWindow {
|
||||||
void SetVisibleOnAllWorkspaces(bool visible) override;
|
void SetVisibleOnAllWorkspaces(bool visible) override;
|
||||||
bool IsVisibleOnAllWorkspaces() override;
|
bool IsVisibleOnAllWorkspaces() override;
|
||||||
|
|
||||||
|
void OnInputEvent(const blink::WebInputEvent& event) override;
|
||||||
|
|
||||||
// Refresh the DraggableRegion views.
|
// Refresh the DraggableRegion views.
|
||||||
void UpdateDraggableRegionViews() {
|
void UpdateDraggableRegionViews() {
|
||||||
UpdateDraggableRegionViews(draggable_regions_);
|
UpdateDraggableRegionViews(draggable_regions_);
|
||||||
|
@ -126,6 +130,11 @@ class NativeWindowMac : public NativeWindow {
|
||||||
// whehter we can drag.
|
// whehter we can drag.
|
||||||
void UpdateDraggableRegionViews(const std::vector<DraggableRegion>& regions);
|
void UpdateDraggableRegionViews(const std::vector<DraggableRegion>& regions);
|
||||||
|
|
||||||
|
void RegisterInputEventObserver(content::RenderViewHost* host);
|
||||||
|
void UnregisterInputEventObserver(content::RenderViewHost* host);
|
||||||
|
void RenderViewHostChanged(content::RenderViewHost* old_host,
|
||||||
|
content::RenderViewHost* new_host);
|
||||||
|
|
||||||
base::scoped_nsobject<AtomNSWindow> window_;
|
base::scoped_nsobject<AtomNSWindow> window_;
|
||||||
base::scoped_nsobject<AtomNSWindowDelegate> window_delegate_;
|
base::scoped_nsobject<AtomNSWindowDelegate> window_delegate_;
|
||||||
|
|
||||||
|
@ -147,6 +156,8 @@ class NativeWindowMac : public NativeWindow {
|
||||||
// The "titleBarStyle" option.
|
// The "titleBarStyle" option.
|
||||||
TitleBarStyle title_bar_style_;
|
TitleBarStyle title_bar_style_;
|
||||||
|
|
||||||
|
bool is_edge_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(NativeWindowMac);
|
DISALLOW_COPY_AND_ASSIGN(NativeWindowMac);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -429,13 +429,14 @@ struct Converter<atom::NativeWindowMac::TitleBarStyle> {
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
NativeWindowMac::NativeWindowMac(
|
NativeWindowMac::NativeWindowMac(
|
||||||
brightray::InspectableWebContents* web_contents,
|
brightray::InspectableWebContents* iWeb_contents,
|
||||||
const mate::Dictionary& options,
|
const mate::Dictionary& options,
|
||||||
NativeWindow* parent)
|
NativeWindow* parent)
|
||||||
: NativeWindow(web_contents, options, parent),
|
: NativeWindow(iWeb_contents, options, parent),
|
||||||
is_kiosk_(false),
|
is_kiosk_(false),
|
||||||
attention_request_id_(0),
|
attention_request_id_(0),
|
||||||
title_bar_style_(NORMAL) {
|
title_bar_style_(NORMAL),
|
||||||
|
is_edge_(false) {
|
||||||
int width = 800, height = 600;
|
int width = 800, height = 600;
|
||||||
options.Get(options::kWidth, &width);
|
options.Get(options::kWidth, &width);
|
||||||
options.Get(options::kHeight, &height);
|
options.Get(options::kHeight, &height);
|
||||||
|
@ -574,17 +575,19 @@ NativeWindowMac::NativeWindowMac(
|
||||||
if ([[event window] windowNumber] != [window_ windowNumber])
|
if ([[event window] windowNumber] != [window_ windowNumber])
|
||||||
return event;
|
return event;
|
||||||
|
|
||||||
if (!web_contents)
|
if (!iWeb_contents)
|
||||||
return event;
|
return event;
|
||||||
|
|
||||||
if (!began && (([event phase] == NSEventPhaseMayBegin) ||
|
if (!began && is_edge_ && (([event phase] == NSEventPhaseMayBegin) ||
|
||||||
([event phase] == NSEventPhaseBegan))) {
|
([event phase] == NSEventPhaseBegan))) {
|
||||||
this->NotifyWindowScrollTouchBegin();
|
this->NotifyWindowScrollTouchBegin();
|
||||||
began = YES;
|
began = YES;
|
||||||
|
is_edge_ = false;
|
||||||
} else if (began && (([event phase] == NSEventPhaseEnded) ||
|
} else if (began && (([event phase] == NSEventPhaseEnded) ||
|
||||||
([event phase] == NSEventPhaseCancelled))) {
|
([event phase] == NSEventPhaseCancelled))) {
|
||||||
this->NotifyWindowScrollTouchEnd();
|
this->NotifyWindowScrollTouchEnd();
|
||||||
began = NO;
|
began = NO;
|
||||||
|
is_edge_ = false;
|
||||||
}
|
}
|
||||||
return event;
|
return event;
|
||||||
}];
|
}];
|
||||||
|
@ -594,6 +597,26 @@ NativeWindowMac::NativeWindowMac(
|
||||||
// Set maximizable state last to ensure zoom button does not get reset
|
// Set maximizable state last to ensure zoom button does not get reset
|
||||||
// by calls to other APIs.
|
// by calls to other APIs.
|
||||||
SetMaximizable(maximizable);
|
SetMaximizable(maximizable);
|
||||||
|
|
||||||
|
RegisterInputEventObserver(web_contents()->GetRenderViewHost());
|
||||||
|
}
|
||||||
|
void NativeWindowMac::RegisterInputEventObserver(
|
||||||
|
content::RenderViewHost* host) {
|
||||||
|
if (host != nullptr)
|
||||||
|
host->GetWidget()->AddInputEventObserver(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NativeWindowMac::UnregisterInputEventObserver(
|
||||||
|
content::RenderViewHost* host) {
|
||||||
|
if (host != nullptr)
|
||||||
|
host->GetWidget()->RemoveInputEventObserver(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NativeWindowMac::RenderViewHostChanged(
|
||||||
|
content::RenderViewHost* old_host,
|
||||||
|
content::RenderViewHost* new_host) {
|
||||||
|
UnregisterInputEventObserver(old_host);
|
||||||
|
RegisterInputEventObserver(new_host);
|
||||||
}
|
}
|
||||||
|
|
||||||
NativeWindowMac::~NativeWindowMac() {
|
NativeWindowMac::~NativeWindowMac() {
|
||||||
|
@ -1197,6 +1220,20 @@ void NativeWindowMac::SetCollectionBehavior(bool on, NSUInteger flag) {
|
||||||
SetMaximizable(was_maximizable);
|
SetMaximizable(was_maximizable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NativeWindowMac::OnInputEvent(const blink::WebInputEvent& event) {
|
||||||
|
switch (event.type) {
|
||||||
|
case blink::WebInputEvent::GestureScrollBegin:
|
||||||
|
case blink::WebInputEvent::GestureScrollUpdate:
|
||||||
|
case blink::WebInputEvent::GestureScrollEnd:
|
||||||
|
{
|
||||||
|
is_edge_ = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
NativeWindow* NativeWindow::Create(
|
NativeWindow* NativeWindow::Create(
|
||||||
brightray::InspectableWebContents* inspectable_web_contents,
|
brightray::InspectableWebContents* inspectable_web_contents,
|
||||||
|
|
Loading…
Reference in a new issue