blob: 0587bb6fa0838b65e661e762aa43024d26574cba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_AURA_WINDOW_TREE_HOST_X11_H_
#define UI_AURA_WINDOW_TREE_HOST_X11_H_
#include <stdint.h>
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "ui/aura/aura_export.h"
#include "ui/aura/window_tree_host.h"
#include "ui/events/platform/platform_event_dispatcher.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/x/x11_atom_cache.h"
// X forward decls to avoid including Xlib.h in a header file.
typedef struct _XDisplay XDisplay;
typedef unsigned long XID;
typedef XID Window;
namespace ui {
class MouseEvent;
}
namespace aura {
class AURA_EXPORT WindowTreeHostX11 : public WindowTreeHost,
public ui::PlatformEventDispatcher {
public:
explicit WindowTreeHostX11(const gfx::Rect& bounds);
~WindowTreeHostX11() override;
// ui::PlatformEventDispatcher:
bool CanDispatchEvent(const ui::PlatformEvent& event) override;
uint32_t DispatchEvent(const ui::PlatformEvent& event) override;
// WindowTreeHost:
ui::EventSource* GetEventSource() override;
gfx::AcceleratedWidget GetAcceleratedWidget() override;
void ShowImpl() override;
void HideImpl() override;
gfx::Rect GetBounds() const override;
void SetBounds(const gfx::Rect& bounds) override;
gfx::Point GetLocationOnNativeScreen() const override;
void SetCapture() override;
void ReleaseCapture() override;
void SetCursorNative(gfx::NativeCursor cursor_type) override;
void MoveCursorToNative(const gfx::Point& location) override;
void OnCursorVisibilityChangedNative(bool show) override;
protected:
// Called when X Configure Notify event is recevied.
virtual void OnConfigureNotify();
// Translates the native mouse location into screen coordinates and
// dispatches the event via WindowEventDispatcher.
virtual void TranslateAndDispatchLocatedEvent(ui::LocatedEvent* event);
::Window x_root_window() { return x_root_window_; }
XDisplay* xdisplay() { return xdisplay_; }
const gfx::Rect& bounds() const { return bounds_; }
ui::X11AtomCache* atom_cache() { return &atom_cache_; }
private:
// Dispatches XI2 events. Note that some events targetted for the X root
// window are dispatched to the aura root window (e.g. touch events after
// calibration).
void DispatchXI2Event(const base::NativeEvent& event);
// Sets the cursor on |xwindow_| to |cursor|. Does not check or update
// |current_cursor_|.
void SetCursorInternal(gfx::NativeCursor cursor);
// The display and the native X window hosting the root window.
XDisplay* xdisplay_;
::Window xwindow_;
// The native root window.
::Window x_root_window_;
// Current Aura cursor.
gfx::NativeCursor current_cursor_;
// Is the window mapped to the screen?
bool window_mapped_;
// The bounds of |xwindow_|.
gfx::Rect bounds_;
ui::X11AtomCache atom_cache_;
DISALLOW_COPY_AND_ASSIGN(WindowTreeHostX11);
};
namespace test {
// Set the default value of the override redirect flag used to
// create a X window for WindowTreeHostX11.
AURA_EXPORT void SetUseOverrideRedirectWindowByDefault(bool override_redirect);
} // namespace test
} // namespace aura
#endif // UI_AURA_WINDOW_TREE_HOST_X11_H_
|