1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h"
10 #include "base/observer_list.h"
11 #include "ui/aura/aura_export.h"
12 #include "ui/base/events/event_handler.h"
13 #include "ui/base/events/event_target.h"
14 #include "ui/gfx/point.h"
17 #include "ui/aura/device_list_updater_aurax11.h"
26 // Creates a platform-specific native event dispatcher.
27 MessageLoop::Dispatcher
* CreateDispatcher();
30 // A singleton object that tracks general state within Aura.
31 // TODO(beng): manage RootWindows.
32 class AURA_EXPORT Env
: public ui::EventTarget
{
37 static Env
* GetInstance();
38 static void DeleteInstance();
40 void AddObserver(EnvObserver
* observer
);
41 void RemoveObserver(EnvObserver
* observer
);
43 bool is_mouse_button_down() const { return mouse_button_flags_
!= 0; }
44 void set_mouse_button_flags(int mouse_button_flags
) {
45 mouse_button_flags_
= mouse_button_flags
;
48 // Gets/sets the last mouse location seen in a mouse event in the screen
50 const gfx::Point
& last_mouse_location() const { return last_mouse_location_
; }
51 void set_last_mouse_location(const gfx::Point
& last_mouse_location
) {
52 last_mouse_location_
= last_mouse_location
;
55 // Whether any touch device is currently down.
56 bool is_touch_down() const { return is_touch_down_
; }
57 void set_touch_down(bool value
) { is_touch_down_
= value
; }
59 // Whether RenderWidgetHostViewAura::OnPaint() should paint white background
60 // when backing store is not present. Default is true.
61 // In some cases when page is using transparent background painting white
62 // background before backing store is initialized causes a white splash.
63 bool render_white_bg() const { return render_white_bg_
; }
64 void set_render_white_bg(bool value
) { render_white_bg_
= value
; }
66 // Returns the native event dispatcher. The result should only be passed to
67 // base::RunLoop(dispatcher), or used to dispatch an event by
68 // |Dispatch(const NativeEvent&)| on it. It must never be stored.
69 #if !defined(OS_MACOSX)
70 MessageLoop::Dispatcher
* GetDispatcher();
73 // Invoked by RootWindow when its host is activated.
74 void RootWindowActivated(RootWindow
* root_window
);
78 friend class RootWindow
;
82 // Called by the Window when it is initialized. Notifies observers.
83 void NotifyWindowInitialized(Window
* window
);
85 // Called by the RootWindow when it is initialized. Notifies observers.
86 void NotifyRootWindowInitialized(RootWindow
* root_window
);
88 // Overridden from ui::EventTarget:
89 virtual bool CanAcceptEvent(const ui::Event
& event
) OVERRIDE
;
90 virtual ui::EventTarget
* GetParentTarget() OVERRIDE
;
92 ObserverList
<EnvObserver
> observers_
;
94 scoped_ptr
<MessageLoop::Dispatcher
> dispatcher_
;
97 static Env
* instance_
;
98 int mouse_button_flags_
;
99 // Location of last mouse event, in screen coordinates.
100 gfx::Point last_mouse_location_
;
102 bool render_white_bg_
;
105 DeviceListUpdaterAuraX11 device_list_updater_aurax11_
;
108 DISALLOW_COPY_AND_ASSIGN(Env
);
113 #endif // UI_AURA_ENV_H_