Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ui / views / widget / desktop_aura / desktop_screen_x11.h
blobff47806eb6799e18740742b5f591e9a56d49deb6
1 // Copyright (c) 2013 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.
5 #ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_SCREEN_X11_H_
6 #define UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_SCREEN_X11_H_
8 #include "base/timer/timer.h"
9 #include "ui/events/platform/platform_event_dispatcher.h"
10 #include "ui/gfx/display_change_notifier.h"
11 #include "ui/gfx/screen.h"
12 #include "ui/views/views_export.h"
14 namespace gfx {
15 class Display;
18 typedef unsigned long XID;
19 typedef XID Window;
20 typedef struct _XDisplay Display;
22 namespace views {
23 class DesktopScreenX11Test;
25 // Our singleton screen implementation that talks to xrandr.
26 class VIEWS_EXPORT DesktopScreenX11 : public gfx::Screen,
27 public ui::PlatformEventDispatcher {
28 public:
29 DesktopScreenX11();
31 virtual ~DesktopScreenX11();
33 // Overridden from gfx::Screen:
34 virtual bool IsDIPEnabled() OVERRIDE;
35 virtual gfx::Point GetCursorScreenPoint() OVERRIDE;
36 virtual gfx::NativeWindow GetWindowUnderCursor() OVERRIDE;
37 virtual gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point)
38 OVERRIDE;
39 virtual int GetNumDisplays() const OVERRIDE;
40 virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE;
41 virtual gfx::Display GetDisplayNearestWindow(
42 gfx::NativeView window) const OVERRIDE;
43 virtual gfx::Display GetDisplayNearestPoint(
44 const gfx::Point& point) const OVERRIDE;
45 virtual gfx::Display GetDisplayMatching(
46 const gfx::Rect& match_rect) const OVERRIDE;
47 virtual gfx::Display GetPrimaryDisplay() const OVERRIDE;
48 virtual void AddObserver(gfx::DisplayObserver* observer) OVERRIDE;
49 virtual void RemoveObserver(gfx::DisplayObserver* observer) OVERRIDE;
51 // ui::PlatformEventDispatcher:
52 virtual bool CanDispatchEvent(const ui::PlatformEvent& event) OVERRIDE;
53 virtual uint32_t DispatchEvent(const ui::PlatformEvent& event) OVERRIDE;
55 private:
56 friend class DesktopScreenX11Test;
58 // Constructor used in tests.
59 DesktopScreenX11(const std::vector<gfx::Display>& test_displays);
61 // Builds a list of displays from the current screen information offered by
62 // the X server.
63 std::vector<gfx::Display> BuildDisplaysFromXRandRInfo();
65 // We delay updating the display so we can coalesce events.
66 void ConfigureTimerFired();
68 Display* xdisplay_;
69 ::Window x_root_window_;
71 // Whether the x server supports the XRandR extension.
72 bool has_xrandr_;
74 // The base of the event numbers used to represent XRandr events used in
75 // decoding events regarding output add/remove.
76 int xrandr_event_base_;
78 // The display objects we present to chrome.
79 std::vector<gfx::Display> displays_;
81 // The timer to delay configuring outputs. See also the comments in
82 // Dispatch().
83 scoped_ptr<base::OneShotTimer<DesktopScreenX11> > configure_timer_;
85 gfx::DisplayChangeNotifier change_notifier_;
87 DISALLOW_COPY_AND_ASSIGN(DesktopScreenX11);
90 } // namespace views
92 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_SCREEN_X11_H_