| 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/display_change_observer_x11.h" | 5 #include "ui/aura/display_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> |
| 11 | 11 |
| 12 #include <X11/extensions/Xrandr.h> | 12 #include <X11/extensions/Xrandr.h> |
| 13 | 13 |
| 14 #include "base/message_pump_aurax11.h" | 14 #include "base/message_pump_aurax11.h" |
| 15 #include "ui/aura/dispatcher_linux.h" | |
| 16 #include "ui/aura/env.h" | 15 #include "ui/aura/env.h" |
| 17 #include "ui/aura/display_manager.h" | 16 #include "ui/aura/display_manager.h" |
| 18 #include "ui/base/x/x11_util.h" | 17 #include "ui/base/x/x11_util.h" |
| 19 #include "ui/compositor/dip_util.h" | 18 #include "ui/compositor/dip_util.h" |
| 20 #include "ui/gfx/display.h" | 19 #include "ui/gfx/display.h" |
| 21 | 20 |
| 22 namespace aura { | 21 namespace aura { |
| 23 namespace internal { | 22 namespace internal { |
| 24 | 23 |
| 25 namespace { | 24 namespace { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 } | 77 } |
| 79 | 78 |
| 80 } // namespace | 79 } // namespace |
| 81 | 80 |
| 82 DisplayChangeObserverX11::DisplayChangeObserverX11() | 81 DisplayChangeObserverX11::DisplayChangeObserverX11() |
| 83 : xdisplay_(base::MessagePumpAuraX11::GetDefaultXDisplay()), | 82 : xdisplay_(base::MessagePumpAuraX11::GetDefaultXDisplay()), |
| 84 x_root_window_(DefaultRootWindow(xdisplay_)), | 83 x_root_window_(DefaultRootWindow(xdisplay_)), |
| 85 xrandr_event_base_(0) { | 84 xrandr_event_base_(0) { |
| 86 int error_base_ignored; | 85 int error_base_ignored; |
| 87 XRRQueryExtension(xdisplay_, &xrandr_event_base_, &error_base_ignored); | 86 XRRQueryExtension(xdisplay_, &xrandr_event_base_, &error_base_ignored); |
| 88 static_cast<DispatcherLinux*>(Env::GetInstance()->GetDispatcher())-> | 87 base::MessagePumpAuraX11::Current()->AddDispatcherForRootWindow(this); |
| 89 AddDispatcherForRootWindow(this); | |
| 90 } | 88 } |
| 91 | 89 |
| 92 DisplayChangeObserverX11::~DisplayChangeObserverX11() { | 90 DisplayChangeObserverX11::~DisplayChangeObserverX11() { |
| 93 static_cast<DispatcherLinux*>(Env::GetInstance()->GetDispatcher())-> | 91 base::MessagePumpAuraX11::Current()->RemoveDispatcherForRootWindow(this); |
| 94 RemoveDispatcherForRootWindow(this); | |
| 95 } | 92 } |
| 96 | 93 |
| 97 bool DisplayChangeObserverX11::Dispatch(const base::NativeEvent& event) { | 94 bool DisplayChangeObserverX11::Dispatch(const base::NativeEvent& event) { |
| 98 if (event->type - xrandr_event_base_ == RRScreenChangeNotify) { | 95 if (event->type - xrandr_event_base_ == RRScreenChangeNotify) { |
| 99 NotifyDisplayChange(); | 96 NotifyDisplayChange(); |
| 100 } | 97 } |
| 101 return true; | 98 return true; |
| 102 } | 99 } |
| 103 | 100 |
| 104 void DisplayChangeObserverX11::NotifyDisplayChange() { | 101 void DisplayChangeObserverX11::NotifyDisplayChange() { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 iter->set_id(id); | 185 iter->set_id(id); |
| 189 ++id; | 186 ++id; |
| 190 } | 187 } |
| 191 } | 188 } |
| 192 | 189 |
| 193 Env::GetInstance()->display_manager()->OnNativeDisplaysChanged(displays); | 190 Env::GetInstance()->display_manager()->OnNativeDisplaysChanged(displays); |
| 194 } | 191 } |
| 195 | 192 |
| 196 } // namespace internal | 193 } // namespace internal |
| 197 } // namespace aura | 194 } // namespace aura |
| OLD | NEW |