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_
12 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class.
15 #include "base/memory/scoped_ptr.h"
16 #include "base/message_loop/message_loop.h"
17 #include "ui/aura/aura_export.h"
18 #include "ui/aura/env_observer.h"
19 #include "ui/aura/window_tree_host.h"
20 #include "ui/base/x/x11_util.h"
21 #include "ui/events/event_source.h"
22 #include "ui/gfx/insets.h"
23 #include "ui/gfx/rect.h"
24 #include "ui/gfx/x/x11_atom_cache.h"
33 class TouchEventCalibrate
;
36 class AURA_EXPORT WindowTreeHostX11
: public WindowTreeHost
,
37 public base::MessageLoop::Dispatcher
,
38 public ui::EventSource
,
41 explicit WindowTreeHostX11(const gfx::Rect
& bounds
);
42 virtual ~WindowTreeHostX11();
44 // Overridden from Dispatcher overrides:
45 virtual bool Dispatch(const base::NativeEvent
& event
) OVERRIDE
;
47 // WindowTreeHost Overrides.
48 virtual RootWindow
* GetRootWindow() OVERRIDE
;
49 virtual gfx::AcceleratedWidget
GetAcceleratedWidget() OVERRIDE
;
50 virtual void Show() OVERRIDE
;
51 virtual void Hide() OVERRIDE
;
52 virtual void ToggleFullScreen() OVERRIDE
;
53 virtual gfx::Rect
GetBounds() const OVERRIDE
;
54 virtual void SetBounds(const gfx::Rect
& bounds
) OVERRIDE
;
55 virtual gfx::Insets
GetInsets() const OVERRIDE
;
56 virtual void SetInsets(const gfx::Insets
& insets
) OVERRIDE
;
57 virtual gfx::Point
GetLocationOnNativeScreen() const OVERRIDE
;
58 virtual void SetCapture() OVERRIDE
;
59 virtual void ReleaseCapture() OVERRIDE
;
60 virtual void SetCursor(gfx::NativeCursor cursor_type
) OVERRIDE
;
61 virtual bool QueryMouseLocation(gfx::Point
* location_return
) OVERRIDE
;
62 virtual bool ConfineCursorToRootWindow() OVERRIDE
;
63 virtual void UnConfineCursor() OVERRIDE
;
64 virtual void OnCursorVisibilityChanged(bool show
) OVERRIDE
;
65 virtual void MoveCursorTo(const gfx::Point
& location
) OVERRIDE
;
66 virtual void PostNativeEvent(const base::NativeEvent
& event
) OVERRIDE
;
67 virtual void OnDeviceScaleFactorChanged(float device_scale_factor
) OVERRIDE
;
68 virtual void PrepareForShutdown() OVERRIDE
;
70 // EnvObserver overrides.
71 virtual void OnWindowInitialized(Window
* window
) OVERRIDE
;
72 virtual void OnRootWindowInitialized(RootWindow
* root_window
) OVERRIDE
;
74 // ui::EventSource overrides.
75 virtual ui::EventProcessor
* GetEventProcessor() OVERRIDE
;
78 class MouseMoveFilter
;
80 bool DispatchEventForRootWindow(const base::NativeEvent
& event
);
82 // Dispatches XI2 events. Note that some events targetted for the X root
83 // window are dispatched to the aura root window (e.g. touch events after
85 void DispatchXI2Event(const base::NativeEvent
& event
);
87 // Returns true if there's an X window manager present... in most cases. Some
88 // window managers (notably, ion3) don't implement enough of ICCCM for us to
89 // detect that they're there.
90 bool IsWindowManagerPresent();
92 // Sets the cursor on |xwindow_| to |cursor|. Does not check or update
94 void SetCursorInternal(gfx::NativeCursor cursor
);
96 // Translates the native mouse location into screen coordinates and and
97 // dispatches the event to WindowTreeHostDelegate.
98 void TranslateAndDispatchMouseEvent(ui::MouseEvent
* event
);
100 // Update is_internal_display_ based on delegate_ state
101 void UpdateIsInternalDisplay();
103 // Set the CrOS touchpad "tap paused" property. It is used to temporarily
104 // turn off the Tap-to-click feature when the mouse pointer is invisible.
105 void SetCrOSTapPaused(bool state
);
107 // The display and the native X window hosting the root window.
111 // The native root window.
112 ::Window x_root_window_
;
114 // Current Aura cursor.
115 gfx::NativeCursor current_cursor_
;
117 // Is the window mapped to the screen?
120 // The bounds of |xwindow_|.
123 // The insets that specifies the effective area within the |window_|.
126 // True if the root host resides on the internal display
127 bool is_internal_display_
;
129 scoped_ptr
<XID
[]> pointer_barriers_
;
131 scoped_ptr
<internal::TouchEventCalibrate
> touch_calibrate_
;
133 scoped_ptr
<MouseMoveFilter
> mouse_move_filter_
;
135 ui::X11AtomCache atom_cache_
;
137 // Touch ids of which the touch press happens at side bezel region.
138 uint32 bezel_tracking_ids_
;
140 DISALLOW_COPY_AND_ASSIGN(WindowTreeHostX11
);
145 // Set the default value of the override redirect flag used to
146 // create a X window for WindowTreeHostX11.
147 AURA_EXPORT
void SetUseOverrideRedirectWindowByDefault(bool override_redirect
);
152 #endif // UI_AURA_ROOT_WINDOW_HOST_X11_H_