cursor_window_controller.h revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
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 {
135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace test{
145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class MirrorWindowTestApi;
155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace internal {
185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class CursorWindowDelegate;
205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Draws a mouse cursor on a given container window.
225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// When cursor compositing is disabled, CursorWindowController is responsible
235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// to scale and rotate the mouse cursor bitmap to match settings of the
245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// primary display.
255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// When cursor compositing is enabled, just draw the cursor as-is.
265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class CursorWindowController {
275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public:
285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  CursorWindowController();
295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ~CursorWindowController();
305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bool is_cursor_compositing_enabled() const {
325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return is_cursor_compositing_enabled_;
335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  }
345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Sets cursor compositing mode on/off.
365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void SetCursorCompositingEnabled(bool enabled);
375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Updates the container window for the cursor window controller.
395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void UpdateContainer();
405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Sets the display on which to draw cursor.
425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Only applicable when cursor compositing is enabled.
435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void SetDisplay(const gfx::Display& display);
445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Sets cursor location, shape, set and visibility.
465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void UpdateLocation();
475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void SetCursor(gfx::NativeCursor cursor);
485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void SetCursorSet(ui::CursorSetType);
495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void SetVisibility(bool visible);
505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) private:
525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  friend class test::MirrorWindowTestApi;
535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Sets the container window for the cursor window controller.
555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Closes the cursor window if |container| is NULL.
565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void SetContainer(aura::Window* container);
575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Sets the bounds of the container in screen coordinates.
595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void SetBoundsInScreen(const gfx::Rect& bounds);
605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Updates cursor image based on current cursor state.
625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void UpdateCursorImage();
635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bool is_cursor_compositing_enabled_;
655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  aura::Window* container_;
665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // The bounds of the container in screen coordinates.
685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  gfx::Rect bounds_in_screen_;
695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // The native_type of the cursor, see definitions in cursor.h
715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  int cursor_type_;
725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ui::CursorSetType cursor_set_;
745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  gfx::Display::Rotation cursor_rotation_;
755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  gfx::Point hot_point_;
765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // The display on which the cursor is drawn.
785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // For mirroring mode, the display is always the primary display.
795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  gfx::Display display_;
805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  scoped_ptr<aura::Window> cursor_window_;
825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  scoped_ptr<CursorWindowDelegate> delegate_;
835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(CursorWindowController);
855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)};
865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}  // namespace internal
885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}  // namespace ash
895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#endif  // ASH_DISPLAY_CURSOR_WINDOW_CONTROLLER_H_
91