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

Side by Side Diff: ui/display/chromeos/x11/native_display_delegate_x11.cc

Issue 336863002: Moving input device hotplug event processing outside of ui/display (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/display/chromeos/x11/native_display_delegate_x11.h" 5 #include "ui/display/chromeos/x11/native_display_delegate_x11.h"
6 6
7 #include <X11/Xatom.h> 7 #include <X11/Xatom.h>
8 #include <X11/Xlib.h> 8 #include <X11/Xlib.h>
9 #include <X11/extensions/dpms.h> 9 #include <X11/extensions/dpms.h>
10 #include <X11/extensions/Xrandr.h> 10 #include <X11/extensions/Xrandr.h>
11 #include <X11/extensions/XInput2.h> 11 #include <X11/extensions/XInput2.h>
12 12
13 #include <utility> 13 #include <utility>
14 14
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/stl_util.h" 16 #include "base/stl_util.h"
17 #include "ui/display/chromeos/x11/display_mode_x11.h" 17 #include "ui/display/chromeos/x11/display_mode_x11.h"
18 #include "ui/display/chromeos/x11/display_snapshot_x11.h" 18 #include "ui/display/chromeos/x11/display_snapshot_x11.h"
19 #include "ui/display/chromeos/x11/display_util_x11.h" 19 #include "ui/display/chromeos/x11/display_util_x11.h"
20 #include "ui/display/chromeos/x11/native_display_event_dispatcher_x11.h" 20 #include "ui/display/chromeos/x11/native_display_event_dispatcher_x11.h"
21 #include "ui/display/types/chromeos/native_display_observer.h" 21 #include "ui/display/types/chromeos/native_display_observer.h"
22 #include "ui/display/util/x11/edid_parser_x11.h" 22 #include "ui/display/util/x11/edid_parser_x11.h"
23 #include "ui/events/device_data_manager.h"
24 #include "ui/events/input_device_event_observer.h"
25 #include "ui/events/platform/platform_event_source.h" 23 #include "ui/events/platform/platform_event_source.h"
26 #include "ui/gfx/geometry/rect.h" 24 #include "ui/gfx/geometry/rect.h"
27 #include "ui/gfx/x/x11_error_tracker.h" 25 #include "ui/gfx/x/x11_error_tracker.h"
28 #include "ui/gfx/x/x11_types.h" 26 #include "ui/gfx/x/x11_types.h"
29 27
30 namespace ui { 28 namespace ui {
31 29
32 namespace { 30 namespace {
33 31
34 // DPI measurements. 32 // DPI measurements.
(...skipping 30 matching lines...) Expand all
65 resampled->green[i] = gamma_ramp->green[gamma_ramp->size - 1]; 63 resampled->green[i] = gamma_ramp->green[gamma_ramp->size - 1];
66 resampled->blue[i] = gamma_ramp->blue[gamma_ramp->size - 1]; 64 resampled->blue[i] = gamma_ramp->blue[gamma_ramp->size - 1];
67 } 65 }
68 } 66 }
69 67
70 #undef RESAMPLE 68 #undef RESAMPLE
71 XRRFreeGamma(gamma_ramp); 69 XRRFreeGamma(gamma_ramp);
72 return resampled; 70 return resampled;
73 } 71 }
74 72
75 class InputHotplugEventObserver : public InputDeviceEventObserver {
76 public:
77 explicit InputHotplugEventObserver(
78 NativeDisplayDelegateX11::HelperDelegate* delegate)
79 : delegate_(delegate) {}
80 virtual ~InputHotplugEventObserver() {}
81
82 // InputDeviceEventObserver:
83 virtual void OnInputDeviceConfigurationChanged() OVERRIDE {
84 delegate_->NotifyDisplayObservers();
85 }
86
87 private:
88 NativeDisplayDelegateX11::HelperDelegate* delegate_; // Not owned.
89
90 DISALLOW_COPY_AND_ASSIGN(InputHotplugEventObserver);
91 };
92
93 } // namespace 73 } // namespace
94 74
95 //////////////////////////////////////////////////////////////////////////////// 75 ////////////////////////////////////////////////////////////////////////////////
96 // NativeDisplayDelegateX11::HelperDelegateX11 76 // NativeDisplayDelegateX11::HelperDelegateX11
97 77
98 class NativeDisplayDelegateX11::HelperDelegateX11 78 class NativeDisplayDelegateX11::HelperDelegateX11
99 : public NativeDisplayDelegateX11::HelperDelegate { 79 : public NativeDisplayDelegateX11::HelperDelegate {
100 public: 80 public:
101 HelperDelegateX11(NativeDisplayDelegateX11* delegate) : delegate_(delegate) {} 81 HelperDelegateX11(NativeDisplayDelegateX11* delegate) : delegate_(delegate) {}
102 virtual ~HelperDelegateX11() {} 82 virtual ~HelperDelegateX11() {}
(...skipping 26 matching lines...) Expand all
129 window_(DefaultRootWindow(display_)), 109 window_(DefaultRootWindow(display_)),
130 screen_(NULL), 110 screen_(NULL),
131 background_color_argb_(0) {} 111 background_color_argb_(0) {}
132 112
133 NativeDisplayDelegateX11::~NativeDisplayDelegateX11() { 113 NativeDisplayDelegateX11::~NativeDisplayDelegateX11() {
134 if (ui::PlatformEventSource::GetInstance()) { 114 if (ui::PlatformEventSource::GetInstance()) {
135 ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher( 115 ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(
136 platform_event_dispatcher_.get()); 116 platform_event_dispatcher_.get());
137 } 117 }
138 118
139 if (input_hotplug_observer_) {
140 ui::DeviceDataManager::GetInstance()->RemoveObserver(
141 input_hotplug_observer_.get());
142 }
143
144 STLDeleteContainerPairSecondPointers(modes_.begin(), modes_.end()); 119 STLDeleteContainerPairSecondPointers(modes_.begin(), modes_.end());
145 } 120 }
146 121
147 void NativeDisplayDelegateX11::Initialize() { 122 void NativeDisplayDelegateX11::Initialize() {
148 int error_base_ignored = 0; 123 int error_base_ignored = 0;
149 int xrandr_event_base = 0; 124 int xrandr_event_base = 0;
150 XRRQueryExtension(display_, &xrandr_event_base, &error_base_ignored); 125 XRRQueryExtension(display_, &xrandr_event_base, &error_base_ignored);
151 126
152 helper_delegate_.reset(new HelperDelegateX11(this)); 127 helper_delegate_.reset(new HelperDelegateX11(this));
153 platform_event_dispatcher_.reset(new NativeDisplayEventDispatcherX11( 128 platform_event_dispatcher_.reset(new NativeDisplayEventDispatcherX11(
154 helper_delegate_.get(), xrandr_event_base)); 129 helper_delegate_.get(), xrandr_event_base));
155 input_hotplug_observer_.reset(
156 new InputHotplugEventObserver(helper_delegate_.get()));
157 ui::DeviceDataManager::GetInstance()->AddObserver(
158 input_hotplug_observer_.get());
159 130
160 if (ui::PlatformEventSource::GetInstance()) { 131 if (ui::PlatformEventSource::GetInstance()) {
161 ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher( 132 ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(
162 platform_event_dispatcher_.get()); 133 platform_event_dispatcher_.get());
163 } 134 }
164 } 135 }
165 136
166 void NativeDisplayDelegateX11::GrabServer() { 137 void NativeDisplayDelegateX11::GrabServer() {
167 CHECK(!screen_) << "Server already grabbed"; 138 CHECK(!screen_) << "Server already grabbed";
168 XGrabServer(display_); 139 XGrabServer(display_);
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 XSetForeground(display_, gc, color.pixel); 642 XSetForeground(display_, gc, color.pixel);
672 XSetFillStyle(display_, gc, FillSolid); 643 XSetFillStyle(display_, gc, FillSolid);
673 int width = DisplayWidth(display_, DefaultScreen(display_)); 644 int width = DisplayWidth(display_, DefaultScreen(display_));
674 int height = DisplayHeight(display_, DefaultScreen(display_)); 645 int height = DisplayHeight(display_, DefaultScreen(display_));
675 XFillRectangle(display_, window_, gc, 0, 0, width, height); 646 XFillRectangle(display_, window_, gc, 0, 0, width, height);
676 XFreeGC(display_, gc); 647 XFreeGC(display_, gc);
677 XFreeColors(display_, colormap, &color.pixel, 1, 0); 648 XFreeColors(display_, colormap, &color.pixel, 1, 0);
678 } 649 }
679 650
680 } // namespace ui 651 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698