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 ASH_DISPLAY_DISPLAY_CHANGE_OBSERVER_X11_H
6#define ASH_DISPLAY_DISPLAY_CHANGE_OBSERVER_X11_H
7
8#include <X11/Xlib.h>
9
10// Xlib.h defines RootWindow.
11#undef RootWindow
12
13#include "ash/ash_export.h"
14#include "ash/shell_observer.h"
15#include "base/basictypes.h"
16#include "chromeos/display/output_configurator.h"
17
18namespace ash {
19namespace internal {
20
21// An object that observes changes in display configuration and
22// update DisplayManagers.
23class DisplayChangeObserverX11
24    : public chromeos::OutputConfigurator::StateController,
25      public chromeos::OutputConfigurator::Observer,
26      public ShellObserver {
27 public:
28  DisplayChangeObserverX11();
29  virtual ~DisplayChangeObserverX11();
30
31  // chromeos::OutputConfigurator::StateController overrides:
32  virtual chromeos::OutputState GetStateForDisplayIds(
33      const std::vector<int64>& outputs) const OVERRIDE;
34  virtual bool GetResolutionForDisplayId(int64 display_id,
35                                         int* width,
36                                         int* height) const OVERRIDE;
37
38  // Overriden from chromeos::OutputConfigurator::Observer:
39  virtual void OnDisplayModeChanged() OVERRIDE;
40
41  // Overriden from ShellObserver:
42  virtual void OnAppTerminating() OVERRIDE;
43
44 private:
45  Display* xdisplay_;
46
47  ::Window x_root_window_;
48
49  int xrandr_event_base_;
50
51  DISALLOW_COPY_AND_ASSIGN(DisplayChangeObserverX11);
52};
53
54}  // namespace internal
55}  // namespace ash
56
57#endif  // ASH_DISPLAY_AURA_DISPLAY_CHANGE_OBSERVER_X11_H
58