OLD | NEW |
---|---|
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/frame_painter.h" | 5 #include "ash/wm/frame_painter.h" |
6 | 6 |
7 #include "ash/ash_constants.h" | 7 #include "ash/ash_constants.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
10 #include "ash/wm/property_util.h" | |
10 #include "ash/wm/window_util.h" | 11 #include "ash/wm/window_util.h" |
11 #include "ash/wm/workspace_controller.h" | 12 #include "ash/wm/workspace_controller.h" |
12 #include "base/logging.h" // DCHECK | 13 #include "base/logging.h" // DCHECK |
13 #include "grit/ui_resources.h" | 14 #include "grit/ui_resources.h" |
14 #include "third_party/skia/include/core/SkCanvas.h" | 15 #include "third_party/skia/include/core/SkCanvas.h" |
15 #include "third_party/skia/include/core/SkColor.h" | 16 #include "third_party/skia/include/core/SkColor.h" |
16 #include "third_party/skia/include/core/SkPaint.h" | 17 #include "third_party/skia/include/core/SkPaint.h" |
17 #include "third_party/skia/include/core/SkPath.h" | 18 #include "third_party/skia/include/core/SkPath.h" |
18 #include "ui/aura/client/aura_constants.h" | 19 #include "ui/aura/client/aura_constants.h" |
19 #include "ui/aura/env.h" | 20 #include "ui/aura/env.h" |
20 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
21 #include "ui/base/animation/slide_animation.h" | 22 #include "ui/base/animation/slide_animation.h" |
22 #include "ui/base/hit_test.h" | 23 #include "ui/base/hit_test.h" |
23 #include "ui/base/layout.h" | 24 #include "ui/base/layout.h" |
24 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
25 #include "ui/base/theme_provider.h" | 26 #include "ui/base/theme_provider.h" |
26 #include "ui/gfx/canvas.h" | 27 #include "ui/gfx/canvas.h" |
27 #include "ui/gfx/font.h" | 28 #include "ui/gfx/font.h" |
28 #include "ui/gfx/image/image.h" | 29 #include "ui/gfx/image/image.h" |
30 #include "ui/gfx/screen.h" | |
29 #include "ui/views/controls/button/image_button.h" | 31 #include "ui/views/controls/button/image_button.h" |
30 #include "ui/views/widget/widget.h" | 32 #include "ui/views/widget/widget.h" |
31 #include "ui/views/widget/widget_delegate.h" | 33 #include "ui/views/widget/widget_delegate.h" |
32 | 34 |
33 namespace { | 35 namespace { |
34 // TODO(jamescook): Border is specified to be a single pixel overlapping | 36 // TODO(jamescook): Border is specified to be a single pixel overlapping |
35 // the web content and may need to be built into the shadow layers instead. | 37 // the web content and may need to be built into the shadow layers instead. |
36 const int kBorderThickness = 0; | 38 const int kBorderThickness = 0; |
37 // Space between left edge of window and popup window icon. | 39 // Space between left edge of window and popup window icon. |
38 const int kIconOffsetX = 4; | 40 const int kIconOffsetX = 4; |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
239 // fullscreen, as it can't be resized in those states. | 241 // fullscreen, as it can't be resized in those states. |
240 int resize_border = | 242 int resize_border = |
241 frame_->IsMaximized() || frame_->IsFullscreen() ? 0 : | 243 frame_->IsMaximized() || frame_->IsFullscreen() ? 0 : |
242 kResizeInsideBoundsSize; | 244 kResizeInsideBoundsSize; |
243 int frame_component = view->GetHTComponentForFrame(point, | 245 int frame_component = view->GetHTComponentForFrame(point, |
244 resize_border, | 246 resize_border, |
245 resize_border, | 247 resize_border, |
246 kResizeAreaCornerSize, | 248 kResizeAreaCornerSize, |
247 kResizeAreaCornerSize, | 249 kResizeAreaCornerSize, |
248 can_ever_resize); | 250 can_ever_resize); |
251 frame_component = AdjustFrameHitCodeForMaximizedModes(frame_component); | |
249 if (frame_component != HTNOWHERE) | 252 if (frame_component != HTNOWHERE) |
250 return frame_component; | 253 return frame_component; |
251 | 254 |
252 int client_component = frame_->client_view()->NonClientHitTest(point); | 255 int client_component = frame_->client_view()->NonClientHitTest(point); |
253 if (client_component != HTNOWHERE) | 256 if (client_component != HTNOWHERE) |
254 return client_component; | 257 return client_component; |
255 | 258 |
256 // Then see if the point is within any of the window controls. | 259 // Then see if the point is within any of the window controls. |
257 if (close_button_->visible() && | 260 if (close_button_->visible() && |
258 close_button_->GetMirroredBounds().Contains(point)) | 261 close_button_->GetMirroredBounds().Contains(point)) |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
587 // Single browser window is very transparent. | 590 // Single browser window is very transparent. |
588 if (UseSoloWindowHeader()) | 591 if (UseSoloWindowHeader()) |
589 return kSoloWindowOpacity; | 592 return kSoloWindowOpacity; |
590 | 593 |
591 // Otherwise, change transparency based on window activation status. | 594 // Otherwise, change transparency based on window activation status. |
592 if (header_mode == ACTIVE) | 595 if (header_mode == ACTIVE) |
593 return kActiveWindowOpacity; | 596 return kActiveWindowOpacity; |
594 return kInactiveWindowOpacity; | 597 return kInactiveWindowOpacity; |
595 } | 598 } |
596 | 599 |
600 int FramePainter::AdjustFrameHitCodeForMaximizedModes(int hit_code) { | |
601 if (hit_code != HTNOWHERE && wm::IsWindowNormal(window_) && | |
602 GetRestoreBoundsInScreen(window_)) { | |
603 // When there is a restore rectangle, a left/right maximized window might | |
604 // be active. | |
605 gfx::Rect bounds = window_->bounds(); | |
sky
2012/09/06 19:45:11
const gfx::Rect& here and next line.
And you need
Mr4D (OOO till 08-26)
2012/09/06 23:16:13
Done.
| |
606 gfx::Rect screen = gfx::Screen::GetDisplayMatching(bounds).work_area(); | |
607 if (bounds.y() == screen.y() && bounds.bottom() == screen.bottom()) { | |
608 // The window is probably either left or right maximized. | |
609 if (bounds.x() == screen.x()) { | |
610 // It is left maximized and we can only allow a right resize. | |
611 return (hit_code == HTBOTTOMRIGHT || | |
612 hit_code == HTTOPRIGHT || | |
613 hit_code == HTRIGHT) ? HTRIGHT : HTNOWHERE; | |
614 } else if (bounds.right() == screen.right()) { | |
615 // It is right maximized and we can only allow a left resize. | |
616 return (hit_code == HTBOTTOMLEFT || | |
617 hit_code == HTTOPLEFT || | |
618 hit_code == HTLEFT) ? HTLEFT : HTNOWHERE; | |
619 } | |
620 } else if (bounds.x() == screen.x() && | |
621 bounds.right() == screen.right()) { | |
622 // If horizontal fill mode is activated we don't allow a left/right | |
623 // resizing. | |
624 if (bounds.right() == screen.right()) { | |
sky
2012/09/06 19:45:11
Shouldn't this check y coordinates (620 checks x c
Mr4D (OOO till 08-26)
2012/09/06 23:16:13
Actually - I don't think that any additional check
| |
625 if (hit_code == HTTOPRIGHT || | |
626 hit_code == HTTOP || | |
627 hit_code == HTTOPLEFT) | |
628 return HTTOP; | |
629 return (hit_code == HTBOTTOMRIGHT || | |
630 hit_code == HTBOTTOM || | |
631 hit_code == HTBOTTOMLEFT) ? HTBOTTOM : HTNOWHERE; | |
632 } | |
633 } | |
634 } | |
635 return hit_code; | |
636 } | |
637 | |
597 // static | 638 // static |
598 bool FramePainter::UseSoloWindowHeader() { | 639 bool FramePainter::UseSoloWindowHeader() { |
599 if (!instances_) | 640 if (!instances_) |
600 return false; // Return value shouldn't matter. | 641 return false; // Return value shouldn't matter. |
601 | 642 |
602 aura::Window* window = NULL; | 643 aura::Window* window = NULL; |
603 for (std::set<FramePainter*>::const_iterator it = instances_->begin(); | 644 for (std::set<FramePainter*>::const_iterator it = instances_->begin(); |
604 it != instances_->end(); | 645 it != instances_->end(); |
605 ++it) { | 646 ++it) { |
606 // The window needs to be a 'normal window'. To exclude constrained windows | 647 // The window needs to be a 'normal window'. To exclude constrained windows |
(...skipping 19 matching lines...) Expand all Loading... | |
626 for (std::set<FramePainter*>::const_iterator it = instances_->begin(); | 667 for (std::set<FramePainter*>::const_iterator it = instances_->begin(); |
627 it != instances_->end(); | 668 it != instances_->end(); |
628 ++it) { | 669 ++it) { |
629 FramePainter* painter = *it; | 670 FramePainter* painter = *it; |
630 if (IsVisibleNormalWindow(painter->window_)) | 671 if (IsVisibleNormalWindow(painter->window_)) |
631 painter->frame_->non_client_view()->SchedulePaint(); | 672 painter->frame_->non_client_view()->SchedulePaint(); |
632 } | 673 } |
633 } | 674 } |
634 | 675 |
635 } // namespace ash | 676 } // namespace ash |
OLD | NEW |