Commit 6983e9fa authored by Maksim Sisov's avatar Maksim Sisov Committed by Commit Bot

X11 and Ozone: Move static methods to DWTHLinux.

At first, I wanted to remove these static methods, but then decided
to keep them and remove later when we no longer need them.

Bug: 990756
Change-Id: If6132986e25bb1c8712acdbc90ce29093616bff7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1860341Reviewed-by: default avatarThomas Anderson <thomasanderson@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Maksim Sisov <msisov@igalia.com>
Cr-Commit-Position: refs/heads/master@{#705946}
parent 9a8c5c02
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
#include <vector> #include <vector>
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" #include "ui/views/widget/desktop_aura/desktop_window_tree_host_linux.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
bool IsFullScreenMode() { bool IsFullScreenMode() {
std::vector<aura::Window*> all_windows = std::vector<aura::Window*> all_windows =
views::DesktopWindowTreeHostX11::GetAllOpenWindows(); views::DesktopWindowTreeHostLinux::GetAllOpenWindows();
// Only the topmost window is checked. This works fine in the most cases, but // Only the topmost window is checked. This works fine in the most cases, but
// it may return false when there are multiple displays and one display has // it may return false when there are multiple displays and one display has
// a fullscreen window but others don't. See: crbug.com/345484 // a fullscreen window but others don't. See: crbug.com/345484
......
...@@ -200,7 +200,7 @@ void SelectFileDialogImplGTK::SelectFileImpl( ...@@ -200,7 +200,7 @@ void SelectFileDialogImplGTK::SelectFileImpl(
host->ReleaseCapture(); host->ReleaseCapture();
std::unique_ptr<base::OnceClosure> callback = std::unique_ptr<base::OnceClosure> callback =
std::make_unique<base::OnceClosure>( std::make_unique<base::OnceClosure>(
views::DesktopWindowTreeHostX11::GetHostForXID( views::DesktopWindowTreeHostLinux::GetHostForWidget(
host->GetAcceleratedWidget()) host->GetAcceleratedWidget())
->DisableEventListening()); ->DisableEventListening());
// OnFilePickerDestroy() is called when |dialog| destroyed, which allows // OnFilePickerDestroy() is called when |dialog| destroyed, which allows
......
...@@ -251,10 +251,10 @@ class UIControlsDesktopX11 : public UIControlsAura { ...@@ -251,10 +251,10 @@ class UIControlsDesktopX11 : public UIControlsAura {
// Most interactive_ui_tests run inside of the aura_test_helper // Most interactive_ui_tests run inside of the aura_test_helper
// environment. This means that we can't rely on display::Screen and several // environment. This means that we can't rely on display::Screen and several
// other things to work properly. Therefore we hack around this by // other things to work properly. Therefore we hack around this by
// iterating across the windows owned DesktopWindowTreeHostX11 since this // iterating across the windows owned DesktopWindowTreeHostLinux since this
// doesn't rely on having a DesktopScreenX11. // doesn't rely on having a DesktopScreenX11.
std::vector<aura::Window*> windows = std::vector<aura::Window*> windows =
DesktopWindowTreeHostX11::GetAllOpenWindows(); DesktopWindowTreeHostLinux::GetAllOpenWindows();
const auto i = const auto i =
std::find_if(windows.cbegin(), windows.cend(), [point](auto* window) { std::find_if(windows.cbegin(), windows.cend(), [point](auto* window) {
return window->GetBoundsInScreen().Contains(point) || return window->GetBoundsInScreen().Contains(point) ||
......
...@@ -13,10 +13,13 @@ ...@@ -13,10 +13,13 @@
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
#include "ui/wm/core/shadow_controller.h" #include "ui/wm/core/shadow_controller.h"
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_linux.h"
#endif
#if defined(USE_X11) #if defined(USE_X11)
#include "ui/gfx/x/x11.h" // nogncheck #include "ui/gfx/x/x11.h" // nogncheck
#include "ui/gfx/x/x11_types.h" // nogncheck #include "ui/gfx/x/x11_types.h" // nogncheck
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
#endif #endif
namespace views { namespace views {
...@@ -69,8 +72,8 @@ BOOL CALLBACK FindAllWindowsCallback(HWND hwnd, LPARAM param) { ...@@ -69,8 +72,8 @@ BOOL CALLBACK FindAllWindowsCallback(HWND hwnd, LPARAM param) {
std::vector<aura::Window*> GetAllTopLevelWindows() { std::vector<aura::Window*> GetAllTopLevelWindows() {
std::vector<aura::Window*> roots; std::vector<aura::Window*> roots;
#if defined(USE_X11) #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
roots = DesktopWindowTreeHostX11::GetAllOpenWindows(); roots = DesktopWindowTreeHostLinux::GetAllOpenWindows();
#elif defined(OS_WIN) #elif defined(OS_WIN)
{ {
FindAllWindowsData data = {&roots}; FindAllWindowsData data = {&roots};
......
...@@ -118,8 +118,8 @@ display::Display DesktopScreenX11::GetDisplayNearestWindow( ...@@ -118,8 +118,8 @@ display::Display DesktopScreenX11::GetDisplayNearestWindow(
// aura::Window's screen bounds. // aura::Window's screen bounds.
aura::WindowTreeHost* host = window->GetHost(); aura::WindowTreeHost* host = window->GetHost();
if (host) { if (host) {
DesktopWindowTreeHostX11* rwh = auto* rwh = DesktopWindowTreeHostLinux::GetHostForWidget(
DesktopWindowTreeHostX11::GetHostForXID(host->GetAcceleratedWidget()); host->GetAcceleratedWidget());
if (rwh) { if (rwh) {
const gfx::Rect pixel_rect = rwh->GetBoundsInPixels(); const gfx::Rect pixel_rect = rwh->GetBoundsInPixels();
const gfx::Rect dip_rect = const gfx::Rect dip_rect =
......
...@@ -19,8 +19,17 @@ ...@@ -19,8 +19,17 @@
#include "ui/views/widget/desktop_aura/window_event_filter_linux.h" #include "ui/views/widget/desktop_aura/window_event_filter_linux.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
DEFINE_UI_CLASS_PROPERTY_TYPE(views::DesktopWindowTreeHostLinux*)
namespace views { namespace views {
std::list<gfx::AcceleratedWidget>* DesktopWindowTreeHostLinux::open_windows_ =
nullptr;
DEFINE_UI_CLASS_PROPERTY_KEY(DesktopWindowTreeHostLinux*,
kHostForRootWindow,
nullptr)
namespace { namespace {
class SwapWithNewSizeObserverHelper : public ui::CompositorObserver { class SwapWithNewSizeObserverHelper : public ui::CompositorObserver {
...@@ -63,7 +72,48 @@ DesktopWindowTreeHostLinux::DesktopWindowTreeHostLinux( ...@@ -63,7 +72,48 @@ DesktopWindowTreeHostLinux::DesktopWindowTreeHostLinux(
: DesktopWindowTreeHostPlatform(native_widget_delegate, : DesktopWindowTreeHostPlatform(native_widget_delegate,
desktop_native_widget_aura) {} desktop_native_widget_aura) {}
DesktopWindowTreeHostLinux::~DesktopWindowTreeHostLinux() = default; DesktopWindowTreeHostLinux::~DesktopWindowTreeHostLinux() {
window()->ClearProperty(kHostForRootWindow);
}
// static
aura::Window* DesktopWindowTreeHostLinux::GetContentWindowForWidget(
gfx::AcceleratedWidget widget) {
auto* host = DesktopWindowTreeHostLinux::GetHostForWidget(widget);
return host ? host->GetContentWindow() : nullptr;
}
// static
DesktopWindowTreeHostLinux* DesktopWindowTreeHostLinux::GetHostForWidget(
gfx::AcceleratedWidget widget) {
aura::WindowTreeHost* host =
aura::WindowTreeHost::GetForAcceleratedWidget(widget);
return host ? host->window()->GetProperty(kHostForRootWindow) : nullptr;
}
// static
std::vector<aura::Window*> DesktopWindowTreeHostLinux::GetAllOpenWindows() {
std::vector<aura::Window*> windows(open_windows().size());
std::transform(open_windows().begin(), open_windows().end(), windows.begin(),
GetContentWindowForWidget);
return windows;
}
// static
void DesktopWindowTreeHostLinux::CleanUpWindowList(
void (*func)(aura::Window* window)) {
if (!open_windows_)
return;
while (!open_windows_->empty()) {
gfx::AcceleratedWidget widget = open_windows_->front();
func(GetContentWindowForWidget(widget));
if (!open_windows_->empty() && open_windows_->front() == widget)
open_windows_->erase(open_windows_->begin());
}
delete open_windows_;
open_windows_ = nullptr;
}
void DesktopWindowTreeHostLinux::SetPendingXVisualId(int x_visual_id) { void DesktopWindowTreeHostLinux::SetPendingXVisualId(int x_visual_id) {
pending_x_visual_id_ = x_visual_id; pending_x_visual_id_ = x_visual_id;
...@@ -106,6 +156,8 @@ void DesktopWindowTreeHostLinux::Init(const Widget::InitParams& params) { ...@@ -106,6 +156,8 @@ void DesktopWindowTreeHostLinux::Init(const Widget::InitParams& params) {
void DesktopWindowTreeHostLinux::OnNativeWidgetCreated( void DesktopWindowTreeHostLinux::OnNativeWidgetCreated(
const Widget::InitParams& params) { const Widget::InitParams& params) {
window()->SetProperty(kHostForRootWindow, this);
CreateNonClientEventFilter(); CreateNonClientEventFilter();
DesktopWindowTreeHostPlatform::OnNativeWidgetCreated(params); DesktopWindowTreeHostPlatform::OnNativeWidgetCreated(params);
} }
...@@ -229,10 +281,26 @@ void DesktopWindowTreeHostLinux::DispatchEvent(ui::Event* event) { ...@@ -229,10 +281,26 @@ void DesktopWindowTreeHostLinux::DispatchEvent(ui::Event* event) {
} }
void DesktopWindowTreeHostLinux::OnClosed() { void DesktopWindowTreeHostLinux::OnClosed() {
open_windows().remove(GetAcceleratedWidget());
DestroyNonClientEventFilter(); DestroyNonClientEventFilter();
DesktopWindowTreeHostPlatform::OnClosed(); DesktopWindowTreeHostPlatform::OnClosed();
} }
void DesktopWindowTreeHostLinux::OnAcceleratedWidgetAvailable(
gfx::AcceleratedWidget widget) {
open_windows().push_front(widget);
DesktopWindowTreeHostPlatform::OnAcceleratedWidgetAvailable(widget);
}
void DesktopWindowTreeHostLinux::OnActivationChanged(bool active) {
if (active) {
auto widget = GetAcceleratedWidget();
open_windows().remove(widget);
open_windows().insert(open_windows().begin(), widget);
}
DesktopWindowTreeHostPlatform::OnActivationChanged(active);
}
void DesktopWindowTreeHostLinux::AddAdditionalInitProperties( void DesktopWindowTreeHostLinux::AddAdditionalInitProperties(
const Widget::InitParams& params, const Widget::InitParams& params,
ui::PlatformWindowInitProperties* properties) { ui::PlatformWindowInitProperties* properties) {
...@@ -318,6 +386,12 @@ ui::PlatformWindowLinux* DesktopWindowTreeHostLinux::GetPlatformWindowLinux() { ...@@ -318,6 +386,12 @@ ui::PlatformWindowLinux* DesktopWindowTreeHostLinux::GetPlatformWindowLinux() {
return static_cast<ui::PlatformWindowLinux*>(platform_window()); return static_cast<ui::PlatformWindowLinux*>(platform_window());
} }
std::list<gfx::AcceleratedWidget>& DesktopWindowTreeHostLinux::open_windows() {
if (!open_windows_)
open_windows_ = new std::list<gfx::AcceleratedWidget>();
return *open_windows_;
}
// As DWTHX11 subclasses DWTHPlatform through DWTHLinux now (during transition // As DWTHX11 subclasses DWTHPlatform through DWTHLinux now (during transition
// period. see https://crbug.com/990756), we need to guard this factory method. // period. see https://crbug.com/990756), we need to guard this factory method.
// TODO(msisov): remove this guard once DWTHX11 is finally merged into // TODO(msisov): remove this guard once DWTHX11 is finally merged into
......
...@@ -35,6 +35,23 @@ class VIEWS_EXPORT DesktopWindowTreeHostLinux ...@@ -35,6 +35,23 @@ class VIEWS_EXPORT DesktopWindowTreeHostLinux
DesktopNativeWidgetAura* desktop_native_widget_aura); DesktopNativeWidgetAura* desktop_native_widget_aura);
~DesktopWindowTreeHostLinux() override; ~DesktopWindowTreeHostLinux() override;
// A way of converting a |widget| into the content_window()
// of the associated DesktopNativeWidgetAura.
static aura::Window* GetContentWindowForWidget(gfx::AcceleratedWidget widget);
// A way of converting a |widget| into this object.
static DesktopWindowTreeHostLinux* GetHostForWidget(
gfx::AcceleratedWidget widget);
// Get all open top-level windows. This includes windows that may not be
// visible. This list is sorted in their stacking order, i.e. the first window
// is the topmost window.
static std::vector<aura::Window*> GetAllOpenWindows();
// Runs the |func| callback for each content-window, and deallocates the
// internal list of open windows.
static void CleanUpWindowList(void (*func)(aura::Window* window));
// This must be called before the window is created, because the visual cannot // This must be called before the window is created, because the visual cannot
// be changed after. Useful for X11. Not in use for Wayland. // be changed after. Useful for X11. Not in use for Wayland.
void SetPendingXVisualId(int x_visual_id); void SetPendingXVisualId(int x_visual_id);
...@@ -64,6 +81,8 @@ class VIEWS_EXPORT DesktopWindowTreeHostLinux ...@@ -64,6 +81,8 @@ class VIEWS_EXPORT DesktopWindowTreeHostLinux
// PlatformWindowDelegateBase: // PlatformWindowDelegateBase:
void DispatchEvent(ui::Event* event) override; void DispatchEvent(ui::Event* event) override;
void OnClosed() override; void OnClosed() override;
void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget) override;
void OnActivationChanged(bool active) override;
private: private:
FRIEND_TEST_ALL_PREFIXES(DesktopWindowTreeHostLinuxTest, HitTest); FRIEND_TEST_ALL_PREFIXES(DesktopWindowTreeHostLinuxTest, HitTest);
...@@ -94,6 +113,9 @@ class VIEWS_EXPORT DesktopWindowTreeHostLinux ...@@ -94,6 +113,9 @@ class VIEWS_EXPORT DesktopWindowTreeHostLinux
const ui::PlatformWindowLinux* GetPlatformWindowLinux() const; const ui::PlatformWindowLinux* GetPlatformWindowLinux() const;
ui::PlatformWindowLinux* GetPlatformWindowLinux(); ui::PlatformWindowLinux* GetPlatformWindowLinux();
// See comment for variable open_windows_.
static std::list<gfx::AcceleratedWidget>& open_windows();
// A handler for events intended for non client area. // A handler for events intended for non client area.
// A posthandler for events intended for non client area. Handles events if no // A posthandler for events intended for non client area. Handles events if no
// other consumer handled them. // other consumer handled them.
...@@ -110,6 +132,10 @@ class VIEWS_EXPORT DesktopWindowTreeHostLinux ...@@ -110,6 +132,10 @@ class VIEWS_EXPORT DesktopWindowTreeHostLinux
uint32_t modal_dialog_counter_ = 0; uint32_t modal_dialog_counter_ = 0;
// A list of all (top-level) windows that have been created but not yet
// destroyed.
static std::list<gfx::AcceleratedWidget>* open_windows_;
// The display and the native X window hosting the root window. // The display and the native X window hosting the root window.
base::WeakPtrFactory<DesktopWindowTreeHostLinux> weak_factory_{this}; base::WeakPtrFactory<DesktopWindowTreeHostLinux> weak_factory_{this};
......
...@@ -66,18 +66,8 @@ ...@@ -66,18 +66,8 @@
#include "ui/accessibility/platform/atk_util_auralinux.h" #include "ui/accessibility/platform/atk_util_auralinux.h"
#endif #endif
DEFINE_UI_CLASS_PROPERTY_TYPE(views::DesktopWindowTreeHostX11*)
namespace views { namespace views {
std::list<XID>* DesktopWindowTreeHostX11::open_windows_ = nullptr;
DEFINE_UI_CLASS_PROPERTY_KEY(aura::Window*, kViewsWindowForRootWindow, NULL)
DEFINE_UI_CLASS_PROPERTY_KEY(DesktopWindowTreeHostX11*,
kHostForRootWindow,
NULL)
namespace { namespace {
bool ShouldDiscardKeyEvent(XEvent* xev) { bool ShouldDiscardKeyEvent(XEvent* xev) {
...@@ -100,35 +90,12 @@ DesktopWindowTreeHostX11::DesktopWindowTreeHostX11( ...@@ -100,35 +90,12 @@ DesktopWindowTreeHostX11::DesktopWindowTreeHostX11(
desktop_native_widget_aura) {} desktop_native_widget_aura) {}
DesktopWindowTreeHostX11::~DesktopWindowTreeHostX11() { DesktopWindowTreeHostX11::~DesktopWindowTreeHostX11() {
window()->ClearProperty(kHostForRootWindow);
wm::SetWindowMoveClient(window(), nullptr); wm::SetWindowMoveClient(window(), nullptr);
// ~DWTHPlatform notifies the DestkopNativeWidgetAura about destruction and // ~DWTHPlatform notifies the DestkopNativeWidgetAura about destruction and
// also destroyes the dispatcher. // also destroyes the dispatcher.
} }
// static
aura::Window* DesktopWindowTreeHostX11::GetContentWindowForXID(XID xid) {
aura::WindowTreeHost* host =
aura::WindowTreeHost::GetForAcceleratedWidget(xid);
return host ? host->window()->GetProperty(kViewsWindowForRootWindow) : NULL;
}
// static
DesktopWindowTreeHostX11* DesktopWindowTreeHostX11::GetHostForXID(XID xid) {
aura::WindowTreeHost* host =
aura::WindowTreeHost::GetForAcceleratedWidget(xid);
return host ? host->window()->GetProperty(kHostForRootWindow) : nullptr;
}
// static
std::vector<aura::Window*> DesktopWindowTreeHostX11::GetAllOpenWindows() {
std::vector<aura::Window*> windows(open_windows().size());
std::transform(open_windows().begin(), open_windows().end(), windows.begin(),
GetContentWindowForXID);
return windows;
}
void DesktopWindowTreeHostX11::AddObserver( void DesktopWindowTreeHostX11::AddObserver(
DesktopWindowTreeHostObserverX11* observer) { DesktopWindowTreeHostObserverX11* observer) {
observer_list_.AddObserver(observer); observer_list_.AddObserver(observer);
...@@ -139,21 +106,6 @@ void DesktopWindowTreeHostX11::RemoveObserver( ...@@ -139,21 +106,6 @@ void DesktopWindowTreeHostX11::RemoveObserver(
observer_list_.RemoveObserver(observer); observer_list_.RemoveObserver(observer);
} }
void DesktopWindowTreeHostX11::CleanUpWindowList(
void (*func)(aura::Window* window)) {
if (!open_windows_)
return;
while (!open_windows_->empty()) {
gfx::AcceleratedWidget widget = open_windows_->front();
func(GetContentWindowForXID(widget));
if (!open_windows_->empty() && open_windows_->front() == widget)
open_windows_->erase(open_windows_->begin());
}
delete open_windows_;
open_windows_ = nullptr;
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// DesktopWindowTreeHostX11, DesktopWindowTreeHost implementation: // DesktopWindowTreeHostX11, DesktopWindowTreeHost implementation:
...@@ -171,9 +123,6 @@ void DesktopWindowTreeHostX11::Init(const Widget::InitParams& params) { ...@@ -171,9 +123,6 @@ void DesktopWindowTreeHostX11::Init(const Widget::InitParams& params) {
void DesktopWindowTreeHostX11::OnNativeWidgetCreated( void DesktopWindowTreeHostX11::OnNativeWidgetCreated(
const Widget::InitParams& params) { const Widget::InitParams& params) {
window()->SetProperty(kViewsWindowForRootWindow, GetContentWindow());
window()->SetProperty(kHostForRootWindow, this);
// Ensure that the X11DesktopHandler exists so that it tracks create/destroy // Ensure that the X11DesktopHandler exists so that it tracks create/destroy
// notify events. // notify events.
X11DesktopHandler::get(); X11DesktopHandler::get();
...@@ -213,42 +162,9 @@ void DesktopWindowTreeHostX11::EndMoveLoop() { ...@@ -213,42 +162,9 @@ void DesktopWindowTreeHostX11::EndMoveLoop() {
x11_window_move_client_->EndMoveLoop(); x11_window_move_client_->EndMoveLoop();
} }
////////////////////////////////////////////////////////////////////////////////
// DesktopWindowTreeHostX11, private:
std::list<gfx::AcceleratedWidget>& DesktopWindowTreeHostX11::open_windows() {
if (!open_windows_)
open_windows_ = new std::list<gfx::AcceleratedWidget>();
return *open_windows_;
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// DesktopWindowTreeHostX11 implementation: // DesktopWindowTreeHostX11 implementation:
void DesktopWindowTreeHostX11::OnClosed() {
open_windows().remove(GetAcceleratedWidget());
DesktopWindowTreeHostLinux::OnClosed();
}
void DesktopWindowTreeHostX11::OnAcceleratedWidgetAvailable(
gfx::AcceleratedWidget widget) {
open_windows().push_front(widget);
WindowTreeHostPlatform::OnAcceleratedWidgetAvailable(widget);
}
void DesktopWindowTreeHostX11::OnAcceleratedWidgetDestroyed() {}
void DesktopWindowTreeHostX11::OnActivationChanged(bool active) {
if (active) {
// TODO(thomasanderson): Remove this window shuffling and use XWindowCache
// instead.
auto widget = GetAcceleratedWidget();
open_windows().remove(widget);
open_windows().insert(open_windows().begin(), widget);
}
DesktopWindowTreeHostPlatform::OnActivationChanged(active);
}
void DesktopWindowTreeHostX11::OnXWindowMapped() { void DesktopWindowTreeHostX11::OnXWindowMapped() {
for (DesktopWindowTreeHostObserverX11& observer : observer_list_) for (DesktopWindowTreeHostObserverX11& observer : observer_list_)
observer.OnWindowMapped(GetXWindow()->window()); observer.OnWindowMapped(GetXWindow()->window());
......
...@@ -44,25 +44,9 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 : public DesktopWindowTreeHostLinux, ...@@ -44,25 +44,9 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 : public DesktopWindowTreeHostLinux,
DesktopNativeWidgetAura* desktop_native_widget_aura); DesktopNativeWidgetAura* desktop_native_widget_aura);
~DesktopWindowTreeHostX11() override; ~DesktopWindowTreeHostX11() override;
// A way of converting an X11 |xid| host window into the content_window()
// of the associated DesktopNativeWidgetAura.
static aura::Window* GetContentWindowForXID(XID xid);
// A way of converting an X11 |xid| host window into this object.
static DesktopWindowTreeHostX11* GetHostForXID(XID xid);
// Get all open top-level windows. This includes windows that may not be
// visible. This list is sorted in their stacking order, i.e. the first window
// is the topmost window.
static std::vector<aura::Window*> GetAllOpenWindows();
void AddObserver(DesktopWindowTreeHostObserverX11* observer); void AddObserver(DesktopWindowTreeHostObserverX11* observer);
void RemoveObserver(DesktopWindowTreeHostObserverX11* observer); void RemoveObserver(DesktopWindowTreeHostObserverX11* observer);
// Runs the |func| callback for each content-window, and deallocates the
// internal list of open windows.
static void CleanUpWindowList(void (*func)(aura::Window* window));
protected: protected:
// Overridden from DesktopWindowTreeHost: // Overridden from DesktopWindowTreeHost:
void Init(const Widget::InitParams& params) override; void Init(const Widget::InitParams& params) override;
...@@ -78,18 +62,11 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 : public DesktopWindowTreeHostLinux, ...@@ -78,18 +62,11 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 : public DesktopWindowTreeHostLinux,
private: private:
friend class DesktopWindowTreeHostX11HighDPITest; friend class DesktopWindowTreeHostX11HighDPITest;
// See comment for variable open_windows_.
static std::list<XID>& open_windows();
// PlatformWindowDelegate overrides: // PlatformWindowDelegate overrides:
// //
// DWTHX11 temporarily overrides the PlatformWindowDelegate methods instead of // DWTHX11 temporarily overrides the PlatformWindowDelegate methods instead of
// underlying DWTHPlatform and WTHPlatform. Eventually, these will be removed // underlying DWTHPlatform and WTHPlatform. Eventually, these will be removed
// from here as we progress in https://crbug.com/990756. // from here as we progress in https://crbug.com/990756.
void OnClosed() override;
void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget) override;
void OnAcceleratedWidgetDestroyed() override;
void OnActivationChanged(bool active) override;
void OnXWindowMapped() override; void OnXWindowMapped() override;
void OnXWindowUnmapped() override; void OnXWindowUnmapped() override;
...@@ -111,10 +88,6 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 : public DesktopWindowTreeHostLinux, ...@@ -111,10 +88,6 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 : public DesktopWindowTreeHostLinux,
base::ObserverList<DesktopWindowTreeHostObserverX11>::Unchecked base::ObserverList<DesktopWindowTreeHostObserverX11>::Unchecked
observer_list_; observer_list_;
// A list of all (top-level) windows that have been created but not yet
// destroyed.
static std::list<gfx::AcceleratedWidget>* open_windows_;
// The display and the native X window hosting the root window. // The display and the native X window hosting the root window.
base::WeakPtrFactory<DesktopWindowTreeHostX11> weak_factory_{this}; base::WeakPtrFactory<DesktopWindowTreeHostX11> weak_factory_{this};
......
...@@ -454,7 +454,7 @@ TEST_F(DesktopWindowTreeHostX11Test, ChildWindowDestructionDuringTearDown) { ...@@ -454,7 +454,7 @@ TEST_F(DesktopWindowTreeHostX11Test, ChildWindowDestructionDuringTearDown) {
ASSERT_NE(parent_widget.GetNativeWindow()->GetHost()->GetAcceleratedWidget(), ASSERT_NE(parent_widget.GetNativeWindow()->GetHost()->GetAcceleratedWidget(),
child_widget.GetNativeWindow()->GetHost()->GetAcceleratedWidget()); child_widget.GetNativeWindow()->GetHost()->GetAcceleratedWidget());
Widget::CloseAllSecondaryWidgets(); Widget::CloseAllSecondaryWidgets();
EXPECT_TRUE(DesktopWindowTreeHostX11::GetAllOpenWindows().empty()); EXPECT_TRUE(DesktopWindowTreeHostLinux::GetAllOpenWindows().empty());
} }
// A Widget that allows setting the min/max size for the widget. // A Widget that allows setting the min/max size for the widget.
......
...@@ -23,7 +23,7 @@ aura::Window* X11TopmostWindowFinder::FindLocalProcessWindowAt( ...@@ -23,7 +23,7 @@ aura::Window* X11TopmostWindowFinder::FindLocalProcessWindowAt(
ignore_ = ignore; ignore_ = ignore;
std::vector<aura::Window*> local_process_windows = std::vector<aura::Window*> local_process_windows =
DesktopWindowTreeHostX11::GetAllOpenWindows(); DesktopWindowTreeHostLinux::GetAllOpenWindows();
if (std::none_of(local_process_windows.cbegin(), local_process_windows.cend(), if (std::none_of(local_process_windows.cbegin(), local_process_windows.cend(),
[this](auto* window) { [this](auto* window) {
return ShouldStopIteratingAtLocalProcessWindow(window); return ShouldStopIteratingAtLocalProcessWindow(window);
...@@ -31,7 +31,8 @@ aura::Window* X11TopmostWindowFinder::FindLocalProcessWindowAt( ...@@ -31,7 +31,8 @@ aura::Window* X11TopmostWindowFinder::FindLocalProcessWindowAt(
return nullptr; return nullptr;
ui::EnumerateTopLevelWindows(this); ui::EnumerateTopLevelWindows(this);
return DesktopWindowTreeHostX11::GetContentWindowForXID(toplevel_); return DesktopWindowTreeHostLinux::GetContentWindowForWidget(
static_cast<gfx::AcceleratedWidget>(toplevel_));
} }
XID X11TopmostWindowFinder::FindWindowAt( XID X11TopmostWindowFinder::FindWindowAt(
...@@ -45,8 +46,8 @@ bool X11TopmostWindowFinder::ShouldStopIterating(XID xid) { ...@@ -45,8 +46,8 @@ bool X11TopmostWindowFinder::ShouldStopIterating(XID xid) {
if (!ui::IsWindowVisible(xid)) if (!ui::IsWindowVisible(xid))
return false; return false;
aura::Window* window = auto* window = DesktopWindowTreeHostLinux::GetContentWindowForWidget(
views::DesktopWindowTreeHostX11::GetContentWindowForXID(xid); static_cast<gfx::AcceleratedWidget>(xid));
if (window) { if (window) {
if (ShouldStopIteratingAtLocalProcessWindow(window)) { if (ShouldStopIteratingAtLocalProcessWindow(window)) {
toplevel_ = xid; toplevel_ = xid;
...@@ -72,9 +73,11 @@ bool X11TopmostWindowFinder::ShouldStopIteratingAtLocalProcessWindow( ...@@ -72,9 +73,11 @@ bool X11TopmostWindowFinder::ShouldStopIteratingAtLocalProcessWindow(
if (!window->IsVisible()) if (!window->IsVisible())
return false; return false;
DesktopWindowTreeHostX11* host = DesktopWindowTreeHostX11::GetHostForXID( auto* host = DesktopWindowTreeHostLinux::GetHostForWidget(
window->GetHost()->GetAcceleratedWidget()); window->GetHost()->GetAcceleratedWidget());
if (!host->GetXRootWindowOuterBounds().Contains(screen_loc_in_pixels_)) if (!static_cast<DesktopWindowTreeHostX11*>(host)
->GetXRootWindowOuterBounds()
.Contains(screen_loc_in_pixels_))
return false; return false;
aura::client::ScreenPositionClient* screen_position_client = aura::client::ScreenPositionClient* screen_position_client =
......
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h" #include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h"
#endif #endif
#if defined(USE_X11) #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
#include "ui/views/linux_ui/linux_ui.h" #include "ui/views/linux_ui/linux_ui.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
#endif #endif
...@@ -1065,7 +1065,7 @@ void NativeWidgetAura::SetInitialFocus(ui::WindowShowState show_state) { ...@@ -1065,7 +1065,7 @@ void NativeWidgetAura::SetInitialFocus(ui::WindowShowState show_state) {
// Widget, public: // Widget, public:
namespace { namespace {
#if defined(OS_WIN) || defined(USE_X11) #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS))
void CloseWindow(aura::Window* window) { void CloseWindow(aura::Window* window) {
if (window) { if (window) {
Widget* widget = Widget::GetWidgetForNativeView(window); Widget* widget = Widget::GetWidgetForNativeView(window);
...@@ -1095,13 +1095,13 @@ void Widget::CloseAllSecondaryWidgets() { ...@@ -1095,13 +1095,13 @@ void Widget::CloseAllSecondaryWidgets() {
EnumThreadWindows(GetCurrentThreadId(), WindowCallbackProc, 0); EnumThreadWindows(GetCurrentThreadId(), WindowCallbackProc, 0);
#endif #endif
#if defined(USE_X11) #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
DesktopWindowTreeHostX11::CleanUpWindowList(CloseWindow); DesktopWindowTreeHostLinux::CleanUpWindowList(CloseWindow);
#endif #endif
} }
const ui::NativeTheme* Widget::GetNativeTheme() const { const ui::NativeTheme* Widget::GetNativeTheme() const {
#if defined(USE_X11) #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
const LinuxUI* linux_ui = LinuxUI::instance(); const LinuxUI* linux_ui = LinuxUI::instance();
if (linux_ui) { if (linux_ui) {
ui::NativeTheme* native_theme = ui::NativeTheme* native_theme =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment