| OLD | NEW |
| 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 UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_HANDLER_H_ | 5 #ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_HANDLER_H_ |
| 6 #define UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_HANDLER_H_ | 6 #define UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_HANDLER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <X11/Xlib.h> | 9 #include <X11/Xlib.h> |
| 10 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. | 10 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. |
| 11 #undef RootWindow | 11 #undef RootWindow |
| 12 | 12 |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "ui/aura/env_observer.h" | 16 #include "ui/aura/env_observer.h" |
| 17 #include "ui/events/platform/platform_event_dispatcher.h" | 17 #include "ui/events/platform/platform_event_dispatcher.h" |
| 18 #include "ui/events/platform/x11/x11_event_source.h" |
| 18 #include "ui/gfx/x/x11_atom_cache.h" | 19 #include "ui/gfx/x/x11_atom_cache.h" |
| 19 #include "ui/gfx/x/x11_types.h" | 20 #include "ui/gfx/x/x11_types.h" |
| 20 #include "ui/views/views_export.h" | 21 #include "ui/views/views_export.h" |
| 21 | 22 |
| 22 namespace base { | 23 namespace base { |
| 23 template <typename T> struct DefaultSingletonTraits; | 24 template <typename T> struct DefaultSingletonTraits; |
| 24 } | 25 } |
| 25 | 26 |
| 26 namespace views { | 27 namespace views { |
| 27 | 28 |
| 28 // A singleton that owns global objects related to the desktop and listens for | 29 // A singleton that owns global objects related to the desktop and listens for |
| 29 // X11 events on the X11 root window. Destroys itself when aura::Env is | 30 // X11 events on the X11 root window. Destroys itself when aura::Env is |
| 30 // deleted. | 31 // deleted. |
| 31 class VIEWS_EXPORT X11DesktopHandler : public ui::PlatformEventDispatcher, | 32 class VIEWS_EXPORT X11DesktopHandler : public ui::PlatformEventDispatcher, |
| 32 public aura::EnvObserver { | 33 public aura::EnvObserver { |
| 33 public: | 34 public: |
| 34 // Returns the singleton handler. | 35 // Returns the singleton handler. |
| 35 static X11DesktopHandler* get(); | 36 static X11DesktopHandler* get(); |
| 36 | 37 |
| 37 // Gets/sets the X11 server time of the most recent mouse click, touch or | 38 // Gets/sets the X11 server time of the most recent mouse click, touch or |
| 38 // key press on a Chrome window. | 39 // key press on a Chrome window. |
| 39 int wm_user_time_ms() const { | 40 int wm_user_time_ms() const { return wm_user_time_ms_; } |
| 40 return wm_user_time_ms_; | 41 void set_wm_user_time_ms(Time time_ms); |
| 41 } | |
| 42 void set_wm_user_time_ms(unsigned long time_ms) { | |
| 43 wm_user_time_ms_ = time_ms; | |
| 44 } | |
| 45 | 42 |
| 46 // Sends a request to the window manager to activate |window|. | 43 // Sends a request to the window manager to activate |window|. |
| 47 // This method should only be called if the window is already mapped. | 44 // This method should only be called if the window is already mapped. |
| 48 void ActivateWindow(::Window window); | 45 void ActivateWindow(::Window window); |
| 49 | 46 |
| 50 // Attempts to get the window manager to deactivate |window| by moving it to | 47 // Attempts to get the window manager to deactivate |window| by moving it to |
| 51 // the bottom of the stack. Regardless of whether |window| was actually | 48 // the bottom of the stack. Regardless of whether |window| was actually |
| 52 // deactivated, sets the window as inactive in our internal state. | 49 // deactivated, sets the window as inactive in our internal state. |
| 53 void DeactivateWindow(::Window window); | 50 void DeactivateWindow(::Window window); |
| 54 | 51 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 XDisplay* xdisplay_; | 85 XDisplay* xdisplay_; |
| 89 | 86 |
| 90 // The native root window. | 87 // The native root window. |
| 91 ::Window x_root_window_; | 88 ::Window x_root_window_; |
| 92 | 89 |
| 93 // The last known active X window | 90 // The last known active X window |
| 94 ::Window x_active_window_; | 91 ::Window x_active_window_; |
| 95 | 92 |
| 96 // The X11 server time of the most recent mouse click, touch, or key press | 93 // The X11 server time of the most recent mouse click, touch, or key press |
| 97 // on a Chrome window. | 94 // on a Chrome window. |
| 98 unsigned long wm_user_time_ms_; | 95 Time wm_user_time_ms_; |
| 99 | 96 |
| 100 // The active window according to X11 server. | 97 // The active window according to X11 server. |
| 101 ::Window current_window_; | 98 ::Window current_window_; |
| 102 | 99 |
| 103 // Whether we should treat |current_window_| as active. In particular, we | 100 // Whether we should treat |current_window_| as active. In particular, we |
| 104 // pretend that a window is deactivated after a call to DeactivateWindow(). | 101 // pretend that a window is deactivated after a call to DeactivateWindow(). |
| 105 ActiveState current_window_active_state_; | 102 ActiveState current_window_active_state_; |
| 106 | 103 |
| 107 ui::X11AtomCache atom_cache_; | 104 ui::X11AtomCache atom_cache_; |
| 108 | 105 |
| 109 bool wm_supports_active_window_; | 106 bool wm_supports_active_window_; |
| 110 | 107 |
| 111 DISALLOW_COPY_AND_ASSIGN(X11DesktopHandler); | 108 DISALLOW_COPY_AND_ASSIGN(X11DesktopHandler); |
| 112 }; | 109 }; |
| 113 | 110 |
| 114 } // namespace views | 111 } // namespace views |
| 115 | 112 |
| 116 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_HANDLER_H_ | 113 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_HANDLER_H_ |
| OLD | NEW |