Allow devtools window to show on other screens
This commit is contained in:
parent
6dfd0518cd
commit
f6171c53ca
1 changed files with 11 additions and 3 deletions
|
@ -91,6 +91,14 @@ bool IsPointInRect(const gfx::Point& point, const gfx::Rect& rect) {
|
||||||
point.y() > rect.y() && point.y() < (rect.height() + rect.y());
|
point.y() > rect.y() && point.y() < (rect.height() + rect.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsPointInScreen(const gfx::Point& point) {
|
||||||
|
for (const auto& display : gfx::Screen::GetScreen()->GetAllDisplays()) {
|
||||||
|
if (IsPointInRect(point, display.bounds()))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void SetZoomLevelForWebContents(content::WebContents* web_contents,
|
void SetZoomLevelForWebContents(content::WebContents* web_contents,
|
||||||
double level) {
|
double level) {
|
||||||
content::HostZoomMap::SetZoomLevel(web_contents, level);
|
content::HostZoomMap::SetZoomLevel(web_contents, level);
|
||||||
|
@ -214,9 +222,9 @@ InspectableWebContentsImpl::InspectableWebContentsImpl(
|
||||||
devtools_bounds_.set_height(600);
|
devtools_bounds_.set_height(600);
|
||||||
devtools_bounds_.set_width(800);
|
devtools_bounds_.set_width(800);
|
||||||
}
|
}
|
||||||
gfx::Rect display = gfx::Screen::GetScreen()
|
if (!IsPointInScreen(devtools_bounds_.origin())) {
|
||||||
->GetDisplayNearestWindow(web_contents->GetNativeView()).bounds();
|
gfx::Rect display = gfx::Screen::GetScreen()->
|
||||||
if (!IsPointInRect(devtools_bounds_.origin(), display)) {
|
GetDisplayNearestWindow(web_contents->GetNativeView()).bounds();
|
||||||
devtools_bounds_.set_x(display.x() + (display.width() - devtools_bounds_.width()) / 2);
|
devtools_bounds_.set_x(display.x() + (display.width() - devtools_bounds_.width()) / 2);
|
||||||
devtools_bounds_.set_y(display.y() + (display.height() - devtools_bounds_.height()) / 2);
|
devtools_bounds_.set_y(display.y() + (display.height() - devtools_bounds_.height()) / 2);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue