2014-05-23 19:47:07 +02:00
|
|
|
// Copyright 2014 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions copyright 2014 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 CEF_LIBCEF_BROWSER_WINDOW_X11_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_WINDOW_X11_H_
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
|
|
|
|
#include "libcef/browser/browser_host_impl.h"
|
|
|
|
|
2014-06-06 21:04:21 +02:00
|
|
|
#include "base/memory/weak_ptr.h"
|
2014-05-23 19:47:07 +02:00
|
|
|
#include "ui/events/platform/platform_event_dispatcher.h"
|
|
|
|
#include "ui/gfx/rect.h"
|
|
|
|
#include "ui/gfx/x/x11_atom_cache.h"
|
|
|
|
|
2014-10-29 19:14:47 +01:00
|
|
|
namespace views {
|
|
|
|
class DesktopWindowTreeHostX11;
|
|
|
|
}
|
|
|
|
|
2014-05-23 19:47:07 +02:00
|
|
|
// Object wrapper for an X11 Window.
|
|
|
|
// Based on WindowTreeHostX11 and DesktopWindowTreeHostX11.
|
|
|
|
class CefWindowX11 : public ui::PlatformEventDispatcher {
|
|
|
|
public:
|
|
|
|
CefWindowX11(CefRefPtr<CefBrowserHostImpl> browser,
|
|
|
|
::Window parent_xwindow,
|
|
|
|
const gfx::Rect& bounds);
|
|
|
|
virtual ~CefWindowX11();
|
|
|
|
|
|
|
|
void Close();
|
|
|
|
|
|
|
|
void Show();
|
|
|
|
void Hide();
|
|
|
|
|
2014-06-06 21:04:21 +02:00
|
|
|
void Focus();
|
|
|
|
|
2014-05-23 19:47:07 +02:00
|
|
|
void SetBounds(const gfx::Rect& bounds);
|
|
|
|
|
|
|
|
gfx::Rect GetBoundsInScreen();
|
|
|
|
|
2014-10-29 19:14:47 +01:00
|
|
|
views::DesktopWindowTreeHostX11* GetHost();
|
|
|
|
|
2014-05-23 19:47:07 +02:00
|
|
|
// ui::PlatformEventDispatcher methods:
|
|
|
|
virtual bool CanDispatchEvent(const ui::PlatformEvent& event) OVERRIDE;
|
|
|
|
virtual uint32_t DispatchEvent(const ui::PlatformEvent& event) OVERRIDE;
|
|
|
|
|
|
|
|
::Window xwindow() const { return xwindow_; }
|
|
|
|
gfx::Rect bounds() const { return bounds_; }
|
|
|
|
|
|
|
|
private:
|
2014-06-06 21:04:21 +02:00
|
|
|
void ContinueFocus();
|
|
|
|
|
2014-05-23 19:47:07 +02:00
|
|
|
CefRefPtr<CefBrowserHostImpl> browser_;
|
|
|
|
|
|
|
|
// The display and the native X window hosting the root window.
|
|
|
|
::Display* xdisplay_;
|
|
|
|
::Window parent_xwindow_;
|
|
|
|
::Window xwindow_;
|
|
|
|
|
|
|
|
// Is the window mapped to the screen?
|
|
|
|
bool window_mapped_;
|
|
|
|
|
|
|
|
// The bounds of |xwindow_|.
|
|
|
|
gfx::Rect bounds_;
|
|
|
|
|
2014-06-06 21:04:21 +02:00
|
|
|
bool focus_pending_;
|
|
|
|
|
2014-05-23 19:47:07 +02:00
|
|
|
ui::X11AtomCache atom_cache_;
|
|
|
|
|
2014-06-06 21:04:21 +02:00
|
|
|
// Must always be the last member.
|
|
|
|
base::WeakPtrFactory<CefWindowX11> weak_ptr_factory_;
|
|
|
|
|
2014-05-23 19:47:07 +02:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(CefWindowX11);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_BROWSER_WINDOW_X11_H_
|