Chromium Code Reviews| Index: ui/aura/desktop_host_linux.cc |
| diff --git a/ui/aura/desktop_host_linux.cc b/ui/aura/desktop_host_linux.cc |
| index 2de31e68518240eb3f72ad280935cb2d5cedc885..71789f17698421a37f486c398186096e24cc5f11 100644 |
| --- a/ui/aura/desktop_host_linux.cc |
| +++ b/ui/aura/desktop_host_linux.cc |
| @@ -241,6 +241,7 @@ class DesktopHostLinux : public DesktopHost { |
| virtual void SetCursor(gfx::NativeCursor cursor_type) OVERRIDE; |
| virtual gfx::Point QueryMouseLocation() OVERRIDE; |
| virtual void PostNativeEvent(const base::NativeEvent& event) OVERRIDE; |
| + virtual void ConvertPointToNativeScreen(gfx::Point* point) const OVERRIDE; |
| // Returns true if there's an X window manager present... in most cases. Some |
| // window managers (notably, ion3) don't implement enough of ICCCM for us to |
| @@ -256,8 +257,8 @@ class DesktopHostLinux : public DesktopHost { |
| // Current Aura cursor. |
| gfx::NativeCursor current_cursor_; |
| - // The size of |xwindow_|. |
| - gfx::Size size_; |
| + // The bounds of |xwindow_|. |
| + gfx::Rect bounds_; |
| DISALLOW_COPY_AND_ASSIGN(DesktopHostLinux); |
| }; |
| @@ -267,7 +268,7 @@ DesktopHostLinux::DesktopHostLinux(const gfx::Rect& bounds) |
| xdisplay_(base::MessagePumpX::GetDefaultXDisplay()), |
| xwindow_(0), |
| current_cursor_(aura::kCursorNull), |
| - size_(bounds.size()) { |
| + bounds_(bounds) { |
| xwindow_ = XCreateSimpleWindow(xdisplay_, DefaultRootWindow(xdisplay_), |
| bounds.x(), bounds.y(), |
| bounds.width(), bounds.height(), |
| @@ -331,11 +332,12 @@ base::MessagePumpDispatcher::DispatchStatus DesktopHostLinux::Dispatch( |
| // It's possible that the X window may be resized by some other means than |
| // from within aura (e.g. the X window manager can change the size). Make |
| // sure the desktop size is maintained properly. |
| - gfx::Size size(xev->xconfigure.width, xev->xconfigure.height); |
| - if (size_ != size) { |
| - size_ = size; |
| - desktop_->OnHostResized(size); |
| - } |
| + gfx::Rect bounds(xev->xconfigure.x, xev->xconfigure.y, |
| + xev->xconfigure.width, xev->xconfigure.height); |
| + bool size_changed = bounds_.size() != bounds.size(); |
| + bounds_ = bounds; |
| + if (size_changed) |
| + desktop_->OnHostResized(bounds.size()); |
| handled = true; |
| break; |
| } |
| @@ -437,11 +439,11 @@ void DesktopHostLinux::ToggleFullScreen() { |
| } |
| gfx::Size DesktopHostLinux::GetSize() const { |
| - return size_; |
| + return bounds_.size(); |
| } |
| void DesktopHostLinux::SetSize(const gfx::Size& size) { |
| - if (size == size_) |
| + if (size == bounds_.size()) |
| return; |
| XResizeWindow(xdisplay_, xwindow_, size.width(), size.height()); |
| @@ -450,8 +452,8 @@ void DesktopHostLinux::SetSize(const gfx::Size& size) { |
| // case if we're running without a window manager. If there's a window |
| // manager, it can modify or ignore the request, but (per ICCCM) we'll get a |
| // (possibly synthetic) ConfigureNotify about the actual size and correct |
| - // |size_| later. |
| - size_ = size; |
| + // |bounds_| later. |
| + bounds_.set_size(size); |
| desktop_->OnHostResized(size); |
| } |
| @@ -478,17 +480,41 @@ gfx::Point DesktopHostLinux::QueryMouseLocation() { |
| &root_x_return, &root_y_return, |
| &win_x_return, &win_y_return, |
| &mask_return); |
| - return gfx::Point(max(0, min(size_.width(), win_x_return)), |
| - max(0, min(size_.height(), win_y_return))); |
| + return gfx::Point(max(0, min(bounds_.width(), win_x_return)), |
| + max(0, min(bounds_.height(), win_y_return))); |
| +} |
| + |
| +void DesktopHostLinux::ConvertPointToNativeScreen(gfx::Point* point) const { |
| + point->Offset(bounds_.x(), bounds_.y()); |
| } |
| void DesktopHostLinux::PostNativeEvent(const base::NativeEvent& native_event) { |
| + const long kInputEventMask = KeyReleaseMask | KeyPressMask | |
| + PointerMotionMask | ButtonPressMask | ButtonReleaseMask; |
| DCHECK(xwindow_); |
| DCHECK(xdisplay_); |
| XEvent xevent = *native_event; |
| xevent.xany.display = xdisplay_; |
| xevent.xany.window = xwindow_; |
| - ::XPutBackEvent(xdisplay_, &xevent); |
| + |
| + switch (xevent.type) { |
| + case MotionNotify: |
| + case KeyPress: |
| + case KeyRelease: |
| + case ButtonPress: |
| + case ButtonRelease: { |
|
Daniel Erat
2011/11/22 00:25:32
i know that we don't do anything with them (now),
oshima
2011/11/22 01:36:10
Because X's Enter/Leave notify doesn't trigger aur
Daniel Erat
2011/11/22 01:46:14
They could get added to aura later, and things wou
oshima
2011/11/22 03:02:09
I just couldn't imagine how this will be needed. O
|
| + xevent.xmotion.root = DefaultRootWindow(xdisplay_); |
|
Daniel Erat
2011/11/22 00:25:32
maybe add a comment mentioning that you're choosin
oshima
2011/11/22 01:36:10
Done.
|
| + xevent.xmotion.time = CurrentTime; |
| + |
| + gfx::Point point(xevent.xmotion.x, xevent.xmotion.y); |
| + ConvertPointToNativeScreen(&point); |
| + xevent.xmotion.x_root = point.x(); |
| + xevent.xmotion.y_root = point.y(); |
| + } |
| + default: |
| + break; |
| + } |
| + ::XSendEvent(xdisplay_, xwindow_, False, kInputEventMask, &xevent); |
|
Daniel Erat
2011/11/22 00:25:32
nit: "::" seems unnecessary here; this function na
oshima
2011/11/22 01:36:10
Done.
|
| } |
| bool DesktopHostLinux::IsWindowManagerPresent() { |