feat: allow setting window shape (#13789)
This binds Widget::SetShape, an API that already exists in Chromium (for Windows and Linux). It's a more reliable method of having some parts of your window be "click-through" than the current `setIgnoreMouseEvents` API, which messes around with the `WS_EX_LAYERED` window style on Windows, causing strange bugs and incompatibility with hardware acceleration.
This commit is contained in:
parent
b22ac5f0a2
commit
3bdff2d238
4 changed files with 28 additions and 0 deletions
|
@ -578,6 +578,10 @@ double TopLevelWindow::GetOpacity() {
|
|||
return window_->GetOpacity();
|
||||
}
|
||||
|
||||
void TopLevelWindow::SetShape(const std::vector<gfx::Rect>& rects) {
|
||||
window_->widget()->SetShape(std::make_unique<std::vector<gfx::Rect>>(rects));
|
||||
}
|
||||
|
||||
void TopLevelWindow::SetRepresentedFilename(const std::string& filename) {
|
||||
window_->SetRepresentedFilename(filename);
|
||||
}
|
||||
|
@ -1007,6 +1011,7 @@ void TopLevelWindow::BuildPrototype(v8::Isolate* isolate,
|
|||
.SetMethod("hasShadow", &TopLevelWindow::HasShadow)
|
||||
.SetMethod("setOpacity", &TopLevelWindow::SetOpacity)
|
||||
.SetMethod("getOpacity", &TopLevelWindow::GetOpacity)
|
||||
.SetMethod("setShape", &TopLevelWindow::SetShape)
|
||||
.SetMethod("setRepresentedFilename",
|
||||
&TopLevelWindow::SetRepresentedFilename)
|
||||
.SetMethod("getRepresentedFilename",
|
||||
|
|
|
@ -148,6 +148,7 @@ class TopLevelWindow : public mate::TrackableObject<TopLevelWindow>,
|
|||
bool HasShadow();
|
||||
void SetOpacity(const double opacity);
|
||||
double GetOpacity();
|
||||
void SetShape(const std::vector<gfx::Rect>& rects);
|
||||
void SetRepresentedFilename(const std::string& filename);
|
||||
std::string GetRepresentedFilename();
|
||||
void SetDocumentEdited(bool edited);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue