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/views/widget/desktop_aura/desktop_screen_x11.h" | 5 #include "ui/views/widget/desktop_aura/desktop_screen_x11.h" |
6 | 6 |
7 #include <X11/extensions/Xrandr.h> | 7 #include <X11/extensions/Xrandr.h> |
8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
9 | 9 |
10 // It clashes with out RootWindow. | 10 // It clashes with out RootWindow. |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 randr_version_minor >= 3; | 134 randr_version_minor >= 3; |
135 | 135 |
136 if (has_xrandr_) { | 136 if (has_xrandr_) { |
137 int error_base_ignored = 0; | 137 int error_base_ignored = 0; |
138 XRRQueryExtension(xdisplay_, &xrandr_event_base_, &error_base_ignored); | 138 XRRQueryExtension(xdisplay_, &xrandr_event_base_, &error_base_ignored); |
139 | 139 |
140 if (ui::PlatformEventSource::GetInstance()) | 140 if (ui::PlatformEventSource::GetInstance()) |
141 ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); | 141 ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); |
142 XRRSelectInput(xdisplay_, | 142 XRRSelectInput(xdisplay_, |
143 x_root_window_, | 143 x_root_window_, |
144 RRScreenChangeNotifyMask | RROutputChangeNotifyMask); | 144 RRScreenChangeNotifyMask | |
145 RROutputChangeNotifyMask | | |
146 RRCrtcChangeNotifyMask); | |
145 | 147 |
146 displays_ = BuildDisplaysFromXRandRInfo(); | 148 displays_ = BuildDisplaysFromXRandRInfo(); |
147 } else { | 149 } else { |
148 displays_ = GetFallbackDisplayList(); | 150 displays_ = GetFallbackDisplayList(); |
149 } | 151 } |
150 } | 152 } |
151 | 153 |
152 DesktopScreenX11::~DesktopScreenX11() { | 154 DesktopScreenX11::~DesktopScreenX11() { |
153 if (has_xrandr_ && ui::PlatformEventSource::GetInstance()) | 155 if (has_xrandr_ && ui::PlatformEventSource::GetInstance()) |
154 ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); | 156 ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
310 | 312 |
311 bool DesktopScreenX11::CanDispatchEvent(const ui::PlatformEvent& event) { | 313 bool DesktopScreenX11::CanDispatchEvent(const ui::PlatformEvent& event) { |
312 return event->type - xrandr_event_base_ == RRScreenChangeNotify || | 314 return event->type - xrandr_event_base_ == RRScreenChangeNotify || |
313 event->type - xrandr_event_base_ == RRNotify; | 315 event->type - xrandr_event_base_ == RRNotify; |
314 } | 316 } |
315 | 317 |
316 uint32_t DesktopScreenX11::DispatchEvent(const ui::PlatformEvent& event) { | 318 uint32_t DesktopScreenX11::DispatchEvent(const ui::PlatformEvent& event) { |
317 if (event->type - xrandr_event_base_ == RRScreenChangeNotify) { | 319 if (event->type - xrandr_event_base_ == RRScreenChangeNotify) { |
318 // Pass the event through to xlib. | 320 // Pass the event through to xlib. |
319 XRRUpdateConfiguration(event); | 321 XRRUpdateConfiguration(event); |
320 } else if (event->type - xrandr_event_base_ == RRNotify) { | 322 } else if (event->type - xrandr_event_base_ == RRNotify) { |
Elliot Glaysher
2014/04/17 17:40:53
I was going to ask if there was something you had
| |
321 // There's some sort of observer dispatch going on here, but I don't think | 323 // There's some sort of observer dispatch going on here, but I don't think |
322 // it's the screen's? | 324 // it's the screen's? |
323 if (configure_timer_.get() && configure_timer_->IsRunning()) { | 325 if (configure_timer_.get() && configure_timer_->IsRunning()) { |
324 configure_timer_->Reset(); | 326 configure_timer_->Reset(); |
325 } else { | 327 } else { |
326 configure_timer_.reset(new base::OneShotTimer<DesktopScreenX11>()); | 328 configure_timer_.reset(new base::OneShotTimer<DesktopScreenX11>()); |
327 configure_timer_->Start( | 329 configure_timer_->Start( |
328 FROM_HERE, | 330 FROM_HERE, |
329 base::TimeDelta::FromMilliseconds(kConfigureDelayMs), | 331 base::TimeDelta::FromMilliseconds(kConfigureDelayMs), |
330 this, | 332 this, |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
433 ProcessDisplayChange(new_displays); | 435 ProcessDisplayChange(new_displays); |
434 } | 436 } |
435 | 437 |
436 //////////////////////////////////////////////////////////////////////////////// | 438 //////////////////////////////////////////////////////////////////////////////// |
437 | 439 |
438 gfx::Screen* CreateDesktopScreen() { | 440 gfx::Screen* CreateDesktopScreen() { |
439 return new DesktopScreenX11; | 441 return new DesktopScreenX11; |
440 } | 442 } |
441 | 443 |
442 } // namespace views | 444 } // namespace views |
OLD | NEW |