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

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

Issue 10827145: Convert Aura to use ui::Event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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
« no previous file with comments | « ui/aura/root_window_host_delegate.h ('k') | ui/aura/root_window_host_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/Xatom.h> 7 #include <X11/Xatom.h>
8 #include <X11/Xcursor/Xcursor.h> 8 #include <X11/Xcursor/Xcursor.h>
9 #include <X11/Xlib.h> 9 #include <X11/Xlib.h>
10 #include <X11/cursorfont.h> 10 #include <X11/cursorfont.h>
11 #include <X11/extensions/XInput2.h> 11 #include <X11/extensions/XInput2.h>
12 #include <X11/extensions/Xfixes.h> 12 #include <X11/extensions/Xfixes.h>
13 #include <X11/extensions/Xrandr.h> 13 #include <X11/extensions/Xrandr.h>
14 #include <algorithm> 14 #include <algorithm>
15 15
16 #include "base/command_line.h" 16 #include "base/command_line.h"
17 #include "base/message_pump_aurax11.h" 17 #include "base/message_pump_aurax11.h"
18 #include "base/stl_util.h" 18 #include "base/stl_util.h"
19 #include "base/stringprintf.h" 19 #include "base/stringprintf.h"
20 #include "grit/ui_resources.h" 20 #include "grit/ui_resources.h"
21 #include "ui/aura/client/capture_client.h" 21 #include "ui/aura/client/capture_client.h"
22 #include "ui/aura/client/user_action_client.h" 22 #include "ui/aura/client/user_action_client.h"
23 #include "ui/aura/dispatcher_linux.h" 23 #include "ui/aura/dispatcher_linux.h"
24 #include "ui/aura/env.h" 24 #include "ui/aura/env.h"
25 #include "ui/aura/event.h"
26 #include "ui/aura/root_window.h" 25 #include "ui/aura/root_window.h"
27 #include "ui/base/cursor/cursor.h" 26 #include "ui/base/cursor/cursor.h"
27 #include "ui/base/event.h"
28 #include "ui/base/keycodes/keyboard_codes.h" 28 #include "ui/base/keycodes/keyboard_codes.h"
29 #include "ui/base/resource/resource_bundle.h" 29 #include "ui/base/resource/resource_bundle.h"
30 #include "ui/base/touch/touch_factory.h" 30 #include "ui/base/touch/touch_factory.h"
31 #include "ui/base/ui_base_switches.h" 31 #include "ui/base/ui_base_switches.h"
32 #include "ui/base/view_prop.h" 32 #include "ui/base/view_prop.h"
33 #include "ui/base/x/x11_util.h" 33 #include "ui/base/x/x11_util.h"
34 #include "ui/compositor/layer.h" 34 #include "ui/compositor/layer.h"
35 #include "ui/gfx/codec/png_codec.h" 35 #include "ui/gfx/codec/png_codec.h"
36 #include "ui/gfx/image/image.h" 36 #include "ui/gfx/image/image.h"
37 #include "ui/gfx/image/image_skia.h" 37 #include "ui/gfx/image/image_skia.h"
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 bool RootWindowHostLinux::Dispatch(const base::NativeEvent& event) { 578 bool RootWindowHostLinux::Dispatch(const base::NativeEvent& event) {
579 XEvent* xev = event; 579 XEvent* xev = event;
580 580
581 CheckXEventForConsistency(xev); 581 CheckXEventForConsistency(xev);
582 582
583 switch (xev->type) { 583 switch (xev->type) {
584 case Expose: 584 case Expose:
585 delegate_->AsRootWindow()->ScheduleFullDraw(); 585 delegate_->AsRootWindow()->ScheduleFullDraw();
586 break; 586 break;
587 case KeyPress: { 587 case KeyPress: {
588 KeyEvent keydown_event(xev, false); 588 ui::KeyEvent keydown_event(xev, false);
589 delegate_->OnHostKeyEvent(&keydown_event); 589 delegate_->OnHostKeyEvent(&keydown_event);
590 break; 590 break;
591 } 591 }
592 case KeyRelease: { 592 case KeyRelease: {
593 KeyEvent keyup_event(xev, false); 593 ui::KeyEvent keyup_event(xev, false);
594 delegate_->OnHostKeyEvent(&keyup_event); 594 delegate_->OnHostKeyEvent(&keyup_event);
595 break; 595 break;
596 } 596 }
597 case ButtonPress: { 597 case ButtonPress: {
598 if (static_cast<int>(xev->xbutton.button) == kBackMouseButton || 598 if (static_cast<int>(xev->xbutton.button) == kBackMouseButton ||
599 static_cast<int>(xev->xbutton.button) == kForwardMouseButton) { 599 static_cast<int>(xev->xbutton.button) == kForwardMouseButton) {
600 client::UserActionClient* gesture_client = 600 client::UserActionClient* gesture_client =
601 client::GetUserActionClient(delegate_->AsRootWindow()); 601 client::GetUserActionClient(delegate_->AsRootWindow());
602 if (gesture_client) { 602 if (gesture_client) {
603 gesture_client->OnUserAction( 603 gesture_client->OnUserAction(
604 static_cast<int>(xev->xbutton.button) == kBackMouseButton ? 604 static_cast<int>(xev->xbutton.button) == kBackMouseButton ?
605 client::UserActionClient::BACK : 605 client::UserActionClient::BACK :
606 client::UserActionClient::FORWARD); 606 client::UserActionClient::FORWARD);
607 } 607 }
608 break; 608 break;
609 } 609 }
610 } // fallthrough 610 } // fallthrough
611 case ButtonRelease: { 611 case ButtonRelease: {
612 MouseEvent mouseev(xev); 612 ui::MouseEvent mouseev(xev);
613 delegate_->OnHostMouseEvent(&mouseev); 613 delegate_->OnHostMouseEvent(&mouseev);
614 break; 614 break;
615 } 615 }
616 case FocusOut: 616 case FocusOut:
617 if (xev->xfocus.mode != NotifyGrab) 617 if (xev->xfocus.mode != NotifyGrab)
618 delegate_->OnHostLostCapture(); 618 delegate_->OnHostLostCapture();
619 break; 619 break;
620 case ConfigureNotify: { 620 case ConfigureNotify: {
621 DCHECK_EQ(xwindow_, xev->xconfigure.window); 621 DCHECK_EQ(xwindow_, xev->xconfigure.window);
622 DCHECK_EQ(xwindow_, xev->xconfigure.event); 622 DCHECK_EQ(xwindow_, xev->xconfigure.event);
(...skipping 22 matching lines...) Expand all
645 break; 645 break;
646 646
647 ui::EventType type = ui::EventTypeFromNative(xev); 647 ui::EventType type = ui::EventTypeFromNative(xev);
648 XEvent last_event; 648 XEvent last_event;
649 int num_coalesced = 0; 649 int num_coalesced = 0;
650 650
651 switch (type) { 651 switch (type) {
652 case ui::ET_TOUCH_PRESSED: 652 case ui::ET_TOUCH_PRESSED:
653 case ui::ET_TOUCH_RELEASED: 653 case ui::ET_TOUCH_RELEASED:
654 case ui::ET_TOUCH_MOVED: { 654 case ui::ET_TOUCH_MOVED: {
655 TouchEvent touchev(xev); 655 ui::TouchEventImpl touchev(xev);
656 delegate_->OnHostTouchEvent(&touchev); 656 delegate_->OnHostTouchEvent(&touchev);
657 break; 657 break;
658 } 658 }
659 case ui::ET_MOUSE_MOVED: 659 case ui::ET_MOUSE_MOVED:
660 case ui::ET_MOUSE_DRAGGED: 660 case ui::ET_MOUSE_DRAGGED:
661 case ui::ET_MOUSE_PRESSED: 661 case ui::ET_MOUSE_PRESSED:
662 case ui::ET_MOUSE_RELEASED: 662 case ui::ET_MOUSE_RELEASED:
663 case ui::ET_MOUSEWHEEL: 663 case ui::ET_MOUSEWHEEL:
664 case ui::ET_MOUSE_ENTERED: 664 case ui::ET_MOUSE_ENTERED:
665 case ui::ET_MOUSE_EXITED: { 665 case ui::ET_MOUSE_EXITED: {
(...skipping 15 matching lines...) Expand all
681 ui::IsTouchpadEvent(xev) && ui::IsNaturalScrollEnabled(); 681 ui::IsTouchpadEvent(xev) && ui::IsNaturalScrollEnabled();
682 gesture_client->OnUserAction( 682 gesture_client->OnUserAction(
683 (button == kBackMouseButton && !reverse_direction) || 683 (button == kBackMouseButton && !reverse_direction) ||
684 (button == kForwardMouseButton && reverse_direction) ? 684 (button == kForwardMouseButton && reverse_direction) ?
685 client::UserActionClient::BACK : 685 client::UserActionClient::BACK :
686 client::UserActionClient::FORWARD); 686 client::UserActionClient::FORWARD);
687 } 687 }
688 break; 688 break;
689 } 689 }
690 } 690 }
691 MouseEvent mouseev(xev); 691 ui::MouseEvent mouseev(xev);
692 delegate_->OnHostMouseEvent(&mouseev); 692 delegate_->OnHostMouseEvent(&mouseev);
693 break; 693 break;
694 } 694 }
695 case ui::ET_SCROLL_FLING_START: 695 case ui::ET_SCROLL_FLING_START:
696 case ui::ET_SCROLL_FLING_CANCEL: 696 case ui::ET_SCROLL_FLING_CANCEL:
697 case ui::ET_SCROLL: { 697 case ui::ET_SCROLL: {
698 ScrollEvent scrollev(xev); 698 ui::ScrollEvent scrollev(xev);
699 delegate_->OnHostScrollEvent(&scrollev); 699 delegate_->OnHostScrollEvent(&scrollev);
700 break; 700 break;
701 } 701 }
702 case ui::ET_UNKNOWN: 702 case ui::ET_UNKNOWN:
703 break; 703 break;
704 default: 704 default:
705 NOTREACHED(); 705 NOTREACHED();
706 } 706 }
707 707
708 // If we coalesced an event we need to free its cookie. 708 // If we coalesced an event we need to free its cookie.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 next_event.xmotion.window == xev->xmotion.window && 761 next_event.xmotion.window == xev->xmotion.window &&
762 next_event.xmotion.subwindow == xev->xmotion.subwindow && 762 next_event.xmotion.subwindow == xev->xmotion.subwindow &&
763 next_event.xmotion.state == xev->xmotion.state) { 763 next_event.xmotion.state == xev->xmotion.state) {
764 XNextEvent(xev->xany.display, &last_event); 764 XNextEvent(xev->xany.display, &last_event);
765 xev = &last_event; 765 xev = &last_event;
766 } else { 766 } else {
767 break; 767 break;
768 } 768 }
769 } 769 }
770 770
771 MouseEvent mouseev(xev); 771 ui::MouseEvent mouseev(xev);
772 delegate_->OnHostMouseEvent(&mouseev); 772 delegate_->OnHostMouseEvent(&mouseev);
773 break; 773 break;
774 } 774 }
775 } 775 }
776 return true; 776 return true;
777 } 777 }
778 778
779 RootWindow* RootWindowHostLinux::GetRootWindow() { 779 RootWindow* RootWindowHostLinux::GetRootWindow() {
780 return delegate_->AsRootWindow(); 780 return delegate_->AsRootWindow();
781 } 781 }
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 ui::ViewProp::GetValue(accelerated_widget, kRootWindowHostLinuxKey)); 1061 ui::ViewProp::GetValue(accelerated_widget, kRootWindowHostLinuxKey));
1062 } 1062 }
1063 1063
1064 // static 1064 // static
1065 gfx::Size RootWindowHost::GetNativeScreenSize() { 1065 gfx::Size RootWindowHost::GetNativeScreenSize() {
1066 ::Display* xdisplay = base::MessagePumpAuraX11::GetDefaultXDisplay(); 1066 ::Display* xdisplay = base::MessagePumpAuraX11::GetDefaultXDisplay();
1067 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); 1067 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0));
1068 } 1068 }
1069 1069
1070 } // namespace aura 1070 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/root_window_host_delegate.h ('k') | ui/aura/root_window_host_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698