| 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/root_window_host_linux.h" | 5 #include "ui/aura/root_window_host_linux.h" |
| 6 | 6 |
| 7 #include <X11/cursorfont.h> | 7 #include <X11/cursorfont.h> |
| 8 #include <X11/extensions/Xfixes.h> | 8 #include <X11/extensions/Xfixes.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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 XEvent* xev = event; | 430 XEvent* xev = event; |
| 431 | 431 |
| 432 CheckXEventForConsistency(xev); | 432 CheckXEventForConsistency(xev); |
| 433 | 433 |
| 434 if (FindEventTarget(event) == x_root_window_) | 434 if (FindEventTarget(event) == x_root_window_) |
| 435 return DispatchEventForRootWindow(event); | 435 return DispatchEventForRootWindow(event); |
| 436 | 436 |
| 437 switch (xev->type) { | 437 switch (xev->type) { |
| 438 case EnterNotify: { | 438 case EnterNotify: { |
| 439 ui::MouseEvent mouseenter_event(xev); | 439 ui::MouseEvent mouseenter_event(xev); |
| 440 delegate_->OnHostMouseEvent(&mouseenter_event); | 440 TranslateAndDispatchMouseEvent(&mouseenter_event); |
| 441 break; | 441 break; |
| 442 } | 442 } |
| 443 case Expose: | 443 case Expose: |
| 444 delegate_->AsRootWindow()->ScheduleFullDraw(); | 444 delegate_->AsRootWindow()->ScheduleFullDraw(); |
| 445 break; | 445 break; |
| 446 case KeyPress: { | 446 case KeyPress: { |
| 447 ui::KeyEvent keydown_event(xev, false); | 447 ui::KeyEvent keydown_event(xev, false); |
| 448 delegate_->OnHostKeyEvent(&keydown_event); | 448 delegate_->OnHostKeyEvent(&keydown_event); |
| 449 break; | 449 break; |
| 450 } | 450 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 462 gesture_client->OnUserAction( | 462 gesture_client->OnUserAction( |
| 463 static_cast<int>(xev->xbutton.button) == kBackMouseButton ? | 463 static_cast<int>(xev->xbutton.button) == kBackMouseButton ? |
| 464 client::UserActionClient::BACK : | 464 client::UserActionClient::BACK : |
| 465 client::UserActionClient::FORWARD); | 465 client::UserActionClient::FORWARD); |
| 466 } | 466 } |
| 467 break; | 467 break; |
| 468 } | 468 } |
| 469 } // fallthrough | 469 } // fallthrough |
| 470 case ButtonRelease: { | 470 case ButtonRelease: { |
| 471 ui::MouseEvent mouseev(xev); | 471 ui::MouseEvent mouseev(xev); |
| 472 delegate_->OnHostMouseEvent(&mouseev); | 472 TranslateAndDispatchMouseEvent(&mouseev); |
| 473 break; | 473 break; |
| 474 } | 474 } |
| 475 case FocusOut: | 475 case FocusOut: |
| 476 if (xev->xfocus.mode != NotifyGrab) | 476 if (xev->xfocus.mode != NotifyGrab) |
| 477 delegate_->OnHostLostCapture(); | 477 delegate_->OnHostLostCapture(); |
| 478 break; | 478 break; |
| 479 case ConfigureNotify: { | 479 case ConfigureNotify: { |
| 480 DCHECK_EQ(xwindow_, xev->xconfigure.event); | 480 DCHECK_EQ(xwindow_, xev->xconfigure.event); |
| 481 DCHECK_EQ(xwindow_, xev->xconfigure.window); | 481 DCHECK_EQ(xwindow_, xev->xconfigure.window); |
| 482 // It's possible that the X window may be resized by some other means | 482 // It's possible that the X window may be resized by some other means |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 next_event.xmotion.subwindow == xev->xmotion.subwindow && | 566 next_event.xmotion.subwindow == xev->xmotion.subwindow && |
| 567 next_event.xmotion.state == xev->xmotion.state) { | 567 next_event.xmotion.state == xev->xmotion.state) { |
| 568 XNextEvent(xev->xany.display, &last_event); | 568 XNextEvent(xev->xany.display, &last_event); |
| 569 xev = &last_event; | 569 xev = &last_event; |
| 570 } else { | 570 } else { |
| 571 break; | 571 break; |
| 572 } | 572 } |
| 573 } | 573 } |
| 574 | 574 |
| 575 ui::MouseEvent mouseev(xev); | 575 ui::MouseEvent mouseev(xev); |
| 576 delegate_->OnHostMouseEvent(&mouseev); | 576 TranslateAndDispatchMouseEvent(&mouseev); |
| 577 break; | 577 break; |
| 578 } | 578 } |
| 579 } | 579 } |
| 580 return true; | 580 return true; |
| 581 } | 581 } |
| 582 | 582 |
| 583 bool RootWindowHostLinux::DispatchEventForRootWindow( | 583 bool RootWindowHostLinux::DispatchEventForRootWindow( |
| 584 const base::NativeEvent& event) { | 584 const base::NativeEvent& event) { |
| 585 switch (event->type) { | 585 switch (event->type) { |
| 586 case ConfigureNotify: | 586 case ConfigureNotify: |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 gesture_client->OnUserAction( | 664 gesture_client->OnUserAction( |
| 665 (button == kBackMouseButton && !reverse_direction) || | 665 (button == kBackMouseButton && !reverse_direction) || |
| 666 (button == kForwardMouseButton && reverse_direction) ? | 666 (button == kForwardMouseButton && reverse_direction) ? |
| 667 client::UserActionClient::BACK : | 667 client::UserActionClient::BACK : |
| 668 client::UserActionClient::FORWARD); | 668 client::UserActionClient::FORWARD); |
| 669 } | 669 } |
| 670 break; | 670 break; |
| 671 } | 671 } |
| 672 } | 672 } |
| 673 ui::MouseEvent mouseev(xev); | 673 ui::MouseEvent mouseev(xev); |
| 674 delegate_->OnHostMouseEvent(&mouseev); | 674 TranslateAndDispatchMouseEvent(&mouseev); |
| 675 break; | 675 break; |
| 676 } | 676 } |
| 677 case ui::ET_MOUSEWHEEL: { | 677 case ui::ET_MOUSEWHEEL: { |
| 678 ui::MouseWheelEvent mouseev(xev); | 678 ui::MouseWheelEvent mouseev(xev); |
| 679 delegate_->OnHostMouseEvent(&mouseev); | 679 TranslateAndDispatchMouseEvent(&mouseev); |
| 680 break; | 680 break; |
| 681 } | 681 } |
| 682 case ui::ET_SCROLL_FLING_START: | 682 case ui::ET_SCROLL_FLING_START: |
| 683 case ui::ET_SCROLL_FLING_CANCEL: | 683 case ui::ET_SCROLL_FLING_CANCEL: |
| 684 case ui::ET_SCROLL: { | 684 case ui::ET_SCROLL: { |
| 685 ui::ScrollEvent scrollev(xev); | 685 ui::ScrollEvent scrollev(xev); |
| 686 delegate_->OnHostScrollEvent(&scrollev); | 686 delegate_->OnHostScrollEvent(&scrollev); |
| 687 break; | 687 break; |
| 688 } | 688 } |
| 689 case ui::ET_UNKNOWN: | 689 case ui::ET_UNKNOWN: |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 // Per ICCCM 2.8, "Manager Selections", window managers should take ownership | 982 // Per ICCCM 2.8, "Manager Selections", window managers should take ownership |
| 983 // of WM_Sn selections (where n is a screen number). | 983 // of WM_Sn selections (where n is a screen number). |
| 984 return XGetSelectionOwner( | 984 return XGetSelectionOwner( |
| 985 xdisplay_, atom_cache_.GetAtom("WM_S0")) != None; | 985 xdisplay_, atom_cache_.GetAtom("WM_S0")) != None; |
| 986 } | 986 } |
| 987 | 987 |
| 988 void RootWindowHostLinux::SetCursorInternal(gfx::NativeCursor cursor) { | 988 void RootWindowHostLinux::SetCursorInternal(gfx::NativeCursor cursor) { |
| 989 XDefineCursor(xdisplay_, xwindow_, cursor.platform()); | 989 XDefineCursor(xdisplay_, xwindow_, cursor.platform()); |
| 990 } | 990 } |
| 991 | 991 |
| 992 void RootWindowHostLinux::TranslateAndDispatchMouseEvent( |
| 993 ui::MouseEvent* event) { |
| 994 RootWindow* root = GetRootWindow(); |
| 995 client::ScreenPositionClient* screen_position_client = |
| 996 GetScreenPositionClient(root); |
| 997 if (screen_position_client && !bounds_.Contains(event->location())) { |
| 998 gfx::Point location(event->location()); |
| 999 screen_position_client->ConvertNativePointToScreen(root, &location); |
| 1000 screen_position_client->ConvertPointFromScreen(root, &location); |
| 1001 event->set_location(location); |
| 1002 event->set_root_location(location); |
| 1003 } |
| 1004 delegate_->OnHostMouseEvent(event); |
| 1005 } |
| 1006 |
| 992 // static | 1007 // static |
| 993 RootWindowHost* RootWindowHost::Create(RootWindowHostDelegate* delegate, | 1008 RootWindowHost* RootWindowHost::Create(RootWindowHostDelegate* delegate, |
| 994 const gfx::Rect& bounds) { | 1009 const gfx::Rect& bounds) { |
| 995 return new RootWindowHostLinux(delegate, bounds); | 1010 return new RootWindowHostLinux(delegate, bounds); |
| 996 } | 1011 } |
| 997 | 1012 |
| 998 // static | 1013 // static |
| 999 RootWindowHost* RootWindowHost::GetForAcceleratedWidget( | 1014 RootWindowHost* RootWindowHost::GetForAcceleratedWidget( |
| 1000 gfx::AcceleratedWidget accelerated_widget) { | 1015 gfx::AcceleratedWidget accelerated_widget) { |
| 1001 return reinterpret_cast<RootWindowHost*>( | 1016 return reinterpret_cast<RootWindowHost*>( |
| 1002 ui::ViewProp::GetValue(accelerated_widget, kRootWindowHostLinuxKey)); | 1017 ui::ViewProp::GetValue(accelerated_widget, kRootWindowHostLinuxKey)); |
| 1003 } | 1018 } |
| 1004 | 1019 |
| 1005 // static | 1020 // static |
| 1006 gfx::Size RootWindowHost::GetNativeScreenSize() { | 1021 gfx::Size RootWindowHost::GetNativeScreenSize() { |
| 1007 ::Display* xdisplay = base::MessagePumpAuraX11::GetDefaultXDisplay(); | 1022 ::Display* xdisplay = base::MessagePumpAuraX11::GetDefaultXDisplay(); |
| 1008 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); | 1023 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); |
| 1009 } | 1024 } |
| 1010 | 1025 |
| 1011 } // namespace aura | 1026 } // namespace aura |
| OLD | NEW |