Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Side by Side Diff: wm/host/root_window_host_linux.h

Issue 11485006: Add window manager component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Push gfx::AcceleratedWidget usage into platform specific code. Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « wm/host/root_window_host_factory_linux.cc ('k') | wm/host/root_window_host_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_AURA_ROOT_WINDOW_HOST_LINUX_H_ 5 #ifndef WM_HOST_ROOT_WINDOW_HOST_LINUX_H_
6 #define UI_AURA_ROOT_WINDOW_HOST_LINUX_H_ 6 #define WM_HOST_ROOT_WINDOW_HOST_LINUX_H_
7 7
8 #include <X11/Xlib.h> 8 #include <X11/Xlib.h>
9 9
10 #include <vector> 10 #include <vector>
11 11
12 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. 12 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class.
13 #undef RootWindow 13 #undef RootWindow
14 14
15 #include "base/hash_tables.h"
15 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
16 #include "base/message_loop.h" 17 #include "base/message_loop.h"
17 #include "ui/aura/root_window_host.h" 18 #include "ui/aura/root_window_host.h"
19 #include "ui/aura/window_observer.h"
18 #include "ui/base/x/x11_atom_cache.h" 20 #include "ui/base/x/x11_atom_cache.h"
19 #include "ui/base/x/x11_util.h" 21 #include "ui/base/x/x11_util.h"
20 #include "ui/gfx/rect.h" 22 #include "ui/gfx/rect.h"
21 23
22 namespace ui { 24 namespace ui {
23 class MouseEvent; 25 class MouseEvent;
24 } 26 }
25 27
26 namespace aura { 28 namespace wm {
29 class ForeignWindow;
27 30
28 namespace internal { 31 namespace internal {
29 class TouchEventCalibrate; 32 class TouchEventCalibrate;
30 } 33 }
31 34
32 class RootWindowHostLinux : public RootWindowHost, 35 // TODO(reveman): Reuse aura::RootWindowHostLinux code.
33 public MessageLoop::Dispatcher { 36 class RootWindowHostLinux : public aura::RootWindowHost,
37 public MessageLoop::Dispatcher,
38 public aura::WindowObserver,
39 public base::SupportsWeakPtr<RootWindowHostLinux> {
34 public: 40 public:
35 explicit RootWindowHostLinux(const gfx::Rect& bounds); 41 explicit RootWindowHostLinux(const gfx::Rect& bounds);
36 virtual ~RootWindowHostLinux(); 42 virtual ~RootWindowHostLinux();
37 43
38 // Overridden from Dispatcher overrides: 44 // Overridden from Dispatcher overrides:
39 virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE; 45 virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE;
40 46
41 // RootWindowHost Overrides. 47 private:
42 virtual void SetDelegate(RootWindowHostDelegate* delegate) OVERRIDE; 48 class MouseMoveFilter;
43 virtual RootWindow* GetRootWindow() OVERRIDE; 49
50 typedef base::hash_map< ::Window, scoped_refptr<ForeignWindow> >
51 ForeignWindowMap;
52
53 bool DispatchEventForRootWindow(const base::NativeEvent& event);
54
55 // Dispatches XI2 events. Note that some events targetted for the X root
56 // window are dispatched to the aura root window (e.g. touch events after
57 // calibration).
58 void DispatchXI2Event(const base::NativeEvent& event);
59
60 // Overridden from aura::RootWindowHost:
61 virtual void SetDelegate(aura::RootWindowHostDelegate* delegate) OVERRIDE;
62 virtual aura::RootWindow* GetRootWindow() OVERRIDE;
44 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; 63 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE;
45 virtual void Show() OVERRIDE; 64 virtual void Show() OVERRIDE;
46 virtual void Hide() OVERRIDE; 65 virtual void Hide() OVERRIDE;
47 virtual void ToggleFullScreen() OVERRIDE; 66 virtual void ToggleFullScreen() OVERRIDE;
48 virtual gfx::Rect GetBounds() const OVERRIDE; 67 virtual gfx::Rect GetBounds() const OVERRIDE;
49 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; 68 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
50 virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE; 69 virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE;
51 virtual void SetCapture() OVERRIDE; 70 virtual void SetCapture() OVERRIDE;
52 virtual void ReleaseCapture() OVERRIDE; 71 virtual void ReleaseCapture() OVERRIDE;
53 virtual void SetCursor(gfx::NativeCursor cursor_type) OVERRIDE; 72 virtual void SetCursor(gfx::NativeCursor cursor_type) OVERRIDE;
54 virtual bool QueryMouseLocation(gfx::Point* location_return) OVERRIDE; 73 virtual bool QueryMouseLocation(gfx::Point* location_return) OVERRIDE;
55 virtual bool ConfineCursorToRootWindow() OVERRIDE; 74 virtual bool ConfineCursorToRootWindow() OVERRIDE;
56 virtual void UnConfineCursor() OVERRIDE; 75 virtual void UnConfineCursor() OVERRIDE;
57 virtual void OnCursorVisibilityChanged(bool show) OVERRIDE; 76 virtual void OnCursorVisibilityChanged(bool show) OVERRIDE;
58 virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE; 77 virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE;
59 virtual void SetFocusWhenShown(bool focus_when_shown) OVERRIDE; 78 virtual void SetFocusWhenShown(bool focus_when_shown) OVERRIDE;
60 virtual bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds, 79 virtual bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds,
61 const gfx::Point& dest_offset, 80 const gfx::Point& dest_offset,
62 SkCanvas* canvas) OVERRIDE; 81 SkCanvas* canvas) OVERRIDE;
63 virtual bool GrabSnapshot( 82 virtual bool GrabSnapshot(
64 const gfx::Rect& snapshot_bounds, 83 const gfx::Rect& snapshot_bounds,
65 std::vector<unsigned char>* png_representation) OVERRIDE; 84 std::vector<unsigned char>* png_representation) OVERRIDE;
66 virtual void PostNativeEvent(const base::NativeEvent& event) OVERRIDE; 85 virtual void PostNativeEvent(const base::NativeEvent& event) OVERRIDE;
67 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; 86 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
68 virtual void PrepareForShutdown() OVERRIDE; 87 virtual void PrepareForShutdown() OVERRIDE;
69 88
70 private:
71 class MouseMoveFilter;
72
73 bool DispatchEventForRootWindow(const base::NativeEvent& event);
74
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);
79
80 // Returns true if there's an X window manager present... in most cases. Some 89 // Returns true if there's an X window manager present... in most cases. Some
81 // window managers (notably, ion3) don't implement enough of ICCCM for us to 90 // window managers (notably, ion3) don't implement enough of ICCCM for us to
82 // detect that they're there. 91 // detect that they're there.
83 bool IsWindowManagerPresent(); 92 bool IsWindowManagerPresent();
84 93
85 // Sets the cursor on |xwindow_| to |cursor|. Does not check or update 94 // Sets the cursor on |xwindow_| to |cursor|. Does not check or update
86 // |current_cursor_|. 95 // |current_cursor_|.
87 void SetCursorInternal(gfx::NativeCursor cursor); 96 void SetCursorInternal(gfx::NativeCursor cursor);
88 97
89 // Translates the native mouse location into screen coordinates and and 98 // Translates the native mouse location into screen coordinates and and
90 // dispatches the event to RootWindowHostDelegate. 99 // dispatches the event to RootWindowHostDelegate.
91 void TranslateAndDispatchMouseEvent(ui::MouseEvent* event); 100 void TranslateAndDispatchMouseEvent(ui::MouseEvent* event);
92 101
93 // Copies and returns |snapshot_bounds| from |xwindow_|. Helper method for 102 // Copies and returns |snapshot_bounds| from |xwindow_|. Helper method for
94 // CopyAreaToSkCanvas() and GrabSnapshot(). 103 // CopyAreaToSkCanvas() and GrabSnapshot().
95 scoped_ptr<ui::XScopedImage> GetXImage(const gfx::Rect& snapshot_bounds); 104 scoped_ptr<ui::XScopedImage> GetXImage(const gfx::Rect& snapshot_bounds);
96 105
97 RootWindowHostDelegate* delegate_; 106 // Overridden from aura::WindowObserver:
107 virtual void OnWindowAdded(aura::Window* window) OVERRIDE;
108 virtual void OnWillRemoveWindow(aura::Window* window) OVERRIDE;
109 virtual void OnWindowStackingChanged(aura::Window* window) OVERRIDE;
110 virtual void OnWindowVisibilityChanged(
111 aura::Window* window, bool visible) OVERRIDE;
112 virtual void OnWindowBoundsChanged(aura::Window* window,
113 const gfx::Rect& old_bounds,
114 const gfx::Rect& new_bounds) OVERRIDE;
115 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
116
117 ::Window GetTopForeignWindow(const aura::Window* window);
118 ::Window FindForeignWindowToStackAbove(const aura::Window* window);
119 void MapWindowIfNeeded(ForeignWindow* window);
120 void UnmapWindowIfNeeded(ForeignWindow* window);
121
122 void RecursiveConfigure(
123 aura::Window* window,
124 gfx::Vector2d offset,
125 ::Window* sibling_to_stack_above,
126 SkRegion* input_region);
127
128 // Configure of native windows.
129 void Configure();
130
131 // Schedule deferred configure of native windows.
132 void ScheduleConfigure(aura::Window* window);
133
134 aura::RootWindowHostDelegate* delegate_;
98 135
99 // The display and the native X window hosting the root window. 136 // The display and the native X window hosting the root window.
100 Display* xdisplay_; 137 Display* xdisplay_;
101 ::Window xwindow_; 138 ::Window xwindow_;
102 139
103 // The native root window. 140 // The native root window.
104 ::Window x_root_window_; 141 ::Window x_root_window_;
105 142
106 // Current Aura cursor. 143 // Current Aura cursor.
107 gfx::NativeCursor current_cursor_; 144 gfx::NativeCursor current_cursor_;
(...skipping 11 matching lines...) Expand all
119 bool focus_when_shown_; 156 bool focus_when_shown_;
120 157
121 scoped_ptr<XID[]> pointer_barriers_; 158 scoped_ptr<XID[]> pointer_barriers_;
122 159
123 scoped_ptr<internal::TouchEventCalibrate> touch_calibrate_; 160 scoped_ptr<internal::TouchEventCalibrate> touch_calibrate_;
124 161
125 scoped_ptr<MouseMoveFilter> mouse_move_filter_; 162 scoped_ptr<MouseMoveFilter> mouse_move_filter_;
126 163
127 ui::X11AtomCache atom_cache_; 164 ui::X11AtomCache atom_cache_;
128 165
166 ForeignWindowMap foreign_windows_;
167 aura::Window* configure_window_;
168
169 // The native input window.
170 ::Window x_input_window_;
171
172 // To ensure we set the default cursor for native windows.
173 bool need_to_set_default_cursor_;
174
129 DISALLOW_COPY_AND_ASSIGN(RootWindowHostLinux); 175 DISALLOW_COPY_AND_ASSIGN(RootWindowHostLinux);
130 }; 176 };
131 177
132 } // namespace aura 178 } // namespace wm
133 179
134 #endif // UI_AURA_ROOT_WINDOW_HOST_LINUX_H_ 180 #endif // WM_HOST_ROOT_WINDOW_HOST_LINUX_H_
OLDNEW
« no previous file with comments | « wm/host/root_window_host_factory_linux.cc ('k') | wm/host/root_window_host_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698