51dde451cc5a5b681639c72f3032bad0bf39496b
[platform/framework/web/crosswalk.git] / src / ozone / impl / 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_WINDOW_TREE_HOST_DELEGATE_WAYLAND_H_
6 #define OZONE_IMPL_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 ozonewayland::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<gfx::AcceleratedWidget>& open_windows();
60
61   unsigned current_focus_window_;
62   bool handle_event_ :1;
63   bool stop_propogation_ :1;
64
65   // Current dispatcher.
66   DesktopWindowTreeHostWayland* current_dispatcher_;
67   // The current root window host that has capture. We need to track this so we
68   // can notify widgets when they have lost capture, which controls a bunch of
69   // things in views like hiding menus.
70   DesktopWindowTreeHostWayland* current_capture_;
71   DesktopWindowTreeHostWayland* current_active_window_;
72   // List of all open windows.
73   std::list<gfx::AcceleratedWidget>* open_windows_;
74   // List of all open aura::Window.
75   std::vector<aura::Window*>* aura_windows_;
76   DISALLOW_COPY_AND_ASSIGN(WindowTreeHostDelegateWayland);
77 };
78
79 }  // namespace views
80
81 #endif  // OZONE_IMPL_WINDOW_TREE_HOST_DELEGATE_WAYLAND_H_