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

Side by Side Diff: chromeos/display/output_configurator.h

Issue 10817028: Add Fade-out/Fade-in animation during output-configuration change. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 4 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 (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 #ifndef CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ 5 #ifndef CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_
6 #define CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ 6 #define CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/event_types.h" 9 #include "base/event_types.h"
10 #include "base/observer_list.h"
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "base/message_loop.h" 12 #include "base/message_loop.h"
12 #include "chromeos/chromeos_export.h" 13 #include "chromeos/chromeos_export.h"
13 14
14 // Forward declarations for Xlib and Xrandr. 15 // Forward declarations for Xlib and Xrandr.
15 // This is so unused X definitions don't pollute the namespace. 16 // This is so unused X definitions don't pollute the namespace.
16 typedef unsigned long XID; 17 typedef unsigned long XID;
17 typedef XID Window; 18 typedef XID Window;
18 typedef XID RROutput; 19 typedef XID RROutput;
19 typedef XID RRCrtc; 20 typedef XID RRCrtc;
(...skipping 13 matching lines...) Expand all
33 STATE_DUAL_PRIMARY_ONLY, 34 STATE_DUAL_PRIMARY_ONLY,
34 STATE_DUAL_SECONDARY_ONLY, 35 STATE_DUAL_SECONDARY_ONLY,
35 }; 36 };
36 37
37 // This class interacts directly with the underlying Xrandr API to manipulate 38 // This class interacts directly with the underlying Xrandr API to manipulate
38 // CTRCs and Outputs. It will likely grow more state, over time, or expose 39 // CTRCs and Outputs. It will likely grow more state, over time, or expose
39 // Output info in other ways as more of the Chrome display code grows up around 40 // Output info in other ways as more of the Chrome display code grows up around
40 // it. 41 // it.
41 class CHROMEOS_EXPORT OutputConfigurator : public MessageLoop::Dispatcher { 42 class CHROMEOS_EXPORT OutputConfigurator : public MessageLoop::Dispatcher {
42 public: 43 public:
44 class Observer {
45 public:
46 // Called when the change of the display mode finished. It will usually
47 // start the fading in the displays.
48 virtual void OnDisplayModeChanged() = 0;
49 };
50
43 explicit OutputConfigurator(bool is_extended_display_enabled); 51 explicit OutputConfigurator(bool is_extended_display_enabled);
44 virtual ~OutputConfigurator(); 52 virtual ~OutputConfigurator();
45 53
46 OutputState output_state() const { return output_state_; } 54 OutputState output_state() const { return output_state_; }
47 55
48 // Called when the user hits ctrl-F4 to request a display mode change. 56 // Called when the user hits ctrl-F4 to request a display mode change.
49 // This method should only return false if it was called in a single-head or 57 // This method should only return false if it was called in a single-head or
50 // headless mode. 58 // headless mode.
51 bool CycleDisplayMode(); 59 bool CycleDisplayMode();
52 60
53 // Called when powerd notifies us that some set of displays should be turned 61 // Called when powerd notifies us that some set of displays should be turned
54 // on or off. This requires enabling or disabling the CRTC associated with 62 // on or off. This requires enabling or disabling the CRTC associated with
55 // the display(s) in question so that the low power state is engaged. 63 // the display(s) in question so that the low power state is engaged.
56 bool ScreenPowerSet(bool power_on, bool all_displays); 64 bool ScreenPowerSet(bool power_on, bool all_displays);
57 65
58 // Force switching the display mode to |new_state|. This method is used when 66 // Force switching the display mode to |new_state|. This method is used when
59 // the user explicitly changes the display mode in the options UI. Returns 67 // the user explicitly changes the display mode in the options UI. Returns
60 // false if it was called in a single-head or headless mode. 68 // false if it was called in a single-head or headless mode.
61 bool SetDisplayMode(OutputState new_state); 69 bool SetDisplayMode(OutputState new_state);
62 70
63 // Called when an RRNotify event is received. The implementation is 71 // Called when an RRNotify event is received. The implementation is
64 // interested in the cases of RRNotify events which correspond to output 72 // interested in the cases of RRNotify events which correspond to output
65 // add/remove events. Note that Output add/remove events are sent in response 73 // add/remove events. Note that Output add/remove events are sent in response
66 // to our own reconfiguration operations so spurious events are common. 74 // to our own reconfiguration operations so spurious events are common.
67 // Spurious events will have no effect. 75 // Spurious events will have no effect.
68 virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE; 76 virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE;
69 77
78 void AddObserver(Observer* observer);
79 void RemoveObserver(Observer* observer);
80
70 private: 81 private:
71 // The information we need to cache from an output to implement operations 82 // The information we need to cache from an output to implement operations
72 // such as power state but also to eliminate duplicate operations within a 83 // such as power state but also to eliminate duplicate operations within a
73 // given action (determining which CRTC to use for a given output, for 84 // given action (determining which CRTC to use for a given output, for
74 // example). 85 // example).
75 struct CachedOutputDescription { 86 struct CachedOutputDescription {
76 RROutput output; 87 RROutput output;
77 RRCrtc crtc; 88 RRCrtc crtc;
78 RRMode mirror_mode; 89 RRMode mirror_mode;
79 RRMode ideal_mode; 90 RRMode ideal_mode;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // doesn't match any supported state. |output_cache_| must be up-to-date with 128 // doesn't match any supported state. |output_cache_| must be up-to-date with
118 // regards to the state of X or this method may return incorrect results. 129 // regards to the state of X or this method may return incorrect results.
119 OutputState InferCurrentState( 130 OutputState InferCurrentState(
120 Display* display, XRRScreenResources* screen) const; 131 Display* display, XRRScreenResources* screen) const;
121 132
122 // Scans the |output_cache_| to determine whether or not we are in a 133 // Scans the |output_cache_| to determine whether or not we are in a
123 // "projecting" state and then calls the DBus kSetIsProjectingMethod on powerd 134 // "projecting" state and then calls the DBus kSetIsProjectingMethod on powerd
124 // with the result. 135 // with the result.
125 void CheckIsProjectingAndNotify(); 136 void CheckIsProjectingAndNotify();
126 137
138 // Fires OnDisplayModeChanged() event to the observers.
139 void NotifyOnDisplayChanged();
140
127 // This is detected by the constructor to determine whether or not we should 141 // This is detected by the constructor to determine whether or not we should
128 // be enabled. If we aren't running on ChromeOS, we can't assume that the 142 // be enabled. If we aren't running on ChromeOS, we can't assume that the
129 // Xrandr X11 extension is supported. 143 // Xrandr X11 extension is supported.
130 // If this flag is set to false, any attempts to change the output 144 // If this flag is set to false, any attempts to change the output
131 // configuration to immediately fail without changing the state. 145 // configuration to immediately fail without changing the state.
132 bool is_running_on_chrome_os_; 146 bool is_running_on_chrome_os_;
133 147
134 // Set to true if the extended display flag is enabled. 148 // Set to true if the extended display flag is enabled.
135 const bool is_extended_display_enabled_; 149 const bool is_extended_display_enabled_;
136 150
(...skipping 17 matching lines...) Expand all
154 int secondary_output_index_; 168 int secondary_output_index_;
155 169
156 // The base of the event numbers used to represent XRandr events used in 170 // The base of the event numbers used to represent XRandr events used in
157 // decoding events regarding output add/remove. 171 // decoding events regarding output add/remove.
158 int xrandr_event_base_; 172 int xrandr_event_base_;
159 173
160 // The display state as derived from the outputs observed in |output_cache_|. 174 // The display state as derived from the outputs observed in |output_cache_|.
161 // This is used for rotating display modes. 175 // This is used for rotating display modes.
162 OutputState output_state_; 176 OutputState output_state_;
163 177
178 ObserverList<Observer> observers_;
179
164 DISALLOW_COPY_AND_ASSIGN(OutputConfigurator); 180 DISALLOW_COPY_AND_ASSIGN(OutputConfigurator);
165 }; 181 };
166 182
167 } // namespace chromeos 183 } // namespace chromeos
168 184
169 #endif // CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ 185 #endif // CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options2/chromeos/display_options_handler.cc ('k') | chromeos/display/output_configurator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698