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.
|
|
|
|
|
2015-11-17 19:20:13 +01:00
|
|
|
#ifndef CEF_LIBCEF_BROWSER_NATIVE_WINDOW_X11_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_NATIVE_WINDOW_X11_H_
|
2014-05-23 19:47:07 +02:00
|
|
|
#pragma once
|
|
|
|
|
2017-03-03 23:37:23 +01:00
|
|
|
// Avoid including <X11/Xlib.h>
|
|
|
|
typedef unsigned long Window;
|
|
|
|
struct _XDisplay;
|
|
|
|
typedef struct _XDisplay Display;
|
2014-05-23 19:47:07 +02:00
|
|
|
|
2020-09-22 21:54:02 +02:00
|
|
|
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
2014-05-23 19:47:07 +02:00
|
|
|
|
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"
|
2020-03-30 22:13:42 +02:00
|
|
|
#include "ui/events/platform/x11/x11_event_source.h"
|
2015-01-09 18:22:10 +01:00
|
|
|
#include "ui/gfx/geometry/rect.h"
|
2014-05-23 19:47:07 +02:00
|
|
|
#include "ui/gfx/x/x11_atom_cache.h"
|
|
|
|
|
2014-10-29 19:14:47 +01:00
|
|
|
namespace views {
|
2020-08-29 00:39:23 +02:00
|
|
|
class DesktopWindowTreeHostLinux;
|
2014-10-29 19:14:47 +01:00
|
|
|
}
|
|
|
|
|
2014-05-23 19:47:07 +02:00
|
|
|
// Object wrapper for an X11 Window.
|
|
|
|
// Based on WindowTreeHostX11 and DesktopWindowTreeHostX11.
|
2020-03-30 22:13:42 +02:00
|
|
|
class CefWindowX11 : public ui::PlatformEventDispatcher,
|
|
|
|
public ui::XEventDispatcher {
|
2014-05-23 19:47:07 +02:00
|
|
|
public:
|
2020-09-22 21:54:02 +02:00
|
|
|
CefWindowX11(CefRefPtr<AlloyBrowserHostImpl> browser,
|
2014-05-23 19:47:07 +02:00
|
|
|
::Window parent_xwindow,
|
2019-02-27 20:18:16 +01:00
|
|
|
const gfx::Rect& bounds,
|
|
|
|
const std::string& title);
|
2014-11-12 20:25:15 +01:00
|
|
|
~CefWindowX11() override;
|
2014-05-23 19:47:07 +02:00
|
|
|
|
|
|
|
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();
|
|
|
|
|
2020-08-29 00:39:23 +02:00
|
|
|
views::DesktopWindowTreeHostLinux* GetHost();
|
2014-10-29 19:14:47 +01:00
|
|
|
|
2014-05-23 19:47:07 +02:00
|
|
|
// ui::PlatformEventDispatcher methods:
|
2014-11-12 20:25:15 +01:00
|
|
|
bool CanDispatchEvent(const ui::PlatformEvent& event) override;
|
|
|
|
uint32_t DispatchEvent(const ui::PlatformEvent& event) override;
|
2014-05-23 19:47:07 +02:00
|
|
|
|
2020-03-30 22:13:42 +02:00
|
|
|
// ui::XEventDispatcher methods:
|
2020-07-08 19:23:29 +02:00
|
|
|
void CheckCanDispatchNextPlatformEvent(x11::Event* x11_event) override;
|
2020-03-30 22:13:42 +02:00
|
|
|
void PlatformEventDispatchFinished() override;
|
|
|
|
ui::PlatformEventDispatcher* GetPlatformEventDispatcher() override;
|
2020-07-08 19:23:29 +02:00
|
|
|
bool DispatchXEvent(x11::Event* x11_event) override;
|
2020-03-30 22:13:42 +02:00
|
|
|
|
2014-05-23 19:47:07 +02:00
|
|
|
::Window xwindow() const { return xwindow_; }
|
|
|
|
gfx::Rect bounds() const { return bounds_; }
|
|
|
|
|
2018-02-28 05:47:36 +01:00
|
|
|
bool TopLevelAlwaysOnTop() const;
|
|
|
|
|
2014-05-23 19:47:07 +02:00
|
|
|
private:
|
2014-06-06 21:04:21 +02:00
|
|
|
void ContinueFocus();
|
|
|
|
|
2020-07-08 19:23:29 +02:00
|
|
|
bool IsTargetedBy(const x11::Event& x11_event) const;
|
2020-08-29 00:39:23 +02:00
|
|
|
void ProcessXEvent(x11::Event* xev);
|
2020-03-30 22:13:42 +02:00
|
|
|
|
2020-09-22 21:54:02 +02:00
|
|
|
CefRefPtr<AlloyBrowserHostImpl> browser_;
|
2014-05-23 19:47:07 +02:00
|
|
|
|
|
|
|
// 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_;
|
|
|
|
|
2020-03-30 22:13:42 +02:00
|
|
|
// Tells if this dispatcher can process next translated event based on a
|
|
|
|
// previous check in ::CheckCanDispatchNextPlatformEvent based on a XID
|
|
|
|
// target.
|
2020-08-29 00:39:23 +02:00
|
|
|
x11::Event* current_xevent_ = nullptr;
|
2020-03-30 22:13:42 +02:00
|
|
|
|
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);
|
|
|
|
};
|
|
|
|
|
2015-11-17 19:20:13 +01:00
|
|
|
#endif // CEF_LIBCEF_BROWSER_NATIVE_WINDOW_X11_H_
|