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_root_window_host_x11.h" | 5 #include "ui/views/widget/desktop_aura/desktop_root_window_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 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 } | 910 } |
911 | 911 |
912 void DesktopWindowTreeHostX11::OnDeviceScaleFactorChanged( | 912 void DesktopWindowTreeHostX11::OnDeviceScaleFactorChanged( |
913 float device_scale_factor) { | 913 float device_scale_factor) { |
914 } | 914 } |
915 | 915 |
916 void DesktopWindowTreeHostX11::PrepareForShutdown() { | 916 void DesktopWindowTreeHostX11::PrepareForShutdown() { |
917 } | 917 } |
918 | 918 |
919 //////////////////////////////////////////////////////////////////////////////// | 919 //////////////////////////////////////////////////////////////////////////////// |
| 920 // DesktopWindowTreeHostX11, ui::EventSource implementation: |
| 921 |
| 922 ui::EventProcessor* DesktopWindowTreeHostX11::GetEventProcessor() { |
| 923 return delegate_->GetEventProcessor(); |
| 924 } |
| 925 |
| 926 //////////////////////////////////////////////////////////////////////////////// |
920 // DesktopWindowTreeHostX11, private: | 927 // DesktopWindowTreeHostX11, private: |
921 | 928 |
922 void DesktopWindowTreeHostX11::InitX11Window( | 929 void DesktopWindowTreeHostX11::InitX11Window( |
923 const Widget::InitParams& params) { | 930 const Widget::InitParams& params) { |
924 unsigned long attribute_mask = CWBackPixmap; | 931 unsigned long attribute_mask = CWBackPixmap; |
925 XSetWindowAttributes swa; | 932 XSetWindowAttributes swa; |
926 memset(&swa, 0, sizeof(swa)); | 933 memset(&swa, 0, sizeof(swa)); |
927 swa.background_pixmap = None; | 934 swa.background_pixmap = None; |
928 | 935 |
929 ::Atom window_type; | 936 ::Atom window_type; |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1105 | 1112 |
1106 void DesktopWindowTreeHostX11::OnCaptureReleased() { | 1113 void DesktopWindowTreeHostX11::OnCaptureReleased() { |
1107 x11_capture_.reset(); | 1114 x11_capture_.reset(); |
1108 g_current_capture = NULL; | 1115 g_current_capture = NULL; |
1109 delegate_->OnHostLostWindowCapture(); | 1116 delegate_->OnHostLostWindowCapture(); |
1110 native_widget_delegate_->OnMouseCaptureLost(); | 1117 native_widget_delegate_->OnMouseCaptureLost(); |
1111 } | 1118 } |
1112 | 1119 |
1113 void DesktopWindowTreeHostX11::DispatchMouseEvent(ui::MouseEvent* event) { | 1120 void DesktopWindowTreeHostX11::DispatchMouseEvent(ui::MouseEvent* event) { |
1114 if (!g_current_capture || g_current_capture == this) { | 1121 if (!g_current_capture || g_current_capture == this) { |
1115 delegate_->OnHostMouseEvent(event); | 1122 SendEventToProcessor(event); |
1116 } else { | 1123 } else { |
1117 // Another DesktopWindowTreeHostX11 has installed itself as | 1124 // Another DesktopWindowTreeHostX11 has installed itself as |
1118 // capture. Translate the event's location and dispatch to the other. | 1125 // capture. Translate the event's location and dispatch to the other. |
1119 event->ConvertLocationToTarget(root_window_->window(), | 1126 event->ConvertLocationToTarget(root_window_->window(), |
1120 g_current_capture->root_window_->window()); | 1127 g_current_capture->root_window_->window()); |
1121 g_current_capture->delegate_->OnHostMouseEvent(event); | 1128 g_current_capture->SendEventToProcessor(event); |
1122 } | 1129 } |
1123 } | 1130 } |
1124 | 1131 |
1125 void DesktopWindowTreeHostX11::DispatchTouchEvent(ui::TouchEvent* event) { | 1132 void DesktopWindowTreeHostX11::DispatchTouchEvent(ui::TouchEvent* event) { |
1126 if (g_current_capture && g_current_capture != this && | 1133 if (g_current_capture && g_current_capture != this && |
1127 event->type() == ui::ET_TOUCH_PRESSED) { | 1134 event->type() == ui::ET_TOUCH_PRESSED) { |
1128 event->ConvertLocationToTarget(root_window_->window(), | 1135 event->ConvertLocationToTarget(root_window_->window(), |
1129 g_current_capture->root_window_->window()); | 1136 g_current_capture->root_window_->window()); |
1130 g_current_capture->delegate_->OnHostTouchEvent(event); | 1137 g_current_capture->SendEventToProcessor(event); |
1131 } else { | 1138 } else { |
1132 delegate_->OnHostTouchEvent(event); | 1139 SendEventToProcessor(event); |
1133 } | 1140 } |
1134 } | 1141 } |
1135 | 1142 |
1136 void DesktopWindowTreeHostX11::ResetWindowRegion() { | 1143 void DesktopWindowTreeHostX11::ResetWindowRegion() { |
1137 // If a custom window shape was supplied then apply it. | 1144 // If a custom window shape was supplied then apply it. |
1138 if (custom_window_shape_) { | 1145 if (custom_window_shape_) { |
1139 XShapeCombineRegion( | 1146 XShapeCombineRegion( |
1140 xdisplay_, xwindow_, ShapeBounding, 0, 0, custom_window_shape_, false); | 1147 xdisplay_, xwindow_, ShapeBounding, 0, 0, custom_window_shape_, false); |
1141 return; | 1148 return; |
1142 } | 1149 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 break; | 1259 break; |
1253 } | 1260 } |
1254 case Expose: { | 1261 case Expose: { |
1255 gfx::Rect damage_rect(xev->xexpose.x, xev->xexpose.y, | 1262 gfx::Rect damage_rect(xev->xexpose.x, xev->xexpose.y, |
1256 xev->xexpose.width, xev->xexpose.height); | 1263 xev->xexpose.width, xev->xexpose.height); |
1257 compositor()->ScheduleRedrawRect(damage_rect); | 1264 compositor()->ScheduleRedrawRect(damage_rect); |
1258 break; | 1265 break; |
1259 } | 1266 } |
1260 case KeyPress: { | 1267 case KeyPress: { |
1261 ui::KeyEvent keydown_event(xev, false); | 1268 ui::KeyEvent keydown_event(xev, false); |
1262 delegate_->OnHostKeyEvent(&keydown_event); | 1269 SendEventToProcessor(&keydown_event); |
1263 break; | 1270 break; |
1264 } | 1271 } |
1265 case KeyRelease: { | 1272 case KeyRelease: { |
1266 ui::KeyEvent keyup_event(xev, false); | 1273 ui::KeyEvent keyup_event(xev, false); |
1267 delegate_->OnHostKeyEvent(&keyup_event); | 1274 SendEventToProcessor(&keyup_event); |
1268 break; | 1275 break; |
1269 } | 1276 } |
1270 case ButtonPress: { | 1277 case ButtonPress: { |
1271 if (static_cast<int>(xev->xbutton.button) == kBackMouseButton || | 1278 if (static_cast<int>(xev->xbutton.button) == kBackMouseButton || |
1272 static_cast<int>(xev->xbutton.button) == kForwardMouseButton) { | 1279 static_cast<int>(xev->xbutton.button) == kForwardMouseButton) { |
1273 aura::client::UserActionClient* gesture_client = | 1280 aura::client::UserActionClient* gesture_client = |
1274 aura::client::GetUserActionClient(root_window_->window()); | 1281 aura::client::GetUserActionClient(root_window_->window()); |
1275 if (gesture_client) { | 1282 if (gesture_client) { |
1276 gesture_client->OnUserAction( | 1283 gesture_client->OnUserAction( |
1277 static_cast<int>(xev->xbutton.button) == kBackMouseButton ? | 1284 static_cast<int>(xev->xbutton.button) == kBackMouseButton ? |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1405 } | 1412 } |
1406 case ui::ET_MOUSEWHEEL: { | 1413 case ui::ET_MOUSEWHEEL: { |
1407 ui::MouseWheelEvent mouseev(xev); | 1414 ui::MouseWheelEvent mouseev(xev); |
1408 DispatchMouseEvent(&mouseev); | 1415 DispatchMouseEvent(&mouseev); |
1409 break; | 1416 break; |
1410 } | 1417 } |
1411 case ui::ET_SCROLL_FLING_START: | 1418 case ui::ET_SCROLL_FLING_START: |
1412 case ui::ET_SCROLL_FLING_CANCEL: | 1419 case ui::ET_SCROLL_FLING_CANCEL: |
1413 case ui::ET_SCROLL: { | 1420 case ui::ET_SCROLL: { |
1414 ui::ScrollEvent scrollev(xev); | 1421 ui::ScrollEvent scrollev(xev); |
1415 delegate_->OnHostScrollEvent(&scrollev); | 1422 SendEventToProcessor(&scrollev); |
1416 break; | 1423 break; |
1417 } | 1424 } |
1418 case ui::ET_UNKNOWN: | 1425 case ui::ET_UNKNOWN: |
1419 break; | 1426 break; |
1420 default: | 1427 default: |
1421 NOTREACHED(); | 1428 NOTREACHED(); |
1422 } | 1429 } |
1423 | 1430 |
1424 // If we coalesced an event we need to free its cookie. | 1431 // If we coalesced an event we need to free its cookie. |
1425 if (num_coalesced > 0) | 1432 if (num_coalesced > 0) |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1583 if (linux_ui) { | 1590 if (linux_ui) { |
1584 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(); | 1591 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(); |
1585 if (native_theme) | 1592 if (native_theme) |
1586 return native_theme; | 1593 return native_theme; |
1587 } | 1594 } |
1588 | 1595 |
1589 return ui::NativeTheme::instance(); | 1596 return ui::NativeTheme::instance(); |
1590 } | 1597 } |
1591 | 1598 |
1592 } // namespace views | 1599 } // namespace views |
OLD | NEW |