summaryrefslogtreecommitdiffstats
path: root/ui/aura
diff options
context:
space:
mode:
Diffstat (limited to 'ui/aura')
-rw-r--r--ui/aura/root_window.cc4
-rw-r--r--ui/aura/root_window.h3
-rw-r--r--ui/aura/root_window_host.h7
-rw-r--r--ui/aura/root_window_host_linux.cc35
-rw-r--r--ui/aura/root_window_host_win.cc4
-rw-r--r--ui/aura/root_window_host_win.h1
6 files changed, 53 insertions, 1 deletions
diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc
index 62db782..ef4e0a1 100644
--- a/ui/aura/root_window.cc
+++ b/ui/aura/root_window.cc
@@ -111,6 +111,10 @@ void RootWindow::SetCursor(gfx::NativeCursor cursor) {
host_->SetCursor(cursor);
}
+void RootWindow::ShowCursor(bool show) {
+ host_->ShowCursor(show);
+}
+
void RootWindow::Run() {
ShowRootWindow();
MessageLoopForUI::current()->Run();
diff --git a/ui/aura/root_window.h b/ui/aura/root_window.h
index f7b0862..0af56b2 100644
--- a/ui/aura/root_window.h
+++ b/ui/aura/root_window.h
@@ -71,6 +71,9 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate,
// Shows the specified cursor.
void SetCursor(gfx::NativeCursor cursor);
+ // Sets current cursor visibility to |show|.
+ void ShowCursor(bool show);
+
// Shows the root window host and runs an event loop for it.
void Run();
diff --git a/ui/aura/root_window_host.h b/ui/aura/root_window_host.h
index c88097d..1c77565 100644
--- a/ui/aura/root_window_host.h
+++ b/ui/aura/root_window_host.h
@@ -54,9 +54,14 @@ class RootWindowHost : public MessageLoop::Dispatcher {
// Returns the location of the RootWindow on native screen.
virtual gfx::Point GetLocationOnNativeScreen() const = 0;
- // Sets the currently displayed cursor.
+ // Sets the currently displayed cursor. Shows the cursor by default.
+ // If you want to update hidden cursor, should call ShowCursor(false)
+ // after this function.
virtual void SetCursor(gfx::NativeCursor cursor) = 0;
+ // Sets current cursor visibility to |show|.
+ virtual void ShowCursor(bool show) = 0;
+
// Queries the mouse's current position relative to the host window.
// The position is constrained within the host window.
// You should probably call RootWindow::last_mouse_location() instead; this
diff --git a/ui/aura/root_window_host_linux.cc b/ui/aura/root_window_host_linux.cc
index 6ed655b..0857a9f 100644
--- a/ui/aura/root_window_host_linux.cc
+++ b/ui/aura/root_window_host_linux.cc
@@ -293,6 +293,7 @@ class RootWindowHostLinux : public RootWindowHost,
virtual void SetSize(const gfx::Size& size) OVERRIDE;
virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE;
virtual void SetCursor(gfx::NativeCursor cursor_type) OVERRIDE;
+ virtual void ShowCursor(bool show) OVERRIDE;
virtual gfx::Point QueryMouseLocation() OVERRIDE;
virtual void PostNativeEvent(const base::NativeEvent& event) OVERRIDE;
@@ -316,6 +317,13 @@ class RootWindowHostLinux : public RootWindowHost,
// Current Aura cursor.
gfx::NativeCursor current_cursor_;
+ // The default cursor is showed after startup, and hidden when touch pressed.
+ // Once mouse moved, the cursor is immediately displayed.
+ bool is_cursor_visible_;
+
+ // The invisible cursor.
+ ::Cursor invisible_cursor_;
+
// The bounds of |xwindow_|.
gfx::Rect bounds_;
@@ -328,6 +336,7 @@ RootWindowHostLinux::RootWindowHostLinux(const gfx::Rect& bounds)
xwindow_(0),
x_root_window_(DefaultRootWindow(xdisplay_)),
current_cursor_(aura::kCursorNull),
+ is_cursor_visible_(true),
bounds_(bounds) {
xwindow_ = XCreateSimpleWindow(xdisplay_, x_root_window_,
bounds.x(), bounds.y(),
@@ -349,6 +358,15 @@ RootWindowHostLinux::RootWindowHostLinux(const gfx::Rect& bounds)
base::MessagePumpX::SetDefaultDispatcher(this);
MessageLoopForUI::current()->AddDestructionObserver(this);
+
+ // Initializes invisiable cursor.
+ char nodata[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
+ XColor black;
+ black.red = black.green = black.blue = 0;
+ Pixmap blank = XCreateBitmapFromData(xdisplay_, xwindow_,
+ nodata, 8, 8);
+ invisible_cursor_ = XCreatePixmapCursor(xdisplay_, blank, blank,
+ &black, &black, 0, 0);
}
RootWindowHostLinux::~RootWindowHostLinux() {
@@ -357,6 +375,8 @@ RootWindowHostLinux::~RootWindowHostLinux() {
// Clears XCursorCache.
ui::GetXCursor(ui::kCursorClearXCursorCache);
+ XFreeCursor(xdisplay_, invisible_cursor_);
+
MessageLoopForUI::current()->RemoveDestructionObserver(this);
base::MessagePumpX::SetDefaultDispatcher(NULL);
}
@@ -575,6 +595,21 @@ void RootWindowHostLinux::SetCursor(gfx::NativeCursor cursor) {
XDefineCursor(xdisplay_, xwindow_, xcursor);
}
+void RootWindowHostLinux::ShowCursor(bool show) {
+ if (show == is_cursor_visible_)
+ return;
+
+ is_cursor_visible_ = show;
+
+ if (show) {
+ int cursor_shape = CursorShapeFromNative(current_cursor_);
+ ::Cursor xcursor = ui::GetXCursor(cursor_shape);
+ XDefineCursor(xdisplay_, xwindow_, xcursor);
+ } else {
+ XDefineCursor(xdisplay_, xwindow_, invisible_cursor_);
+ }
+}
+
gfx::Point RootWindowHostLinux::QueryMouseLocation() {
::Window root_return, child_return;
int root_x_return, root_y_return, win_x_return, win_y_return;
diff --git a/ui/aura/root_window_host_win.cc b/ui/aura/root_window_host_win.cc
index 577f5d0..443da6b 100644
--- a/ui/aura/root_window_host_win.cc
+++ b/ui/aura/root_window_host_win.cc
@@ -223,6 +223,10 @@ void RootWindowHostWin::SetCursor(gfx::NativeCursor native_cursor) {
::SetCursor(LoadCursor(NULL, cursor_id));
}
+void RootWindowHostWin::ShowCursor(bool show) {
+ NOTIMPLEMENTED();
+}
+
gfx::Point RootWindowHostWin::QueryMouseLocation() {
POINT pt;
GetCursorPos(&pt);
diff --git a/ui/aura/root_window_host_win.h b/ui/aura/root_window_host_win.h
index 29ca65f..ad9547f 100644
--- a/ui/aura/root_window_host_win.h
+++ b/ui/aura/root_window_host_win.h
@@ -29,6 +29,7 @@ class RootWindowHostWin : public RootWindowHost, public ui::WindowImpl {
virtual void SetSize(const gfx::Size& size) OVERRIDE;
virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE;
virtual void SetCursor(gfx::NativeCursor cursor) OVERRIDE;
+ virtual void ShowCursor(bool show) OVERRIDE;
virtual gfx::Point QueryMouseLocation() OVERRIDE;
virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE;