| 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 return windows; | 171 return windows; |
| 172 } | 172 } |
| 173 | 173 |
| 174 gfx::Rect DesktopWindowTreeHostX11::GetX11RootWindowBounds() const { | 174 gfx::Rect DesktopWindowTreeHostX11::GetX11RootWindowBounds() const { |
| 175 return bounds_; | 175 return bounds_; |
| 176 } | 176 } |
| 177 | 177 |
| 178 void DesktopWindowTreeHostX11::HandleNativeWidgetActivationChanged( | 178 void DesktopWindowTreeHostX11::HandleNativeWidgetActivationChanged( |
| 179 bool active) { | 179 bool active) { |
| 180 if (active) { | 180 if (active) { |
| 181 delegate_->OnHostActivated(); | 181 OnHostActivated(); |
| 182 open_windows().remove(xwindow_); | 182 open_windows().remove(xwindow_); |
| 183 open_windows().insert(open_windows().begin(), xwindow_); | 183 open_windows().insert(open_windows().begin(), xwindow_); |
| 184 } | 184 } |
| 185 | 185 |
| 186 desktop_native_widget_aura_->HandleActivationChanged(active); | 186 desktop_native_widget_aura_->HandleActivationChanged(active); |
| 187 | 187 |
| 188 native_widget_delegate_->AsWidget()->GetRootView()->SchedulePaint(); | 188 native_widget_delegate_->AsWidget()->GetRootView()->SchedulePaint(); |
| 189 } | 189 } |
| 190 | 190 |
| 191 void DesktopWindowTreeHostX11::AddObserver( | 191 void DesktopWindowTreeHostX11::AddObserver( |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 } | 225 } |
| 226 | 226 |
| 227 void DesktopWindowTreeHostX11::OnRootWindowCreated( | 227 void DesktopWindowTreeHostX11::OnRootWindowCreated( |
| 228 aura::WindowEventDispatcher* dispatcher, | 228 aura::WindowEventDispatcher* dispatcher, |
| 229 const Widget::InitParams& params) { | 229 const Widget::InitParams& params) { |
| 230 dispatcher_ = dispatcher; | 230 dispatcher_ = dispatcher; |
| 231 | 231 |
| 232 dispatcher_->window()->SetProperty(kViewsWindowForRootWindow, | 232 dispatcher_->window()->SetProperty(kViewsWindowForRootWindow, |
| 233 content_window_); | 233 content_window_); |
| 234 dispatcher_->window()->SetProperty(kHostForRootWindow, this); | 234 dispatcher_->window()->SetProperty(kHostForRootWindow, this); |
| 235 delegate_ = dispatcher_; | |
| 236 | 235 |
| 237 // Ensure that the X11DesktopHandler exists so that it dispatches activation | 236 // Ensure that the X11DesktopHandler exists so that it dispatches activation |
| 238 // messages to us. | 237 // messages to us. |
| 239 X11DesktopHandler::get(); | 238 X11DesktopHandler::get(); |
| 240 | 239 |
| 241 // TODO(erg): Unify this code once the other consumer goes away. | 240 // TODO(erg): Unify this code once the other consumer goes away. |
| 242 x11_window_event_filter_.reset(new X11WindowEventFilter(dispatcher_, this)); | 241 x11_window_event_filter_.reset(new X11WindowEventFilter(dispatcher_, this)); |
| 243 SetUseNativeFrame(params.type == Widget::InitParams::TYPE_WINDOW && | 242 SetUseNativeFrame(params.type == Widget::InitParams::TYPE_WINDOW && |
| 244 !params.remove_standard_frame); | 243 !params.remove_standard_frame); |
| 245 desktop_native_widget_aura_->root_window_event_filter()->AddHandler( | 244 desktop_native_widget_aura_->root_window_event_filter()->AddHandler( |
| (...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 float device_scale_factor) { | 907 float device_scale_factor) { |
| 909 } | 908 } |
| 910 | 909 |
| 911 void DesktopWindowTreeHostX11::PrepareForShutdown() { | 910 void DesktopWindowTreeHostX11::PrepareForShutdown() { |
| 912 } | 911 } |
| 913 | 912 |
| 914 //////////////////////////////////////////////////////////////////////////////// | 913 //////////////////////////////////////////////////////////////////////////////// |
| 915 // DesktopWindowTreeHostX11, ui::EventSource implementation: | 914 // DesktopWindowTreeHostX11, ui::EventSource implementation: |
| 916 | 915 |
| 917 ui::EventProcessor* DesktopWindowTreeHostX11::GetEventProcessor() { | 916 ui::EventProcessor* DesktopWindowTreeHostX11::GetEventProcessor() { |
| 918 return delegate_->GetEventProcessor(); | 917 return dispatcher(); |
| 919 } | 918 } |
| 920 | 919 |
| 921 //////////////////////////////////////////////////////////////////////////////// | 920 //////////////////////////////////////////////////////////////////////////////// |
| 922 // DesktopWindowTreeHostX11, private: | 921 // DesktopWindowTreeHostX11, private: |
| 923 | 922 |
| 924 void DesktopWindowTreeHostX11::InitX11Window( | 923 void DesktopWindowTreeHostX11::InitX11Window( |
| 925 const Widget::InitParams& params) { | 924 const Widget::InitParams& params) { |
| 926 unsigned long attribute_mask = CWBackPixmap; | 925 unsigned long attribute_mask = CWBackPixmap; |
| 927 XSetWindowAttributes swa; | 926 XSetWindowAttributes swa; |
| 928 memset(&swa, 0, sizeof(swa)); | 927 memset(&swa, 0, sizeof(swa)); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1116 } | 1115 } |
| 1117 | 1116 |
| 1118 void DesktopWindowTreeHostX11::SetUseNativeFrame(bool use_native_frame) { | 1117 void DesktopWindowTreeHostX11::SetUseNativeFrame(bool use_native_frame) { |
| 1119 use_native_frame_ = use_native_frame; | 1118 use_native_frame_ = use_native_frame; |
| 1120 x11_window_event_filter_->SetUseHostWindowBorders(use_native_frame); | 1119 x11_window_event_filter_->SetUseHostWindowBorders(use_native_frame); |
| 1121 } | 1120 } |
| 1122 | 1121 |
| 1123 void DesktopWindowTreeHostX11::OnCaptureReleased() { | 1122 void DesktopWindowTreeHostX11::OnCaptureReleased() { |
| 1124 x11_capture_.reset(); | 1123 x11_capture_.reset(); |
| 1125 g_current_capture = NULL; | 1124 g_current_capture = NULL; |
| 1126 delegate_->OnHostLostWindowCapture(); | 1125 OnHostLostWindowCapture(); |
| 1127 native_widget_delegate_->OnMouseCaptureLost(); | 1126 native_widget_delegate_->OnMouseCaptureLost(); |
| 1128 } | 1127 } |
| 1129 | 1128 |
| 1130 void DesktopWindowTreeHostX11::DispatchMouseEvent(ui::MouseEvent* event) { | 1129 void DesktopWindowTreeHostX11::DispatchMouseEvent(ui::MouseEvent* event) { |
| 1131 if (!g_current_capture || g_current_capture == this) { | 1130 if (!g_current_capture || g_current_capture == this) { |
| 1132 SendEventToProcessor(event); | 1131 SendEventToProcessor(event); |
| 1133 } else { | 1132 } else { |
| 1134 // Another DesktopWindowTreeHostX11 has installed itself as | 1133 // Another DesktopWindowTreeHostX11 has installed itself as |
| 1135 // capture. Translate the event's location and dispatch to the other. | 1134 // capture. Translate the event's location and dispatch to the other. |
| 1136 event->ConvertLocationToTarget(dispatcher_->window(), | 1135 event->ConvertLocationToTarget(dispatcher_->window(), |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1316 // No event is created for X11-release events for mouse-wheel buttons. | 1315 // No event is created for X11-release events for mouse-wheel buttons. |
| 1317 break; | 1316 break; |
| 1318 default: | 1317 default: |
| 1319 NOTREACHED() << event_type; | 1318 NOTREACHED() << event_type; |
| 1320 } | 1319 } |
| 1321 break; | 1320 break; |
| 1322 } | 1321 } |
| 1323 case FocusOut: | 1322 case FocusOut: |
| 1324 if (xev->xfocus.mode != NotifyGrab) { | 1323 if (xev->xfocus.mode != NotifyGrab) { |
| 1325 ReleaseCapture(); | 1324 ReleaseCapture(); |
| 1326 delegate_->OnHostLostWindowCapture(); | 1325 OnHostLostWindowCapture(); |
| 1327 } else { | 1326 } else { |
| 1328 delegate_->OnHostLostMouseGrab(); | 1327 dispatcher()->OnHostLostMouseGrab(); |
| 1329 } | 1328 } |
| 1330 break; | 1329 break; |
| 1331 case FocusIn: | 1330 case FocusIn: |
| 1332 X11DesktopHandler::get()->ProcessXEvent(xev); | 1331 X11DesktopHandler::get()->ProcessXEvent(xev); |
| 1333 break; | 1332 break; |
| 1334 case ConfigureNotify: { | 1333 case ConfigureNotify: { |
| 1335 DCHECK_EQ(xwindow_, xev->xconfigure.window); | 1334 DCHECK_EQ(xwindow_, xev->xconfigure.window); |
| 1336 DCHECK_EQ(xwindow_, xev->xconfigure.event); | 1335 DCHECK_EQ(xwindow_, xev->xconfigure.event); |
| 1337 // It's possible that the X window may be resized by some other means than | 1336 // It's possible that the X window may be resized by some other means than |
| 1338 // from within aura (e.g. the X window manager can change the size). Make | 1337 // from within aura (e.g. the X window manager can change the size). Make |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1574 if (linux_ui) { | 1573 if (linux_ui) { |
| 1575 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(); | 1574 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(); |
| 1576 if (native_theme) | 1575 if (native_theme) |
| 1577 return native_theme; | 1576 return native_theme; |
| 1578 } | 1577 } |
| 1579 | 1578 |
| 1580 return ui::NativeTheme::instance(); | 1579 return ui::NativeTheme::instance(); |
| 1581 } | 1580 } |
| 1582 | 1581 |
| 1583 } // namespace views | 1582 } // namespace views |
| OLD | NEW |