Skip to content

Commit

Permalink
Re-Reland Linux Window Control Alignment
Browse files Browse the repository at this point in the history
Modifying CustomFrameView to layout window controls based on user configurations. For linux begin observing the configs and changes. For other systems fall back on a default ordering.

This reland addresses changes to custom_frame_view_unittest.cc that landed before the original patch. Causing a build failure.

Original code review: https://codereview.chromium.org/281353009/
Revert code review: https://codereview.chromium.org/294473016

Revert "Revert 272352 "Reland Linux Window Control Alignment""
This reverts commit b6f34fb.

TBR=oshima, sadrul

TEST=CustomFrameViewTest
BUG=351917

Review URL: https://codereview.chromium.org/296283003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272576 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
jonross@chromium.org committed May 23, 2014
1 parent 7dadd85 commit e6de855
Show file tree
Hide file tree
Showing 9 changed files with 575 additions and 71 deletions.
6 changes: 3 additions & 3 deletions ash/extended_desktop_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ TEST_F(ExtendedDesktopTest, MoveWindowWithTransient) {
w1, gfx::Rect(50, 50, 50, 50), false /* transient */);
// Transient child of the transient child.
views::Widget* w1_t11 = CreateTestWidgetWithParent(
w1_t1, gfx::Rect(1200, 70, 30, 30), false /* transient */);
w1_t1, gfx::Rect(1200, 70, 35, 35), false /* transient */);

