Revert of Roll src/third_party/WebKit e0eac24:489c548 (svn 193311:193320) (patchset...
[chromium-blink-merge.git] / ui / aura / window_tree_host_x11.h
bloba37f89c4234e33441cd519b4de36587f7298a440
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/event_source.h"
12 #include "ui/events/platform/platform_event_dispatcher.h"
13 #include "ui/gfx/geometry/insets.h"
14 #include "ui/gfx/geometry/rect.h"
15 #include "ui/gfx/x/x11_atom_cache.h"
17 // X forward decls to avoid including Xlib.h in a header file.
18 typedef struct _XDisplay XDisplay;
19 typedef unsigned long XID;
20 typedef XID Window;
22 namespace ui {
23 class MouseEvent;
26 namespace aura {
28 namespace internal {
29 class TouchEventCalibrate;
32 class AURA_EXPORT WindowTreeHostX11 : public WindowTreeHost,
33 public ui::EventSource,
34 public ui::PlatformEventDispatcher {
36 public:
37 explicit WindowTreeHostX11(const gfx::Rect& bounds);
38 ~WindowTreeHostX11() override;
40 // ui::PlatformEventDispatcher:
41 bool CanDispatchEvent(const ui::PlatformEvent& event) override;
42 uint32_t DispatchEvent(const ui::PlatformEvent& event) override;
44 // WindowTreeHost:
45 ui::EventSource* GetEventSource() override;
46 gfx::AcceleratedWidget GetAcceleratedWidget() override;
47 void Show() override;
48 void Hide() override;
49 gfx::Rect GetBounds() const override;
50 void SetBounds(const gfx::Rect& bounds) override;
51 gfx::Point GetLocationOnNativeScreen() const override;
52 void SetCapture() override;
53 void ReleaseCapture() override;
54 void SetCursorNative(gfx::NativeCursor cursor_type) override;
55 void MoveCursorToNative(const gfx::Point& location) override;
56 void OnCursorVisibilityChangedNative(bool show) override;
58 // ui::EventSource overrides.
59 ui::EventProcessor* GetEventProcessor() override;
61 protected:
62 // Called when X Configure Notify event is recevied.
63 virtual void OnConfigureNotify();
65 // Translates the native mouse location into screen coordinates and
66 // dispatches the event via WindowEventDispatcher.
67 virtual void TranslateAndDispatchLocatedEvent(ui::LocatedEvent* event);
69 ::Window x_root_window() { return x_root_window_; }
70 XDisplay* xdisplay() { return xdisplay_; }
71 const gfx::Rect& bounds() const { return bounds_; }
72 ui::X11AtomCache* atom_cache() { return &atom_cache_; }
74 private:
75 // Dispatches XI2 events. Note that some events targetted for the X root
76 // window are dispatched to the aura root window (e.g. touch events after
77 // calibration).
78 void DispatchXI2Event(const base::NativeEvent& event);
80 // Sets the cursor on |xwindow_| to |cursor|. Does not check or update
81 // |current_cursor_|.
82 void SetCursorInternal(gfx::NativeCursor cursor);
84 // The display and the native X window hosting the root window.
85 XDisplay* xdisplay_;
86 ::Window xwindow_;
88 // The native root window.
89 ::Window x_root_window_;
91 // Current Aura cursor.
92 gfx::NativeCursor current_cursor_;
94 // Is the window mapped to the screen?
95 bool window_mapped_;
97 // The bounds of |xwindow_|.
98 gfx::Rect bounds_;
100 scoped_ptr<internal::TouchEventCalibrate> touch_calibrate_;
102 ui::X11AtomCache atom_cache_;
104 DISALLOW_COPY_AND_ASSIGN(WindowTreeHostX11);
107 namespace test {
109 // Set the default value of the override redirect flag used to
110 // create a X window for WindowTreeHostX11.
111 AURA_EXPORT void SetUseOverrideRedirectWindowByDefault(bool override_redirect);
113 } // namespace test
114 } // namespace aura
116 #endif // UI_AURA_WINDOW_TREE_HOST_X11_H_