Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(270)

Side by Side Diff: ui/display/chromeos/x11/native_display_event_dispatcher_x11.cc

Issue 187073002: Refactoring display configuration state to allow generic state objects (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ordering Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "ui/display/chromeos/x11/display_mode_x11.h"
7 #include "ui/display/chromeos/x11/display_snapshot_x11.h"
6 8
7 #include <X11/extensions/Xrandr.h> 9 #include <X11/extensions/Xrandr.h>
8 10
9 namespace chromeos { 11 namespace ui {
10 12
11 NativeDisplayEventDispatcherX11::NativeDisplayEventDispatcherX11( 13 NativeDisplayEventDispatcherX11::NativeDisplayEventDispatcherX11(
12 NativeDisplayDelegateX11::HelperDelegate* delegate, int xrandr_event_base) 14 NativeDisplayDelegateX11::HelperDelegate* delegate,
13 : delegate_(delegate), 15 int xrandr_event_base)
14 xrandr_event_base_(xrandr_event_base) {} 16 : delegate_(delegate), xrandr_event_base_(xrandr_event_base) {}
15 17
16 NativeDisplayEventDispatcherX11::~NativeDisplayEventDispatcherX11() {} 18 NativeDisplayEventDispatcherX11::~NativeDisplayEventDispatcherX11() {}
17 19
18 uint32_t NativeDisplayEventDispatcherX11::Dispatch( 20 uint32_t NativeDisplayEventDispatcherX11::Dispatch(
19 const base::NativeEvent& event) { 21 const base::NativeEvent& event) {
20 if (event->type - xrandr_event_base_ == RRScreenChangeNotify) { 22 if (event->type - xrandr_event_base_ == RRScreenChangeNotify) {
21 VLOG(1) << "Received RRScreenChangeNotify event"; 23 VLOG(1) << "Received RRScreenChangeNotify event";
22 delegate_->UpdateXRandRConfiguration(event); 24 delegate_->UpdateXRandRConfiguration(event);
23 return POST_DISPATCH_PERFORM_DEFAULT; 25 return POST_DISPATCH_PERFORM_DEFAULT;
24 } 26 }
(...skipping 12 matching lines...) Expand all
37 return POST_DISPATCH_PERFORM_DEFAULT; 39 return POST_DISPATCH_PERFORM_DEFAULT;
38 40
39 const bool connected = (action == RR_Connected); 41 const bool connected = (action == RR_Connected);
40 VLOG(1) << "Received RRNotify_OutputChange event:" 42 VLOG(1) << "Received RRNotify_OutputChange event:"
41 << " output=" << output_change_event->output 43 << " output=" << output_change_event->output
42 << " crtc=" << output_change_event->crtc 44 << " crtc=" << output_change_event->crtc
43 << " mode=" << output_change_event->mode 45 << " mode=" << output_change_event->mode
44 << " action=" << (connected ? "connected" : "disconnected"); 46 << " action=" << (connected ? "connected" : "disconnected");
45 47
46 bool found_changed_output = false; 48 bool found_changed_output = false;
47 const std::vector<OutputConfigurator::OutputSnapshot>& cached_outputs = 49 const std::vector<DisplaySnapshot*>& cached_outputs =
48 delegate_->GetCachedOutputs(); 50 delegate_->GetCachedOutputs();
49 for (std::vector<OutputConfigurator::OutputSnapshot>::const_iterator 51 for (std::vector<DisplaySnapshot*>::const_iterator it =
50 it = cached_outputs.begin(); 52 cached_outputs.begin();
51 it != cached_outputs.end(); ++it) { 53 it != cached_outputs.end();
52 if (it->output == output_change_event->output) { 54 ++it) {
53 if (connected && it->crtc == output_change_event->crtc && 55 const DisplaySnapshotX11* x11_output =
54 it->current_mode == output_change_event->mode) { 56 static_cast<const DisplaySnapshotX11*>(*it);
57 const DisplayModeX11* x11_mode =
58 static_cast<const DisplayModeX11*>(x11_output->current_mode());
59
60 if (x11_output->output() == output_change_event->output) {
61 if (connected && x11_output->crtc() == output_change_event->crtc &&
62 x11_mode->mode_id() == output_change_event->mode) {
55 VLOG(1) << "Ignoring event describing already-cached state"; 63 VLOG(1) << "Ignoring event describing already-cached state";
56 return POST_DISPATCH_PERFORM_DEFAULT; 64 return POST_DISPATCH_PERFORM_DEFAULT;
57 } 65 }
58 found_changed_output = true; 66 found_changed_output = true;
59 break; 67 break;
60 } 68 }
61 } 69 }
62 70
63 if (!connected && !found_changed_output) { 71 if (!connected && !found_changed_output) {
64 VLOG(1) << "Ignoring event describing already-disconnected output"; 72 VLOG(1) << "Ignoring event describing already-disconnected output";
65 return POST_DISPATCH_PERFORM_DEFAULT; 73 return POST_DISPATCH_PERFORM_DEFAULT;
66 } 74 }
67 75
68 delegate_->NotifyDisplayObservers(); 76 delegate_->NotifyDisplayObservers();
69 77
70 return POST_DISPATCH_PERFORM_DEFAULT; 78 return POST_DISPATCH_PERFORM_DEFAULT;
71 } 79 }
72 80
73 } // namespace chromeos 81 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698