| 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 "chromeos/display/native_display_event_dispatcher_x11.h" | 5 #include "ui/display/chromeos/x11/native_display_event_dispatcher_x11.h" |
| 6 | 6 |
| 7 #include <X11/extensions/Xrandr.h> | 7 #include <X11/extensions/Xrandr.h> |
| 8 | 8 |
| 9 namespace chromeos { | 9 namespace ui { |
| 10 | 10 |
| 11 NativeDisplayEventDispatcherX11::NativeDisplayEventDispatcherX11( | 11 NativeDisplayEventDispatcherX11::NativeDisplayEventDispatcherX11( |
| 12 NativeDisplayDelegateX11::HelperDelegate* delegate, int xrandr_event_base) | 12 NativeDisplayDelegateX11::HelperDelegate* delegate, |
| 13 : delegate_(delegate), | 13 int xrandr_event_base) |
| 14 xrandr_event_base_(xrandr_event_base) {} | 14 : delegate_(delegate), xrandr_event_base_(xrandr_event_base) {} |
| 15 | 15 |
| 16 NativeDisplayEventDispatcherX11::~NativeDisplayEventDispatcherX11() {} | 16 NativeDisplayEventDispatcherX11::~NativeDisplayEventDispatcherX11() {} |
| 17 | 17 |
| 18 uint32_t NativeDisplayEventDispatcherX11::Dispatch( | 18 uint32_t NativeDisplayEventDispatcherX11::Dispatch( |
| 19 const base::NativeEvent& event) { | 19 const base::NativeEvent& event) { |
| 20 if (event->type - xrandr_event_base_ == RRScreenChangeNotify) { | 20 if (event->type - xrandr_event_base_ == RRScreenChangeNotify) { |
| 21 VLOG(1) << "Received RRScreenChangeNotify event"; | 21 VLOG(1) << "Received RRScreenChangeNotify event"; |
| 22 delegate_->UpdateXRandRConfiguration(event); | 22 delegate_->UpdateXRandRConfiguration(event); |
| 23 return POST_DISPATCH_PERFORM_DEFAULT; | 23 return POST_DISPATCH_PERFORM_DEFAULT; |
| 24 } | 24 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 39 const bool connected = (action == RR_Connected); | 39 const bool connected = (action == RR_Connected); |
| 40 VLOG(1) << "Received RRNotify_OutputChange event:" | 40 VLOG(1) << "Received RRNotify_OutputChange event:" |
| 41 << " output=" << output_change_event->output | 41 << " output=" << output_change_event->output |
| 42 << " crtc=" << output_change_event->crtc | 42 << " crtc=" << output_change_event->crtc |
| 43 << " mode=" << output_change_event->mode | 43 << " mode=" << output_change_event->mode |
| 44 << " action=" << (connected ? "connected" : "disconnected"); | 44 << " action=" << (connected ? "connected" : "disconnected"); |
| 45 | 45 |
| 46 bool found_changed_output = false; | 46 bool found_changed_output = false; |
| 47 const std::vector<OutputConfigurator::OutputSnapshot>& cached_outputs = | 47 const std::vector<OutputConfigurator::OutputSnapshot>& cached_outputs = |
| 48 delegate_->GetCachedOutputs(); | 48 delegate_->GetCachedOutputs(); |
| 49 for (std::vector<OutputConfigurator::OutputSnapshot>::const_iterator | 49 for (std::vector<OutputConfigurator::OutputSnapshot>::const_iterator it = |
| 50 it = cached_outputs.begin(); | 50 cached_outputs.begin(); |
| 51 it != cached_outputs.end(); ++it) { | 51 it != cached_outputs.end(); |
| 52 ++it) { |
| 52 if (it->output == output_change_event->output) { | 53 if (it->output == output_change_event->output) { |
| 53 if (connected && it->crtc == output_change_event->crtc && | 54 if (connected && it->crtc == output_change_event->crtc && |
| 54 it->current_mode == output_change_event->mode) { | 55 it->current_mode == output_change_event->mode) { |
| 55 VLOG(1) << "Ignoring event describing already-cached state"; | 56 VLOG(1) << "Ignoring event describing already-cached state"; |
| 56 return POST_DISPATCH_PERFORM_DEFAULT; | 57 return POST_DISPATCH_PERFORM_DEFAULT; |
| 57 } | 58 } |
| 58 found_changed_output = true; | 59 found_changed_output = true; |
| 59 break; | 60 break; |
| 60 } | 61 } |
| 61 } | 62 } |
| 62 | 63 |
| 63 if (!connected && !found_changed_output) { | 64 if (!connected && !found_changed_output) { |
| 64 VLOG(1) << "Ignoring event describing already-disconnected output"; | 65 VLOG(1) << "Ignoring event describing already-disconnected output"; |
| 65 return POST_DISPATCH_PERFORM_DEFAULT; | 66 return POST_DISPATCH_PERFORM_DEFAULT; |
| 66 } | 67 } |
| 67 | 68 |
| 68 delegate_->NotifyDisplayObservers(); | 69 delegate_->NotifyDisplayObservers(); |
| 69 | 70 |
| 70 return POST_DISPATCH_PERFORM_DEFAULT; | 71 return POST_DISPATCH_PERFORM_DEFAULT; |
| 71 } | 72 } |
| 72 | 73 |
| 73 } // namespace chromeos | 74 } // namespace ui |
| OLD | NEW |