| 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/XInput2.h> | 9 #include <X11/extensions/XInput2.h> |
| 10 #include <X11/extensions/Xrandr.h> | 10 #include <X11/extensions/Xrandr.h> |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 } | 565 } |
| 566 | 566 |
| 567 void WindowTreeHostX11::SetCapture() { | 567 void WindowTreeHostX11::SetCapture() { |
| 568 // TODO(oshima): Grab x input. | 568 // TODO(oshima): Grab x input. |
| 569 } | 569 } |
| 570 | 570 |
| 571 void WindowTreeHostX11::ReleaseCapture() { | 571 void WindowTreeHostX11::ReleaseCapture() { |
| 572 // TODO(oshima): Release x input. | 572 // TODO(oshima): Release x input. |
| 573 } | 573 } |
| 574 | 574 |
| 575 void WindowTreeHostX11::PostNativeEvent( | |
| 576 const base::NativeEvent& native_event) { | |
| 577 DCHECK(xwindow_); | |
| 578 DCHECK(xdisplay_); | |
| 579 XEvent xevent = *native_event; | |
| 580 xevent.xany.display = xdisplay_; | |
| 581 xevent.xany.window = xwindow_; | |
| 582 | |
| 583 switch (xevent.type) { | |
| 584 case EnterNotify: | |
| 585 case LeaveNotify: | |
| 586 case MotionNotify: | |
| 587 case KeyPress: | |
| 588 case KeyRelease: | |
| 589 case ButtonPress: | |
| 590 case ButtonRelease: { | |
| 591 // The fields used below are in the same place for all of events | |
| 592 // above. Using xmotion from XEvent's unions to avoid repeating | |
| 593 // the code. | |
| 594 xevent.xmotion.root = x_root_window_; | |
| 595 xevent.xmotion.time = CurrentTime; | |
| 596 | |
| 597 gfx::Point point(xevent.xmotion.x, xevent.xmotion.y); | |
| 598 ConvertPointToNativeScreen(&point); | |
| 599 xevent.xmotion.x_root = point.x(); | |
| 600 xevent.xmotion.y_root = point.y(); | |
| 601 } | |
| 602 default: | |
| 603 break; | |
| 604 } | |
| 605 XSendEvent(xdisplay_, xwindow_, False, 0, &xevent); | |
| 606 XFlush(xdisplay_); | |
| 607 } | |
| 608 | |
| 609 void WindowTreeHostX11::SetCursorNative(gfx::NativeCursor cursor) { | 575 void WindowTreeHostX11::SetCursorNative(gfx::NativeCursor cursor) { |
| 610 if (cursor == current_cursor_) | 576 if (cursor == current_cursor_) |
| 611 return; | 577 return; |
| 612 current_cursor_ = cursor; | 578 current_cursor_ = cursor; |
| 613 SetCursorInternal(cursor); | 579 SetCursorInternal(cursor); |
| 614 } | 580 } |
| 615 | 581 |
| 616 void WindowTreeHostX11::MoveCursorToNative(const gfx::Point& location) { | 582 void WindowTreeHostX11::MoveCursorToNative(const gfx::Point& location) { |
| 617 XWarpPointer(xdisplay_, None, x_root_window_, 0, 0, 0, 0, | 583 XWarpPointer(xdisplay_, None, x_root_window_, 0, 0, 0, 0, |
| 618 bounds_.x() + location.x(), | 584 bounds_.x() + location.x(), |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 } | 693 } |
| 728 | 694 |
| 729 namespace test { | 695 namespace test { |
| 730 | 696 |
| 731 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) { | 697 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) { |
| 732 default_override_redirect = override_redirect; | 698 default_override_redirect = override_redirect; |
| 733 } | 699 } |
| 734 | 700 |
| 735 } // namespace test | 701 } // namespace test |
| 736 } // namespace aura | 702 } // namespace aura |
| OLD | NEW |