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/monitor_change_observer_x11.h" | 5 #include "ui/aura/monitor_change_observer_x11.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 } // namespace | 46 } // namespace |
47 | 47 |
48 MonitorChangeObserverX11::MonitorChangeObserverX11() | 48 MonitorChangeObserverX11::MonitorChangeObserverX11() |
49 : xdisplay_(base::MessagePumpX::GetDefaultXDisplay()), | 49 : xdisplay_(base::MessagePumpX::GetDefaultXDisplay()), |
50 x_root_window_(DefaultRootWindow(xdisplay_)), | 50 x_root_window_(DefaultRootWindow(xdisplay_)), |
51 xrandr_event_base_(0) { | 51 xrandr_event_base_(0) { |
52 XRRSelectInput(xdisplay_, x_root_window_, RRScreenChangeNotifyMask); | 52 XRRSelectInput(xdisplay_, x_root_window_, RRScreenChangeNotifyMask); |
53 int error_base_ignored; | 53 int error_base_ignored; |
54 XRRQueryExtension(xdisplay_, &xrandr_event_base_, &error_base_ignored); | 54 XRRQueryExtension(xdisplay_, &xrandr_event_base_, &error_base_ignored); |
55 static_cast<DispatcherLinux*>( | 55 static_cast<DispatcherLinux*>(Env::GetInstance()->GetDispatcher())-> |
56 Env::GetInstance()->GetDispatcher())-> | 56 RegisterRootWindowDispatcher(this); |
57 WindowDispatcherCreated(x_root_window_, this); | |
58 } | 57 } |
59 | 58 |
60 MonitorChangeObserverX11::~MonitorChangeObserverX11() { | 59 MonitorChangeObserverX11::~MonitorChangeObserverX11() { |
61 static_cast<DispatcherLinux*>( | 60 static_cast<DispatcherLinux*>(Env::GetInstance()->GetDispatcher())-> |
62 Env::GetInstance()->GetDispatcher())-> | 61 UnregisterRootWindowDispatcher(this); |
63 WindowDispatcherDestroying(x_root_window_); | |
64 } | 62 } |
65 | 63 |
66 bool MonitorChangeObserverX11::Dispatch(const base::NativeEvent& event) { | 64 bool MonitorChangeObserverX11::Dispatch(const base::NativeEvent& event) { |
67 if (event->type - xrandr_event_base_ == RRScreenChangeNotify) { | 65 if (event->type - xrandr_event_base_ == RRScreenChangeNotify) { |
68 NotifyMonitorChange(); | 66 NotifyMonitorChange(); |
69 } | 67 } |
70 return true; | 68 return true; |
71 } | 69 } |
72 | 70 |
73 void MonitorChangeObserverX11::NotifyMonitorChange() { | 71 void MonitorChangeObserverX11::NotifyMonitorChange() { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 for (std::vector<gfx::Monitor>::iterator iter = monitors.begin(); | 135 for (std::vector<gfx::Monitor>::iterator iter = monitors.begin(); |
138 iter != monitors.end(); ++iter, ++id) | 136 iter != monitors.end(); ++iter, ++id) |
139 (*iter).set_id(id); | 137 (*iter).set_id(id); |
140 | 138 |
141 Env::GetInstance()->monitor_manager() | 139 Env::GetInstance()->monitor_manager() |
142 ->OnNativeMonitorsChanged(monitors); | 140 ->OnNativeMonitorsChanged(monitors); |
143 } | 141 } |
144 | 142 |
145 } // namespace internal | 143 } // namespace internal |
146 } // namespace aura | 144 } // namespace aura |
OLD | NEW |