summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-17 21:52:27 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-17 21:52:27 +0000
commit62a929643ca5ed6bbafd06593ae811bb6d718dd3 (patch)
treecbf61f22a93687e6690764bf1e24c1a608cf99f9
parent3b543ab59106f2f889df2412766572836d408bd4 (diff)
downloadchromium_src-62a929643ca5ed6bbafd06593ae811bb6d718dd3.zip
chromium_src-62a929643ca5ed6bbafd06593ae811bb6d718dd3.tar.gz
chromium_src-62a929643ca5ed6bbafd06593ae811bb6d718dd3.tar.bz2
More shell hookup:
- NULL window_ in NativeWidgetAura::OnWindowDestroyed before notifying its delegate, and add a NULL check in NativeWidgetAura::SchedulePaint to prevent calls triggered by the Widget's RootView's destruction from calling into it. There may be a better fix here but it probably involves destroying the RootView sooner which is scary. - Adds a mock status area. BUG=none TEST=none Review URL: http://codereview.chromium.org/7920016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101662 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ui/aura/window.cc9
-rw-r--r--ui/aura_shell/aura_shell.gyp10
-rw-r--r--ui/aura_shell/aura_shell_main.cc1
-rw-r--r--ui/aura_shell/desktop_background_view.cc7
-rw-r--r--ui/aura_shell/desktop_background_view.h2
-rw-r--r--ui/aura_shell/desktop_layout_manager.cc10
-rw-r--r--ui/aura_shell/desktop_layout_manager.h5
-rw-r--r--ui/aura_shell/shell_factory.h2
-rw-r--r--ui/aura_shell/status_area_view.cc37
-rw-r--r--ui/aura_shell/status_area_view.h19
-rw-r--r--views/widget/native_widget_aura.cc19
-rw-r--r--views/widget/native_widget_aura.h4
12 files changed, 115 insertions, 10 deletions
diff --git a/ui/aura/window.cc b/ui/aura/window.cc
index e1197da..fc9209c 100644
--- a/ui/aura/window.cc
+++ b/ui/aura/window.cc
@@ -9,6 +9,7 @@
#include "base/logging.h"
#include "ui/aura/desktop.h"
#include "ui/aura/event.h"
+#include "ui/aura/focus_manager.h"
#include "ui/aura/layout_manager.h"
#include "ui/aura/window_delegate.h"
#include "ui/aura/window_manager.h"
@@ -30,6 +31,14 @@ Window::~Window() {
// Let the delegate know we're in the processing of destroying.
if (delegate_)
delegate_->OnWindowDestroying();
+
+ // Update the FocusManager in case we were focused. This must be done before
+ // we are removed from the hierarchy otherwise we won't be able to find the
+ // FocusManager.
+ internal::FocusManager* focus_manager = GetFocusManager();
+ if (focus_manager && focus_manager->focused_window() == this)
+ focus_manager->SetFocusedWindow(NULL);
+
// Then destroy the children.
while (!children_.empty()) {
Window* child = children_[0];
diff --git a/ui/aura_shell/aura_shell.gyp b/ui/aura_shell/aura_shell.gyp
index 77f947e..65312b0 100644
--- a/ui/aura_shell/aura_shell.gyp
+++ b/ui/aura_shell/aura_shell.gyp
@@ -93,6 +93,16 @@
'<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources/ui_resources.rc',
'<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources_standard/ui_resources_standard.rc',
],
+ },
+ # It's convenient for aura_shell developers to be able to build all
+ # compositor and aura targets from within this solution.
+ {
+ 'target_name': 'convenience',
+ 'type': 'none',
+ 'dependencies': [
+ '../gfx/compositor/compositor.gyp:*',
+ '../aura/aura.gyp:*',
+ ],
},
],
}
diff --git a/ui/aura_shell/aura_shell_main.cc b/ui/aura_shell/aura_shell_main.cc
index c7cc81f..29699c1 100644
--- a/ui/aura_shell/aura_shell_main.cc
+++ b/ui/aura_shell/aura_shell_main.cc
@@ -24,6 +24,7 @@ void InitDesktopWindow() {
desktop_layout->set_background_widget(CreateDesktopBackground());
desktop_layout->set_launcher_widget(CreateLauncher());
+ desktop_layout->set_status_area_widget(CreateStatusArea());
}
} // namespace internal
diff --git a/ui/aura_shell/desktop_background_view.cc b/ui/aura_shell/desktop_background_view.cc
index f066c8b..9f359c9 100644
--- a/ui/aura_shell/desktop_background_view.cc
+++ b/ui/aura_shell/desktop_background_view.cc
@@ -33,13 +33,12 @@ void DesktopBackgroundView::OnPaint(gfx::Canvas* canvas) {
canvas->TileImageInt(wallpaper_, 0, 0, width(), height());
}
-void DesktopBackgroundView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
- LOG(WARNING) << "Here";
+bool DesktopBackgroundView::OnMousePressed(const views::MouseEvent& event) {
+ return true;
}
-bool DesktopBackgroundView::OnMousePressed(const views::MouseEvent& event) {
+void DesktopBackgroundView::OnMouseReleased(const views::MouseEvent& event) {
SampleWindow::CreateSampleWindow();
- return true;
}
AURA_SHELL_EXPORT views::Widget* CreateDesktopBackground() {
diff --git a/ui/aura_shell/desktop_background_view.h b/ui/aura_shell/desktop_background_view.h
index 0b1c3662..09020ae 100644
--- a/ui/aura_shell/desktop_background_view.h
+++ b/ui/aura_shell/desktop_background_view.h
@@ -21,8 +21,8 @@ class DesktopBackgroundView : public views::WidgetDelegateView {
private:
// Overridden from views::View:
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
- virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;
virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
+ virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
SkBitmap wallpaper_;
diff --git a/ui/aura_shell/desktop_layout_manager.cc b/ui/aura_shell/desktop_layout_manager.cc
index 9dca12b..b86c31f 100644
--- a/ui/aura_shell/desktop_layout_manager.cc
+++ b/ui/aura_shell/desktop_layout_manager.cc
@@ -16,7 +16,8 @@ namespace internal {
DesktopLayoutManager::DesktopLayoutManager(aura::Window* owner)
: owner_(owner),
background_widget_(NULL),
- launcher_widget_(NULL) {
+ launcher_widget_(NULL),
+ status_area_widget_(NULL) {
}
DesktopLayoutManager::~DesktopLayoutManager() {
@@ -35,6 +36,13 @@ void DesktopLayoutManager::OnWindowResized() {
owner_->bounds().bottom() - launcher_bounds.height(),
launcher_bounds.width(),
launcher_bounds.height()));
+
+ gfx::Rect status_area_bounds = status_area_widget_->GetWindowScreenBounds();
+ status_area_widget_->SetBounds(
+ gfx::Rect(owner_->bounds().right() - status_area_bounds.width(),
+ 0,
+ status_area_bounds.width(),
+ status_area_bounds.height()));
}
} // namespace internal
diff --git a/ui/aura_shell/desktop_layout_manager.h b/ui/aura_shell/desktop_layout_manager.h
index c053a56..e25d582 100644
--- a/ui/aura_shell/desktop_layout_manager.h
+++ b/ui/aura_shell/desktop_layout_manager.h
@@ -33,6 +33,10 @@ class AURA_SHELL_EXPORT DesktopLayoutManager : public aura::LayoutManager {
launcher_widget_ = launcher_widget;
}
+ void set_status_area_widget(views::Widget* status_area_widget) {
+ status_area_widget_ = status_area_widget;
+ }
+
private:
// Overridden from aura::LayoutManager:
virtual void OnWindowResized() OVERRIDE;
@@ -40,6 +44,7 @@ class AURA_SHELL_EXPORT DesktopLayoutManager : public aura::LayoutManager {
aura::Window* owner_;
views::Widget* background_widget_;
views::Widget* launcher_widget_;
+ views::Widget* status_area_widget_;
DISALLOW_COPY_AND_ASSIGN(DesktopLayoutManager);
};
diff --git a/ui/aura_shell/shell_factory.h b/ui/aura_shell/shell_factory.h
index 40eaaf7..7b6fd8b 100644
--- a/ui/aura_shell/shell_factory.h
+++ b/ui/aura_shell/shell_factory.h
@@ -21,6 +21,8 @@ AURA_SHELL_EXPORT views::Widget* CreateDesktopBackground();
AURA_SHELL_EXPORT views::Widget* CreateLauncher();
+AURA_SHELL_EXPORT views::Widget* CreateStatusArea();
+
} // namespace internal
} // namespace aura_shell
diff --git a/ui/aura_shell/status_area_view.cc b/ui/aura_shell/status_area_view.cc
index 54d1ac7..089d02b 100644
--- a/ui/aura_shell/status_area_view.cc
+++ b/ui/aura_shell/status_area_view.cc
@@ -4,7 +4,44 @@
#include "ui/aura_shell/status_area_view.h"
+#include "grit/ui_resources.h"
+#include "ui/aura/desktop.h"
+#include "ui/aura_shell/aura_shell_export.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/gfx/canvas.h"
+#include "views/widget/widget.h"
+
namespace aura_shell {
namespace internal {
+
+StatusAreaView::StatusAreaView()
+ : status_mock_(*ResourceBundle::GetSharedInstance().GetBitmapNamed(
+ IDR_AURA_STATUS_MOCK)) {
+}
+StatusAreaView::~StatusAreaView() {
+}
+
+gfx::Size StatusAreaView::GetPreferredSize() {
+ return gfx::Size(status_mock_.width(), status_mock_.height());
+}
+
+void StatusAreaView::OnPaint(gfx::Canvas* canvas) {
+ canvas->DrawBitmapInt(status_mock_, 0, 0);
+}
+
+AURA_SHELL_EXPORT views::Widget* CreateStatusArea() {
+ StatusAreaView* status_area_view = new StatusAreaView;
+ views::Widget* widget = new views::Widget;
+ views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL);
+ gfx::Size ps = status_area_view->GetPreferredSize();
+ params.bounds = gfx::Rect(0, 0, ps.width(), ps.height());
+ params.parent = aura::Desktop::GetInstance()->window();
+ params.delegate = status_area_view;
+ widget->Init(params);
+ widget->SetContentsView(status_area_view);
+ widget->Show();
+ return widget;
+}
+
} // namespace internal
} // namespace aura_shell
diff --git a/ui/aura_shell/status_area_view.h b/ui/aura_shell/status_area_view.h
index 2c1b4c5..873acc7 100644
--- a/ui/aura_shell/status_area_view.h
+++ b/ui/aura_shell/status_area_view.h
@@ -6,8 +6,27 @@
#define UI_AURA_SHELL_STATUS_AREA_VIEW_H_
#pragma once
+#include "third_party/skia/include/core/SkBitmap.h"
+#include "views/widget/widget_delegate.h"
+
namespace aura_shell {
namespace internal {
+
+class StatusAreaView : public views::WidgetDelegateView {
+ public:
+ StatusAreaView();
+ virtual ~StatusAreaView();
+
+ // Overridden from views::View:
+ virtual gfx::Size GetPreferredSize() OVERRIDE;
+ private:
+ virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
+
+ SkBitmap status_mock_;
+
+ DISALLOW_COPY_AND_ASSIGN(StatusAreaView);
+};
+
} // namespace internal
} // namespace aura_shell
diff --git a/views/widget/native_widget_aura.cc b/views/widget/native_widget_aura.cc
index 06a5d95..cf22211 100644
--- a/views/widget/native_widget_aura.cc
+++ b/views/widget/native_widget_aura.cc
@@ -25,7 +25,8 @@ namespace views {
NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate)
: delegate_(delegate),
ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))),
- ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) {
+ ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET),
+ ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)) {
}
NativeWidgetAura::~NativeWidgetAura() {
@@ -240,11 +241,17 @@ void NativeWidgetAura::SetShape(gfx::NativeRegion region) {
}
void NativeWidgetAura::Close() {
- NOTIMPLEMENTED();
+ Hide();
+
+ if (close_widget_factory_.empty()) {
+ MessageLoop::current()->PostTask(FROM_HERE,
+ close_widget_factory_.NewRunnableMethod(
+ &NativeWidgetAura::CloseNow));
+ }
}
void NativeWidgetAura::CloseNow() {
- NOTIMPLEMENTED();
+ delete window_;
}
void NativeWidgetAura::EnableClose(bool enable) {
@@ -341,7 +348,8 @@ void NativeWidgetAura::RunShellDrag(View* view,
}
void NativeWidgetAura::SchedulePaintInRect(const gfx::Rect& rect) {
- window_->SchedulePaintInRect(rect);
+ if (window_)
+ window_->SchedulePaintInRect(rect);
}
void NativeWidgetAura::SetCursor(gfx::NativeCursor cursor) {
@@ -407,6 +415,7 @@ void NativeWidgetAura::OnWindowDestroying() {
}
void NativeWidgetAura::OnWindowDestroyed() {
+ window_ = NULL;
delegate_->OnNativeWidgetDestroyed();
if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET)
delete this;
@@ -457,6 +466,8 @@ NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeWindow(
// static
NativeWidgetPrivate* NativeWidgetPrivate::GetTopLevelNativeWidget(
gfx::NativeView native_view) {
+ if (!native_view)
+ return NULL;
aura::Window* toplevel = native_view;
aura::Window* parent = native_view->parent();
while (parent) {
diff --git a/views/widget/native_widget_aura.h b/views/widget/native_widget_aura.h
index 0227d6f..8a115f1 100644
--- a/views/widget/native_widget_aura.h
+++ b/views/widget/native_widget_aura.h
@@ -133,6 +133,10 @@ class NativeWidgetAura : public internal::NativeWidgetPrivate,
// See class documentation for Widget in widget.h for a note about ownership.
Widget::InitParams::Ownership ownership_;
+ // The following factory is used for calls to close the NativeWidgetAura
+ // instance.
+ ScopedRunnableMethodFactory<NativeWidgetAura> close_widget_factory_;
+
DISALLOW_COPY_AND_ASSIGN(NativeWidgetAura);
};