views::Widget* w11 = CreateTestWidgetWithParent(
w1, gfx::Rect(10, 10, 40, 40), true /* child */);
Expand All @@ -532,7 +532,7 @@ TEST_F(ExtendedDesktopTest, MoveWindowWithTransient) {
EXPECT_EQ(root_windows[0], w11_t1->GetNativeView()->GetRootWindow());
EXPECT_EQ("50,50 50x50",
w1_t1->GetWindowBoundsInScreen().ToString());
EXPECT_EQ("1200,70 30x30",
EXPECT_EQ("1200,70 35x35",
w1_t11->GetWindowBoundsInScreen().ToString());
EXPECT_EQ("20,20 40x40",
w11->GetWindowBoundsInScreen().ToString());
Expand All @@ -552,7 +552,7 @@ TEST_F(ExtendedDesktopTest, MoveWindowWithTransient) {
// Transient window's screen bounds stays the same.
EXPECT_EQ("50,50 50x50",
w1_t1->GetWindowBoundsInScreen().ToString());
EXPECT_EQ("1200,70 30x30",
EXPECT_EQ("1200,70 35x35",
w1_t11->GetWindowBoundsInScreen().ToString());
EXPECT_EQ("1300,100 80x80",
w11_t1->GetWindowBoundsInScreen().ToString());
Expand Down
21 changes: 19 additions & 2 deletions ash/wm/system_gesture_event_filter_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "ash/wm/system_gesture_event_filter.h"

#include <vector>

#include "ash/accelerators/accelerator_controller.h"
#include "ash/ash_switches.h"
#include "ash/display/display_manager.h"
Expand Down Expand Up @@ -38,6 +40,7 @@
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
#include "ui/views/window/non_client_view.h"
#include "ui/views/window/window_button_order_provider.h"

namespace ash {
namespace test {
Expand Down Expand Up @@ -138,6 +141,20 @@ class SystemGestureEventFilterTest

// Overridden from AshTestBase:
virtual void SetUp() OVERRIDE {
// TODO(jonross): TwoFingerDragDelayed() and ThreeFingerGestureStopsDrag()
// both use hardcoded touch points, assuming that they target empty header
// space. Window control order now reflects configuration files and can
// change. The tests should be improved to dynamically decide touch points.
// To address this we specify the originally expected window control
// positions to be consistent across tests.
std::vector<views::FrameButton> leading;
std::vector<views::FrameButton> trailing;
trailing.push_back(views::FRAME_BUTTON_MINIMIZE);
trailing.push_back(views::FRAME_BUTTON_MAXIMIZE);
trailing.push_back(views::FRAME_BUTTON_CLOSE);
views::WindowButtonOrderProvider::GetInstance()->
SetWindowButtonOrder(leading, trailing);

if (!docked_enabled_) {
CommandLine::ForCurrentProcess()->AppendSwitch(
ash::switches::kAshDisableDockedWindows);
Expand Down Expand Up @@ -437,7 +454,7 @@ TEST_P(SystemGestureEventFilterTest,
}

TEST_P(SystemGestureEventFilterTest, TwoFingerDragDelayed) {
gfx::Rect bounds(0, 0, 100, 100);
gfx::Rect bounds(0, 0, 200, 100);
aura::Window* root_window = Shell::GetPrimaryRootWindow();
views::Widget* toplevel = views::Widget::CreateWindowWithContextAndBounds(
new ResizableWidgetDelegate, root_window, bounds);
Expand Down Expand Up @@ -472,7 +489,7 @@ TEST_P(SystemGestureEventFilterTest, TwoFingerDragDelayed) {
}

TEST_P(SystemGestureEventFilterTest, ThreeFingerGestureStopsDrag) {
gfx::Rect bounds(0, 0, 100, 100);
gfx::Rect bounds(0, 0, 200, 100);
aura::Window* root_window = Shell::GetPrimaryRootWindow();
views::Widget* toplevel = views::Widget::CreateWindowWithContextAndBounds(
new ResizableWidgetDelegate, root_window, bounds);
Expand Down
83 changes: 83 additions & 0 deletions ui/views/linux_ui/window_button_order_provider.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/views/window/window_button_order_provider.h"

#include "ui/views/linux_ui/linux_ui.h"
#include "ui/views/linux_ui/window_button_order_observer.h"

namespace views {

namespace {

class WindowButtonOrderObserverDelegate : public WindowButtonOrderProvider,
public WindowButtonOrderObserver {
public:
WindowButtonOrderObserverDelegate();
virtual ~WindowButtonOrderObserverDelegate();

// WindowButtonOrderObserver:
virtual void OnWindowButtonOrderingChange(
const std::vector<views::FrameButton>& leading_buttons,
const std::vector<views::FrameButton>& trailing_buttons) OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(WindowButtonOrderObserverDelegate);
};

///////////////////////////////////////////////////////////////////////////////
// WindowButtonOrderObserverDelegate, public:

WindowButtonOrderObserverDelegate::WindowButtonOrderObserverDelegate() {
views::LinuxUI* ui = views::LinuxUI::instance();
if (ui)
ui->AddWindowButtonOrderObserver(this);
}

WindowButtonOrderObserverDelegate::~WindowButtonOrderObserverDelegate() {
views::LinuxUI* ui = views::LinuxUI::instance();
if (ui)
ui->RemoveWindowButtonOrderObserver(this);
}

void WindowButtonOrderObserverDelegate::OnWindowButtonOrderingChange(
const std::vector<views::FrameButton>& leading_buttons,
const std::vector<views::FrameButton>& trailing_buttons) {
SetWindowButtonOrder(leading_buttons, trailing_buttons);
}

} // namespace

// static
WindowButtonOrderProvider* WindowButtonOrderProvider::instance_ = NULL;

///////////////////////////////////////////////////////////////////////////////
// WindowButtonOrderProvider, public:

// static
WindowButtonOrderProvider* WindowButtonOrderProvider::GetInstance() {
if (!instance_)
instance_ = new WindowButtonOrderObserverDelegate;
return instance_;
}

///////////////////////////////////////////////////////////////////////////////
// WindowButtonOrderProvider, protected:

WindowButtonOrderProvider::WindowButtonOrderProvider() {
trailing_buttons_.push_back(views::FRAME_BUTTON_MINIMIZE);
trailing_buttons_.push_back(views::FRAME_BUTTON_MAXIMIZE);
trailing_buttons_.push_back(views::FRAME_BUTTON_CLOSE);
}

WindowButtonOrderProvider::~WindowButtonOrderProvider() {
}

void WindowButtonOrderProvider::SetWindowButtonOrder(
const std::vector<views::FrameButton>& leading_buttons,
const std::vector<views::FrameButton>& trailing_buttons) {
leading_buttons_ = leading_buttons;
trailing_buttons_ = trailing_buttons;
}

} // namespace views
7 changes: 7 additions & 0 deletions ui/views/views.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@
'linux_ui/status_icon_linux.h',
'linux_ui/status_icon_linux.cc',
'linux_ui/window_button_order_observer.h',
'linux_ui/window_button_order_provider.cc',
'metrics.cc',
'metrics.h',
'metrics_aura.cc',
Expand Down Expand Up @@ -448,6 +449,8 @@
'window/native_frame_view.h',
'window/non_client_view.cc',
'window/non_client_view.h',
'window/window_button_order_provider.cc',
'window/window_button_order_provider.h',
'window/window_resources.h',
'window/window_shape.cc',
'window/window_shape.h',
Expand Down Expand Up @@ -476,6 +479,9 @@
'dependencies': [
'../shell_dialogs/shell_dialogs.gyp:shell_dialogs',
],
'sources!': [
'window/window_button_order_provider.cc',
],
}, { # OS=="linux" and chromeos==0
'sources/': [
['exclude', 'linux_ui'],
Expand Down Expand Up @@ -689,6 +695,7 @@
'widget/root_view_unittest.cc',
'widget/widget_unittest.cc',
'widget/window_reorderer_unittest.cc',
'window/custom_frame_view_unittest.cc',
'window/dialog_client_view_unittest.cc',
'window/dialog_delegate_unittest.cc',
],
Expand Down
Loading

0 comments on commit e6de855

Please sign in to comment.