summaryrefslogtreecommitdiffstats
path: root/ui/aura/root_window.h
blob: 82c0534a23c83eccfc57823a1680665c5399b133 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// 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_ROOT_WINDOW_H_
#define UI_AURA_ROOT_WINDOW_H_
#pragma once

#include "ui/aura/window.h"

namespace aura {

class MouseEvent;

namespace internal {

class FocusManager;

// A Window subclass that handles event targeting for certain types of
// MouseEvent.
class RootWindow : public Window {
 public:
  RootWindow();
  virtual ~RootWindow();

  // Handles a mouse event. Returns true if handled.
  bool HandleMouseEvent(const MouseEvent& event);

  // Handles a key event. Returns true if handled.
  bool HandleKeyEvent(const KeyEvent& event);

  // Sets capture to the specified window.
  void SetCapture(Window* window);

  // If |window| has mouse capture, the current capture window is set to NULL.
  void ReleaseCapture(Window* window);

  // Returns the window that has mouse capture.
  Window* capture_window() { return capture_window_; }

  // Invoked when a child window is destroyed. Cleans up any references to the
  // Window.
  void WindowDestroying(Window* window);

  // Current handler for mouse events.
  Window* mouse_pressed_handler() { return mouse_pressed_handler_; }

  // Overridden from Window:
  virtual FocusManager* GetFocusManager() OVERRIDE;

 protected:
  // Overridden from Window:
  virtual internal::RootWindow* GetRoot() OVERRIDE;

 private:
  // Called whenever the mouse moves, tracks the current |mouse_moved_handler_|,
  // sending exited and entered events as its value changes.
  void HandleMouseMoved(const MouseEvent& event, Window* target);

  Window* mouse_pressed_handler_;
  Window* mouse_moved_handler_;
  scoped_ptr<FocusManager> focus_manager_;
  Window* capture_window_;

  DISALLOW_COPY_AND_ASSIGN(RootWindow);
};

}  // namespace internal
}  // namespace aura

#endif  // UI_AURA_ROOT_WINDOW_H_