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

Unified Diff: ui/aura/toplevel_window_event_filter.cc

Issue 8273040: Minimum size for aura window (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comments. moved&merged tests Created 9 years, 2 months 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 side-by-side diff with in-line comments
Download patch
Index: ui/aura/toplevel_window_event_filter.cc
diff --git a/ui/aura/toplevel_window_event_filter.cc b/ui/aura/toplevel_window_event_filter.cc
index 98d29d302ca3d7e22f83460086447e22a07668d6..a6a5f6bed130753df958fe93fd3834c7556ec3af 100644
--- a/ui/aura/toplevel_window_event_filter.cc
+++ b/ui/aura/toplevel_window_event_filter.cc
@@ -130,10 +130,10 @@ bool ToplevelWindowEventFilter::OnMouseEvent(Window* target,
switch (event->type()) {
case ui::ET_MOUSE_MOVED:
- window_component_ =
- target->delegate()->GetNonClientComponent(event->location());
+ UpdateWindowComponentForEvent(target, event);
break;
case ui::ET_MOUSE_PRESSED:
Ben Goodger (Google) 2011/10/16 22:23:33 Add this comment above this line: We also update
oshima 2011/10/17 19:30:57 This happens when mouse is released and then press
+ UpdateWindowComponentForEvent(target, event);
mouse_down_bounds_ = target->bounds();
mouse_down_offset_in_target_ = event->location();
mouse_down_offset_in_parent_ = mouse_down_offset_in_target_;
@@ -184,6 +184,12 @@ bool ToplevelWindowEventFilter::HandleDrag(Window* target, MouseEvent* event) {
return true;
}
+void ToplevelWindowEventFilter::UpdateWindowComponentForEvent(
+ Window* target, MouseEvent* event) {
+ window_component_ =
+ target->delegate()->GetNonClientComponent(event->location());
+}
+
gfx::Point ToplevelWindowEventFilter::GetOriginForDrag(
int bounds_change,
Window* target,
@@ -232,10 +238,18 @@ gfx::Size ToplevelWindowEventFilter::GetSizeForDrag(int bounds_change,
int x_multiplier = GetXMultiplierForWindowComponent(window_component_);
int y_multiplier = GetYMultiplierForWindowComponent(window_component_);
- size.Enlarge(size_change_direction & kBoundsChangeDirection_Horizontal ?
- x_multiplier * (first_x - second_x) : 0,
- size_change_direction & kBoundsChangeDirection_Vertical ?
- y_multiplier * (first_y - second_y) : 0);
+
+ int width = size.width() +
+ (size_change_direction & kBoundsChangeDirection_Horizontal ?
+ x_multiplier * (first_x - second_x) : 0);
+ int height = size.height() +
+ (size_change_direction & kBoundsChangeDirection_Vertical ?
+ y_multiplier * (first_y - second_y) : 0);
+
+ // Enforce minimum window size.
+ const gfx::Size min_size = target->minimum_size();
+ size.SetSize(std::max(width, min_size.width()),
+ std::max(height, min_size.height()));
}
return size;
}

Powered by Google App Engine
This is Rietveld 408576698