Upstream version 6.35.121.0
[platform/framework/web/crosswalk.git] / src / ozone / ui / desktop_aura / window_tree_host_delegate_wayland.h
1 // Copyright 2014 Intel Corporation. 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.
4
5 #ifndef OZONE_IMPL_DESKTOP_AURA_WINDOW_TREE_HOST_DELEGATE_WAYLAND_H_
6 #define OZONE_IMPL_DESKTOP_AURA_WINDOW_TREE_HOST_DELEGATE_WAYLAND_H_
7
8 #include <list>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/message_loop/message_loop.h"
13 #include "ozone/ui/events/window_change_observer.h"
14 #include "ui/events/event.h"
15 #include "ui/events/event_source.h"
16 #include "ui/gfx/native_widget_types.h"
17
18 namespace views {
19
20 class DesktopWindowTreeHostWayland;
21
22 // A static class used by DesktopWindowTreeHostWayland to dispatch native events
23 // and basic window management.
24 class WindowTreeHostDelegateWayland
25     : public base::MessagePumpDispatcher,
26       public ui::EventSource,
27       public ui::WindowChangeObserver {
28  public:
29   WindowTreeHostDelegateWayland();
30   virtual ~WindowTreeHostDelegateWayland();
31
32   void OnRootWindowCreated(unsigned handle);
33   void OnRootWindowClosed(unsigned handle);
34
35   void SetActiveWindow(DesktopWindowTreeHostWayland* dispatcher);
36   DesktopWindowTreeHostWayland* GetActiveWindow() const;
37
38   void SetCapture(DesktopWindowTreeHostWayland* dispatcher);
39   DesktopWindowTreeHostWayland* GetCurrentCapture() const;
40
41   const std::vector<aura::Window*>& GetAllOpenWindows();
42
43   // Overridden frm ui::EventSource
44   virtual ui::EventProcessor* GetEventProcessor() OVERRIDE;
45  private:
46   // Overridden from Dispatcher:
47   virtual uint32_t Dispatch(const base::NativeEvent& event) OVERRIDE;
48   // Window Change Observer.
49   virtual void OnWindowFocused(unsigned handle) OVERRIDE;
50   virtual void OnWindowEnter(unsigned handle) OVERRIDE;
51   virtual void OnWindowLeave(unsigned handle) OVERRIDE;
52   virtual void OnWindowClose(unsigned handle) OVERRIDE;
53   virtual void OnWindowResized(unsigned windowhandle,
54                                unsigned width,
55                                unsigned height) OVERRIDE;
56
57   // Dispatches a mouse event.
58   void DispatchMouseEvent(ui::MouseEvent* event);
59   std::list<unsigned>& open_windows();
60   unsigned GetWindowHandle(gfx::AcceleratedWidget widget);
61
62   unsigned current_focus_window_;
63   bool handle_event_ :1;
64   bool stop_propogation_ :1;
65
66   // Current dispatcher.
67   DesktopWindowTreeHostWayland* current_dispatcher_;
68   // The current root window host that has capture. We need to track this so we
69   // can notify widgets when they have lost capture, which controls a bunch of
70   // things in views like hiding menus.
71   DesktopWindowTreeHostWayland* current_capture_;
72   DesktopWindowTreeHostWayland* current_active_window_;
73   // List of all open windows.
74   std::list<unsigned>* open_windows_;
75   // List of all open aura::Window.
76   std::vector<aura::Window*>* aura_windows_;
77   DISALLOW_COPY_AND_ASSIGN(WindowTreeHostDelegateWayland);
78 };
79
80 }  // namespace views
81
82 #endif  // OZONE_IMPL_DESKTOP_AURA_WINDOW_TREE_HOST_DELEGATE_WAYLAND_H_