2018-03-06 05:07:06 +00:00
|
|
|
// Copyright (c) 2018 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2020-02-04 20:19:40 +00:00
|
|
|
#include "shell/browser/api/electron_api_browser_window.h"
|
2018-03-06 05:07:06 +00:00
|
|
|
|
2021-08-17 06:29:49 +00:00
|
|
|
#include "content/browser/web_contents/web_contents_impl.h" // nogncheck
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/browser/native_window_views.h"
|
2021-06-16 16:58:30 +00:00
|
|
|
#include "ui/aura/window.h"
|
2018-03-06 06:04:40 +00:00
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
namespace electron {
|
2018-03-06 05:07:06 +00:00
|
|
|
|
|
|
|
namespace api {
|
|
|
|
|
|
|
|
void BrowserWindow::UpdateDraggableRegions(
|
2019-06-03 17:43:04 +00:00
|
|
|
const std::vector<mojom::DraggableRegionPtr>& regions) {
|
2018-03-06 05:44:36 +00:00
|
|
|
if (window_->has_frame())
|
|
|
|
return;
|
2021-06-16 16:58:30 +00:00
|
|
|
|
2021-08-17 21:00:49 +00:00
|
|
|
if (&draggable_regions_ != ®ions && web_contents()) {
|
2021-08-17 06:29:49 +00:00
|
|
|
auto* view =
|
|
|
|
static_cast<content::WebContentsImpl*>(web_contents())->GetView();
|
|
|
|
if (view) {
|
|
|
|
const gfx::NativeView nv = view->GetNativeView();
|
2021-07-29 21:27:02 +00:00
|
|
|
auto const offset = nv->GetBoundsInRootWindow();
|
|
|
|
auto snapped_regions = mojo::Clone(regions);
|
|
|
|
for (auto& snapped_region : snapped_regions) {
|
|
|
|
snapped_region->bounds.Offset(offset.x(), offset.y());
|
|
|
|
}
|
|
|
|
|
|
|
|
draggable_regions_ = mojo::Clone(snapped_regions);
|
2021-06-16 16:58:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-18 01:55:30 +00:00
|
|
|
static_cast<NativeWindowViews*>(window_.get())
|
2021-06-16 16:58:30 +00:00
|
|
|
->UpdateDraggableRegions(draggable_regions_);
|
2018-03-06 05:07:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace api
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
} // namespace electron
|