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/extensions/shape.h> | 7 #include <X11/extensions/shape.h> |
8 #include <X11/extensions/XInput2.h> | 8 #include <X11/extensions/XInput2.h> |
9 #include <X11/Xatom.h> | 9 #include <X11/Xatom.h> |
10 #include <X11/Xregion.h> | 10 #include <X11/Xregion.h> |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 void DesktopWindowTreeHostX11::AddObserver( | 215 void DesktopWindowTreeHostX11::AddObserver( |
216 views::DesktopWindowTreeHostObserverX11* observer) { | 216 views::DesktopWindowTreeHostObserverX11* observer) { |
217 observer_list_.AddObserver(observer); | 217 observer_list_.AddObserver(observer); |
218 } | 218 } |
219 | 219 |
220 void DesktopWindowTreeHostX11::RemoveObserver( | 220 void DesktopWindowTreeHostX11::RemoveObserver( |
221 views::DesktopWindowTreeHostObserverX11* observer) { | 221 views::DesktopWindowTreeHostObserverX11* observer) { |
222 observer_list_.RemoveObserver(observer); | 222 observer_list_.RemoveObserver(observer); |
223 } | 223 } |
224 | 224 |
| 225 void DesktopWindowTreeHostX11::SwapNonClientEventHandler( |
| 226 scoped_ptr<ui::EventHandler> handler) { |
| 227 wm::CompoundEventFilter* compound_event_filter = |
| 228 desktop_native_widget_aura_->root_window_event_filter(); |
| 229 if (x11_non_client_event_filter_) |
| 230 compound_event_filter->RemoveHandler(x11_non_client_event_filter_.get()); |
| 231 compound_event_filter->AddHandler(handler.get()); |
| 232 x11_non_client_event_filter_ = handler.Pass(); |
| 233 } |
| 234 |
225 void DesktopWindowTreeHostX11::CleanUpWindowList() { | 235 void DesktopWindowTreeHostX11::CleanUpWindowList() { |
226 delete open_windows_; | 236 delete open_windows_; |
227 open_windows_ = NULL; | 237 open_windows_ = NULL; |
228 } | 238 } |
229 | 239 |
230 //////////////////////////////////////////////////////////////////////////////// | 240 //////////////////////////////////////////////////////////////////////////////// |
231 // DesktopWindowTreeHostX11, DesktopWindowTreeHost implementation: | 241 // DesktopWindowTreeHostX11, DesktopWindowTreeHost implementation: |
232 | 242 |
233 void DesktopWindowTreeHostX11::Init(aura::Window* content_window, | 243 void DesktopWindowTreeHostX11::Init(aura::Window* content_window, |
234 const Widget::InitParams& params) { | 244 const Widget::InitParams& params) { |
(...skipping 16 matching lines...) Expand all Loading... |
251 void DesktopWindowTreeHostX11::OnNativeWidgetCreated( | 261 void DesktopWindowTreeHostX11::OnNativeWidgetCreated( |
252 const Widget::InitParams& params) { | 262 const Widget::InitParams& params) { |
253 window()->SetProperty(kViewsWindowForRootWindow, content_window_); | 263 window()->SetProperty(kViewsWindowForRootWindow, content_window_); |
254 window()->SetProperty(kHostForRootWindow, this); | 264 window()->SetProperty(kHostForRootWindow, this); |
255 | 265 |
256 // Ensure that the X11DesktopHandler exists so that it dispatches activation | 266 // Ensure that the X11DesktopHandler exists so that it dispatches activation |
257 // messages to us. | 267 // messages to us. |
258 X11DesktopHandler::get(); | 268 X11DesktopHandler::get(); |
259 | 269 |
260 // TODO(erg): Unify this code once the other consumer goes away. | 270 // TODO(erg): Unify this code once the other consumer goes away. |
261 x11_window_event_filter_.reset(new X11WindowEventFilter(this)); | 271 SwapNonClientEventHandler( |
| 272 scoped_ptr<ui::EventHandler>(new X11WindowEventFilter(this)).Pass()); |
262 SetUseNativeFrame(params.type == Widget::InitParams::TYPE_WINDOW && | 273 SetUseNativeFrame(params.type == Widget::InitParams::TYPE_WINDOW && |
263 !params.remove_standard_frame); | 274 !params.remove_standard_frame); |
264 desktop_native_widget_aura_->root_window_event_filter()->AddHandler( | |
265 x11_window_event_filter_.get()); | |
266 | 275 |
267 x11_window_move_client_.reset(new X11DesktopWindowMoveClient); | 276 x11_window_move_client_.reset(new X11DesktopWindowMoveClient); |
268 aura::client::SetWindowMoveClient(window(), x11_window_move_client_.get()); | 277 aura::client::SetWindowMoveClient(window(), x11_window_move_client_.get()); |
269 | 278 |
270 SetWindowTransparency(); | 279 SetWindowTransparency(); |
271 | 280 |
272 native_widget_delegate_->OnNativeWidgetCreated(true); | 281 native_widget_delegate_->OnNativeWidgetCreated(true); |
273 } | 282 } |
274 | 283 |
275 scoped_ptr<corewm::Tooltip> DesktopWindowTreeHostX11::CreateTooltip() { | 284 scoped_ptr<corewm::Tooltip> DesktopWindowTreeHostX11::CreateTooltip() { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 | 328 |
320 // If we have a parent, remove ourselves from its children list. | 329 // If we have a parent, remove ourselves from its children list. |
321 if (window_parent_) { | 330 if (window_parent_) { |
322 window_parent_->window_children_.erase(this); | 331 window_parent_->window_children_.erase(this); |
323 window_parent_ = NULL; | 332 window_parent_ = NULL; |
324 } | 333 } |
325 | 334 |
326 // Remove the event listeners we've installed. We need to remove these | 335 // Remove the event listeners we've installed. We need to remove these |
327 // because otherwise we get assert during ~WindowEventDispatcher(). | 336 // because otherwise we get assert during ~WindowEventDispatcher(). |
328 desktop_native_widget_aura_->root_window_event_filter()->RemoveHandler( | 337 desktop_native_widget_aura_->root_window_event_filter()->RemoveHandler( |
329 x11_window_event_filter_.get()); | 338 x11_non_client_event_filter_.get()); |
| 339 x11_non_client_event_filter_.reset(); |
330 | 340 |
331 // Destroy the compositor before destroying the |xwindow_| since shutdown | 341 // Destroy the compositor before destroying the |xwindow_| since shutdown |
332 // may try to swap, and the swap without a window causes an X error, which | 342 // may try to swap, and the swap without a window causes an X error, which |
333 // causes a crash with in-process renderer. | 343 // causes a crash with in-process renderer. |
334 DestroyCompositor(); | 344 DestroyCompositor(); |
335 | 345 |
336 open_windows().remove(xwindow_); | 346 open_windows().remove(xwindow_); |
337 // Actually free our native resources. | 347 // Actually free our native resources. |
338 if (ui::PlatformEventSource::GetInstance()) | 348 if (ui::PlatformEventSource::GetInstance()) |
339 ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); | 349 ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); |
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1264 &xclient); | 1274 &xclient); |
1265 } | 1275 } |
1266 | 1276 |
1267 bool DesktopWindowTreeHostX11::HasWMSpecProperty(const char* property) const { | 1277 bool DesktopWindowTreeHostX11::HasWMSpecProperty(const char* property) const { |
1268 return window_properties_.find(atom_cache_.GetAtom(property)) != | 1278 return window_properties_.find(atom_cache_.GetAtom(property)) != |
1269 window_properties_.end(); | 1279 window_properties_.end(); |
1270 } | 1280 } |
1271 | 1281 |
1272 void DesktopWindowTreeHostX11::SetUseNativeFrame(bool use_native_frame) { | 1282 void DesktopWindowTreeHostX11::SetUseNativeFrame(bool use_native_frame) { |
1273 use_native_frame_ = use_native_frame; | 1283 use_native_frame_ = use_native_frame; |
1274 x11_window_event_filter_->SetUseHostWindowBorders(use_native_frame); | 1284 ui::SetUseOSWindowFrame(xwindow_, use_native_frame); |
1275 ResetWindowRegion(); | 1285 ResetWindowRegion(); |
1276 } | 1286 } |
1277 | 1287 |
1278 void DesktopWindowTreeHostX11::OnCaptureReleased() { | 1288 void DesktopWindowTreeHostX11::OnCaptureReleased() { |
1279 x11_capture_.reset(); | 1289 x11_capture_.reset(); |
1280 g_current_capture = NULL; | 1290 g_current_capture = NULL; |
1281 OnHostLostWindowCapture(); | 1291 OnHostLostWindowCapture(); |
1282 native_widget_delegate_->OnMouseCaptureLost(); | 1292 native_widget_delegate_->OnMouseCaptureLost(); |
1283 } | 1293 } |
1284 | 1294 |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1767 if (linux_ui) { | 1777 if (linux_ui) { |
1768 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); | 1778 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); |
1769 if (native_theme) | 1779 if (native_theme) |
1770 return native_theme; | 1780 return native_theme; |
1771 } | 1781 } |
1772 | 1782 |
1773 return ui::NativeTheme::instance(); | 1783 return ui::NativeTheme::instance(); |
1774 } | 1784 } |
1775 | 1785 |
1776 } // namespace views | 1786 } // namespace views |
OLD | NEW |