Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(528)

Side by Side Diff: ui/aura/root_window_host_linux.cc

Issue 10948020: Convert native mouse locations to the locations in screen coordinate in RootWindowHostLinux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 OnHostMouseEventInternal(&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
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 OnHostMouseEventInternal(&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
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 OnHostMouseEventInternal(&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
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 OnHostMouseEventInternal(&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 OnHostMouseEventInternal(&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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 // Per ICCCM 2.8, "Manager Selections", window managers should take ownership 972 // Per ICCCM 2.8, "Manager Selections", window managers should take ownership
973 // of WM_Sn selections (where n is a screen number). 973 // of WM_Sn selections (where n is a screen number).
974 return XGetSelectionOwner( 974 return XGetSelectionOwner(
975 xdisplay_, atom_cache_.GetAtom("WM_S0")) != None; 975 xdisplay_, atom_cache_.GetAtom("WM_S0")) != None;
976 } 976 }
977 977
978 void RootWindowHostLinux::SetCursorInternal(gfx::NativeCursor cursor) { 978 void RootWindowHostLinux::SetCursorInternal(gfx::NativeCursor cursor) {
979 XDefineCursor(xdisplay_, xwindow_, cursor.platform()); 979 XDefineCursor(xdisplay_, xwindow_, cursor.platform());
980 } 980 }
981 981
982 void RootWindowHostLinux::OnHostMouseEventInternal(ui::MouseEvent* event) {
983 client::ScreenPositionClient* screen_position_client =
984 GetScreenPositionClient(GetRootWindow());
oshima 2012/09/18 23:10:15 nit. assigning RootWindow to root would make it cl
mazda 2012/09/18 23:44:57 Done.
985 if (screen_position_client && !bounds_.Contains(event->location())) {
986 gfx::Point location(event->location());
987 screen_position_client->ConvertNativePointToScreen(GetRootWindow(),
988 &location);
989 screen_position_client->ConvertPointFromScreen(GetRootWindow(),
990 &location);
991 event->set_location(location);
992 event->set_root_location(location);
993 }
994 delegate_->OnHostMouseEvent(event);
995 }
996
982 // static 997 // static
983 RootWindowHost* RootWindowHost::Create(RootWindowHostDelegate* delegate, 998 RootWindowHost* RootWindowHost::Create(RootWindowHostDelegate* delegate,
984 const gfx::Rect& bounds) { 999 const gfx::Rect& bounds) {
985 return new RootWindowHostLinux(delegate, bounds); 1000 return new RootWindowHostLinux(delegate, bounds);
986 } 1001 }
987 1002
988 // static 1003 // static
989 RootWindowHost* RootWindowHost::GetForAcceleratedWidget( 1004 RootWindowHost* RootWindowHost::GetForAcceleratedWidget(
990 gfx::AcceleratedWidget accelerated_widget) { 1005 gfx::AcceleratedWidget accelerated_widget) {
991 return reinterpret_cast<RootWindowHost*>( 1006 return reinterpret_cast<RootWindowHost*>(
992 ui::ViewProp::GetValue(accelerated_widget, kRootWindowHostLinuxKey)); 1007 ui::ViewProp::GetValue(accelerated_widget, kRootWindowHostLinuxKey));
993 } 1008 }
994 1009
995 // static 1010 // static
996 gfx::Size RootWindowHost::GetNativeScreenSize() { 1011 gfx::Size RootWindowHost::GetNativeScreenSize() {
997 ::Display* xdisplay = base::MessagePumpAuraX11::GetDefaultXDisplay(); 1012 ::Display* xdisplay = base::MessagePumpAuraX11::GetDefaultXDisplay();
998 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); 1013 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0));
999 } 1014 }
1000 1015
1001 } // namespace aura 1016 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698