Merge pull request #9108 from yuya-oc/add-macos-sheet-events
Add sheet-begin and sheet-end events to macOS BrowserWindow
This commit is contained in:
commit
dc8b43901b
8 changed files with 88 additions and 0 deletions
|
@ -263,6 +263,14 @@ void Window::OnWindowSwipe(const std::string& direction) {
|
||||||
Emit("swipe", direction);
|
Emit("swipe", direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::OnWindowSheetBegin() {
|
||||||
|
Emit("sheet-begin");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Window::OnWindowSheetEnd() {
|
||||||
|
Emit("sheet-end");
|
||||||
|
}
|
||||||
|
|
||||||
void Window::OnWindowEnterHtmlFullScreen() {
|
void Window::OnWindowEnterHtmlFullScreen() {
|
||||||
Emit("enter-html-full-screen");
|
Emit("enter-html-full-screen");
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,6 +79,8 @@ class Window : public mate::TrackableObject<Window>,
|
||||||
void OnWindowScrollTouchEnd() override;
|
void OnWindowScrollTouchEnd() override;
|
||||||
void OnWindowScrollTouchEdge() override;
|
void OnWindowScrollTouchEdge() override;
|
||||||
void OnWindowSwipe(const std::string& direction) override;
|
void OnWindowSwipe(const std::string& direction) override;
|
||||||
|
void OnWindowSheetBegin() override;
|
||||||
|
void OnWindowSheetEnd() override;
|
||||||
void OnWindowEnterFullScreen() override;
|
void OnWindowEnterFullScreen() override;
|
||||||
void OnWindowLeaveFullScreen() override;
|
void OnWindowLeaveFullScreen() override;
|
||||||
void OnWindowEnterHtmlFullScreen() override;
|
void OnWindowEnterHtmlFullScreen() override;
|
||||||
|
|
|
@ -554,6 +554,16 @@ void NativeWindow::NotifyWindowSwipe(const std::string& direction) {
|
||||||
observer.OnWindowSwipe(direction);
|
observer.OnWindowSwipe(direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NativeWindow::NotifyWindowSheetBegin() {
|
||||||
|
for (NativeWindowObserver& observer : observers_)
|
||||||
|
observer.OnWindowSheetBegin();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NativeWindow::NotifyWindowSheetEnd() {
|
||||||
|
for (NativeWindowObserver& observer : observers_)
|
||||||
|
observer.OnWindowSheetEnd();
|
||||||
|
}
|
||||||
|
|
||||||
void NativeWindow::NotifyWindowLeaveFullScreen() {
|
void NativeWindow::NotifyWindowLeaveFullScreen() {
|
||||||
for (NativeWindowObserver& observer : observers_)
|
for (NativeWindowObserver& observer : observers_)
|
||||||
observer.OnWindowLeaveFullScreen();
|
observer.OnWindowLeaveFullScreen();
|
||||||
|
|
|
@ -233,6 +233,8 @@ class NativeWindow : public base::SupportsUserData,
|
||||||
void NotifyWindowScrollTouchEnd();
|
void NotifyWindowScrollTouchEnd();
|
||||||
void NotifyWindowScrollTouchEdge();
|
void NotifyWindowScrollTouchEdge();
|
||||||
void NotifyWindowSwipe(const std::string& direction);
|
void NotifyWindowSwipe(const std::string& direction);
|
||||||
|
void NotifyWindowSheetBegin();
|
||||||
|
void NotifyWindowSheetEnd();
|
||||||
void NotifyWindowEnterFullScreen();
|
void NotifyWindowEnterFullScreen();
|
||||||
void NotifyWindowLeaveFullScreen();
|
void NotifyWindowLeaveFullScreen();
|
||||||
void NotifyWindowEnterHtmlFullScreen();
|
void NotifyWindowEnterHtmlFullScreen();
|
||||||
|
|
|
@ -313,6 +313,14 @@ bool ScopedDisableResize::disable_resize_ = false;
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)windowWillBeginSheet:(NSNotification *)notification {
|
||||||
|
shell_->NotifyWindowSheetBegin();
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)windowDidEndSheet:(NSNotification *)notification {
|
||||||
|
shell_->NotifyWindowSheetEnd();
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface AtomPreviewItem : NSObject <QLPreviewItem>
|
@interface AtomPreviewItem : NSObject <QLPreviewItem>
|
||||||
|
|
|
@ -67,6 +67,8 @@ class NativeWindowObserver {
|
||||||
virtual void OnWindowScrollTouchEnd() {}
|
virtual void OnWindowScrollTouchEnd() {}
|
||||||
virtual void OnWindowScrollTouchEdge() {}
|
virtual void OnWindowScrollTouchEdge() {}
|
||||||
virtual void OnWindowSwipe(const std::string& direction) {}
|
virtual void OnWindowSwipe(const std::string& direction) {}
|
||||||
|
virtual void OnWindowSheetBegin() {}
|
||||||
|
virtual void OnWindowSheetEnd() {}
|
||||||
virtual void OnWindowEnterFullScreen() {}
|
virtual void OnWindowEnterFullScreen() {}
|
||||||
virtual void OnWindowLeaveFullScreen() {}
|
virtual void OnWindowLeaveFullScreen() {}
|
||||||
virtual void OnWindowEnterHtmlFullScreen() {}
|
virtual void OnWindowEnterHtmlFullScreen() {}
|
||||||
|
|
|
@ -498,6 +498,14 @@ Returns:
|
||||||
|
|
||||||
Emitted on 3-finger swipe. Possible directions are `up`, `right`, `down`, `left`.
|
Emitted on 3-finger swipe. Possible directions are `up`, `right`, `down`, `left`.
|
||||||
|
|
||||||
|
#### Event: 'sheet-begin' _macOS_
|
||||||
|
|
||||||
|
Emitted when the window opens a sheet.
|
||||||
|
|
||||||
|
#### Event: 'sheet-end' _macOS_
|
||||||
|
|
||||||
|
Emitted when the window has closed a sheet.
|
||||||
|
|
||||||
### Static Methods
|
### Static Methods
|
||||||
|
|
||||||
The `BrowserWindow` class has the following static methods:
|
The `BrowserWindow` class has the following static methods:
|
||||||
|
|
|
@ -1191,6 +1191,54 @@ describe('BrowserWindow module', function () {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('sheet-begin event', function () {
|
||||||
|
if (process.platform !== 'darwin') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let sheet = null
|
||||||
|
|
||||||
|
afterEach(function () {
|
||||||
|
return closeWindow(sheet, {assertSingleWindow: false}).then(function () { sheet = null })
|
||||||
|
})
|
||||||
|
|
||||||
|
it('emits when window opens a sheet', function (done) {
|
||||||
|
w.show()
|
||||||
|
w.once('sheet-begin', function () {
|
||||||
|
sheet.close()
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
sheet = new BrowserWindow({
|
||||||
|
modal: true,
|
||||||
|
parent: w
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('sheet-end event', function () {
|
||||||
|
if (process.platform !== 'darwin') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let sheet = null
|
||||||
|
|
||||||
|
afterEach(function () {
|
||||||
|
return closeWindow(sheet, {assertSingleWindow: false}).then(function () { sheet = null })
|
||||||
|
})
|
||||||
|
|
||||||
|
it('emits when window has closed a sheet', function (done) {
|
||||||
|
w.show()
|
||||||
|
sheet = new BrowserWindow({
|
||||||
|
modal: true,
|
||||||
|
parent: w
|
||||||
|
})
|
||||||
|
w.once('sheet-end', function () {
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
sheet.close()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('beginFrameSubscription method', function () {
|
describe('beginFrameSubscription method', function () {
|
||||||
// This test is too slow, only test it on CI.
|
// This test is too slow, only test it on CI.
|
||||||
if (!isCI) return
|
if (!isCI) return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue