Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: components/exo/shell_surface.cc

Issue 2467173002: exo: Fix widget positioning for pop-ups (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/exo/display.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/exo/shell_surface.h" 5 #include "components/exo/shell_surface.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/aura/wm_window_aura.h" 9 #include "ash/aura/wm_window_aura.h"
10 #include "ash/common/shelf/wm_shelf.h" 10 #include "ash/common/shelf/wm_shelf.h"
(...skipping 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 // Use |geometry_| if set, otherwise use the visual bounds of the surface. 1220 // Use |geometry_| if set, otherwise use the visual bounds of the surface.
1221 return geometry_.IsEmpty() ? gfx::Rect(surface_->window()->layer()->size()) 1221 return geometry_.IsEmpty() ? gfx::Rect(surface_->window()->layer()->size())
1222 : geometry_; 1222 : geometry_;
1223 } 1223 }
1224 1224
1225 gfx::Point ShellSurface::GetSurfaceOrigin() const { 1225 gfx::Point ShellSurface::GetSurfaceOrigin() const {
1226 gfx::Rect window_bounds = widget_->GetNativeWindow()->bounds(); 1226 gfx::Rect window_bounds = widget_->GetNativeWindow()->bounds();
1227 1227
1228 // If initial bounds were specified then surface origin is always relative 1228 // If initial bounds were specified then surface origin is always relative
1229 // to those bounds. 1229 // to those bounds.
1230 if (!initial_bounds_.IsEmpty()) 1230 if (!initial_bounds_.IsEmpty()) {
1231 return initial_bounds_.origin() - window_bounds.OffsetFromOrigin(); 1231 gfx::Point origin = window_bounds.origin();
1232 wm::ConvertPointToScreen(widget_->GetNativeWindow()->parent(), &origin);
1233 return initial_bounds_.origin() - origin.OffsetFromOrigin();
1234 }
1232 1235
1233 gfx::Rect visible_bounds = GetVisibleBounds(); 1236 gfx::Rect visible_bounds = GetVisibleBounds();
1234 switch (resize_component_) { 1237 switch (resize_component_) {
1235 case HTCAPTION: 1238 case HTCAPTION:
1236 return origin_ - visible_bounds.OffsetFromOrigin(); 1239 return origin_ - visible_bounds.OffsetFromOrigin();
1237 case HTBOTTOM: 1240 case HTBOTTOM:
1238 case HTRIGHT: 1241 case HTRIGHT:
1239 case HTBOTTOMRIGHT: 1242 case HTBOTTOMRIGHT:
1240 return gfx::Point() - visible_bounds.OffsetFromOrigin(); 1243 return gfx::Point() - visible_bounds.OffsetFromOrigin();
1241 case HTTOP: 1244 case HTTOP:
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 return; 1282 return;
1280 1283
1281 gfx::Rect visible_bounds = GetVisibleBounds(); 1284 gfx::Rect visible_bounds = GetVisibleBounds();
1282 gfx::Rect new_widget_bounds = visible_bounds; 1285 gfx::Rect new_widget_bounds = visible_bounds;
1283 1286
1284 // Avoid changing widget origin unless initial bounds were specified and 1287 // Avoid changing widget origin unless initial bounds were specified and
1285 // widget origin is always relative to it. 1288 // widget origin is always relative to it.
1286 if (initial_bounds_.IsEmpty()) 1289 if (initial_bounds_.IsEmpty())
1287 new_widget_bounds.set_origin(widget_->GetWindowBoundsInScreen().origin()); 1290 new_widget_bounds.set_origin(widget_->GetWindowBoundsInScreen().origin());
1288 1291
1292 else {
reveman 2016/11/02 14:24:19 nit: {} for the if-scope above too if needed for e
Dominik Laskowski 2016/11/03 19:56:53 Done.
1293 new_widget_bounds.set_origin(initial_bounds_.origin() +
1294 visible_bounds.OffsetFromOrigin());
1295 }
1296
1289 // Update widget origin using the surface origin if the current location of 1297 // Update widget origin using the surface origin if the current location of
1290 // surface is being anchored to one side of the widget as a result of a 1298 // surface is being anchored to one side of the widget as a result of a
1291 // resize operation. 1299 // resize operation.
1292 if (resize_component_ != HTCAPTION) { 1300 if (resize_component_ != HTCAPTION) {
1293 gfx::Point new_widget_origin = 1301 gfx::Point new_widget_origin =
1294 GetSurfaceOrigin() + visible_bounds.OffsetFromOrigin(); 1302 GetSurfaceOrigin() + visible_bounds.OffsetFromOrigin();
1295 wm::ConvertPointToScreen(widget_->GetNativeWindow(), &new_widget_origin); 1303 wm::ConvertPointToScreen(widget_->GetNativeWindow(), &new_widget_origin);
1296 new_widget_bounds.set_origin(new_widget_origin); 1304 new_widget_bounds.set_origin(new_widget_origin);
1297 } 1305 }
1298 1306
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1391 shadow_overlay_->layer()->Add(shadow->layer()); 1399 shadow_overlay_->layer()->Add(shadow->layer());
1392 window->AddChild(shadow_overlay_); 1400 window->AddChild(shadow_overlay_);
1393 shadow_overlay_->Show(); 1401 shadow_overlay_->Show();
1394 } 1402 }
1395 shadow_overlay_->SetBounds(shadow_bounds); 1403 shadow_overlay_->SetBounds(shadow_bounds);
1396 shadow->SetContentBounds(gfx::Rect(shadow_bounds.size())); 1404 shadow->SetContentBounds(gfx::Rect(shadow_bounds.size()));
1397 } 1405 }
1398 } 1406 }
1399 1407
1400 } // namespace exo 1408 } // namespace exo
OLDNEW
« no previous file with comments | « components/exo/display.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698