| OLD | NEW |
| 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> |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 window_(DefaultRootWindow(display_)), | 108 window_(DefaultRootWindow(display_)), |
| 109 background_color_argb_(0) {} | 109 background_color_argb_(0) {} |
| 110 | 110 |
| 111 NativeDisplayDelegateX11::~NativeDisplayDelegateX11() { | 111 NativeDisplayDelegateX11::~NativeDisplayDelegateX11() { |
| 112 if (ui::PlatformEventSource::GetInstance() && | 112 if (ui::PlatformEventSource::GetInstance() && |
| 113 platform_event_dispatcher_.get()) { | 113 platform_event_dispatcher_.get()) { |
| 114 ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher( | 114 ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher( |
| 115 platform_event_dispatcher_.get()); | 115 platform_event_dispatcher_.get()); |
| 116 } | 116 } |
| 117 | 117 |
| 118 STLDeleteContainerPairSecondPointers(modes_.begin(), modes_.end()); | 118 base::STLDeleteContainerPairSecondPointers(modes_.begin(), modes_.end()); |
| 119 } | 119 } |
| 120 | 120 |
| 121 void NativeDisplayDelegateX11::Initialize() { | 121 void NativeDisplayDelegateX11::Initialize() { |
| 122 int error_base_ignored = 0; | 122 int error_base_ignored = 0; |
| 123 int xrandr_event_base = 0; | 123 int xrandr_event_base = 0; |
| 124 XRRQueryExtension(display_, &xrandr_event_base, &error_base_ignored); | 124 XRRQueryExtension(display_, &xrandr_event_base, &error_base_ignored); |
| 125 | 125 |
| 126 helper_delegate_.reset(new HelperDelegateX11(this)); | 126 helper_delegate_.reset(new HelperDelegateX11(this)); |
| 127 platform_event_dispatcher_.reset(new NativeDisplayEventDispatcherX11( | 127 platform_event_dispatcher_.reset(new NativeDisplayEventDispatcherX11( |
| 128 helper_delegate_.get(), xrandr_event_base)); | 128 helper_delegate_.get(), xrandr_event_base)); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 observers_.AddObserver(observer); | 278 observers_.AddObserver(observer); |
| 279 } | 279 } |
| 280 | 280 |
| 281 void NativeDisplayDelegateX11::RemoveObserver(NativeDisplayObserver* observer) { | 281 void NativeDisplayDelegateX11::RemoveObserver(NativeDisplayObserver* observer) { |
| 282 observers_.RemoveObserver(observer); | 282 observers_.RemoveObserver(observer); |
| 283 } | 283 } |
| 284 | 284 |
| 285 void NativeDisplayDelegateX11::InitModes() { | 285 void NativeDisplayDelegateX11::InitModes() { |
| 286 CHECK(screen_) << "Server not grabbed"; | 286 CHECK(screen_) << "Server not grabbed"; |
| 287 | 287 |
| 288 STLDeleteContainerPairSecondPointers(modes_.begin(), modes_.end()); | 288 base::STLDeleteContainerPairSecondPointers(modes_.begin(), modes_.end()); |
| 289 modes_.clear(); | 289 modes_.clear(); |
| 290 | 290 |
| 291 for (int i = 0; i < screen_->nmode; ++i) { | 291 for (int i = 0; i < screen_->nmode; ++i) { |
| 292 const XRRModeInfo& info = screen_->modes[i]; | 292 const XRRModeInfo& info = screen_->modes[i]; |
| 293 float refresh_rate = 0.0f; | 293 float refresh_rate = 0.0f; |
| 294 if (info.hTotal && info.vTotal) { | 294 if (info.hTotal && info.vTotal) { |
| 295 refresh_rate = | 295 refresh_rate = |
| 296 static_cast<float>(info.dotClock) / | 296 static_cast<float>(info.dotClock) / |
| 297 (static_cast<float>(info.hTotal) * static_cast<float>(info.vTotal)); | 297 (static_cast<float>(info.hTotal) * static_cast<float>(info.vTotal)); |
| 298 } | 298 } |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 XSetForeground(display_, gc, color.pixel); | 655 XSetForeground(display_, gc, color.pixel); |
| 656 XSetFillStyle(display_, gc, FillSolid); | 656 XSetFillStyle(display_, gc, FillSolid); |
| 657 int width = DisplayWidth(display_, DefaultScreen(display_)); | 657 int width = DisplayWidth(display_, DefaultScreen(display_)); |
| 658 int height = DisplayHeight(display_, DefaultScreen(display_)); | 658 int height = DisplayHeight(display_, DefaultScreen(display_)); |
| 659 XFillRectangle(display_, window_, gc, 0, 0, width, height); | 659 XFillRectangle(display_, window_, gc, 0, 0, width, height); |
| 660 XFreeGC(display_, gc); | 660 XFreeGC(display_, gc); |
| 661 XFreeColors(display_, colormap, &color.pixel, 1, 0); | 661 XFreeColors(display_, colormap, &color.pixel, 1, 0); |
| 662 } | 662 } |
| 663 | 663 |
| 664 } // namespace ui | 664 } // namespace ui |
| OLD | NEW |