Fix build break
[chromium-blink-merge.git] / ui / aura / root_window_host_x11.h
blob2a8b5804dc30c8baf05447907cab8a0a30ad46ec
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_ROOT_WINDOW_HOST_X11_H_
6 #define UI_AURA_ROOT_WINDOW_HOST_X11_H_
8 #include <X11/Xlib.h>
10 #include <vector>
12 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class.
13 #undef RootWindow
15 #include "base/memory/scoped_ptr.h"
16 #include "base/message_loop.h"
17 #include "ui/aura/env_observer.h"
18 #include "ui/aura/root_window_host.h"
19 #include "ui/base/x/x11_atom_cache.h"
20 #include "ui/base/x/x11_util.h"
21 #include "ui/gfx/insets.h"
22 #include "ui/gfx/rect.h"
24 namespace ui {
25 class MouseEvent;
28 namespace aura {
30 namespace internal {
31 class TouchEventCalibrate;
34 class RootWindowHostX11 : public RootWindowHost,
35 public MessageLoop::Dispatcher,
36 public EnvObserver {
37 public:
38 explicit RootWindowHostX11(const gfx::Rect& bounds);
39 virtual ~RootWindowHostX11();
41 // Overridden from Dispatcher overrides:
42 virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE;
44 // RootWindowHost Overrides.
45 virtual void SetDelegate(RootWindowHostDelegate* delegate) OVERRIDE;
46 virtual RootWindow* GetRootWindow() OVERRIDE;
47 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE;
48 virtual void Show() OVERRIDE;
49 virtual void Hide() OVERRIDE;
50 virtual void ToggleFullScreen() OVERRIDE;
51 virtual gfx::Rect GetBounds() const OVERRIDE;
52 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
53 virtual gfx::Insets GetInsets() const OVERRIDE;
54 virtual void SetInsets(const gfx::Insets& insets) OVERRIDE;
55 virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE;
56 virtual void SetCapture() OVERRIDE;
57 virtual void ReleaseCapture() OVERRIDE;
58 virtual void SetCursor(gfx::NativeCursor cursor_type) OVERRIDE;
59 virtual bool QueryMouseLocation(gfx::Point* location_return) OVERRIDE;
60 virtual bool ConfineCursorToRootWindow() OVERRIDE;
61 virtual void UnConfineCursor() OVERRIDE;
62 virtual void OnCursorVisibilityChanged(bool show) OVERRIDE;
63 virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE;
64 virtual void SetFocusWhenShown(bool focus_when_shown) OVERRIDE;
65 virtual bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds,
66 const gfx::Point& dest_offset,
67 SkCanvas* canvas) OVERRIDE;
68 virtual bool GrabSnapshot(
69 const gfx::Rect& snapshot_bounds,
70 std::vector<unsigned char>* png_representation) OVERRIDE;
71 virtual void PostNativeEvent(const base::NativeEvent& event) OVERRIDE;
72 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
73 virtual void PrepareForShutdown() OVERRIDE;
75 // EnvObserver overrides.
76 virtual void OnWindowInitialized(Window* window) OVERRIDE;
77 virtual void OnRootWindowInitialized(RootWindow* root_window) OVERRIDE;
78 private:
79 class MouseMoveFilter;
81 bool DispatchEventForRootWindow(const base::NativeEvent& event);
83 // Dispatches XI2 events. Note that some events targetted for the X root
84 // window are dispatched to the aura root window (e.g. touch events after
85 // calibration).
86 void DispatchXI2Event(const base::NativeEvent& event);
88 // Returns true if there's an X window manager present... in most cases. Some
89 // window managers (notably, ion3) don't implement enough of ICCCM for us to
90 // detect that they're there.
91 bool IsWindowManagerPresent();
93 // Sets the cursor on |xwindow_| to |cursor|. Does not check or update
94 // |current_cursor_|.
95 void SetCursorInternal(gfx::NativeCursor cursor);
97 // Translates the native mouse location into screen coordinates and and
98 // dispatches the event to RootWindowHostDelegate.
99 void TranslateAndDispatchMouseEvent(ui::MouseEvent* event);
101 // Copies and returns |snapshot_bounds| from |xwindow_|. Helper method for
102 // CopyAreaToSkCanvas() and GrabSnapshot().
103 scoped_ptr<ui::XScopedImage> GetXImage(const gfx::Rect& snapshot_bounds);
105 // Update is_internal_display_ based on delegate_ state
106 void UpdateIsInternalDisplay();
108 RootWindowHostDelegate* delegate_;
110 // The display and the native X window hosting the root window.
111 Display* xdisplay_;
112 ::Window xwindow_;
114 // The native root window.
115 ::Window x_root_window_;
117 // Current Aura cursor.
118 gfx::NativeCursor current_cursor_;
120 // Is the window mapped to the screen?
121 bool window_mapped_;
123 // The bounds of |xwindow_|.
124 gfx::Rect bounds_;
126 // The insets that specifies the effective area within the |window_|.
127 gfx::Insets insets_;
129 // The bounds of |x_root_window_|.
130 gfx::Rect x_root_bounds_;
132 // True if the root host resides on the internal display
133 bool is_internal_display_;
135 // True if the window should be focused when the window is shown.
136 bool focus_when_shown_;
138 scoped_ptr<XID[]> pointer_barriers_;
140 scoped_ptr<internal::TouchEventCalibrate> touch_calibrate_;
142 scoped_ptr<MouseMoveFilter> mouse_move_filter_;
144 ui::X11AtomCache atom_cache_;
146 DISALLOW_COPY_AND_ASSIGN(RootWindowHostX11);
149 } // namespace aura
151 #endif // UI_AURA_ROOT_WINDOW_HOST_X11_H_