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

Side by Side Diff: ash/wm/workspace/workspace_window_resizer.cc

Issue 1540753002: Switch to standard integer types in ash/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: arraysize Created 5 years 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 | « ash/wm/workspace/workspace_window_resizer.h ('k') | ash/wm/workspace_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/wm/workspace/workspace_window_resizer.h" 5 #include "ash/wm/workspace/workspace_window_resizer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 w = src.right() - x; 217 w = src.right() - x;
218 } else if (edge.secondary_edge == SECONDARY_MAGNETISM_EDGE_TRAILING) { 218 } else if (edge.secondary_edge == SECONDARY_MAGNETISM_EDGE_TRAILING) {
219 w += attach_origin.x() - src.x(); 219 w += attach_origin.x() - src.x();
220 } 220 }
221 break; 221 break;
222 } 222 }
223 return gfx::Rect(x, y, w, h); 223 return gfx::Rect(x, y, w, h);
224 } 224 }
225 225
226 // Converts a window component edge to the magnetic edge to snap to. 226 // Converts a window component edge to the magnetic edge to snap to.
227 uint32 WindowComponentToMagneticEdge(int window_component) { 227 uint32_t WindowComponentToMagneticEdge(int window_component) {
228 switch (window_component) { 228 switch (window_component) {
229 case HTTOPLEFT: 229 case HTTOPLEFT:
230 return MAGNETISM_EDGE_LEFT | MAGNETISM_EDGE_TOP; 230 return MAGNETISM_EDGE_LEFT | MAGNETISM_EDGE_TOP;
231 case HTTOPRIGHT: 231 case HTTOPRIGHT:
232 return MAGNETISM_EDGE_TOP | MAGNETISM_EDGE_RIGHT; 232 return MAGNETISM_EDGE_TOP | MAGNETISM_EDGE_RIGHT;
233 case HTBOTTOMLEFT: 233 case HTBOTTOMLEFT:
234 return MAGNETISM_EDGE_LEFT | MAGNETISM_EDGE_BOTTOM; 234 return MAGNETISM_EDGE_LEFT | MAGNETISM_EDGE_BOTTOM;
235 case HTBOTTOMRIGHT: 235 case HTBOTTOMRIGHT:
236 return MAGNETISM_EDGE_RIGHT | MAGNETISM_EDGE_BOTTOM; 236 return MAGNETISM_EDGE_RIGHT | MAGNETISM_EDGE_BOTTOM;
237 case HTTOP: 237 case HTTOP:
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 magnetism_window_->GetBoundsInScreen(), 710 magnetism_window_->GetBoundsInScreen(),
711 magnetism_edge_); 711 magnetism_edge_);
712 aura::client::GetScreenPositionClient(GetTarget()->GetRootWindow())-> 712 aura::client::GetScreenPositionClient(GetTarget()->GetRootWindow())->
713 ConvertPointFromScreen(GetTarget()->parent(), &point); 713 ConvertPointFromScreen(GetTarget()->parent(), &point);
714 bounds->set_origin(point); 714 bounds->set_origin(point);
715 } 715 }
716 } 716 }
717 717
718 void WorkspaceWindowResizer::MagneticallySnapResizeToOtherWindows( 718 void WorkspaceWindowResizer::MagneticallySnapResizeToOtherWindows(
719 gfx::Rect* bounds) { 719 gfx::Rect* bounds) {
720 const uint32 edges = WindowComponentToMagneticEdge( 720 const uint32_t edges =
721 details().window_component); 721 WindowComponentToMagneticEdge(details().window_component);
722 if (UpdateMagnetismWindow(*bounds, edges)) { 722 if (UpdateMagnetismWindow(*bounds, edges)) {
723 *bounds = ScreenUtil::ConvertRectFromScreen( 723 *bounds = ScreenUtil::ConvertRectFromScreen(
724 GetTarget()->parent(), 724 GetTarget()->parent(),
725 BoundsForMagneticResizeAttach( 725 BoundsForMagneticResizeAttach(
726 ScreenUtil::ConvertRectToScreen(GetTarget()->parent(), *bounds), 726 ScreenUtil::ConvertRectToScreen(GetTarget()->parent(), *bounds),
727 magnetism_window_->GetBoundsInScreen(), 727 magnetism_window_->GetBoundsInScreen(),
728 magnetism_edge_)); 728 magnetism_edge_));
729 } 729 }
730 } 730 }
731 731
732 bool WorkspaceWindowResizer::UpdateMagnetismWindow(const gfx::Rect& bounds, 732 bool WorkspaceWindowResizer::UpdateMagnetismWindow(const gfx::Rect& bounds,
733 uint32 edges) { 733 uint32_t edges) {
734 // |bounds| are in coordinates of original window's parent. 734 // |bounds| are in coordinates of original window's parent.
735 gfx::Rect bounds_in_screen = 735 gfx::Rect bounds_in_screen =
736 ScreenUtil::ConvertRectToScreen(GetTarget()->parent(), bounds); 736 ScreenUtil::ConvertRectToScreen(GetTarget()->parent(), bounds);
737 MagnetismMatcher matcher(bounds_in_screen, edges); 737 MagnetismMatcher matcher(bounds_in_screen, edges);
738 738
739 // If we snapped to a window then check it first. That way we don't bounce 739 // If we snapped to a window then check it first. That way we don't bounce
740 // around when close to multiple edges. 740 // around when close to multiple edges.
741 if (magnetism_window_) { 741 if (magnetism_window_) {
742 if (window_tracker_.Contains(magnetism_window_) && 742 if (window_tracker_.Contains(magnetism_window_) &&
743 matcher.ShouldAttach(magnetism_window_->GetBoundsInScreen(), 743 matcher.ShouldAttach(magnetism_window_->GetBoundsInScreen(),
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 bounds->set_y(bottom_edge - bounds->height()); 858 bounds->set_y(bottom_edge - bounds->height());
859 updated = true; 859 updated = true;
860 } 860 }
861 return updated; 861 return updated;
862 } 862 }
863 863
864 void WorkspaceWindowResizer::StickToWorkAreaOnResize( 864 void WorkspaceWindowResizer::StickToWorkAreaOnResize(
865 const gfx::Rect& work_area, 865 const gfx::Rect& work_area,
866 int sticky_size, 866 int sticky_size,
867 gfx::Rect* bounds) const { 867 gfx::Rect* bounds) const {
868 const uint32 edges = WindowComponentToMagneticEdge( 868 const uint32_t edges =
869 details().window_component); 869 WindowComponentToMagneticEdge(details().window_component);
870 const int left_edge = work_area.x(); 870 const int left_edge = work_area.x();
871 const int right_edge = work_area.right(); 871 const int right_edge = work_area.right();
872 const int top_edge = work_area.y(); 872 const int top_edge = work_area.y();
873 const int bottom_edge = work_area.bottom(); 873 const int bottom_edge = work_area.bottom();
874 if (edges & MAGNETISM_EDGE_TOP && 874 if (edges & MAGNETISM_EDGE_TOP &&
875 ShouldStickToEdge(bounds->y() - top_edge, sticky_size)) { 875 ShouldStickToEdge(bounds->y() - top_edge, sticky_size)) {
876 bounds->set_height(bounds->bottom() - top_edge); 876 bounds->set_height(bounds->bottom() - top_edge);
877 bounds->set_y(top_edge); 877 bounds->set_y(top_edge);
878 } 878 }
879 if (edges & MAGNETISM_EDGE_LEFT && 879 if (edges & MAGNETISM_EDGE_LEFT &&
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED); 1055 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED);
1056 gfx::Rect snapped_bounds = ScreenUtil::GetDisplayWorkAreaBoundsInParent( 1056 gfx::Rect snapped_bounds = ScreenUtil::GetDisplayWorkAreaBoundsInParent(
1057 GetTarget()); 1057 GetTarget());
1058 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) 1058 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED)
1059 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width()); 1059 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width());
1060 snapped_bounds.set_width(bounds_in_parent.width()); 1060 snapped_bounds.set_width(bounds_in_parent.width());
1061 return bounds_in_parent == snapped_bounds; 1061 return bounds_in_parent == snapped_bounds;
1062 } 1062 }
1063 1063
1064 } // namespace ash 1064 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_window_resizer.h ('k') | ash/wm/workspace_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698