Roll src/third_party/WebKit 9301d6f:4619053 (svn 201058:201059)
[chromium-blink-merge.git] / ui / aura / window_tree_host_x11.h
blobbc994a7eb877df92d5faa1d49221ea4f432e7da7
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.
5 #ifndef UI_AURA_WINDOW_TREE_HOST_X11_H_
6 #define UI_AURA_WINDOW_TREE_HOST_X11_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "ui/aura/aura_export.h"
10 #include "ui/aura/window_tree_host.h"
11 #include "ui/events/platform/platform_event_dispatcher.h"
12 #include "ui/gfx/geometry/insets.h"
13 #include "ui/gfx/geometry/rect.h"
14 #include "ui/gfx/x/x11_atom_cache.h"
16 // X forward decls to avoid including Xlib.h in a header file.
17 typedef struct _XDisplay XDisplay;
18 typedef unsigned long XID;
19 typedef XID Window;
21 namespace ui {
22 class MouseEvent;
25 namespace aura {
27 namespace internal {
28 class TouchEventCalibrate;
31 class AURA_EXPORT WindowTreeHostX11 : public WindowTreeHost,
32 public ui::PlatformEventDispatcher {
34 public:
35 explicit WindowTreeHostX11(const gfx::Rect& bounds);
36 ~WindowTreeHostX11() override;
38 // ui::PlatformEventDispatcher:
39 bool CanDispatchEvent(const ui::PlatformEvent& event) override;
40 uint32_t DispatchEvent(const ui::PlatformEvent& event) override;
42 // WindowTreeHost:
43 ui::EventSource* GetEventSource() override;
44 gfx::AcceleratedWidget GetAcceleratedWidget() override;
45 void ShowImpl() override;
46 void HideImpl() override;
47 gfx::Rect GetBounds() const override;
48 void SetBounds(const gfx::Rect& bounds) override;
49 gfx::Point GetLocationOnNativeScreen() const override;
50 void SetCapture() override;
51 void ReleaseCapture() override;
52 void SetCursorNative(gfx::NativeCursor cursor_type) override;
53 void MoveCursorToNative(const gfx::Point& location) override;
54 void OnCursorVisibilityChangedNative(bool show) override;
56 protected:
57 // Called when X Configure Notify event is recevied.
58 virtual void OnConfigureNotify();
60 // Translates the native mouse location into screen coordinates and
61 // dispatches the event via WindowEventDispatcher.
62 virtual void TranslateAndDispatchLocatedEvent(ui::LocatedEvent* event);
64 ::Window x_root_window() { return x_root_window_; }
65 XDisplay* xdisplay() { return xdisplay_; }
66 const gfx::Rect& bounds() const { return bounds_; }
67 ui::X11AtomCache* atom_cache() { return &atom_cache_; }
69 private:
70 // Dispatches XI2 events. Note that some events targetted for the X root
71 // window are dispatched to the aura root window (e.g. touch events after
72 // calibration).
73 void DispatchXI2Event(const base::NativeEvent& event);
75 // Sets the cursor on |xwindow_| to |cursor|. Does not check or update
76 // |current_cursor_|.
77 void SetCursorInternal(gfx::NativeCursor cursor);
79 // The display and the native X window hosting the root window.
80 XDisplay* xdisplay_;
81 ::Window xwindow_;
83 // The native root window.
84 ::Window x_root_window_;
86 // Current Aura cursor.
87 gfx::NativeCursor current_cursor_;
89 // Is the window mapped to the screen?
90 bool window_mapped_;
92 // The bounds of |xwindow_|.
93 gfx::Rect bounds_;
95 scoped_ptr<internal::TouchEventCalibrate> touch_calibrate_;
97 ui::X11AtomCache atom_cache_;
99 DISALLOW_COPY_AND_ASSIGN(WindowTreeHostX11);
102 namespace test {
104 // Set the default value of the override redirect flag used to
105 // create a X window for WindowTreeHostX11.
106 AURA_EXPORT void SetUseOverrideRedirectWindowByDefault(bool override_redirect);
108 } // namespace test
109 } // namespace aura
111 #endif // UI_AURA_WINDOW_TREE_HOST_X11_H_