summaryrefslogtreecommitdiffstats
path: root/ui/aura
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-22 18:15:58 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-22 18:15:58 +0000
commit70ccf7061242e1b405f58fb423dab470d9ec69ab (patch)
treecf8a1e58792098286aa4ce6e2a4859449aa77fe5 /ui/aura
parentc7f2ef7cee78dffc7fceea096ea482750b31fad1 (diff)
downloadchromium_src-70ccf7061242e1b405f58fb423dab470d9ec69ab.zip
chromium_src-70ccf7061242e1b405f58fb423dab470d9ec69ab.tar.gz
chromium_src-70ccf7061242e1b405f58fb423dab470d9ec69ab.tar.bz2
Adds a NonClientFrameView for generic toplevel windows.Also adds a feeble (but better than what there was) attempt at sometimes updating the cursor. Will have to be replaced by a better system, but it's a start.http://crbug.com/97247TEST=none
Review URL: http://codereview.chromium.org/7977012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102312 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura')
-rw-r--r--ui/aura/aura.gyp1
-rw-r--r--ui/aura/cursor.h23
-rw-r--r--ui/aura/demo/demo_main.cc5
-rw-r--r--ui/aura/desktop.cc4
-rw-r--r--ui/aura/desktop.h6
-rw-r--r--ui/aura/desktop_host.h4
-rw-r--r--ui/aura/desktop_host_linux.cc5
-rw-r--r--ui/aura/desktop_host_win.cc22
-rw-r--r--ui/aura/desktop_host_win.h1
-rw-r--r--ui/aura/toplevel_window_event_filter.cc22
-rw-r--r--ui/aura/toplevel_window_event_filter.h2
11 files changed, 89 insertions, 6 deletions
diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp
index 765d5a5..c97ba686 100644
--- a/ui/aura/aura.gyp
+++ b/ui/aura/aura.gyp
@@ -23,6 +23,7 @@
'AURA_IMPLEMENTATION',
],
'sources': [
+ 'cursor.h',
'desktop_host.h',
'desktop_host_linux.cc',
'desktop_host_win.cc',
diff --git a/ui/aura/cursor.h b/ui/aura/cursor.h
new file mode 100644
index 0000000..f8e8dda
--- /dev/null
+++ b/ui/aura/cursor.h
@@ -0,0 +1,23 @@
+// Copyright (c) 2011 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.
+
+#ifndef UI_AURA_CURSOR_H_
+#define UI_AURA_CURSOR_H_
+#pragma once
+
+#include "ui/aura/aura_export.h"
+
+namespace aura {
+
+enum AURA_EXPORT CursorType {
+ CURSOR_POINTER,
+ CURSOR_LINK,
+ CURSOR_WAIT,
+ CURSOR_SIZE_HORIZONTAL,
+ CURSOR_SIZE_VERTICAL
+};
+
+} // namespace aura
+
+#endif // UI_AURA_CURSOR_H_
diff --git a/ui/aura/demo/demo_main.cc b/ui/aura/demo/demo_main.cc
index ca60c8b..6e30336 100644
--- a/ui/aura/demo/demo_main.cc
+++ b/ui/aura/demo/demo_main.cc
@@ -37,19 +37,16 @@ class DemoWindowDelegate : public aura::WindowDelegate {
virtual bool OnKeyEvent(aura::KeyEvent* event) OVERRIDE {
return false;
}
-
virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE {
return HTCAPTION;
}
-
virtual bool OnMouseEvent(aura::MouseEvent* event) OVERRIDE {
return true;
}
-
+ virtual void OnCaptureLost() OVERRIDE {}
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
canvas->AsCanvasSkia()->drawColor(color_, SkXfermode::kSrc_Mode);
}
-
virtual void OnWindowDestroying() OVERRIDE {}
virtual void OnWindowDestroyed() OVERRIDE {}
diff --git a/ui/aura/desktop.cc b/ui/aura/desktop.cc
index 50b3802..8b5d0c8 100644
--- a/ui/aura/desktop.cc
+++ b/ui/aura/desktop.cc
@@ -57,6 +57,10 @@ void Desktop::SetSize(const gfx::Size& size) {
host_->SetSize(size);
}
+void Desktop::SetCursor(CursorType cursor_type) {
+ host_->SetCursor(cursor_type);
+}
+
void Desktop::Run() {
Show();
MessageLoopForUI::current()->Run(host_.get());
diff --git a/ui/aura/desktop.h b/ui/aura/desktop.h
index 41826c6d..ef41597 100644
--- a/ui/aura/desktop.h
+++ b/ui/aura/desktop.h
@@ -9,8 +9,9 @@
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "base/task.h"
-#include "ui/aura/root_window.h"
#include "ui/aura/aura_export.h"
+#include "ui/aura/cursor.h"
+#include "ui/aura/root_window.h"
#include "ui/gfx/compositor/compositor.h"
#include "ui/gfx/native_widget_types.h"
@@ -38,6 +39,9 @@ class AURA_EXPORT Desktop : public ui::CompositorDelegate {
// Sets the size of the desktop.
void SetSize(const gfx::Size& size);
+ // Shows the specified cursor.
+ void SetCursor(CursorType cursor_type);
+
// Shows the desktop host and runs an event loop for it.
void Run();
diff --git a/ui/aura/desktop_host.h b/ui/aura/desktop_host.h
index 8c2cfa6..e9e134a 100644
--- a/ui/aura/desktop_host.h
+++ b/ui/aura/desktop_host.h
@@ -7,6 +7,7 @@
#pragma once
#include "base/message_loop.h"
+#include "ui/aura/cursor.h"
#include "ui/gfx/native_widget_types.h"
namespace gfx {
@@ -40,6 +41,9 @@ class DesktopHost : public MessageLoop::Dispatcher {
// Gets/Sets the size of the DesktopHost.
virtual gfx::Size GetSize() = 0;
virtual void SetSize(const gfx::Size& size) = 0;
+
+ // Sets the currently displayed cursor.
+ virtual void SetCursor(CursorType cursor_type) = 0;
};
} // namespace aura
diff --git a/ui/aura/desktop_host_linux.cc b/ui/aura/desktop_host_linux.cc
index e088ba5..15fbfe7 100644
--- a/ui/aura/desktop_host_linux.cc
+++ b/ui/aura/desktop_host_linux.cc
@@ -30,6 +30,7 @@ class DesktopHostLinux : public DesktopHost {
virtual void Show() OVERRIDE;
virtual gfx::Size GetSize() OVERRIDE;
virtual void SetSize(const gfx::Size& size) OVERRIDE;
+ virtual void SetCursor(CursorType cursor_type) OVERRIDE;
Desktop* desktop_;
@@ -113,6 +114,10 @@ void DesktopHostLinux::SetSize(const gfx::Size& size) {
XResizeWindow(xdisplay_, xwindow_, size.width(), size.height());
}
+void DesktopHostLinux::SetCursor(CursorType cursor_type) {
+ NOTIMPLEMENTED();
+}
+
} // namespace
// static
diff --git a/ui/aura/desktop_host_win.cc b/ui/aura/desktop_host_win.cc
index ef1de50..e078c7d 100644
--- a/ui/aura/desktop_host_win.cc
+++ b/ui/aura/desktop_host_win.cc
@@ -58,6 +58,28 @@ void DesktopHostWin::SetSize(const gfx::Size& size) {
SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOREDRAW | SWP_NOREPOSITION);
}
+void DesktopHostWin::SetCursor(CursorType cursor_type) {
+ switch (cursor_type) {
+ case CURSOR_POINTER:
+ ::SetCursor(LoadCursor(NULL, IDC_ARROW));
+ break;
+ case CURSOR_LINK:
+ ::SetCursor(LoadCursor(NULL, IDC_HAND));
+ break;
+ case CURSOR_WAIT:
+ ::SetCursor(LoadCursor(NULL, IDC_WAIT));
+ break;
+ case CURSOR_SIZE_HORIZONTAL:
+ ::SetCursor(LoadCursor(NULL, IDC_SIZEWE));
+ break;
+ case CURSOR_SIZE_VERTICAL:
+ ::SetCursor(LoadCursor(NULL, IDC_SIZENS));
+ break;
+ default:
+ break;
+ }
+}
+
void DesktopHostWin::OnClose() {
// TODO: this obviously shouldn't be here.
MessageLoopForUI::current()->Quit();
diff --git a/ui/aura/desktop_host_win.h b/ui/aura/desktop_host_win.h
index 78e34eb..45bdaf3 100644
--- a/ui/aura/desktop_host_win.h
+++ b/ui/aura/desktop_host_win.h
@@ -26,6 +26,7 @@ class DesktopHostWin : public DesktopHost, public ui::WindowImpl {
virtual void Show() OVERRIDE;
virtual gfx::Size GetSize() OVERRIDE;
virtual void SetSize(const gfx::Size& size) OVERRIDE;
+ virtual void SetCursor(CursorType cursor_type) OVERRIDE;
private:
BEGIN_MSG_MAP_EX(DesktopHostWin)
diff --git a/ui/aura/toplevel_window_event_filter.cc b/ui/aura/toplevel_window_event_filter.cc
index be648c8..de9a77d4 100644
--- a/ui/aura/toplevel_window_event_filter.cc
+++ b/ui/aura/toplevel_window_event_filter.cc
@@ -4,6 +4,8 @@
#include "ui/aura/toplevel_window_event_filter.h"
+#include "ui/aura/cursor.h"
+#include "ui/aura/desktop.h"
#include "ui/aura/event.h"
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
@@ -25,9 +27,12 @@ ToplevelWindowEventFilter::~ToplevelWindowEventFilter() {
bool ToplevelWindowEventFilter::OnMouseEvent(Window* target,
MouseEvent* event) {
switch (event->type()) {
- case ui::ET_MOUSE_PRESSED:
+ case ui::ET_MOUSE_MOVED:
window_component_ =
target->delegate()->GetNonClientComponent(event->location());
+ UpdateCursorForWindowComponent();
+ break;
+ case ui::ET_MOUSE_PRESSED:
MoveWindowToFront(target);
mouse_down_offset_ = event->location();
window_location_ = target->bounds().origin();
@@ -64,4 +69,19 @@ void ToplevelWindowEventFilter::MoveWindowToFront(Window* target) {
}
}
+void ToplevelWindowEventFilter::UpdateCursorForWindowComponent() {
+ switch (window_component_) {
+ case HTLEFT:
+ case HTRIGHT:
+ Desktop::GetInstance()->SetCursor(CURSOR_SIZE_HORIZONTAL);
+ break;
+ case HTBOTTOM:
+ Desktop::GetInstance()->SetCursor(CURSOR_SIZE_VERTICAL);
+ break;
+ default:
+ Desktop::GetInstance()->SetCursor(CURSOR_POINTER);
+ break;
+ }
+}
+
} // namespace aura
diff --git a/ui/aura/toplevel_window_event_filter.h b/ui/aura/toplevel_window_event_filter.h
index 33cc092..7126b35 100644
--- a/ui/aura/toplevel_window_event_filter.h
+++ b/ui/aura/toplevel_window_event_filter.h
@@ -28,6 +28,8 @@ class ToplevelWindowEventFilter : public EventFilter {
// respective z-orders.
void MoveWindowToFront(Window* target);
+ void UpdateCursorForWindowComponent();
+
gfx::Point mouse_down_offset_;
gfx::Point window_location_;
int window_component_;