| 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> |
| 11 #include <X11/Xutil.h> | 11 #include <X11/Xutil.h> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/debug/trace_event.h" | 14 #include "base/debug/trace_event.h" |
| 15 #include "base/message_loop/message_pump_x11.h" | 15 #include "base/message_loop/message_pump_x11.h" |
| 16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "third_party/skia/include/core/SkPath.h" | 18 #include "third_party/skia/include/core/SkPath.h" |
| 19 #include "ui/aura/client/cursor_client.h" | 19 #include "ui/aura/client/cursor_client.h" |
| 20 #include "ui/aura/client/focus_client.h" | 20 #include "ui/aura/client/focus_client.h" |
| 21 #include "ui/aura/client/user_action_client.h" | |
| 22 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
| 23 #include "ui/aura/window_event_dispatcher.h" | 22 #include "ui/aura/window_event_dispatcher.h" |
| 24 #include "ui/aura/window_property.h" | 23 #include "ui/aura/window_property.h" |
| 25 #include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h" | 24 #include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h" |
| 26 #include "ui/base/x/x11_util.h" | 25 #include "ui/base/x/x11_util.h" |
| 27 #include "ui/events/event_utils.h" | 26 #include "ui/events/event_utils.h" |
| 28 #include "ui/events/x/device_data_manager.h" | 27 #include "ui/events/x/device_data_manager.h" |
| 29 #include "ui/events/x/device_list_cache_x.h" | 28 #include "ui/events/x/device_list_cache_x.h" |
| 30 #include "ui/events/x/touch_factory_x11.h" | 29 #include "ui/events/x/touch_factory_x11.h" |
| 31 #include "ui/gfx/image/image_skia.h" | 30 #include "ui/gfx/image/image_skia.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 58 std::list<XID>* DesktopWindowTreeHostX11::open_windows_ = NULL; | 57 std::list<XID>* DesktopWindowTreeHostX11::open_windows_ = NULL; |
| 59 | 58 |
| 60 DEFINE_WINDOW_PROPERTY_KEY( | 59 DEFINE_WINDOW_PROPERTY_KEY( |
| 61 aura::Window*, kViewsWindowForRootWindow, NULL); | 60 aura::Window*, kViewsWindowForRootWindow, NULL); |
| 62 | 61 |
| 63 DEFINE_WINDOW_PROPERTY_KEY( | 62 DEFINE_WINDOW_PROPERTY_KEY( |
| 64 DesktopWindowTreeHostX11*, kHostForRootWindow, NULL); | 63 DesktopWindowTreeHostX11*, kHostForRootWindow, NULL); |
| 65 | 64 |
| 66 namespace { | 65 namespace { |
| 67 | 66 |
| 68 // Standard Linux mouse buttons for going back and forward. | |
| 69 const int kBackMouseButton = 8; | |
| 70 const int kForwardMouseButton = 9; | |
| 71 | |
| 72 // Constants that are part of EWMH. | 67 // Constants that are part of EWMH. |
| 73 const int k_NET_WM_STATE_ADD = 1; | 68 const int k_NET_WM_STATE_ADD = 1; |
| 74 const int k_NET_WM_STATE_REMOVE = 0; | 69 const int k_NET_WM_STATE_REMOVE = 0; |
| 75 | 70 |
| 76 const char* kAtomsToCache[] = { | 71 const char* kAtomsToCache[] = { |
| 77 "UTF8_STRING", | 72 "UTF8_STRING", |
| 78 "WM_DELETE_WINDOW", | 73 "WM_DELETE_WINDOW", |
| 79 "WM_PROTOCOLS", | 74 "WM_PROTOCOLS", |
| 80 "WM_S0", | 75 "WM_S0", |
| 81 "_NET_WM_ICON", | 76 "_NET_WM_ICON", |
| (...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1295 case KeyPress: { | 1290 case KeyPress: { |
| 1296 ui::KeyEvent keydown_event(xev, false); | 1291 ui::KeyEvent keydown_event(xev, false); |
| 1297 SendEventToProcessor(&keydown_event); | 1292 SendEventToProcessor(&keydown_event); |
| 1298 break; | 1293 break; |
| 1299 } | 1294 } |
| 1300 case KeyRelease: { | 1295 case KeyRelease: { |
| 1301 ui::KeyEvent keyup_event(xev, false); | 1296 ui::KeyEvent keyup_event(xev, false); |
| 1302 SendEventToProcessor(&keyup_event); | 1297 SendEventToProcessor(&keyup_event); |
| 1303 break; | 1298 break; |
| 1304 } | 1299 } |
| 1305 case ButtonPress: { | 1300 case ButtonPress: |
| 1306 if (static_cast<int>(xev->xbutton.button) == kBackMouseButton || | |
| 1307 static_cast<int>(xev->xbutton.button) == kForwardMouseButton) { | |
| 1308 aura::client::UserActionClient* gesture_client = | |
| 1309 aura::client::GetUserActionClient(dispatcher_->window()); | |
| 1310 if (gesture_client) { | |
| 1311 gesture_client->OnUserAction( | |
| 1312 static_cast<int>(xev->xbutton.button) == kBackMouseButton ? | |
| 1313 aura::client::UserActionClient::BACK : | |
| 1314 aura::client::UserActionClient::FORWARD); | |
| 1315 } | |
| 1316 break; | |
| 1317 } | |
| 1318 } // fallthrough | |
| 1319 case ButtonRelease: { | 1301 case ButtonRelease: { |
| 1320 ui::EventType event_type = ui::EventTypeFromNative(xev); | 1302 ui::EventType event_type = ui::EventTypeFromNative(xev); |
| 1321 switch (event_type) { | 1303 switch (event_type) { |
| 1322 case ui::ET_MOUSEWHEEL: { | 1304 case ui::ET_MOUSEWHEEL: { |
| 1323 ui::MouseWheelEvent mouseev(xev); | 1305 ui::MouseWheelEvent mouseev(xev); |
| 1324 DispatchMouseEvent(&mouseev); | 1306 DispatchMouseEvent(&mouseev); |
| 1325 break; | 1307 break; |
| 1326 } | 1308 } |
| 1327 case ui::ET_MOUSE_PRESSED: | 1309 case ui::ET_MOUSE_PRESSED: |
| 1328 case ui::ET_MOUSE_RELEASED: { | 1310 case ui::ET_MOUSE_RELEASED: { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1401 case ui::ET_MOUSE_PRESSED: | 1383 case ui::ET_MOUSE_PRESSED: |
| 1402 case ui::ET_MOUSE_RELEASED: | 1384 case ui::ET_MOUSE_RELEASED: |
| 1403 case ui::ET_MOUSE_ENTERED: | 1385 case ui::ET_MOUSE_ENTERED: |
| 1404 case ui::ET_MOUSE_EXITED: { | 1386 case ui::ET_MOUSE_EXITED: { |
| 1405 if (type == ui::ET_MOUSE_MOVED || type == ui::ET_MOUSE_DRAGGED) { | 1387 if (type == ui::ET_MOUSE_MOVED || type == ui::ET_MOUSE_DRAGGED) { |
| 1406 // If this is a motion event, we want to coalesce all pending motion | 1388 // If this is a motion event, we want to coalesce all pending motion |
| 1407 // events that are at the top of the queue. | 1389 // events that are at the top of the queue. |
| 1408 num_coalesced = ui::CoalescePendingMotionEvents(xev, &last_event); | 1390 num_coalesced = ui::CoalescePendingMotionEvents(xev, &last_event); |
| 1409 if (num_coalesced > 0) | 1391 if (num_coalesced > 0) |
| 1410 xev = &last_event; | 1392 xev = &last_event; |
| 1411 } else if (type == ui::ET_MOUSE_PRESSED) { | |
| 1412 XIDeviceEvent* xievent = | |
| 1413 static_cast<XIDeviceEvent*>(xev->xcookie.data); | |
| 1414 int button = xievent->detail; | |
| 1415 if (button == kBackMouseButton || button == kForwardMouseButton) { | |
| 1416 aura::client::UserActionClient* gesture_client = | |
| 1417 aura::client::GetUserActionClient( | |
| 1418 delegate_->AsDispatcher()->window()); | |
| 1419 if (gesture_client) { | |
| 1420 bool reverse_direction = | |
| 1421 ui::IsTouchpadEvent(xev) && ui::IsNaturalScrollEnabled(); | |
| 1422 gesture_client->OnUserAction( | |
| 1423 (button == kBackMouseButton && !reverse_direction) || | |
| 1424 (button == kForwardMouseButton && reverse_direction) ? | |
| 1425 aura::client::UserActionClient::BACK : | |
| 1426 aura::client::UserActionClient::FORWARD); | |
| 1427 } | |
| 1428 break; | |
| 1429 } | |
| 1430 } else if (type == ui::ET_MOUSE_RELEASED) { | |
| 1431 XIDeviceEvent* xievent = | |
| 1432 static_cast<XIDeviceEvent*>(xev->xcookie.data); | |
| 1433 int button = xievent->detail; | |
| 1434 if (button == kBackMouseButton || button == kForwardMouseButton) { | |
| 1435 // We've already passed the back/forward mouse down to the user | |
| 1436 // action client; we want to swallow the corresponding release. | |
| 1437 break; | |
| 1438 } | |
| 1439 } | 1393 } |
| 1440 ui::MouseEvent mouseev(xev); | 1394 ui::MouseEvent mouseev(xev); |
| 1441 DispatchMouseEvent(&mouseev); | 1395 DispatchMouseEvent(&mouseev); |
| 1442 break; | 1396 break; |
| 1443 } | 1397 } |
| 1444 case ui::ET_MOUSEWHEEL: { | 1398 case ui::ET_MOUSEWHEEL: { |
| 1445 ui::MouseWheelEvent mouseev(xev); | 1399 ui::MouseWheelEvent mouseev(xev); |
| 1446 DispatchMouseEvent(&mouseev); | 1400 DispatchMouseEvent(&mouseev); |
| 1447 break; | 1401 break; |
| 1448 } | 1402 } |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1620 if (linux_ui) { | 1574 if (linux_ui) { |
| 1621 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(); | 1575 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(); |
| 1622 if (native_theme) | 1576 if (native_theme) |
| 1623 return native_theme; | 1577 return native_theme; |
| 1624 } | 1578 } |
| 1625 | 1579 |
| 1626 return ui::NativeTheme::instance(); | 1580 return ui::NativeTheme::instance(); |
| 1627 } | 1581 } |
| 1628 | 1582 |
| 1629 } // namespace views | 1583 } // namespace views |
| OLD | NEW |