Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / ui / views / widget / desktop_aura / x11_desktop_handler.h
index 577827e..0e9a956 100644 (file)
@@ -9,7 +9,9 @@
 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class.
 #undef RootWindow
 
-#include "base/message_loop/message_loop.h"
+#include <vector>
+
+#include "base/message_loop/message_pump_dispatcher.h"
 #include "ui/aura/env_observer.h"
 #include "ui/gfx/x/x11_atom_cache.h"
 #include "ui/gfx/x/x11_types.h"
@@ -22,25 +24,41 @@ namespace views {
 // A singleton that owns global objects related to the desktop and listens for
 // X11 events on the X11 root window. Destroys itself when aura::Env is
 // deleted.
-class VIEWS_EXPORT X11DesktopHandler : public base::MessageLoop::Dispatcher,
+class VIEWS_EXPORT X11DesktopHandler : public base::MessagePumpDispatcher,
                                        public aura::EnvObserver {
  public:
   // Returns the singleton handler.
   static X11DesktopHandler* get();
 
   // Sends a request to the window manager to activate |window|.
+  // This method should only be called if the window is already mapped.
   void ActivateWindow(::Window window);
 
+  // Deactivates the |window| and activates the window just below it in z-order.
+  // |window| must be active.
+  void DeactivateWindow(::Window window);
+
   // Checks if the current active window is |window|.
   bool IsActiveWindow(::Window window) const;
 
-  // Overridden from MessageLoop::Dispatcher:
-  virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE;
+  // Processes activation/focus related events. Some of these events are
+  // dispatched to the X11 window dispatcher, and not to the X11 root-window
+  // dispatcher. The window dispatcher sends these events to here.
+  void ProcessXEvent(const base::NativeEvent& event);
+
+  // Overridden from MessagePumpDispatcher:
+  virtual uint32_t Dispatch(const base::NativeEvent& event) OVERRIDE;
 
   // Overridden from aura::EnvObserver:
   virtual void OnWindowInitialized(aura::Window* window) OVERRIDE;
   virtual void OnWillDestroyEnv() OVERRIDE;
 
+  // Allows to override wm_supports_active_window_ value for tests. If the WM
+  // supports _NET_ACTIVE_WINDOW, activation is async otherwise it is sync.
+  void SetWMSupportsActiveWindowForTests(bool value) {
+    wm_supports_active_window_ = value;
+  }
+
  private:
   explicit X11DesktopHandler();
   virtual ~X11DesktopHandler();
@@ -48,6 +66,11 @@ class VIEWS_EXPORT X11DesktopHandler : public base::MessageLoop::Dispatcher,
   // Handles changes in activation.
   void OnActiveWindowChanged(::Window window);
 
+  // Return the next window to activate based on the current list of windows.
+  // This should only be called if there is an active window. In other words, if
+  // current_window_ is different from None.
+  ::Window GetNextToActivateInStack(const std::vector< ::Window >& windows);
+
   // The display and the native X window hosting the root window.
   XDisplay* xdisplay_;
 
@@ -59,6 +82,8 @@ class VIEWS_EXPORT X11DesktopHandler : public base::MessageLoop::Dispatcher,
 
   ui::X11AtomCache atom_cache_;
 
+  bool wm_supports_active_window_;
+
   DISALLOW_COPY_AND_ASSIGN(X11DesktopHandler);
 };