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
;
28 class TouchEventCalibrate
;
31 class AURA_EXPORT WindowTreeHostX11
: public WindowTreeHost
,
32 public ui::PlatformEventDispatcher
{
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
;
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
;
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_
; }
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
73 void DispatchXI2Event(const base::NativeEvent
& event
);
75 // Sets the cursor on |xwindow_| to |cursor|. Does not check or update
77 void SetCursorInternal(gfx::NativeCursor cursor
);
79 // The display and the native X window hosting the root window.
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?
92 // The bounds of |xwindow_|.
95 scoped_ptr
<internal::TouchEventCalibrate
> touch_calibrate_
;
97 ui::X11AtomCache atom_cache_
;
99 DISALLOW_COPY_AND_ASSIGN(WindowTreeHostX11
);
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
);
111 #endif // UI_AURA_WINDOW_TREE_HOST_X11_H_