| Index: ui/aura/window_tree_host_x11.cc
|
| diff --git a/ui/aura/window_tree_host_x11.cc b/ui/aura/window_tree_host_x11.cc
|
| index 185885888286781161f4b77b0bd07f1963da5ba5..22b0bfeed28bed3758a2e5c9dbe0f89704026924 100644
|
| --- a/ui/aura/window_tree_host_x11.cc
|
| +++ b/ui/aura/window_tree_host_x11.cc
|
| @@ -6,7 +6,6 @@
|
|
|
| #include <strings.h>
|
| #include <X11/cursorfont.h>
|
| -#include <X11/extensions/Xfixes.h>
|
| #include <X11/extensions/XInput2.h>
|
| #include <X11/extensions/Xrandr.h>
|
| #include <X11/Xatom.h>
|
| @@ -26,8 +25,8 @@
|
| #include "base/strings/stringprintf.h"
|
| #include "base/sys_info.h"
|
| #include "ui/aura/client/cursor_client.h"
|
| -#include "ui/aura/client/screen_position_client.h"
|
| #include "ui/aura/env.h"
|
| +#include "ui/aura/window.h"
|
| #include "ui/aura/window_event_dispatcher.h"
|
| #include "ui/base/cursor/cursor.h"
|
| #include "ui/base/ui_base_switches.h"
|
| @@ -40,7 +39,6 @@
|
| #include "ui/events/event_switches.h"
|
| #include "ui/events/event_utils.h"
|
| #include "ui/events/keycodes/keyboard_codes.h"
|
| -#include "ui/events/platform/platform_event_observer.h"
|
| #include "ui/events/platform/x11/x11_event_source.h"
|
| #include "ui/events/x/device_data_manager.h"
|
| #include "ui/events/x/device_list_cache_x.h"
|
| @@ -108,137 +106,6 @@ bool default_override_redirect = false;
|
|
|
| } // namespace
|
|
|
| -namespace internal {
|
| -
|
| -// Accomplishes 2 tasks concerning touch event calibration:
|
| -// 1. Being a message-pump observer,
|
| -// routes all the touch events to the X root window,
|
| -// where they can be calibrated later.
|
| -// 2. Has the Calibrate method that does the actual bezel calibration,
|
| -// when invoked from X root window's event dispatcher.
|
| -class TouchEventCalibrate : public ui::PlatformEventObserver {
|
| - public:
|
| - TouchEventCalibrate()
|
| - : left_(0),
|
| - right_(0),
|
| - top_(0),
|
| - bottom_(0) {
|
| - if (ui::PlatformEventSource::GetInstance())
|
| - ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(this);
|
| -#if defined(USE_XI2_MT)
|
| - std::vector<std::string> parts;
|
| - if (Tokenize(CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
|
| - switches::kTouchCalibration), ",", &parts) >= 4) {
|
| - if (!base::StringToInt(parts[0], &left_))
|
| - DLOG(ERROR) << "Incorrect left border calibration value passed.";
|
| - if (!base::StringToInt(parts[1], &right_))
|
| - DLOG(ERROR) << "Incorrect right border calibration value passed.";
|
| - if (!base::StringToInt(parts[2], &top_))
|
| - DLOG(ERROR) << "Incorrect top border calibration value passed.";
|
| - if (!base::StringToInt(parts[3], &bottom_))
|
| - DLOG(ERROR) << "Incorrect bottom border calibration value passed.";
|
| - }
|
| -#endif // defined(USE_XI2_MT)
|
| - }
|
| -
|
| - virtual ~TouchEventCalibrate() {
|
| - if (ui::PlatformEventSource::GetInstance())
|
| - ui::PlatformEventSource::GetInstance()->RemovePlatformEventObserver(this);
|
| - }
|
| -
|
| - // Modify the location of the |event|,
|
| - // expanding it from |bounds| to (|bounds| + bezels).
|
| - // Required when touchscreen is bigger than screen (i.e. has bezels),
|
| - // because we receive events in touchscreen coordinates,
|
| - // which need to be expanded when converting to screen coordinates,
|
| - // so that location on bezels will be outside of screen area.
|
| - void Calibrate(ui::TouchEvent* event, const gfx::Rect& bounds) {
|
| -#if defined(USE_XI2_MT)
|
| - int x = event->x();
|
| - int y = event->y();
|
| -
|
| - if (!left_ && !right_ && !top_ && !bottom_)
|
| - return;
|
| -
|
| - const int resolution_x = bounds.width();
|
| - const int resolution_y = bounds.height();
|
| - // The "grace area" (10% in this case) is to make it easier for the user to
|
| - // navigate to the corner.
|
| - const double kGraceAreaFraction = 0.1;
|
| - if (left_ || right_) {
|
| - // Offset the x position to the real
|
| - x -= left_;
|
| - // Check if we are in the grace area of the left side.
|
| - // Note: We might not want to do this when the gesture is locked?
|
| - if (x < 0 && x > -left_ * kGraceAreaFraction)
|
| - x = 0;
|
| - // Check if we are in the grace area of the right side.
|
| - // Note: We might not want to do this when the gesture is locked?
|
| - if (x > resolution_x - left_ &&
|
| - x < resolution_x - left_ + right_ * kGraceAreaFraction)
|
| - x = resolution_x - left_;
|
| - // Scale the screen area back to the full resolution of the screen.
|
| - x = (x * resolution_x) / (resolution_x - (right_ + left_));
|
| - }
|
| - if (top_ || bottom_) {
|
| - // When there is a top bezel we add our border,
|
| - y -= top_;
|
| -
|
| - // Check if we are in the grace area of the top side.
|
| - // Note: We might not want to do this when the gesture is locked?
|
| - if (y < 0 && y > -top_ * kGraceAreaFraction)
|
| - y = 0;
|
| -
|
| - // Check if we are in the grace area of the bottom side.
|
| - // Note: We might not want to do this when the gesture is locked?
|
| - if (y > resolution_y - top_ &&
|
| - y < resolution_y - top_ + bottom_ * kGraceAreaFraction)
|
| - y = resolution_y - top_;
|
| - // Scale the screen area back to the full resolution of the screen.
|
| - y = (y * resolution_y) / (resolution_y - (bottom_ + top_));
|
| - }
|
| -
|
| - // Set the modified coordinate back to the event.
|
| - if (event->root_location() == event->location()) {
|
| - // Usually those will be equal,
|
| - // if not, I am not sure what the correct value should be.
|
| - event->set_root_location(gfx::Point(x, y));
|
| - }
|
| - event->set_location(gfx::Point(x, y));
|
| -#endif // defined(USE_XI2_MT)
|
| - }
|
| -
|
| - private:
|
| - // ui::PlatformEventObserver:
|
| - virtual void WillProcessEvent(const ui::PlatformEvent& event) OVERRIDE {
|
| -#if defined(USE_XI2_MT)
|
| - if (event->type == GenericEvent &&
|
| - (event->xgeneric.evtype == XI_TouchBegin ||
|
| - event->xgeneric.evtype == XI_TouchUpdate ||
|
| - event->xgeneric.evtype == XI_TouchEnd)) {
|
| - XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(event->xcookie.data);
|
| - xievent->event = xievent->root;
|
| - xievent->event_x = xievent->root_x;
|
| - xievent->event_y = xievent->root_y;
|
| - }
|
| -#endif // defined(USE_XI2_MT)
|
| - }
|
| -
|
| - virtual void DidProcessEvent(const ui::PlatformEvent& event) OVERRIDE {}
|
| -
|
| - // The difference in screen's native resolution pixels between
|
| - // the border of the touchscreen and the border of the screen,
|
| - // aka bezel sizes.
|
| - int left_;
|
| - int right_;
|
| - int top_;
|
| - int bottom_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(TouchEventCalibrate);
|
| -};
|
| -
|
| -} // namespace internal
|
| -
|
| ////////////////////////////////////////////////////////////////////////////////
|
| // WindowTreeHostX11
|
|
|
| @@ -249,8 +116,6 @@ WindowTreeHostX11::WindowTreeHostX11(const gfx::Rect& bounds)
|
| current_cursor_(ui::kCursorNull),
|
| window_mapped_(false),
|
| bounds_(bounds),
|
| - is_internal_display_(false),
|
| - touch_calibrate_(new internal::TouchEventCalibrate),
|
| atom_cache_(xdisplay_, kAtomsToCache) {
|
| XSetWindowAttributes swa;
|
| memset(&swa, 0, sizeof(swa));
|
| @@ -309,17 +174,13 @@ WindowTreeHostX11::WindowTreeHostX11(const gfx::Rect& bounds)
|
|
|
| XRRSelectInput(xdisplay_, x_root_window_,
|
| RRScreenChangeNotifyMask | RROutputChangeNotifyMask);
|
| - Env::GetInstance()->AddObserver(this);
|
| CreateCompositor(GetAcceleratedWidget());
|
| }
|
|
|
| WindowTreeHostX11::~WindowTreeHostX11() {
|
| - Env::GetInstance()->RemoveObserver(this);
|
| if (ui::PlatformEventSource::GetInstance())
|
| ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this);
|
|
|
| - UnConfineCursor();
|
| -
|
| DestroyCompositor();
|
| DestroyDispatcher();
|
| XDestroyWindow(xdisplay_, xwindow_);
|
| @@ -352,12 +213,12 @@ uint32_t WindowTreeHostX11::DispatchEvent(const ui::PlatformEvent& event) {
|
| // EnterNotify creates ET_MOUSE_MOVE. Mark as synthesized as this is not
|
| // real mouse move event.
|
| mouse_event.set_flags(mouse_event.flags() | ui::EF_IS_SYNTHESIZED);
|
| - TranslateAndDispatchMouseEvent(&mouse_event);
|
| + TranslateAndDispatchLocatedEvent(&mouse_event);
|
| break;
|
| }
|
| case LeaveNotify: {
|
| ui::MouseEvent mouse_event(xev);
|
| - TranslateAndDispatchMouseEvent(&mouse_event);
|
| + TranslateAndDispatchLocatedEvent(&mouse_event);
|
| break;
|
| }
|
| case Expose: {
|
| @@ -381,13 +242,13 @@ uint32_t WindowTreeHostX11::DispatchEvent(const ui::PlatformEvent& event) {
|
| switch (ui::EventTypeFromNative(xev)) {
|
| case ui::ET_MOUSEWHEEL: {
|
| ui::MouseWheelEvent mouseev(xev);
|
| - TranslateAndDispatchMouseEvent(&mouseev);
|
| + TranslateAndDispatchLocatedEvent(&mouseev);
|
| break;
|
| }
|
| case ui::ET_MOUSE_PRESSED:
|
| case ui::ET_MOUSE_RELEASED: {
|
| ui::MouseEvent mouseev(xev);
|
| - TranslateAndDispatchMouseEvent(&mouseev);
|
| + TranslateAndDispatchLocatedEvent(&mouseev);
|
| break;
|
| }
|
| case ui::ET_UNKNOWN:
|
| @@ -413,13 +274,7 @@ uint32_t WindowTreeHostX11::DispatchEvent(const ui::PlatformEvent& event) {
|
| bool size_changed = bounds_.size() != bounds.size();
|
| bool origin_changed = bounds_.origin() != bounds.origin();
|
| bounds_ = bounds;
|
| - UpdateIsInternalDisplay();
|
| - // Always update barrier and mouse location because |bounds_| might
|
| - // have already been updated in |SetBounds|.
|
| - if (pointer_barriers_) {
|
| - UnConfineCursor();
|
| - ConfineCursorToRootWindow();
|
| - }
|
| + OnConfigureNotify();
|
| if (size_changed)
|
| OnHostResized(bounds.size());
|
| if (origin_changed)
|
| @@ -480,7 +335,7 @@ uint32_t WindowTreeHostX11::DispatchEvent(const ui::PlatformEvent& event) {
|
| }
|
|
|
| ui::MouseEvent mouseev(xev);
|
| - TranslateAndDispatchMouseEvent(&mouseev);
|
| + TranslateAndDispatchLocatedEvent(&mouseev);
|
| break;
|
| }
|
| }
|
| @@ -522,10 +377,6 @@ void WindowTreeHostX11::Hide() {
|
| }
|
| }
|
|
|
| -void WindowTreeHostX11::ToggleFullScreen() {
|
| - NOTIMPLEMENTED();
|
| -}
|
| -
|
| gfx::Rect WindowTreeHostX11::GetBounds() const {
|
| return bounds_;
|
| }
|
| @@ -561,7 +412,6 @@ void WindowTreeHostX11::SetBounds(const gfx::Rect& bounds) {
|
| // (possibly synthetic) ConfigureNotify about the actual size and correct
|
| // |bounds_| later.
|
| bounds_ = bounds;
|
| - UpdateIsInternalDisplay();
|
| if (origin_changed)
|
| OnHostMoved(bounds.origin());
|
| if (size_changed || current_scale != new_scale) {
|
| @@ -571,18 +421,6 @@ void WindowTreeHostX11::SetBounds(const gfx::Rect& bounds) {
|
| }
|
| }
|
|
|
| -gfx::Insets WindowTreeHostX11::GetInsets() const {
|
| - return insets_;
|
| -}
|
| -
|
| -void WindowTreeHostX11::SetInsets(const gfx::Insets& insets) {
|
| - insets_ = insets;
|
| - if (pointer_barriers_) {
|
| - UnConfineCursor();
|
| - ConfineCursorToRootWindow();
|
| - }
|
| -}
|
| -
|
| gfx::Point WindowTreeHostX11::GetLocationOnNativeScreen() const {
|
| return bounds_.origin();
|
| }
|
| @@ -619,54 +457,6 @@ bool WindowTreeHostX11::QueryMouseLocation(gfx::Point* location_return) {
|
| win_y_return >= 0 && win_y_return < bounds_.height());
|
| }
|
|
|
| -bool WindowTreeHostX11::ConfineCursorToRootWindow() {
|
| -#if XFIXES_MAJOR >= 5
|
| - DCHECK(!pointer_barriers_.get());
|
| - if (pointer_barriers_)
|
| - return false;
|
| - pointer_barriers_.reset(new XID[4]);
|
| - gfx::Rect bounds(bounds_);
|
| - bounds.Inset(insets_);
|
| - // Horizontal, top barriers.
|
| - pointer_barriers_[0] = XFixesCreatePointerBarrier(
|
| - xdisplay_, x_root_window_,
|
| - bounds.x(), bounds.y(), bounds.right(), bounds.y(),
|
| - BarrierPositiveY,
|
| - 0, XIAllDevices);
|
| - // Horizontal, bottom barriers.
|
| - pointer_barriers_[1] = XFixesCreatePointerBarrier(
|
| - xdisplay_, x_root_window_,
|
| - bounds.x(), bounds.bottom(), bounds.right(), bounds.bottom(),
|
| - BarrierNegativeY,
|
| - 0, XIAllDevices);
|
| - // Vertical, left barriers.
|
| - pointer_barriers_[2] = XFixesCreatePointerBarrier(
|
| - xdisplay_, x_root_window_,
|
| - bounds.x(), bounds.y(), bounds.x(), bounds.bottom(),
|
| - BarrierPositiveX,
|
| - 0, XIAllDevices);
|
| - // Vertical, right barriers.
|
| - pointer_barriers_[3] = XFixesCreatePointerBarrier(
|
| - xdisplay_, x_root_window_,
|
| - bounds.right(), bounds.y(), bounds.right(), bounds.bottom(),
|
| - BarrierNegativeX,
|
| - 0, XIAllDevices);
|
| -#endif
|
| - return true;
|
| -}
|
| -
|
| -void WindowTreeHostX11::UnConfineCursor() {
|
| -#if XFIXES_MAJOR >= 5
|
| - if (pointer_barriers_) {
|
| - XFixesDestroyPointerBarrier(xdisplay_, pointer_barriers_[0]);
|
| - XFixesDestroyPointerBarrier(xdisplay_, pointer_barriers_[1]);
|
| - XFixesDestroyPointerBarrier(xdisplay_, pointer_barriers_[2]);
|
| - XFixesDestroyPointerBarrier(xdisplay_, pointer_barriers_[3]);
|
| - pointer_barriers_.reset();
|
| - }
|
| -#endif
|
| -}
|
| -
|
| void WindowTreeHostX11::PostNativeEvent(
|
| const base::NativeEvent& native_event) {
|
| DCHECK(xwindow_);
|
| @@ -718,25 +508,6 @@ void WindowTreeHostX11::MoveCursorToNative(const gfx::Point& location) {
|
| }
|
|
|
| void WindowTreeHostX11::OnCursorVisibilityChangedNative(bool show) {
|
| - SetCrOSTapPaused(!show);
|
| -}
|
| -
|
| -void WindowTreeHostX11::OnWindowInitialized(Window* window) {
|
| -}
|
| -
|
| -void WindowTreeHostX11::OnHostInitialized(WindowTreeHost* host) {
|
| - // TODO(beng): I'm not sure that this comment makes much sense anymore??
|
| - // UpdateIsInternalDisplay relies on WED's kDisplayIdKey property being set
|
| - // available by the time WED::Init is called. (set in
|
| - // DisplayManager::CreateRootWindowForDisplay)
|
| - // Ready when NotifyHostInitialized is called from WED::Init.
|
| - if (host != this)
|
| - return;
|
| - UpdateIsInternalDisplay();
|
| -
|
| - // We have to enable Tap-to-click by default because the cursor is set to
|
| - // visible in Shell::InitRootWindowController.
|
| - SetCrOSTapPaused(false);
|
| }
|
|
|
| ui::EventProcessor* WindowTreeHostX11::GetEventProcessor() {
|
| @@ -772,26 +543,11 @@ void WindowTreeHostX11::DispatchXI2Event(const base::NativeEvent& event) {
|
| // RootWindow will cause problem. So only generate the ui::TouchEvent
|
| // when we are sure it belongs to this RootWindow.
|
| if (base::SysInfo::IsRunningOnChromeOS() &&
|
| - !bounds_.Contains(ui::EventLocationFromNative(xev)))
|
| - break;
|
| -#endif // defined(OS_CHROMEOS)
|
| + !bounds().Contains(ui::EventLocationFromNative(xev)))
|
| + return;
|
| +#endif
|
| ui::TouchEvent touchev(xev);
|
| -#if defined(OS_CHROMEOS)
|
| - if (base::SysInfo::IsRunningOnChromeOS()) {
|
| - // X maps the touch-surface to the size of the X root-window.
|
| - // In multi-monitor setup, Coordinate Transformation Matrix
|
| - // repositions the touch-surface onto part of X root-window
|
| - // containing aura root-window corresponding to the touchscreen.
|
| - // However, if aura root-window has non-zero origin,
|
| - // we need to relocate the event into aura root-window coordinates.
|
| - touchev.Relocate(bounds_.origin());
|
| -#if defined(USE_XI2_MT)
|
| - if (is_internal_display_)
|
| - touch_calibrate_->Calibrate(&touchev, bounds_);
|
| -#endif // defined(USE_XI2_MT)
|
| - }
|
| -#endif // defined(OS_CHROMEOS)
|
| - SendEventToProcessor(&touchev);
|
| + TranslateAndDispatchLocatedEvent(&touchev);
|
| break;
|
| }
|
| case ui::ET_MOUSE_MOVED:
|
| @@ -808,12 +564,12 @@ void WindowTreeHostX11::DispatchXI2Event(const base::NativeEvent& event) {
|
| xev = &last_event;
|
| }
|
| ui::MouseEvent mouseev(xev);
|
| - TranslateAndDispatchMouseEvent(&mouseev);
|
| + TranslateAndDispatchLocatedEvent(&mouseev);
|
| break;
|
| }
|
| case ui::ET_MOUSEWHEEL: {
|
| ui::MouseWheelEvent mouseev(xev);
|
| - TranslateAndDispatchMouseEvent(&mouseev);
|
| + TranslateAndDispatchLocatedEvent(&mouseev);
|
| break;
|
| }
|
| case ui::ET_SCROLL_FLING_START:
|
| @@ -847,63 +603,11 @@ void WindowTreeHostX11::SetCursorInternal(gfx::NativeCursor cursor) {
|
| XDefineCursor(xdisplay_, xwindow_, cursor.platform());
|
| }
|
|
|
| -void WindowTreeHostX11::TranslateAndDispatchMouseEvent(
|
| - ui::MouseEvent* event) {
|
| - Window* root_window = window();
|
| - client::ScreenPositionClient* screen_position_client =
|
| - client::GetScreenPositionClient(root_window);
|
| - gfx::Rect local(bounds_.size());
|
| -
|
| - if (screen_position_client && !local.Contains(event->location())) {
|
| - gfx::Point location(event->location());
|
| - // In order to get the correct point in screen coordinates
|
| - // during passive grab, we first need to find on which host window
|
| - // the mouse is on, and find out the screen coordinates on that
|
| - // host window, then convert it back to this host window's coordinate.
|
| - screen_position_client->ConvertHostPointToScreen(root_window, &location);
|
| - screen_position_client->ConvertPointFromScreen(root_window, &location);
|
| - ConvertPointToHost(&location);
|
| - event->set_location(location);
|
| - event->set_root_location(location);
|
| - }
|
| - SendEventToProcessor(event);
|
| -}
|
| +void WindowTreeHostX11::OnConfigureNotify() {}
|
|
|
| -void WindowTreeHostX11::UpdateIsInternalDisplay() {
|
| - Window* root_window = window();
|
| - gfx::Screen* screen = gfx::Screen::GetScreenFor(root_window);
|
| - gfx::Display display = screen->GetDisplayNearestWindow(root_window);
|
| - is_internal_display_ = display.IsInternal();
|
| -}
|
| -
|
| -void WindowTreeHostX11::SetCrOSTapPaused(bool state) {
|
| -#if defined(OS_CHROMEOS)
|
| - if (!ui::IsXInput2Available())
|
| - return;
|
| - // Temporarily pause tap-to-click when the cursor is hidden.
|
| - Atom prop = atom_cache_.GetAtom("Tap Paused");
|
| - unsigned char value = state;
|
| - XIDeviceList dev_list =
|
| - ui::DeviceListCacheX::GetInstance()->GetXI2DeviceList(xdisplay_);
|
| -
|
| - // Only slave pointer devices could possibly have tap-paused property.
|
| - for (int i = 0; i < dev_list.count; i++) {
|
| - if (dev_list[i].use == XISlavePointer) {
|
| - Atom old_type;
|
| - int old_format;
|
| - unsigned long old_nvalues, bytes;
|
| - unsigned char* data;
|
| - int result = XIGetProperty(xdisplay_, dev_list[i].deviceid, prop, 0, 0,
|
| - False, AnyPropertyType, &old_type, &old_format,
|
| - &old_nvalues, &bytes, &data);
|
| - if (result != Success)
|
| - continue;
|
| - XFree(data);
|
| - XIChangeProperty(xdisplay_, dev_list[i].deviceid, prop, XA_INTEGER, 8,
|
| - PropModeReplace, &value, 1);
|
| - }
|
| - }
|
| -#endif
|
| +void WindowTreeHostX11::TranslateAndDispatchLocatedEvent(
|
| + ui::LocatedEvent* event) {
|
| + SendEventToProcessor(event);
|
| }
|
|
|
| // static
|
|
|