fix: draggable regions with devtools open (#29696)
This commit is contained in:
parent
6fd9e4280c
commit
d59e2d7b2e
5 changed files with 25 additions and 9 deletions
|
@ -396,6 +396,10 @@ void BrowserWindow::ResetBrowserViews() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BrowserWindow::OnDevToolsResized() {
|
||||||
|
UpdateDraggableRegions(draggable_regions_);
|
||||||
|
}
|
||||||
|
|
||||||
void BrowserWindow::SetVibrancy(v8::Isolate* isolate,
|
void BrowserWindow::SetVibrancy(v8::Isolate* isolate,
|
||||||
v8::Local<v8::Value> value) {
|
v8::Local<v8::Value> value) {
|
||||||
std::string type = gin::V8ToString(isolate, value);
|
std::string type = gin::V8ToString(isolate, value);
|
||||||
|
|
|
@ -63,9 +63,7 @@ class BrowserWindow : public BaseWindow,
|
||||||
void OnActivateContents() override;
|
void OnActivateContents() override;
|
||||||
void OnPageTitleUpdated(const std::u16string& title,
|
void OnPageTitleUpdated(const std::u16string& title,
|
||||||
bool explicit_set) override;
|
bool explicit_set) override;
|
||||||
#if defined(OS_MAC)
|
|
||||||
void OnDevToolsResized() override;
|
void OnDevToolsResized() override;
|
||||||
#endif
|
|
||||||
|
|
||||||
// NativeWindowObserver:
|
// NativeWindowObserver:
|
||||||
void RequestPreferredWidth(int* width) override;
|
void RequestPreferredWidth(int* width) override;
|
||||||
|
@ -118,9 +116,7 @@ class BrowserWindow : public BaseWindow,
|
||||||
// it should be cancelled when we can prove that the window is responsive.
|
// it should be cancelled when we can prove that the window is responsive.
|
||||||
base::CancelableRepeatingClosure window_unresponsive_closure_;
|
base::CancelableRepeatingClosure window_unresponsive_closure_;
|
||||||
|
|
||||||
#if defined(OS_MAC)
|
|
||||||
std::vector<mojom::DraggableRegionPtr> draggable_regions_;
|
std::vector<mojom::DraggableRegionPtr> draggable_regions_;
|
||||||
#endif
|
|
||||||
|
|
||||||
v8::Global<v8::Value> web_contents_;
|
v8::Global<v8::Value> web_contents_;
|
||||||
base::WeakPtr<api::WebContents> api_web_contents_;
|
base::WeakPtr<api::WebContents> api_web_contents_;
|
||||||
|
|
|
@ -37,10 +37,6 @@ void BrowserWindow::OverrideNSWindowContentView(
|
||||||
[contentView viewDidMoveToWindow];
|
[contentView viewDidMoveToWindow];
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserWindow::OnDevToolsResized() {
|
|
||||||
UpdateDraggableRegions(draggable_regions_);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BrowserWindow::UpdateDraggableRegions(
|
void BrowserWindow::UpdateDraggableRegions(
|
||||||
const std::vector<mojom::DraggableRegionPtr>& regions) {
|
const std::vector<mojom::DraggableRegionPtr>& regions) {
|
||||||
if (window_->has_frame())
|
if (window_->has_frame())
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "shell/browser/api/electron_api_browser_window.h"
|
#include "shell/browser/api/electron_api_browser_window.h"
|
||||||
|
|
||||||
#include "shell/browser/native_window_views.h"
|
#include "shell/browser/native_window_views.h"
|
||||||
|
#include "ui/aura/window.h"
|
||||||
|
|
||||||
namespace electron {
|
namespace electron {
|
||||||
|
|
||||||
|
@ -14,8 +15,20 @@ void BrowserWindow::UpdateDraggableRegions(
|
||||||
const std::vector<mojom::DraggableRegionPtr>& regions) {
|
const std::vector<mojom::DraggableRegionPtr>& regions) {
|
||||||
if (window_->has_frame())
|
if (window_->has_frame())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (&draggable_regions_ != ®ions) {
|
||||||
|
auto const offset =
|
||||||
|
web_contents()->GetNativeView()->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);
|
||||||
|
}
|
||||||
|
|
||||||
static_cast<NativeWindowViews*>(window_.get())
|
static_cast<NativeWindowViews*>(window_.get())
|
||||||
->UpdateDraggableRegions(regions);
|
->UpdateDraggableRegions(draggable_regions_);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace api
|
} // namespace api
|
||||||
|
|
|
@ -127,6 +127,10 @@ void InspectableWebContentsViewViews::ShowDevTools(bool activate) {
|
||||||
} else {
|
} else {
|
||||||
devtools_window_->ShowInactive();
|
devtools_window_->ShowInactive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update draggable regions to account for the new dock position.
|
||||||
|
if (GetDelegate())
|
||||||
|
GetDelegate()->DevToolsResized();
|
||||||
} else {
|
} else {
|
||||||
devtools_web_view_->SetVisible(true);
|
devtools_web_view_->SetVisible(true);
|
||||||
devtools_web_view_->SetWebContents(
|
devtools_web_view_->SetWebContents(
|
||||||
|
@ -227,6 +231,9 @@ void InspectableWebContentsViewViews::Layout() {
|
||||||
|
|
||||||
devtools_web_view_->SetBoundsRect(new_devtools_bounds);
|
devtools_web_view_->SetBoundsRect(new_devtools_bounds);
|
||||||
contents_web_view_->SetBoundsRect(new_contents_bounds);
|
contents_web_view_->SetBoundsRect(new_contents_bounds);
|
||||||
|
|
||||||
|
if (GetDelegate())
|
||||||
|
GetDelegate()->DevToolsResized();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace electron
|
} // namespace electron
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue