OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" | 5 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" |
6 | 6 |
7 #include <X11/Xatom.h> | 7 #include <X11/Xatom.h> |
8 #include <X11/Xregion.h> | 8 #include <X11/Xregion.h> |
9 #include <X11/Xutil.h> | 9 #include <X11/Xutil.h> |
10 #include <X11/extensions/XInput2.h> | 10 #include <X11/extensions/XInput2.h> |
11 #include <X11/extensions/shape.h> | 11 #include <X11/extensions/shape.h> |
| 12 |
12 #include <utility> | 13 #include <utility> |
13 | 14 |
14 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/memory/ptr_util.h" |
15 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
16 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
17 #include "base/trace_event/trace_event.h" | 19 #include "base/trace_event/trace_event.h" |
18 #include "third_party/skia/include/core/SkPath.h" | 20 #include "third_party/skia/include/core/SkPath.h" |
19 #include "ui/aura/client/cursor_client.h" | 21 #include "ui/aura/client/cursor_client.h" |
20 #include "ui/aura/client/focus_client.h" | 22 #include "ui/aura/client/focus_client.h" |
21 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
22 #include "ui/aura/window_event_dispatcher.h" | 24 #include "ui/aura/window_event_dispatcher.h" |
23 #include "ui/aura/window_property.h" | 25 #include "ui/aura/window_property.h" |
24 #include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h" | 26 #include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h" |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 views::DesktopWindowTreeHostObserverX11* observer) { | 245 views::DesktopWindowTreeHostObserverX11* observer) { |
244 observer_list_.AddObserver(observer); | 246 observer_list_.AddObserver(observer); |
245 } | 247 } |
246 | 248 |
247 void DesktopWindowTreeHostX11::RemoveObserver( | 249 void DesktopWindowTreeHostX11::RemoveObserver( |
248 views::DesktopWindowTreeHostObserverX11* observer) { | 250 views::DesktopWindowTreeHostObserverX11* observer) { |
249 observer_list_.RemoveObserver(observer); | 251 observer_list_.RemoveObserver(observer); |
250 } | 252 } |
251 | 253 |
252 void DesktopWindowTreeHostX11::SwapNonClientEventHandler( | 254 void DesktopWindowTreeHostX11::SwapNonClientEventHandler( |
253 scoped_ptr<ui::EventHandler> handler) { | 255 std::unique_ptr<ui::EventHandler> handler) { |
254 wm::CompoundEventFilter* compound_event_filter = | 256 wm::CompoundEventFilter* compound_event_filter = |
255 desktop_native_widget_aura_->root_window_event_filter(); | 257 desktop_native_widget_aura_->root_window_event_filter(); |
256 if (x11_non_client_event_filter_) | 258 if (x11_non_client_event_filter_) |
257 compound_event_filter->RemoveHandler(x11_non_client_event_filter_.get()); | 259 compound_event_filter->RemoveHandler(x11_non_client_event_filter_.get()); |
258 compound_event_filter->AddHandler(handler.get()); | 260 compound_event_filter->AddHandler(handler.get()); |
259 x11_non_client_event_filter_ = std::move(handler); | 261 x11_non_client_event_filter_ = std::move(handler); |
260 } | 262 } |
261 | 263 |
262 void DesktopWindowTreeHostX11::CleanUpWindowList( | 264 void DesktopWindowTreeHostX11::CleanUpWindowList( |
263 void (*func)(aura::Window* window)) { | 265 void (*func)(aura::Window* window)) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 const Widget::InitParams& params) { | 302 const Widget::InitParams& params) { |
301 window()->SetProperty(kViewsWindowForRootWindow, content_window_); | 303 window()->SetProperty(kViewsWindowForRootWindow, content_window_); |
302 window()->SetProperty(kHostForRootWindow, this); | 304 window()->SetProperty(kHostForRootWindow, this); |
303 | 305 |
304 // Ensure that the X11DesktopHandler exists so that it dispatches activation | 306 // Ensure that the X11DesktopHandler exists so that it dispatches activation |
305 // messages to us. | 307 // messages to us. |
306 X11DesktopHandler::get(); | 308 X11DesktopHandler::get(); |
307 | 309 |
308 // TODO(erg): Unify this code once the other consumer goes away. | 310 // TODO(erg): Unify this code once the other consumer goes away. |
309 SwapNonClientEventHandler( | 311 SwapNonClientEventHandler( |
310 scoped_ptr<ui::EventHandler>(new X11WindowEventFilter(this))); | 312 std::unique_ptr<ui::EventHandler>(new X11WindowEventFilter(this))); |
311 SetUseNativeFrame(params.type == Widget::InitParams::TYPE_WINDOW && | 313 SetUseNativeFrame(params.type == Widget::InitParams::TYPE_WINDOW && |
312 !params.remove_standard_frame); | 314 !params.remove_standard_frame); |
313 | 315 |
314 x11_window_move_client_.reset(new X11DesktopWindowMoveClient); | 316 x11_window_move_client_.reset(new X11DesktopWindowMoveClient); |
315 aura::client::SetWindowMoveClient(window(), x11_window_move_client_.get()); | 317 aura::client::SetWindowMoveClient(window(), x11_window_move_client_.get()); |
316 | 318 |
317 SetWindowTransparency(); | 319 SetWindowTransparency(); |
318 | 320 |
319 native_widget_delegate_->OnNativeWidgetCreated(true); | 321 native_widget_delegate_->OnNativeWidgetCreated(true); |
320 } | 322 } |
321 | 323 |
322 scoped_ptr<corewm::Tooltip> DesktopWindowTreeHostX11::CreateTooltip() { | 324 std::unique_ptr<corewm::Tooltip> DesktopWindowTreeHostX11::CreateTooltip() { |
323 return make_scoped_ptr(new corewm::TooltipAura); | 325 return base::WrapUnique(new corewm::TooltipAura); |
324 } | 326 } |
325 | 327 |
326 scoped_ptr<aura::client::DragDropClient> | 328 std::unique_ptr<aura::client::DragDropClient> |
327 DesktopWindowTreeHostX11::CreateDragDropClient( | 329 DesktopWindowTreeHostX11::CreateDragDropClient( |
328 DesktopNativeCursorManager* cursor_manager) { | 330 DesktopNativeCursorManager* cursor_manager) { |
329 drag_drop_client_ = new DesktopDragDropClientAuraX11( | 331 drag_drop_client_ = new DesktopDragDropClientAuraX11( |
330 window(), cursor_manager, xdisplay_, xwindow_); | 332 window(), cursor_manager, xdisplay_, xwindow_); |
331 drag_drop_client_->Init(); | 333 drag_drop_client_->Init(); |
332 return make_scoped_ptr(drag_drop_client_); | 334 return base::WrapUnique(drag_drop_client_); |
333 } | 335 } |
334 | 336 |
335 void DesktopWindowTreeHostX11::Close() { | 337 void DesktopWindowTreeHostX11::Close() { |
336 // TODO(erg): Might need to do additional hiding tasks here. | 338 // TODO(erg): Might need to do additional hiding tasks here. |
337 delayed_resize_task_.Cancel(); | 339 delayed_resize_task_.Cancel(); |
338 | 340 |
339 if (!close_widget_factory_.HasWeakPtrs()) { | 341 if (!close_widget_factory_.HasWeakPtrs()) { |
340 // And we delay the close so that if we are called from an ATL callback, | 342 // And we delay the close so that if we are called from an ATL callback, |
341 // we don't destroy the window before the callback returned (as the caller | 343 // we don't destroy the window before the callback returned (as the caller |
342 // may delete ourselves on destroy and the ATL callback would still | 344 // may delete ourselves on destroy and the ATL callback would still |
(...skipping 1692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2035 if (linux_ui) { | 2037 if (linux_ui) { |
2036 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); | 2038 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); |
2037 if (native_theme) | 2039 if (native_theme) |
2038 return native_theme; | 2040 return native_theme; |
2039 } | 2041 } |
2040 | 2042 |
2041 return ui::NativeThemeAura::instance(); | 2043 return ui::NativeThemeAura::instance(); |
2042 } | 2044 } |
2043 | 2045 |
2044 } // namespace views | 2046 } // namespace views |
OLD | NEW |