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

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

Issue 188223002: Clean up WindowEventDispatcher some more. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 9 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/window_tree_host_x11.h ('k') | ui/aura/window_tree_host_x11_unittest.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/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/Xfixes.h> 9 #include <X11/extensions/Xfixes.h>
10 #include <X11/extensions/XInput2.h> 10 #include <X11/extensions/XInput2.h>
(...skipping 17 matching lines...) Expand all
28 #include "base/strings/stringprintf.h" 28 #include "base/strings/stringprintf.h"
29 #include "base/sys_info.h" 29 #include "base/sys_info.h"
30 #include "ui/aura/client/cursor_client.h" 30 #include "ui/aura/client/cursor_client.h"
31 #include "ui/aura/client/screen_position_client.h" 31 #include "ui/aura/client/screen_position_client.h"
32 #include "ui/aura/env.h" 32 #include "ui/aura/env.h"
33 #include "ui/aura/window_event_dispatcher.h" 33 #include "ui/aura/window_event_dispatcher.h"
34 #include "ui/base/cursor/cursor.h" 34 #include "ui/base/cursor/cursor.h"
35 #include "ui/base/ui_base_switches.h" 35 #include "ui/base/ui_base_switches.h"
36 #include "ui/base/view_prop.h" 36 #include "ui/base/view_prop.h"
37 #include "ui/base/x/x11_util.h" 37 #include "ui/base/x/x11_util.h"
38 #include "ui/compositor/compositor.h"
38 #include "ui/compositor/dip_util.h" 39 #include "ui/compositor/dip_util.h"
39 #include "ui/compositor/layer.h" 40 #include "ui/compositor/layer.h"
40 #include "ui/events/event.h" 41 #include "ui/events/event.h"
41 #include "ui/events/event_utils.h" 42 #include "ui/events/event_utils.h"
42 #include "ui/events/keycodes/keyboard_codes.h" 43 #include "ui/events/keycodes/keyboard_codes.h"
43 #include "ui/events/x/device_data_manager.h" 44 #include "ui/events/x/device_data_manager.h"
44 #include "ui/events/x/device_list_cache_x.h" 45 #include "ui/events/x/device_list_cache_x.h"
45 #include "ui/events/x/touch_factory_x11.h" 46 #include "ui/events/x/touch_factory_x11.h"
46 #include "ui/gfx/screen.h" 47 #include "ui/gfx/screen.h"
47 48
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 case ui::ET_UNKNOWN: 412 case ui::ET_UNKNOWN:
412 // No event is created for X11-release events for mouse-wheel buttons. 413 // No event is created for X11-release events for mouse-wheel buttons.
413 break; 414 break;
414 default: 415 default:
415 NOTREACHED(); 416 NOTREACHED();
416 } 417 }
417 break; 418 break;
418 } 419 }
419 case FocusOut: 420 case FocusOut:
420 if (xev->xfocus.mode != NotifyGrab) 421 if (xev->xfocus.mode != NotifyGrab)
421 delegate_->OnHostLostWindowCapture(); 422 OnHostLostWindowCapture();
422 break; 423 break;
423 case ConfigureNotify: { 424 case ConfigureNotify: {
424 DCHECK_EQ(xwindow_, xev->xconfigure.event); 425 DCHECK_EQ(xwindow_, xev->xconfigure.event);
425 DCHECK_EQ(xwindow_, xev->xconfigure.window); 426 DCHECK_EQ(xwindow_, xev->xconfigure.window);
426 // It's possible that the X window may be resized by some other means 427 // It's possible that the X window may be resized by some other means
427 // than from within aura (e.g. the X window manager can change the 428 // than from within aura (e.g. the X window manager can change the
428 // size). Make sure the root window size is maintained properly. 429 // size). Make sure the root window size is maintained properly.
429 gfx::Rect bounds(xev->xconfigure.x, xev->xconfigure.y, 430 gfx::Rect bounds(xev->xconfigure.x, xev->xconfigure.y,
430 xev->xconfigure.width, xev->xconfigure.height); 431 xev->xconfigure.width, xev->xconfigure.height);
431 bool size_changed = bounds_.size() != bounds.size(); 432 bool size_changed = bounds_.size() != bounds.size();
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 } 545 }
545 546
546 gfx::Rect WindowTreeHostX11::GetBounds() const { 547 gfx::Rect WindowTreeHostX11::GetBounds() const {
547 return bounds_; 548 return bounds_;
548 } 549 }
549 550
550 void WindowTreeHostX11::SetBounds(const gfx::Rect& bounds) { 551 void WindowTreeHostX11::SetBounds(const gfx::Rect& bounds) {
551 // Even if the host window's size doesn't change, aura's root window 552 // Even if the host window's size doesn't change, aura's root window
552 // size, which is in DIP, changes when the scale changes. 553 // size, which is in DIP, changes when the scale changes.
553 float current_scale = compositor()->device_scale_factor(); 554 float current_scale = compositor()->device_scale_factor();
554 float new_scale = gfx::Screen::GetScreenFor( 555 float new_scale = gfx::Screen::GetScreenFor(window())->
555 delegate_->AsDispatcher()->window())->GetDisplayNearestWindow( 556 GetDisplayNearestWindow(window()).device_scale_factor();
556 delegate_->AsDispatcher()->window()).device_scale_factor();
557 bool origin_changed = bounds_.origin() != bounds.origin(); 557 bool origin_changed = bounds_.origin() != bounds.origin();
558 bool size_changed = bounds_.size() != bounds.size(); 558 bool size_changed = bounds_.size() != bounds.size();
559 XWindowChanges changes = {0}; 559 XWindowChanges changes = {0};
560 unsigned value_mask = 0; 560 unsigned value_mask = 0;
561 561
562 if (size_changed) { 562 if (size_changed) {
563 changes.width = bounds.width(); 563 changes.width = bounds.width();
564 changes.height = bounds.height(); 564 changes.height = bounds.height();
565 value_mask = CWHeight | CWWidth; 565 value_mask = CWHeight | CWWidth;
566 } 566 }
(...skipping 11 matching lines...) Expand all
578 // manager, it can modify or ignore the request, but (per ICCCM) we'll get a 578 // manager, it can modify or ignore the request, but (per ICCCM) we'll get a
579 // (possibly synthetic) ConfigureNotify about the actual size and correct 579 // (possibly synthetic) ConfigureNotify about the actual size and correct
580 // |bounds_| later. 580 // |bounds_| later.
581 bounds_ = bounds; 581 bounds_ = bounds;
582 UpdateIsInternalDisplay(); 582 UpdateIsInternalDisplay();
583 if (origin_changed) 583 if (origin_changed)
584 OnHostMoved(bounds.origin()); 584 OnHostMoved(bounds.origin());
585 if (size_changed || current_scale != new_scale) { 585 if (size_changed || current_scale != new_scale) {
586 OnHostResized(bounds.size()); 586 OnHostResized(bounds.size());
587 } else { 587 } else {
588 delegate_->AsDispatcher()->window()->SchedulePaintInRect( 588 window()->SchedulePaintInRect(window()->bounds());
589 delegate_->AsDispatcher()->window()->bounds());
590 } 589 }
591 } 590 }
592 591
593 gfx::Insets WindowTreeHostX11::GetInsets() const { 592 gfx::Insets WindowTreeHostX11::GetInsets() const {
594 return insets_; 593 return insets_;
595 } 594 }
596 595
597 void WindowTreeHostX11::SetInsets(const gfx::Insets& insets) { 596 void WindowTreeHostX11::SetInsets(const gfx::Insets& insets) {
598 insets_ = insets; 597 insets_ = insets;
599 if (pointer_barriers_) { 598 if (pointer_barriers_) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 case KeyRelease: 701 case KeyRelease:
703 case ButtonPress: 702 case ButtonPress:
704 case ButtonRelease: { 703 case ButtonRelease: {
705 // The fields used below are in the same place for all of events 704 // The fields used below are in the same place for all of events
706 // above. Using xmotion from XEvent's unions to avoid repeating 705 // above. Using xmotion from XEvent's unions to avoid repeating
707 // the code. 706 // the code.
708 xevent.xmotion.root = x_root_window_; 707 xevent.xmotion.root = x_root_window_;
709 xevent.xmotion.time = CurrentTime; 708 xevent.xmotion.time = CurrentTime;
710 709
711 gfx::Point point(xevent.xmotion.x, xevent.xmotion.y); 710 gfx::Point point(xevent.xmotion.x, xevent.xmotion.y);
712 delegate_->AsDispatcher()->host()->ConvertPointToNativeScreen(&point); 711 ConvertPointToNativeScreen(&point);
713 xevent.xmotion.x_root = point.x(); 712 xevent.xmotion.x_root = point.x();
714 xevent.xmotion.y_root = point.y(); 713 xevent.xmotion.y_root = point.y();
715 } 714 }
716 default: 715 default:
717 break; 716 break;
718 } 717 }
719 XSendEvent(xdisplay_, xwindow_, False, 0, &xevent); 718 XSendEvent(xdisplay_, xwindow_, False, 0, &xevent);
720 } 719 }
721 720
722 void WindowTreeHostX11::OnDeviceScaleFactorChanged( 721 void WindowTreeHostX11::OnDeviceScaleFactorChanged(
(...skipping 19 matching lines...) Expand all
742 741
743 void WindowTreeHostX11::OnCursorVisibilityChangedNative(bool show) { 742 void WindowTreeHostX11::OnCursorVisibilityChangedNative(bool show) {
744 SetCrOSTapPaused(!show); 743 SetCrOSTapPaused(!show);
745 } 744 }
746 745
747 void WindowTreeHostX11::OnWindowInitialized(Window* window) { 746 void WindowTreeHostX11::OnWindowInitialized(Window* window) {
748 } 747 }
749 748
750 void WindowTreeHostX11::OnRootWindowInitialized( 749 void WindowTreeHostX11::OnRootWindowInitialized(
751 WindowEventDispatcher* d) { 750 WindowEventDispatcher* d) {
752 // UpdateIsInternalDisplay relies on: 751 // UpdateIsInternalDisplay relies on WED's kDisplayIdKey property being set
753 // 1. delegate_ pointing to WindowEventDispatcher - available after 752 // available by the time WED::Init is called. (set in
754 // SetDelegate. 753 // DisplayManager::CreateRootWindowForDisplay)
755 // 2. WED's kDisplayIdKey property set - available by the time
756 // WED::Init is called.
757 // (set in DisplayManager::CreateRootWindowForDisplay)
758 // Ready when NotifyRootWindowInitialized is called from WED::Init. 754 // Ready when NotifyRootWindowInitialized is called from WED::Init.
759 if (!delegate_ || d != dispatcher()) 755 if (d != dispatcher())
760 return; 756 return;
761 UpdateIsInternalDisplay(); 757 UpdateIsInternalDisplay();
762 758
763 // We have to enable Tap-to-click by default because the cursor is set to 759 // We have to enable Tap-to-click by default because the cursor is set to
764 // visible in Shell::InitRootWindowController. 760 // visible in Shell::InitRootWindowController.
765 SetCrOSTapPaused(false); 761 SetCrOSTapPaused(false);
766 } 762 }
767 763
768 ui::EventProcessor* WindowTreeHostX11::GetEventProcessor() { 764 ui::EventProcessor* WindowTreeHostX11::GetEventProcessor() {
769 return delegate_->GetEventProcessor(); 765 return dispatcher();
770 } 766 }
771 767
772 void WindowTreeHostX11::DispatchXI2Event(const base::NativeEvent& event) { 768 void WindowTreeHostX11::DispatchXI2Event(const base::NativeEvent& event) {
773 ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); 769 ui::TouchFactory* factory = ui::TouchFactory::GetInstance();
774 XEvent* xev = event; 770 XEvent* xev = event;
775 if (!factory->ShouldProcessXI2Event(xev)) 771 if (!factory->ShouldProcessXI2Event(xev))
776 return; 772 return;
777 773
778 TRACE_EVENT1("input", "WindowTreeHostX11::DispatchXI2Event", 774 TRACE_EVENT1("input", "WindowTreeHostX11::DispatchXI2Event",
779 "event_latency_us", 775 "event_latency_us",
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 } 955 }
960 956
961 namespace test { 957 namespace test {
962 958
963 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) { 959 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) {
964 default_override_redirect = override_redirect; 960 default_override_redirect = override_redirect;
965 } 961 }
966 962
967 } // namespace test 963 } // namespace test
968 } // namespace aura 964 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/window_tree_host_x11.h ('k') | ui/aura/window_tree_host_x11_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698