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.
5 #ifndef OZONE_IMPL_WINDOW_TREE_HOST_DELEGATE_WAYLAND_H_
6 #define OZONE_IMPL_WINDOW_TREE_HOST_DELEGATE_WAYLAND_H_
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"
20 class DesktopWindowTreeHostWayland;
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 {
29 WindowTreeHostDelegateWayland();
30 virtual ~WindowTreeHostDelegateWayland();
32 void OnRootWindowCreated(unsigned handle);
33 void OnRootWindowClosed(unsigned handle);
35 void SetActiveWindow(DesktopWindowTreeHostWayland* dispatcher);
36 DesktopWindowTreeHostWayland* GetActiveWindow() const;
38 void SetCapture(DesktopWindowTreeHostWayland* dispatcher);
39 DesktopWindowTreeHostWayland* GetCurrentCapture() const;
41 const std::vector<aura::Window*>& GetAllOpenWindows();
43 // Overridden frm ui::EventSource
44 virtual ui::EventProcessor* GetEventProcessor() OVERRIDE;
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,
55 unsigned height) OVERRIDE;
57 // Dispatches a mouse event.
58 void DispatchMouseEvent(ui::MouseEvent* event);
59 std::list<gfx::AcceleratedWidget>& open_windows();
61 unsigned current_focus_window_;
62 bool handle_event_ :1;
63 bool stop_propogation_ :1;
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);
81 #endif // OZONE_IMPL_WINDOW_TREE_HOST_DELEGATE_WAYLAND_H_