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

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: addressd comment 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
« no previous file with comments | « ui/aura/toplevel_window_event_filter.h ('k') | ui/aura/toplevel_window_event_filter_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 d57d0721fe7fbe23f397e34e515d0641af1ad23c..707e3a7790cc5bcff17e692e8b6fdcf32f26a6ee 100644
--- a/ui/aura/toplevel_window_event_filter.cc
+++ b/ui/aura/toplevel_window_event_filter.cc
@@ -130,10 +130,13 @@ 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:
+ // We also update the current window component here because for the
+ // mouse-drag-release-press case, where the mouse is released and
+ // pressed without mouse move event.
+ 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_;
@@ -192,6 +195,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,
@@ -240,10 +249,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;
}
« no previous file with comments | « ui/aura/toplevel_window_event_filter.h ('k') | ui/aura/toplevel_window_event_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698