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
3 // found in the LICENSE file.
4 
5 #ifndef UI_DISPLAY_DISPLAY_OBSERVER_H_
6 #define UI_DISPLAY_DISPLAY_OBSERVER_H_
7 
8 #include <stdint.h>
9 
10 #include "base/observer_list_types.h"
11 #include "ui/display/display_export.h"
12 
13 namespace display {
14 class Display;
15 
16 // Observers for display configuration changes.
17 class DISPLAY_EXPORT DisplayObserver : public base::CheckedObserver {
18  public:
19   enum DisplayMetric {
20     DISPLAY_METRIC_NONE = 0,
21     DISPLAY_METRIC_BOUNDS = 1 << 0,
22     DISPLAY_METRIC_WORK_AREA = 1 << 1,
23     DISPLAY_METRIC_DEVICE_SCALE_FACTOR = 1 << 2,
24     DISPLAY_METRIC_ROTATION = 1 << 3,
25     DISPLAY_METRIC_PRIMARY = 1 << 4,
26     DISPLAY_METRIC_MIRROR_STATE = 1 << 5,
27     DISPLAY_METRIC_COLOR_SPACE = 1 << 6,
28   };
29 
30   // This may be called before other methods to signal changes are about to
31   // happen. Not all classes that support DisplayObserver call this.
32   virtual void OnWillProcessDisplayChanges();
33 
34   // Called after OnWillProcessDisplayChanges() to indicate display changes have
35   // completed. Not all classes that support DisplayObserver call this.
36   virtual void OnDidProcessDisplayChanges();
37 
38   // Called when |new_display| has been added.
39   virtual void OnDisplayAdded(const Display& new_display);
40 
41   // Called when |old_display| has been removed.
42   virtual void OnDisplayRemoved(const Display& old_display);
43 
44   // Called when the metrics of a display change.
45   // |changed_metrics| is a bitmask of DisplayMatric types indicating which
46   // metrics have changed. Eg; if mirroring changes (either from true to false,
47   // or false to true), than the DISPLAY_METRIC_MIRROR_STATE bit is set in
48   // changed_metrics.
49   virtual void OnDisplayMetricsChanged(const Display& display,
50                                        uint32_t changed_metrics);
51 
52   // Called when the (platform-specific) workspace ID changes to
53   // |new_workspace|.
54   virtual void OnCurrentWorkspaceChanged(const std::string& new_workspace);
55 
56  protected:
57   ~DisplayObserver() override;
58 };
59 
60 }  // namespace display
61 
62 #endif  // UI_DISPLAY_DISPLAY_OBSERVER_H_
63