| 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/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.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/window.h" | 21 #include "ui/aura/window.h" |
| 22 #include "ui/aura/window_event_dispatcher.h" | 22 #include "ui/aura/window_event_dispatcher.h" |
| 23 #include "ui/aura/window_property.h" | 23 #include "ui/aura/window_property.h" |
| 24 #include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h" | 24 #include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h" |
| 25 #include "ui/base/hit_test.h" | 25 #include "ui/base/hit_test.h" |
| 26 #include "ui/base/ime/input_method.h" |
| 26 #include "ui/base/x/x11_util.h" | 27 #include "ui/base/x/x11_util.h" |
| 27 #include "ui/events/devices/x11/device_data_manager_x11.h" | 28 #include "ui/events/devices/x11/device_data_manager_x11.h" |
| 28 #include "ui/events/devices/x11/device_list_cache_x11.h" | 29 #include "ui/events/devices/x11/device_list_cache_x11.h" |
| 29 #include "ui/events/devices/x11/touch_factory_x11.h" | 30 #include "ui/events/devices/x11/touch_factory_x11.h" |
| 30 #include "ui/events/event_utils.h" | 31 #include "ui/events/event_utils.h" |
| 31 #include "ui/events/platform/platform_event_source.h" | 32 #include "ui/events/platform/platform_event_source.h" |
| 32 #include "ui/events/platform/x11/x11_event_source.h" | 33 #include "ui/events/platform/x11/x11_event_source.h" |
| 33 #include "ui/gfx/display.h" | 34 #include "ui/gfx/display.h" |
| 34 #include "ui/gfx/geometry/insets.h" | 35 #include "ui/gfx/geometry/insets.h" |
| 35 #include "ui/gfx/geometry/size_conversions.h" | 36 #include "ui/gfx/geometry/size_conversions.h" |
| (...skipping 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1510 void DesktopWindowTreeHostX11::DispatchTouchEvent(ui::TouchEvent* event) { | 1511 void DesktopWindowTreeHostX11::DispatchTouchEvent(ui::TouchEvent* event) { |
| 1511 if (g_current_capture && g_current_capture != this && | 1512 if (g_current_capture && g_current_capture != this && |
| 1512 event->type() == ui::ET_TOUCH_PRESSED) { | 1513 event->type() == ui::ET_TOUCH_PRESSED) { |
| 1513 ConvertEventToDifferentHost(event, g_current_capture); | 1514 ConvertEventToDifferentHost(event, g_current_capture); |
| 1514 g_current_capture->SendEventToProcessor(event); | 1515 g_current_capture->SendEventToProcessor(event); |
| 1515 } else { | 1516 } else { |
| 1516 SendEventToProcessor(event); | 1517 SendEventToProcessor(event); |
| 1517 } | 1518 } |
| 1518 } | 1519 } |
| 1519 | 1520 |
| 1521 void DesktopWindowTreeHostX11::DispatchKeyEvent(ui::KeyEvent* event) { |
| 1522 GetInputMethod()->DispatchKeyEvent(*event); |
| 1523 event->StopPropagation(); |
| 1524 } |
| 1525 |
| 1520 void DesktopWindowTreeHostX11::ConvertEventToDifferentHost( | 1526 void DesktopWindowTreeHostX11::ConvertEventToDifferentHost( |
| 1521 ui::LocatedEvent* located_event, | 1527 ui::LocatedEvent* located_event, |
| 1522 DesktopWindowTreeHostX11* host) { | 1528 DesktopWindowTreeHostX11* host) { |
| 1523 DCHECK_NE(this, host); | 1529 DCHECK_NE(this, host); |
| 1524 const gfx::Display display_src = | 1530 const gfx::Display display_src = |
| 1525 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(window()); | 1531 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(window()); |
| 1526 const gfx::Display display_dest = | 1532 const gfx::Display display_dest = |
| 1527 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(host->window()); | 1533 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(host->window()); |
| 1528 DCHECK_EQ(display_src.device_scale_factor(), | 1534 DCHECK_EQ(display_src.device_scale_factor(), |
| 1529 display_dest.device_scale_factor()); | 1535 display_dest.device_scale_factor()); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1738 break; | 1744 break; |
| 1739 } | 1745 } |
| 1740 case Expose: { | 1746 case Expose: { |
| 1741 gfx::Rect damage_rect_in_pixels(xev->xexpose.x, xev->xexpose.y, | 1747 gfx::Rect damage_rect_in_pixels(xev->xexpose.x, xev->xexpose.y, |
| 1742 xev->xexpose.width, xev->xexpose.height); | 1748 xev->xexpose.width, xev->xexpose.height); |
| 1743 compositor()->ScheduleRedrawRect(damage_rect_in_pixels); | 1749 compositor()->ScheduleRedrawRect(damage_rect_in_pixels); |
| 1744 break; | 1750 break; |
| 1745 } | 1751 } |
| 1746 case KeyPress: { | 1752 case KeyPress: { |
| 1747 ui::KeyEvent keydown_event(xev); | 1753 ui::KeyEvent keydown_event(xev); |
| 1748 SendEventToProcessor(&keydown_event); | 1754 DispatchKeyEvent(&keydown_event); |
| 1749 break; | 1755 break; |
| 1750 } | 1756 } |
| 1751 case KeyRelease: { | 1757 case KeyRelease: { |
| 1752 // There is no way to deactivate a window in X11 so ignore input if | 1758 // There is no way to deactivate a window in X11 so ignore input if |
| 1753 // window is supposed to be 'inactive'. See comments in | 1759 // window is supposed to be 'inactive'. See comments in |
| 1754 // X11DesktopHandler::DeactivateWindow() for more details. | 1760 // X11DesktopHandler::DeactivateWindow() for more details. |
| 1755 if (!IsActive() && !HasCapture()) | 1761 if (!IsActive() && !HasCapture()) |
| 1756 break; | 1762 break; |
| 1757 | 1763 |
| 1758 ui::KeyEvent key_event(xev); | 1764 ui::KeyEvent key_event(xev); |
| 1759 SendEventToProcessor(&key_event); | 1765 DispatchKeyEvent(&key_event); |
| 1760 break; | 1766 break; |
| 1761 } | 1767 } |
| 1762 case ButtonPress: | 1768 case ButtonPress: |
| 1763 case ButtonRelease: { | 1769 case ButtonRelease: { |
| 1764 ui::EventType event_type = ui::EventTypeFromNative(xev); | 1770 ui::EventType event_type = ui::EventTypeFromNative(xev); |
| 1765 switch (event_type) { | 1771 switch (event_type) { |
| 1766 case ui::ET_MOUSEWHEEL: { | 1772 case ui::ET_MOUSEWHEEL: { |
| 1767 ui::MouseWheelEvent mouseev(xev); | 1773 ui::MouseWheelEvent mouseev(xev); |
| 1768 DispatchMouseEvent(&mouseev); | 1774 DispatchMouseEvent(&mouseev); |
| 1769 break; | 1775 break; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1874 case ui::ET_SCROLL_FLING_START: | 1880 case ui::ET_SCROLL_FLING_START: |
| 1875 case ui::ET_SCROLL_FLING_CANCEL: | 1881 case ui::ET_SCROLL_FLING_CANCEL: |
| 1876 case ui::ET_SCROLL: { | 1882 case ui::ET_SCROLL: { |
| 1877 ui::ScrollEvent scrollev(xev); | 1883 ui::ScrollEvent scrollev(xev); |
| 1878 SendEventToProcessor(&scrollev); | 1884 SendEventToProcessor(&scrollev); |
| 1879 break; | 1885 break; |
| 1880 } | 1886 } |
| 1881 case ui::ET_KEY_PRESSED: | 1887 case ui::ET_KEY_PRESSED: |
| 1882 case ui::ET_KEY_RELEASED: { | 1888 case ui::ET_KEY_RELEASED: { |
| 1883 ui::KeyEvent key_event(xev); | 1889 ui::KeyEvent key_event(xev); |
| 1884 SendEventToProcessor(&key_event); | 1890 DispatchKeyEvent(&key_event); |
| 1885 break; | 1891 break; |
| 1886 } | 1892 } |
| 1887 case ui::ET_UNKNOWN: | 1893 case ui::ET_UNKNOWN: |
| 1888 break; | 1894 break; |
| 1889 default: | 1895 default: |
| 1890 NOTREACHED(); | 1896 NOTREACHED(); |
| 1891 } | 1897 } |
| 1892 | 1898 |
| 1893 // If we coalesced an event we need to free its cookie. | 1899 // If we coalesced an event we need to free its cookie. |
| 1894 if (num_coalesced > 0) | 1900 if (num_coalesced > 0) |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2050 if (linux_ui) { | 2056 if (linux_ui) { |
| 2051 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); | 2057 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); |
| 2052 if (native_theme) | 2058 if (native_theme) |
| 2053 return native_theme; | 2059 return native_theme; |
| 2054 } | 2060 } |
| 2055 | 2061 |
| 2056 return ui::NativeTheme::instance(); | 2062 return ui::NativeTheme::instance(); |
| 2057 } | 2063 } |
| 2058 | 2064 |
| 2059 } // namespace views | 2065 } // namespace views |
| OLD | NEW |