| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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 UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_SCREEN_X11_H_ | 5 #ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_SCREEN_X11_H_ |
| 6 #define UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_SCREEN_X11_H_ | 6 #define UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_SCREEN_X11_H_ |
| 7 | 7 |
| 8 #include "base/message_loop/message_pump_dispatcher.h" | |
| 9 #include "base/observer_list.h" | 8 #include "base/observer_list.h" |
| 10 #include "base/timer/timer.h" | 9 #include "base/timer/timer.h" |
| 10 #include "ui/events/platform/platform_event_dispatcher.h" |
| 11 #include "ui/gfx/screen.h" | 11 #include "ui/gfx/screen.h" |
| 12 #include "ui/views/views_export.h" | 12 #include "ui/views/views_export.h" |
| 13 | 13 |
| 14 namespace gfx { | 14 namespace gfx { |
| 15 class Display; | 15 class Display; |
| 16 } | 16 } |
| 17 | 17 |
| 18 typedef unsigned long XID; | 18 typedef unsigned long XID; |
| 19 typedef XID Window; | 19 typedef XID Window; |
| 20 typedef struct _XDisplay Display; | 20 typedef struct _XDisplay Display; |
| 21 | 21 |
| 22 namespace views { | 22 namespace views { |
| 23 class DesktopScreenX11Test; | 23 class DesktopScreenX11Test; |
| 24 | 24 |
| 25 // Our singleton screen implementation that talks to xrandr. | 25 // Our singleton screen implementation that talks to xrandr. |
| 26 class VIEWS_EXPORT DesktopScreenX11 : public gfx::Screen, | 26 class VIEWS_EXPORT DesktopScreenX11 : public gfx::Screen, |
| 27 public base::MessagePumpDispatcher { | 27 public ui::PlatformEventDispatcher { |
| 28 public: | 28 public: |
| 29 DesktopScreenX11(); | 29 DesktopScreenX11(); |
| 30 | 30 |
| 31 virtual ~DesktopScreenX11(); | 31 virtual ~DesktopScreenX11(); |
| 32 | 32 |
| 33 // Takes a set of displays and dispatches the screen change events to | 33 // Takes a set of displays and dispatches the screen change events to |
| 34 // listeners. Exposed for testing. | 34 // listeners. Exposed for testing. |
| 35 void ProcessDisplayChange(const std::vector<gfx::Display>& displays); | 35 void ProcessDisplayChange(const std::vector<gfx::Display>& displays); |
| 36 | 36 |
| 37 // Overridden from gfx::Screen: | 37 // Overridden from gfx::Screen: |
| 38 virtual bool IsDIPEnabled() OVERRIDE; | 38 virtual bool IsDIPEnabled() OVERRIDE; |
| 39 virtual gfx::Point GetCursorScreenPoint() OVERRIDE; | 39 virtual gfx::Point GetCursorScreenPoint() OVERRIDE; |
| 40 virtual gfx::NativeWindow GetWindowUnderCursor() OVERRIDE; | 40 virtual gfx::NativeWindow GetWindowUnderCursor() OVERRIDE; |
| 41 virtual gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) | 41 virtual gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) |
| 42 OVERRIDE; | 42 OVERRIDE; |
| 43 virtual int GetNumDisplays() const OVERRIDE; | 43 virtual int GetNumDisplays() const OVERRIDE; |
| 44 virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE; | 44 virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE; |
| 45 virtual gfx::Display GetDisplayNearestWindow( | 45 virtual gfx::Display GetDisplayNearestWindow( |
| 46 gfx::NativeView window) const OVERRIDE; | 46 gfx::NativeView window) const OVERRIDE; |
| 47 virtual gfx::Display GetDisplayNearestPoint( | 47 virtual gfx::Display GetDisplayNearestPoint( |
| 48 const gfx::Point& point) const OVERRIDE; | 48 const gfx::Point& point) const OVERRIDE; |
| 49 virtual gfx::Display GetDisplayMatching( | 49 virtual gfx::Display GetDisplayMatching( |
| 50 const gfx::Rect& match_rect) const OVERRIDE; | 50 const gfx::Rect& match_rect) const OVERRIDE; |
| 51 virtual gfx::Display GetPrimaryDisplay() const OVERRIDE; | 51 virtual gfx::Display GetPrimaryDisplay() const OVERRIDE; |
| 52 virtual void AddObserver(gfx::DisplayObserver* observer) OVERRIDE; | 52 virtual void AddObserver(gfx::DisplayObserver* observer) OVERRIDE; |
| 53 virtual void RemoveObserver(gfx::DisplayObserver* observer) OVERRIDE; | 53 virtual void RemoveObserver(gfx::DisplayObserver* observer) OVERRIDE; |
| 54 | 54 |
| 55 // Overridden from MessagePumpDispatcher: | 55 // ui::PlatformEventDispatcher: |
| 56 virtual uint32_t Dispatch(const base::NativeEvent& event) OVERRIDE; | 56 virtual bool CanDispatchEvent(const ui::PlatformEvent& event) OVERRIDE; |
| 57 virtual uint32_t DispatchEvent(const ui::PlatformEvent& event) OVERRIDE; |
| 57 | 58 |
| 58 private: | 59 private: |
| 59 friend class DesktopScreenX11Test; | 60 friend class DesktopScreenX11Test; |
| 60 | 61 |
| 61 // Constructor used in tests. | 62 // Constructor used in tests. |
| 62 DesktopScreenX11(const std::vector<gfx::Display>& test_displays); | 63 DesktopScreenX11(const std::vector<gfx::Display>& test_displays); |
| 63 | 64 |
| 64 // Builds a list of displays from the current screen information offered by | 65 // Builds a list of displays from the current screen information offered by |
| 65 // the X server. | 66 // the X server. |
| 66 std::vector<gfx::Display> BuildDisplaysFromXRandRInfo(); | 67 std::vector<gfx::Display> BuildDisplaysFromXRandRInfo(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 86 scoped_ptr<base::OneShotTimer<DesktopScreenX11> > configure_timer_; | 87 scoped_ptr<base::OneShotTimer<DesktopScreenX11> > configure_timer_; |
| 87 | 88 |
| 88 ObserverList<gfx::DisplayObserver> observer_list_; | 89 ObserverList<gfx::DisplayObserver> observer_list_; |
| 89 | 90 |
| 90 DISALLOW_COPY_AND_ASSIGN(DesktopScreenX11); | 91 DISALLOW_COPY_AND_ASSIGN(DesktopScreenX11); |
| 91 }; | 92 }; |
| 92 | 93 |
| 93 } // namespace views | 94 } // namespace views |
| 94 | 95 |
| 95 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_SCREEN_X11_H_ | 96 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_SCREEN_X11_H_ |
| OLD | NEW |