| 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/aura/window_tree_host_x11.h" | 5 #include "ui/aura/window_tree_host_x11.h" |
| 6 | 6 |
| 7 #include <strings.h> | 7 #include <strings.h> |
| 8 #include <X11/cursorfont.h> | 8 #include <X11/cursorfont.h> |
| 9 #include <X11/extensions/Xfixes.h> | 9 #include <X11/extensions/Xfixes.h> |
| 10 #include <X11/extensions/XInput2.h> | 10 #include <X11/extensions/XInput2.h> |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 XEvent* xev = event; | 356 XEvent* xev = event; |
| 357 | 357 |
| 358 if (FindEventTarget(event) == x_root_window_) { | 358 if (FindEventTarget(event) == x_root_window_) { |
| 359 if (event->type == GenericEvent) | 359 if (event->type == GenericEvent) |
| 360 DispatchXI2Event(event); | 360 DispatchXI2Event(event); |
| 361 return POST_DISPATCH_NONE; | 361 return POST_DISPATCH_NONE; |
| 362 } | 362 } |
| 363 | 363 |
| 364 switch (xev->type) { | 364 switch (xev->type) { |
| 365 case EnterNotify: { | 365 case EnterNotify: { |
| 366 aura::Window* root_window = GetDispatcher()->window(); | 366 aura::Window* root_window = window(); |
| 367 client::CursorClient* cursor_client = | 367 client::CursorClient* cursor_client = |
| 368 client::GetCursorClient(root_window); | 368 client::GetCursorClient(root_window); |
| 369 if (cursor_client) { | 369 if (cursor_client) { |
| 370 const gfx::Display display = gfx::Screen::GetScreenFor(root_window)-> | 370 const gfx::Display display = gfx::Screen::GetScreenFor(root_window)-> |
| 371 GetDisplayNearestWindow(root_window); | 371 GetDisplayNearestWindow(root_window); |
| 372 cursor_client->SetDisplay(display); | 372 cursor_client->SetDisplay(display); |
| 373 } | 373 } |
| 374 ui::MouseEvent mouse_event(xev); | 374 ui::MouseEvent mouse_event(xev); |
| 375 // EnterNotify creates ET_MOUSE_MOVE. Mark as synthesized as this is not | 375 // EnterNotify creates ET_MOUSE_MOVE. Mark as synthesized as this is not |
| 376 // real mouse move event. | 376 // real mouse move event. |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 void WindowTreeHostX11::SetCapture() { | 628 void WindowTreeHostX11::SetCapture() { |
| 629 // TODO(oshima): Grab x input. | 629 // TODO(oshima): Grab x input. |
| 630 } | 630 } |
| 631 | 631 |
| 632 void WindowTreeHostX11::ReleaseCapture() { | 632 void WindowTreeHostX11::ReleaseCapture() { |
| 633 // TODO(oshima): Release x input. | 633 // TODO(oshima): Release x input. |
| 634 } | 634 } |
| 635 | 635 |
| 636 bool WindowTreeHostX11::QueryMouseLocation(gfx::Point* location_return) { | 636 bool WindowTreeHostX11::QueryMouseLocation(gfx::Point* location_return) { |
| 637 client::CursorClient* cursor_client = | 637 client::CursorClient* cursor_client = |
| 638 client::GetCursorClient(GetDispatcher()->window()); | 638 client::GetCursorClient(window()); |
| 639 if (cursor_client && !cursor_client->IsMouseEventsEnabled()) { | 639 if (cursor_client && !cursor_client->IsMouseEventsEnabled()) { |
| 640 *location_return = gfx::Point(0, 0); | 640 *location_return = gfx::Point(0, 0); |
| 641 return false; | 641 return false; |
| 642 } | 642 } |
| 643 | 643 |
| 644 ::Window root_return, child_return; | 644 ::Window root_return, child_return; |
| 645 int root_x_return, root_y_return, win_x_return, win_y_return; | 645 int root_x_return, root_y_return, win_x_return, win_y_return; |
| 646 unsigned int mask_return; | 646 unsigned int mask_return; |
| 647 XQueryPointer(xdisplay_, | 647 XQueryPointer(xdisplay_, |
| 648 xwindow_, | 648 xwindow_, |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 } | 760 } |
| 761 | 761 |
| 762 void WindowTreeHostX11::OnCursorVisibilityChangedNative(bool show) { | 762 void WindowTreeHostX11::OnCursorVisibilityChangedNative(bool show) { |
| 763 SetCrOSTapPaused(!show); | 763 SetCrOSTapPaused(!show); |
| 764 } | 764 } |
| 765 | 765 |
| 766 void WindowTreeHostX11::OnWindowInitialized(Window* window) { | 766 void WindowTreeHostX11::OnWindowInitialized(Window* window) { |
| 767 } | 767 } |
| 768 | 768 |
| 769 void WindowTreeHostX11::OnRootWindowInitialized( | 769 void WindowTreeHostX11::OnRootWindowInitialized( |
| 770 WindowEventDispatcher* dispatcher) { | 770 WindowEventDispatcher* d) { |
| 771 // UpdateIsInternalDisplay relies on: | 771 // UpdateIsInternalDisplay relies on: |
| 772 // 1. delegate_ pointing to WindowEventDispatcher - available after | 772 // 1. delegate_ pointing to WindowEventDispatcher - available after |
| 773 // SetDelegate. | 773 // SetDelegate. |
| 774 // 2. WED's kDisplayIdKey property set - available by the time | 774 // 2. WED's kDisplayIdKey property set - available by the time |
| 775 // WED::Init is called. | 775 // WED::Init is called. |
| 776 // (set in DisplayManager::CreateRootWindowForDisplay) | 776 // (set in DisplayManager::CreateRootWindowForDisplay) |
| 777 // Ready when NotifyRootWindowInitialized is called from WED::Init. | 777 // Ready when NotifyRootWindowInitialized is called from WED::Init. |
| 778 if (!delegate_ || dispatcher != GetDispatcher()) | 778 if (!delegate_ || d != dispatcher()) |
| 779 return; | 779 return; |
| 780 UpdateIsInternalDisplay(); | 780 UpdateIsInternalDisplay(); |
| 781 | 781 |
| 782 // We have to enable Tap-to-click by default because the cursor is set to | 782 // We have to enable Tap-to-click by default because the cursor is set to |
| 783 // visible in Shell::InitRootWindowController. | 783 // visible in Shell::InitRootWindowController. |
| 784 SetCrOSTapPaused(false); | 784 SetCrOSTapPaused(false); |
| 785 } | 785 } |
| 786 | 786 |
| 787 ui::EventProcessor* WindowTreeHostX11::GetEventProcessor() { | 787 ui::EventProcessor* WindowTreeHostX11::GetEventProcessor() { |
| 788 return delegate_->GetEventProcessor(); | 788 return delegate_->GetEventProcessor(); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 return XGetSelectionOwner( | 923 return XGetSelectionOwner( |
| 924 xdisplay_, atom_cache_.GetAtom("WM_S0")) != None; | 924 xdisplay_, atom_cache_.GetAtom("WM_S0")) != None; |
| 925 } | 925 } |
| 926 | 926 |
| 927 void WindowTreeHostX11::SetCursorInternal(gfx::NativeCursor cursor) { | 927 void WindowTreeHostX11::SetCursorInternal(gfx::NativeCursor cursor) { |
| 928 XDefineCursor(xdisplay_, xwindow_, cursor.platform()); | 928 XDefineCursor(xdisplay_, xwindow_, cursor.platform()); |
| 929 } | 929 } |
| 930 | 930 |
| 931 void WindowTreeHostX11::TranslateAndDispatchMouseEvent( | 931 void WindowTreeHostX11::TranslateAndDispatchMouseEvent( |
| 932 ui::MouseEvent* event) { | 932 ui::MouseEvent* event) { |
| 933 Window* root_window = GetDispatcher()->window(); | 933 Window* root_window = window(); |
| 934 client::ScreenPositionClient* screen_position_client = | 934 client::ScreenPositionClient* screen_position_client = |
| 935 client::GetScreenPositionClient(root_window); | 935 client::GetScreenPositionClient(root_window); |
| 936 gfx::Rect local(bounds_.size()); | 936 gfx::Rect local(bounds_.size()); |
| 937 | 937 |
| 938 if (screen_position_client && !local.Contains(event->location())) { | 938 if (screen_position_client && !local.Contains(event->location())) { |
| 939 gfx::Point location(event->location()); | 939 gfx::Point location(event->location()); |
| 940 // In order to get the correct point in screen coordinates | 940 // In order to get the correct point in screen coordinates |
| 941 // during passive grab, we first need to find on which host window | 941 // during passive grab, we first need to find on which host window |
| 942 // the mouse is on, and find out the screen coordinates on that | 942 // the mouse is on, and find out the screen coordinates on that |
| 943 // host window, then convert it back to this host window's coordinate. | 943 // host window, then convert it back to this host window's coordinate. |
| 944 screen_position_client->ConvertHostPointToScreen(root_window, &location); | 944 screen_position_client->ConvertHostPointToScreen(root_window, &location); |
| 945 screen_position_client->ConvertPointFromScreen(root_window, &location); | 945 screen_position_client->ConvertPointFromScreen(root_window, &location); |
| 946 ConvertPointToHost(&location); | 946 ConvertPointToHost(&location); |
| 947 event->set_location(location); | 947 event->set_location(location); |
| 948 event->set_root_location(location); | 948 event->set_root_location(location); |
| 949 } | 949 } |
| 950 SendEventToProcessor(event); | 950 SendEventToProcessor(event); |
| 951 } | 951 } |
| 952 | 952 |
| 953 void WindowTreeHostX11::UpdateIsInternalDisplay() { | 953 void WindowTreeHostX11::UpdateIsInternalDisplay() { |
| 954 Window* root_window = GetDispatcher()->window(); | 954 Window* root_window = window(); |
| 955 gfx::Screen* screen = gfx::Screen::GetScreenFor(root_window); | 955 gfx::Screen* screen = gfx::Screen::GetScreenFor(root_window); |
| 956 gfx::Display display = screen->GetDisplayNearestWindow(root_window); | 956 gfx::Display display = screen->GetDisplayNearestWindow(root_window); |
| 957 is_internal_display_ = display.IsInternal(); | 957 is_internal_display_ = display.IsInternal(); |
| 958 } | 958 } |
| 959 | 959 |
| 960 void WindowTreeHostX11::SetCrOSTapPaused(bool state) { | 960 void WindowTreeHostX11::SetCrOSTapPaused(bool state) { |
| 961 #if defined(OS_CHROMEOS) | 961 #if defined(OS_CHROMEOS) |
| 962 if (!ui::IsXInput2Available()) | 962 if (!ui::IsXInput2Available()) |
| 963 return; | 963 return; |
| 964 // Temporarily pause tap-to-click when the cursor is hidden. | 964 // Temporarily pause tap-to-click when the cursor is hidden. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 999 } | 999 } |
| 1000 | 1000 |
| 1001 namespace test { | 1001 namespace test { |
| 1002 | 1002 |
| 1003 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) { | 1003 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) { |
| 1004 default_override_redirect = override_redirect; | 1004 default_override_redirect = override_redirect; |
| 1005 } | 1005 } |
| 1006 | 1006 |
| 1007 } // namespace test | 1007 } // namespace test |
| 1008 } // namespace aura | 1008 } // namespace aura |
| OLD | NEW |