| 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 a57f2a9a343a32db6d303ce3002b55fa0762cdbc..ba5433307a016dcd4b40c9830fe39c2fb0946764 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>
|
| @@ -28,8 +27,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"
|
| @@ -108,138 +107,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 base::MessagePumpObserver {
|
| - public:
|
| - TouchEventCalibrate()
|
| - : left_(0),
|
| - right_(0),
|
| - top_(0),
|
| - bottom_(0) {
|
| - base::MessageLoopForUI::current()->AddObserver(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() {
|
| - base::MessageLoopForUI::current()->RemoveObserver(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:
|
| - // Overridden from base::MessagePumpObserver:
|
| - virtual base::EventStatus WillProcessEvent(
|
| - const base::NativeEvent& 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)
|
| - return base::EVENT_CONTINUE;
|
| - }
|
| -
|
| - virtual void DidProcessEvent(const base::NativeEvent& 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
|
|
|
| @@ -250,8 +117,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));
|
| @@ -310,17 +175,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);
|
| base::MessagePumpX11::Current()->RemoveDispatcherForRootWindow(this);
|
| base::MessagePumpX11::Current()->RemoveDispatcherForWindow(xwindow_);
|
|
|
| - UnConfineCursor();
|
| -
|
| DestroyCompositor();
|
| DestroyDispatcher();
|
| XDestroyWindow(xdisplay_, xwindow_);
|
| @@ -349,12 +210,12 @@ uint32_t WindowTreeHostX11::Dispatch(const base::NativeEvent& 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: {
|
| @@ -378,13 +239,13 @@ uint32_t WindowTreeHostX11::Dispatch(const base::NativeEvent& 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:
|
| @@ -410,6 +271,8 @@ uint32_t WindowTreeHostX11::Dispatch(const base::NativeEvent& event) {
|
| bool size_changed = bounds_.size() != bounds.size();
|
| bool origin_changed = bounds_.origin() != bounds.origin();
|
| bounds_ = bounds;
|
| + OnConfigureNotify();
|
| + /*
|
| UpdateIsInternalDisplay();
|
| // Always update barrier and mouse location because |bounds_| might
|
| // have already been updated in |SetBounds|.
|
| @@ -417,6 +280,7 @@ uint32_t WindowTreeHostX11::Dispatch(const base::NativeEvent& event) {
|
| UnConfineCursor();
|
| ConfineCursorToRootWindow();
|
| }
|
| + */
|
| if (size_changed)
|
| OnHostResized(bounds.size());
|
| if (origin_changed)
|
| @@ -477,7 +341,7 @@ uint32_t WindowTreeHostX11::Dispatch(const base::NativeEvent& event) {
|
| }
|
|
|
| ui::MouseEvent mouseev(xev);
|
| - TranslateAndDispatchMouseEvent(&mouseev);
|
| + TranslateAndDispatchLocatedEvent(&mouseev);
|
| break;
|
| }
|
| }
|
| @@ -518,10 +382,6 @@ void WindowTreeHostX11::Hide() {
|
| }
|
| }
|
|
|
| -void WindowTreeHostX11::ToggleFullScreen() {
|
| - NOTIMPLEMENTED();
|
| -}
|
| -
|
| gfx::Rect WindowTreeHostX11::GetBounds() const {
|
| return bounds_;
|
| }
|
| @@ -557,7 +417,7 @@ void WindowTreeHostX11::SetBounds(const gfx::Rect& bounds) {
|
| // (possibly synthetic) ConfigureNotify about the actual size and correct
|
| // |bounds_| later.
|
| bounds_ = bounds;
|
| - UpdateIsInternalDisplay();
|
| + //UpdateIsInternalDisplay();
|
| if (origin_changed)
|
| OnHostMoved(bounds.origin());
|
| if (size_changed || current_scale != new_scale) {
|
| @@ -567,6 +427,7 @@ void WindowTreeHostX11::SetBounds(const gfx::Rect& bounds) {
|
| }
|
| }
|
|
|
| +/*
|
| gfx::Insets WindowTreeHostX11::GetInsets() const {
|
| return insets_;
|
| }
|
| @@ -578,6 +439,7 @@ void WindowTreeHostX11::SetInsets(const gfx::Insets& insets) {
|
| ConfineCursorToRootWindow();
|
| }
|
| }
|
| +*/
|
|
|
| gfx::Point WindowTreeHostX11::GetLocationOnNativeScreen() const {
|
| return bounds_.origin();
|
| @@ -615,54 +477,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_);
|
| @@ -714,25 +528,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() {
|
| @@ -759,35 +554,8 @@ void WindowTreeHostX11::DispatchXI2Event(const base::NativeEvent& event) {
|
| case ui::ET_TOUCH_PRESSED:
|
| case ui::ET_TOUCH_CANCELLED:
|
| case ui::ET_TOUCH_RELEASED: {
|
| -#if defined(OS_CHROMEOS)
|
| - // Bail out early before generating a ui::TouchEvent if this event
|
| - // is not within the range of this RootWindow. Converting an xevent
|
| - // to ui::TouchEvent might change the state of the global touch tracking
|
| - // state, e.g. touch release event can remove the touch id from the
|
| - // record, and doing this multiple time when there are multiple
|
| - // 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)
|
| 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:
|
| @@ -804,12 +572,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:
|
| @@ -843,35 +611,21 @@ 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);
|
| - }
|
| +void WindowTreeHostX11::TranslateAndDispatchLocatedEvent(
|
| + ui::LocatedEvent* event) {
|
| SendEventToProcessor(event);
|
| }
|
|
|
| +/*
|
| 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())
|
| @@ -901,6 +655,7 @@ void WindowTreeHostX11::SetCrOSTapPaused(bool state) {
|
| }
|
| #endif
|
| }
|
| +*/
|
|
|
| // static
|
| WindowTreeHost* WindowTreeHost::Create(const gfx::Rect& bounds) {
|
|
|