15d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved.
25d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// found in the LICENSE file.
45d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
55d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#ifndef ASH_DISPLAY_CURSOR_WINDOW_CONTROLLER_H_
65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define ASH_DISPLAY_CURSOR_WINDOW_CONTROLLER_H_
75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/aura/window.h"
95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/base/cursor/cursor.h"
105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/gfx/display.h"
115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace ash {
135c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liunamespace test {
145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class MirrorWindowTestApi;
155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class CursorWindowDelegate;
185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Draws a mouse cursor on a given container window.
205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// When cursor compositing is disabled, CursorWindowController is responsible
215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// to scale and rotate the mouse cursor bitmap to match settings of the
225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// primary display.
235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// When cursor compositing is enabled, just draw the cursor as-is.
245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class CursorWindowController {
255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public:
265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  CursorWindowController();
275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ~CursorWindowController();
285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bool is_cursor_compositing_enabled() const {
305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return is_cursor_compositing_enabled_;
315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  }
325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Sets cursor compositing mode on/off.
345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void SetCursorCompositingEnabled(bool enabled);
355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Updates the container window for the cursor window controller.
375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void UpdateContainer();
385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Sets the display on which to draw cursor.
405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Only applicable when cursor compositing is enabled.
415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void SetDisplay(const gfx::Display& display);
425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Sets cursor location, shape, set and visibility.
445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void UpdateLocation();
455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void SetCursor(gfx::NativeCursor cursor);
465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void SetCursorSet(ui::CursorSetType);
475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void SetVisibility(bool visible);
485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) private:
505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  friend class test::MirrorWindowTestApi;
515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Sets the container window for the cursor window controller.
535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Closes the cursor window if |container| is NULL.
545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void SetContainer(aura::Window* container);
555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Sets the bounds of the container in screen coordinates.
575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void SetBoundsInScreen(const gfx::Rect& bounds);
585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Updates cursor image based on current cursor state.
605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void UpdateCursorImage();
615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bool is_cursor_compositing_enabled_;
635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  aura::Window* container_;
645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // The bounds of the container in screen coordinates.
665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  gfx::Rect bounds_in_screen_;
675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // The native_type of the cursor, see definitions in cursor.h
695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  int cursor_type_;
705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ui::CursorSetType cursor_set_;
725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  gfx::Display::Rotation cursor_rotation_;
735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  gfx::Point hot_point_;
745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // The display on which the cursor is drawn.
765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // For mirroring mode, the display is always the primary display.
775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  gfx::Display display_;
785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  scoped_ptr<aura::Window> cursor_window_;
805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  scoped_ptr<CursorWindowDelegate> delegate_;
815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(CursorWindowController);
835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)};
845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}  // namespace ash
865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#endif  // ASH_DISPLAY_CURSOR_WINDOW_CONTROLLER_H_
88