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

Side by Side Diff: ash/wm/frame_painter.cc

Issue 10918077: Adding proper dragging behavior for L/R maximized windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: It looks like if git merged wrong here... Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/wm/frame_painter.h ('k') | ash/wm/frame_painter_unittest.cc » ('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/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
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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 // Single browser window is very transparent. 606 // Single browser window is very transparent.
604 if (UseSoloWindowHeader()) 607 if (UseSoloWindowHeader())
605 return kSoloWindowOpacity; 608 return kSoloWindowOpacity;
606 609
607 // Otherwise, change transparency based on window activation status. 610 // Otherwise, change transparency based on window activation status.
608 if (header_mode == ACTIVE) 611 if (header_mode == ACTIVE)
609 return kActiveWindowOpacity; 612 return kActiveWindowOpacity;
610 return kInactiveWindowOpacity; 613 return kInactiveWindowOpacity;
611 } 614 }
612 615
616 int FramePainter::AdjustFrameHitCodeForMaximizedModes(int hit_code) {
617 if (hit_code != HTNOWHERE && wm::IsWindowNormal(window_) &&
618 GetRestoreBoundsInScreen(window_)) {
619 // When there is a restore rectangle, a left/right maximized window might
620 // be active.
621 const gfx::Rect& bounds = frame_->GetWindowBoundsInScreen();
622 const gfx::Rect& screen =
623 gfx::Screen::GetDisplayMatching(bounds).work_area();
624 if (bounds.y() == screen.y() && bounds.bottom() == screen.bottom()) {
625 // The window is probably either left or right maximized.
626 if (bounds.x() == screen.x()) {
627 // It is left maximized and we can only allow a right resize.
628 return (hit_code == HTBOTTOMRIGHT ||
629 hit_code == HTTOPRIGHT ||
630 hit_code == HTRIGHT) ? HTRIGHT : HTNOWHERE;
631 } else if (bounds.right() == screen.right()) {
632 // It is right maximized and we can only allow a left resize.
633 return (hit_code == HTBOTTOMLEFT ||
634 hit_code == HTTOPLEFT ||
635 hit_code == HTLEFT) ? HTLEFT : HTNOWHERE;
636 }
637 } else if (bounds.x() == screen.x() &&
638 bounds.right() == screen.right()) {
639 // If horizontal fill mode is activated we don't allow a left/right
640 // resizing.
641 if (hit_code == HTTOPRIGHT ||
642 hit_code == HTTOP ||
643 hit_code == HTTOPLEFT)
644 return HTTOP;
645 return (hit_code == HTBOTTOMRIGHT ||
646 hit_code == HTBOTTOM ||
647 hit_code == HTBOTTOMLEFT) ? HTBOTTOM : HTNOWHERE;
648 }
649 }
650 return hit_code;
651 }
652
613 // static 653 // static
614 bool FramePainter::UseSoloWindowHeader() { 654 bool FramePainter::UseSoloWindowHeader() {
615 if (!instances_) 655 if (!instances_)
616 return false; // Return value shouldn't matter. 656 return false; // Return value shouldn't matter.
617 657
618 aura::Window* window = NULL; 658 aura::Window* window = NULL;
619 for (std::set<FramePainter*>::const_iterator it = instances_->begin(); 659 for (std::set<FramePainter*>::const_iterator it = instances_->begin();
620 it != instances_->end(); 660 it != instances_->end();
621 ++it) { 661 ++it) {
622 // The window needs to be a 'normal window'. To exclude constrained windows 662 // The window needs to be a 'normal window'. To exclude constrained windows
(...skipping 19 matching lines...) Expand all
642 for (std::set<FramePainter*>::const_iterator it = instances_->begin(); 682 for (std::set<FramePainter*>::const_iterator it = instances_->begin();
643 it != instances_->end(); 683 it != instances_->end();
644 ++it) { 684 ++it) {
645 FramePainter* painter = *it; 685 FramePainter* painter = *it;
646 if (IsVisibleNormalWindow(painter->window_)) 686 if (IsVisibleNormalWindow(painter->window_))
647 painter->frame_->non_client_view()->SchedulePaint(); 687 painter->frame_->non_client_view()->SchedulePaint();
648 } 688 }
649 } 689 }
650 690
651 } // namespace ash 691 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/frame_painter.h ('k') | ash/wm/frame_painter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698