| 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 return windows; | 176 return windows; |
| 177 } | 177 } |
| 178 | 178 |
| 179 gfx::Rect DesktopWindowTreeHostX11::GetX11RootWindowBounds() const { | 179 gfx::Rect DesktopWindowTreeHostX11::GetX11RootWindowBounds() const { |
| 180 return bounds_; | 180 return bounds_; |
| 181 } | 181 } |
| 182 | 182 |
| 183 void DesktopWindowTreeHostX11::HandleNativeWidgetActivationChanged( | 183 void DesktopWindowTreeHostX11::HandleNativeWidgetActivationChanged( |
| 184 bool active) { | 184 bool active) { |
| 185 if (active) { | 185 if (active) { |
| 186 OnHostActivated(); | 186 delegate_->OnHostActivated(); |
| 187 open_windows().remove(xwindow_); | 187 open_windows().remove(xwindow_); |
| 188 open_windows().insert(open_windows().begin(), xwindow_); | 188 open_windows().insert(open_windows().begin(), xwindow_); |
| 189 } | 189 } |
| 190 | 190 |
| 191 desktop_native_widget_aura_->HandleActivationChanged(active); | 191 desktop_native_widget_aura_->HandleActivationChanged(active); |
| 192 | 192 |
| 193 native_widget_delegate_->AsWidget()->GetRootView()->SchedulePaint(); | 193 native_widget_delegate_->AsWidget()->GetRootView()->SchedulePaint(); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void DesktopWindowTreeHostX11::AddObserver( | 196 void DesktopWindowTreeHostX11::AddObserver( |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 } | 230 } |
| 231 | 231 |
| 232 void DesktopWindowTreeHostX11::OnRootWindowCreated( | 232 void DesktopWindowTreeHostX11::OnRootWindowCreated( |
| 233 aura::WindowEventDispatcher* dispatcher, | 233 aura::WindowEventDispatcher* dispatcher, |
| 234 const Widget::InitParams& params) { | 234 const Widget::InitParams& params) { |
| 235 dispatcher_ = dispatcher; | 235 dispatcher_ = dispatcher; |
| 236 | 236 |
| 237 dispatcher_->window()->SetProperty(kViewsWindowForRootWindow, | 237 dispatcher_->window()->SetProperty(kViewsWindowForRootWindow, |
| 238 content_window_); | 238 content_window_); |
| 239 dispatcher_->window()->SetProperty(kHostForRootWindow, this); | 239 dispatcher_->window()->SetProperty(kHostForRootWindow, this); |
| 240 delegate_ = dispatcher_; |
| 240 | 241 |
| 241 // If we're given a parent, we need to mark ourselves as transient to another | 242 // If we're given a parent, we need to mark ourselves as transient to another |
| 242 // window. Otherwise activation gets screwy. | 243 // window. Otherwise activation gets screwy. |
| 243 gfx::NativeView parent = params.parent; | 244 gfx::NativeView parent = params.parent; |
| 244 if (!params.child && params.parent) { | 245 if (!params.child && params.parent) { |
| 245 corewm::AddTransientChild(parent, content_window_); | 246 corewm::AddTransientChild(parent, content_window_); |
| 246 } | 247 } |
| 247 | 248 |
| 248 // Ensure that the X11DesktopHandler exists so that it dispatches activation | 249 // Ensure that the X11DesktopHandler exists so that it dispatches activation |
| 249 // messages to us. | 250 // messages to us. |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 float device_scale_factor) { | 920 float device_scale_factor) { |
| 920 } | 921 } |
| 921 | 922 |
| 922 void DesktopWindowTreeHostX11::PrepareForShutdown() { | 923 void DesktopWindowTreeHostX11::PrepareForShutdown() { |
| 923 } | 924 } |
| 924 | 925 |
| 925 //////////////////////////////////////////////////////////////////////////////// | 926 //////////////////////////////////////////////////////////////////////////////// |
| 926 // DesktopWindowTreeHostX11, ui::EventSource implementation: | 927 // DesktopWindowTreeHostX11, ui::EventSource implementation: |
| 927 | 928 |
| 928 ui::EventProcessor* DesktopWindowTreeHostX11::GetEventProcessor() { | 929 ui::EventProcessor* DesktopWindowTreeHostX11::GetEventProcessor() { |
| 929 return dispatcher(); | 930 return delegate_->GetEventProcessor(); |
| 930 } | 931 } |
| 931 | 932 |
| 932 //////////////////////////////////////////////////////////////////////////////// | 933 //////////////////////////////////////////////////////////////////////////////// |
| 933 // DesktopWindowTreeHostX11, private: | 934 // DesktopWindowTreeHostX11, private: |
| 934 | 935 |
| 935 void DesktopWindowTreeHostX11::InitX11Window( | 936 void DesktopWindowTreeHostX11::InitX11Window( |
| 936 const Widget::InitParams& params) { | 937 const Widget::InitParams& params) { |
| 937 unsigned long attribute_mask = CWBackPixmap; | 938 unsigned long attribute_mask = CWBackPixmap; |
| 938 XSetWindowAttributes swa; | 939 XSetWindowAttributes swa; |
| 939 memset(&swa, 0, sizeof(swa)); | 940 memset(&swa, 0, sizeof(swa)); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1127 } | 1128 } |
| 1128 | 1129 |
| 1129 void DesktopWindowTreeHostX11::SetUseNativeFrame(bool use_native_frame) { | 1130 void DesktopWindowTreeHostX11::SetUseNativeFrame(bool use_native_frame) { |
| 1130 use_native_frame_ = use_native_frame; | 1131 use_native_frame_ = use_native_frame; |
| 1131 x11_window_event_filter_->SetUseHostWindowBorders(use_native_frame); | 1132 x11_window_event_filter_->SetUseHostWindowBorders(use_native_frame); |
| 1132 } | 1133 } |
| 1133 | 1134 |
| 1134 void DesktopWindowTreeHostX11::OnCaptureReleased() { | 1135 void DesktopWindowTreeHostX11::OnCaptureReleased() { |
| 1135 x11_capture_.reset(); | 1136 x11_capture_.reset(); |
| 1136 g_current_capture = NULL; | 1137 g_current_capture = NULL; |
| 1137 OnHostLostWindowCapture(); | 1138 delegate_->OnHostLostWindowCapture(); |
| 1138 native_widget_delegate_->OnMouseCaptureLost(); | 1139 native_widget_delegate_->OnMouseCaptureLost(); |
| 1139 } | 1140 } |
| 1140 | 1141 |
| 1141 void DesktopWindowTreeHostX11::DispatchMouseEvent(ui::MouseEvent* event) { | 1142 void DesktopWindowTreeHostX11::DispatchMouseEvent(ui::MouseEvent* event) { |
| 1142 if (!g_current_capture || g_current_capture == this) { | 1143 if (!g_current_capture || g_current_capture == this) { |
| 1143 SendEventToProcessor(event); | 1144 SendEventToProcessor(event); |
| 1144 } else { | 1145 } else { |
| 1145 // Another DesktopWindowTreeHostX11 has installed itself as | 1146 // Another DesktopWindowTreeHostX11 has installed itself as |
| 1146 // capture. Translate the event's location and dispatch to the other. | 1147 // capture. Translate the event's location and dispatch to the other. |
| 1147 event->ConvertLocationToTarget(dispatcher_->window(), | 1148 event->ConvertLocationToTarget(dispatcher_->window(), |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1340 // No event is created for X11-release events for mouse-wheel buttons. | 1341 // No event is created for X11-release events for mouse-wheel buttons. |
| 1341 break; | 1342 break; |
| 1342 default: | 1343 default: |
| 1343 NOTREACHED() << event_type; | 1344 NOTREACHED() << event_type; |
| 1344 } | 1345 } |
| 1345 break; | 1346 break; |
| 1346 } | 1347 } |
| 1347 case FocusOut: | 1348 case FocusOut: |
| 1348 if (xev->xfocus.mode != NotifyGrab) { | 1349 if (xev->xfocus.mode != NotifyGrab) { |
| 1349 ReleaseCapture(); | 1350 ReleaseCapture(); |
| 1350 OnHostLostWindowCapture(); | 1351 delegate_->OnHostLostWindowCapture(); |
| 1351 } else { | 1352 } else { |
| 1352 dispatcher()->OnHostLostMouseGrab(); | 1353 delegate_->OnHostLostMouseGrab(); |
| 1353 } | 1354 } |
| 1354 break; | 1355 break; |
| 1355 case FocusIn: | 1356 case FocusIn: |
| 1356 X11DesktopHandler::get()->ProcessXEvent(xev); | 1357 X11DesktopHandler::get()->ProcessXEvent(xev); |
| 1357 break; | 1358 break; |
| 1358 case ConfigureNotify: { | 1359 case ConfigureNotify: { |
| 1359 DCHECK_EQ(xwindow_, xev->xconfigure.window); | 1360 DCHECK_EQ(xwindow_, xev->xconfigure.window); |
| 1360 DCHECK_EQ(xwindow_, xev->xconfigure.event); | 1361 DCHECK_EQ(xwindow_, xev->xconfigure.event); |
| 1361 // It's possible that the X window may be resized by some other means than | 1362 // It's possible that the X window may be resized by some other means than |
| 1362 // from within aura (e.g. the X window manager can change the size). Make | 1363 // from within aura (e.g. the X window manager can change the size). Make |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1413 // events that are at the top of the queue. | 1414 // events that are at the top of the queue. |
| 1414 num_coalesced = ui::CoalescePendingMotionEvents(xev, &last_event); | 1415 num_coalesced = ui::CoalescePendingMotionEvents(xev, &last_event); |
| 1415 if (num_coalesced > 0) | 1416 if (num_coalesced > 0) |
| 1416 xev = &last_event; | 1417 xev = &last_event; |
| 1417 } else if (type == ui::ET_MOUSE_PRESSED) { | 1418 } else if (type == ui::ET_MOUSE_PRESSED) { |
| 1418 XIDeviceEvent* xievent = | 1419 XIDeviceEvent* xievent = |
| 1419 static_cast<XIDeviceEvent*>(xev->xcookie.data); | 1420 static_cast<XIDeviceEvent*>(xev->xcookie.data); |
| 1420 int button = xievent->detail; | 1421 int button = xievent->detail; |
| 1421 if (button == kBackMouseButton || button == kForwardMouseButton) { | 1422 if (button == kBackMouseButton || button == kForwardMouseButton) { |
| 1422 aura::client::UserActionClient* gesture_client = | 1423 aura::client::UserActionClient* gesture_client = |
| 1423 aura::client::GetUserActionClient(window()); | 1424 aura::client::GetUserActionClient( |
| 1425 delegate_->AsDispatcher()->window()); |
| 1424 if (gesture_client) { | 1426 if (gesture_client) { |
| 1425 bool reverse_direction = | 1427 bool reverse_direction = |
| 1426 ui::IsTouchpadEvent(xev) && ui::IsNaturalScrollEnabled(); | 1428 ui::IsTouchpadEvent(xev) && ui::IsNaturalScrollEnabled(); |
| 1427 gesture_client->OnUserAction( | 1429 gesture_client->OnUserAction( |
| 1428 (button == kBackMouseButton && !reverse_direction) || | 1430 (button == kBackMouseButton && !reverse_direction) || |
| 1429 (button == kForwardMouseButton && reverse_direction) ? | 1431 (button == kForwardMouseButton && reverse_direction) ? |
| 1430 aura::client::UserActionClient::BACK : | 1432 aura::client::UserActionClient::BACK : |
| 1431 aura::client::UserActionClient::FORWARD); | 1433 aura::client::UserActionClient::FORWARD); |
| 1432 } | 1434 } |
| 1433 break; | 1435 break; |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1625 if (linux_ui) { | 1627 if (linux_ui) { |
| 1626 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(); | 1628 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(); |
| 1627 if (native_theme) | 1629 if (native_theme) |
| 1628 return native_theme; | 1630 return native_theme; |
| 1629 } | 1631 } |
| 1630 | 1632 |
| 1631 return ui::NativeTheme::instance(); | 1633 return ui::NativeTheme::instance(); |
| 1632 } | 1634 } |
| 1633 | 1635 |
| 1634 } // namespace views | 1636 } // namespace views |
| OLD | NEW |