Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2060)

Unified Diff: ui/aura/hostwm/host_window_manager_x11.h

Issue 10789018: aura: Add X11 host window management. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Keep ash switches alphabetized. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/aura/hostwm/host_window_manager_x11.h
diff --git a/ui/aura/hostwm/host_window_manager_x11.h b/ui/aura/hostwm/host_window_manager_x11.h
new file mode 100644
index 0000000000000000000000000000000000000000..59db716d37f3a31fcc7adc250cbfe243914d60cc
--- /dev/null
+++ b/ui/aura/hostwm/host_window_manager_x11.h
@@ -0,0 +1,262 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_AURA_HOSTWM_HOST_WINDOW_MANAGER_X11_H
+#define UI_AURA_HOSTWM_HOST_WINDOW_MANAGER_X11_H
+
+#include <X11/Xlib.h>
+
+// Xlib.h defines RootWindow.
+#undef RootWindow
+
+#include "base/basictypes.h"
+#include "base/message_loop.h"
+#include "ui/aura/env_observer.h"
+#include "ui/aura/focus_change_observer.h"
+#include "ui/aura/hostwm/host_window_delegate.h"
+#include "ui/aura/hostwm/host_window_manager_client.h"
+#include "ui/aura/root_window_observer.h"
+#include "ui/aura/x11_atom_cache.h"
+#include "ui/aura/window_observer.h"
+
+#include <map>
+
+namespace aura {
+class HostWindowManagerX11;
+class RedirectedHostWindowX11;
+
+void SetBaseX11ErrorHandler(XErrorHandler error_handler);
+int CallBaseX11ErrorHandler(Display* d, XErrorEvent* e);
+
+class HostWindowManagerX11WindowObserver : public EnvObserver,
+ public WindowObserver {
+ public:
+ HostWindowManagerX11WindowObserver(HostWindowManagerX11* manager);
+ virtual ~HostWindowManagerX11WindowObserver() {}
+
+ // Implements EnvObserver:
+ virtual void OnWindowInitialized(Window* window) OVERRIDE;
+
+ // Implements WindowObserver:
+ virtual void OnWillRemoveWindow(Window* window) OVERRIDE;
+ virtual void OnWindowDestroyed(Window* window) OVERRIDE;
+ virtual void OnWindowStackingChanged(Window* window) OVERRIDE;
+ virtual void OnWindowVisibilityChanged(Window* window, bool visible)
+ OVERRIDE;
+ virtual void OnWindowBoundsChanged(Window* window,
+ const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds) OVERRIDE;
+
+ private:
+ HostWindowManagerX11* host_window_manager_;
+
+ DISALLOW_COPY_AND_ASSIGN(HostWindowManagerX11WindowObserver);
+};
+
+class HostWindowX11
+ : public base::RefCounted<HostWindowX11>,
+ public HostWindowDelegate {
+ public:
+ HostWindowX11(::XID xwindow, unsigned state);
+
+ // Implements HostWindowDelegate:
+ virtual void CloseWindow() OVERRIDE {}
+ virtual bool CanResize() OVERRIDE;
+
+ virtual bool CanConfigure();
+ virtual bool CanActivate();
+ virtual void OnMapNotify() {}
+ virtual void OnUnmapNotify() {}
+ virtual void OnConfigureNotify(gfx::Rect bounds, ::Window above) {}
+
+ ::XID xid() { return xwindow_; }
+
+ unsigned state() { return state_; }
+ // TODO(reveman): Update WM_STATE property.
+ void set_state(unsigned state) { state_ = state; }
+
+ protected:
+ virtual ~HostWindowX11();
+
+ Display* xdisplay_;
+ ::XID xwindow_;
+ unsigned state_;
+
+ private:
+ friend class base::RefCounted<HostWindowX11>;
+
+ DISALLOW_COPY_AND_ASSIGN(HostWindowX11);
+};
+
+class InputHostWindowX11 : public HostWindowX11 {
+ public:
+ InputHostWindowX11(::XID xwindow);
+
+ // Implements HostWindowDelegate:
+ virtual void CloseWindow() OVERRIDE;
+ virtual bool CanResize() OVERRIDE;
+
+ // Overridden from HostWindowX11:
+ virtual bool CanConfigure() OVERRIDE;
+ virtual bool CanActivate() OVERRIDE;
+
+ private:
+ virtual ~InputHostWindowX11();
+
+ DISALLOW_COPY_AND_ASSIGN(InputHostWindowX11);
+};
+
+class RedirectedHostWindowX11 : public HostWindowX11,
+ public MessageLoop::Dispatcher {
+public:
+ RedirectedHostWindowX11(HostWindowManagerX11* manager,
+ ::Window xwindow,
+ const gfx::Size& size);
+
+ // Implements HostWindowDelegate:
+ virtual void CloseWindow() OVERRIDE {}
+ virtual bool CanResize() OVERRIDE;
+
+ // Overridden from HostWindowX11:
+ virtual bool CanConfigure() OVERRIDE;
+ virtual bool CanActivate() OVERRIDE;
+ virtual void OnMapNotify() OVERRIDE;
+ virtual void OnUnmapNotify() OVERRIDE;
+ virtual void OnConfigureNotify(gfx::Rect bounds, ::Window above) OVERRIDE;
+
+ // Overridden from Dispatcher:
+ virtual bool Dispatch(const base::NativeEvent& xev) OVERRIDE;
+
+ void UpdateExternalTexture();
+ void SetSize(const gfx::Size& size);
+ void SetVisible(bool visible);
+
+protected:
+ virtual ~RedirectedHostWindowX11();
+
+ HostWindowManagerX11* host_window_manager_;
+ gfx::Size size_;
+ bool visible_;
+
+ DISALLOW_COPY_AND_ASSIGN(RedirectedHostWindowX11);
+};
+
+class ManagedRedirectedHostWindowX11 : public RedirectedHostWindowX11 {
+public:
+ ManagedRedirectedHostWindowX11(HostWindowManagerX11* manager,
+ ::Window xwindow,
+ const gfx::Size& size);
+
+ // Implements HostWindowDelegate:
+ virtual void CloseWindow() OVERRIDE;
+ virtual bool CanResize() OVERRIDE;
+
+ // Overridden from HostWindowX11:
+ virtual bool CanConfigure() OVERRIDE;
+ virtual bool CanActivate() OVERRIDE;
+ virtual void OnMapNotify() OVERRIDE;
+ virtual void OnUnmapNotify() OVERRIDE;
+ virtual void OnConfigureNotify(gfx::Rect bounds, ::Window above) OVERRIDE;
+
+private:
+ virtual ~ManagedRedirectedHostWindowX11();
+
+ DISALLOW_COPY_AND_ASSIGN(ManagedRedirectedHostWindowX11);
+};
+
+class HostWindowManagerX11RootEventObserver
+ : public MessageLoop::Dispatcher,
+ public RootWindowObserver,
+ public FocusChangeObserver {
+public:
+ HostWindowManagerX11RootEventObserver(HostWindowManagerX11* manager);
+ virtual ~HostWindowManagerX11RootEventObserver() {}
+
+ // Overridden from Dispatcher:
+ virtual bool Dispatch(const base::NativeEvent& xev) OVERRIDE;
+
+ // Overridden from RootWindowObserver:
+ virtual void OnCursorChanged(
+ const RootWindow* root, ui::PlatformCursor cursor) OVERRIDE;
+
+ // Overridden from FocusChangeObserver:
+ virtual void OnWindowFocused(Window* window) OVERRIDE;
+
+private:
+ HostWindowManagerX11* host_window_manager_;
+ Display* xdisplay_;
+
+ bool ProcessHostWindowUpdate(const base::NativeEvent& xev);
+ bool ProcessHostWindowRequest(const base::NativeEvent& xev);
+
+ DISALLOW_COPY_AND_ASSIGN(HostWindowManagerX11RootEventObserver);
+};
+
+class AURA_EXPORT HostWindowManagerX11
+ : public base::SupportsWeakPtr<HostWindowManagerX11> {
+public:
+ HostWindowManagerX11(client::HostWindowManagerClient* client);
+ virtual ~HostWindowManagerX11();
+
+ void Init();
+ void HostWindowNeedsConfigure(Window* window);
+
+ int damage_event_base() { return damage_event_base_; };
+
+ private:
+ void RegisterNewTopLevel(::Window xwindow);
+ void RegisterNewTopLevel(
+ ::Window xwindow, const gfx::Rect bounds, bool managed);
+ ::Window GetTopHostWindow(Window* window);
+ ::Window FindHostWindowToStackAbove(Window* window);
+ void RecursiveConfigureHostWindow(
+ Window* window,
+ gfx::Point origin,
+ ::Window& sibling_to_stack_above,
+ ::Window& focus_window,
+ bool has_focus);
+ void CreateHostInputWindowIfNeeded(Window* window);
+
+ // Configure all host windows in |configure_window_| subtree.
+ void ConfigureHostWindows();
+
+ Display* xdisplay_;
+
+ ::Window x_root_window_;
+ Window* configure_window_;
+ int damage_event_base_;
+
+ scoped_ptr<HostWindowManagerX11WindowObserver> window_observer_;
+ scoped_ptr<HostWindowManagerX11RootEventObserver> event_observer_;
+
+ // This holds all host windows being redirected, with a mapping from native
+ // representation to the host window id.
+ std::map<gfx::NativeWindow, ::Window> host_windows_;
+
+ // Holds a TopLevel struct for each redirected window, with a mapping from
+ // host window id to struct.
+ std::map< ::Window, scoped_refptr<HostWindowX11> >
+ top_level_windows_;
+
+ // Mapping from the native representation to host window id.
+ std::map< ::Window, gfx::NativeWindow> native_windows_;
+
+ // This holds all input only host windows, with a mapping from the native
+ // representation to host window struct.
+ std::map<gfx::NativeWindow, scoped_refptr<InputHostWindowX11> >
+ input_host_windows_;
+
+ X11AtomCache atom_cache_;
+
+ client::HostWindowManagerClient* client_;
+
+ friend class HostWindowManagerX11WindowObserver;
+ friend class HostWindowManagerX11RootEventObserver;
+ friend class RedirectedHostWindowX11;
+ friend class ManagedRedirectedHostWindowX11;
+};
+
+} // namespace aura
+
+#endif // UI_AURA_HOSTWM_HOST_WINDOW_MANAGER_X11_H

Powered by Google App Engine
This is Rietveld 408576698