forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PlatformScreen interface in Ozone.
Added OzonePlatform::CreateScreen(), which returns in instance of the new PlatformScren interface. Also added aura::SceenOzone that implements display::Screen on top of PlatformScreen. Bug: 850650 Change-Id: I3481dda921f564f0c117d9c8a0e8ce060254f4c3 Reviewed-on: https://chromium-review.googlesource.com/1162354 Commit-Queue: Sergey Ulanov <sergeyu@chromium.org> Reviewed-by: Scott Violet <sky@chromium.org> Reviewed-by: Robert Kroeger <rjkroege@chromium.org> Reviewed-by: Michael Spang <spang@chromium.org> Cr-Commit-Position: refs/heads/master@{#582792}
- Loading branch information
1 parent
9fc51b5
commit 9885115
Showing
15 changed files
with
286 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// Copyright 2018 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. | ||
|
||
#include "ui/aura/screen_ozone.h" | ||
|
||
#include "ui/aura/window.h" | ||
#include "ui/aura/window_tree_host.h" | ||
#include "ui/display/display.h" | ||
#include "ui/display/screen.h" | ||
|
||
namespace aura { | ||
|
||
ScreenOzone::ScreenOzone(std::unique_ptr<ui::PlatformScreen> platform_screen) | ||
: platform_screen_(std::move(platform_screen)) {} | ||
ScreenOzone::~ScreenOzone() = default; | ||
|
||
gfx::Point ScreenOzone::GetCursorScreenPoint() { | ||
return platform_screen_->GetCursorScreenPoint(); | ||
} | ||
|
||
bool ScreenOzone::IsWindowUnderCursor(gfx::NativeWindow window) { | ||
return GetWindowAtScreenPoint(GetCursorScreenPoint()) == window; | ||
} | ||
|
||
gfx::NativeWindow ScreenOzone::GetWindowAtScreenPoint(const gfx::Point& point) { | ||
auto widget = platform_screen_->GetAcceleratedWidgetAtScreenPoint(point); | ||
if (!widget) | ||
return nullptr; | ||
|
||
aura::WindowTreeHost* host = | ||
aura::WindowTreeHost::GetForAcceleratedWidget(widget); | ||
return host ? host->window() : nullptr; | ||
} | ||
|
||
int ScreenOzone::GetNumDisplays() const { | ||
return GetAllDisplays().size(); | ||
} | ||
|
||
const std::vector<display::Display>& ScreenOzone::GetAllDisplays() const { | ||
return platform_screen_->GetAllDisplays(); | ||
} | ||
|
||
display::Display ScreenOzone::GetDisplayNearestWindow( | ||
gfx::NativeWindow window) const { | ||
gfx::AcceleratedWidget widget = GetAcceleratedWidgetForWindow(window); | ||
if (!widget) | ||
return GetPrimaryDisplay(); | ||
|
||
return platform_screen_->GetDisplayForAcceleratedWidget(widget); | ||
} | ||
|
||
display::Display ScreenOzone::GetDisplayNearestView( | ||
gfx::NativeView view) const { | ||
return GetDisplayNearestWindow(view); | ||
} | ||
|
||
display::Display ScreenOzone::GetDisplayNearestPoint( | ||
const gfx::Point& point) const { | ||
return platform_screen_->GetDisplayNearestPoint(point); | ||
} | ||
|
||
display::Display ScreenOzone::GetDisplayMatching( | ||
const gfx::Rect& match_rect) const { | ||
return platform_screen_->GetDisplayMatching(match_rect); | ||
} | ||
|
||
display::Display ScreenOzone::GetPrimaryDisplay() const { | ||
return platform_screen_->GetPrimaryDisplay(); | ||
} | ||
|
||
void ScreenOzone::AddObserver(display::DisplayObserver* observer) { | ||
platform_screen_->AddObserver(observer); | ||
} | ||
|
||
void ScreenOzone::RemoveObserver(display::DisplayObserver* observer) { | ||
platform_screen_->RemoveObserver(observer); | ||
} | ||
|
||
gfx::AcceleratedWidget ScreenOzone::GetAcceleratedWidgetForWindow( | ||
aura::Window* window) const { | ||
if (!window) | ||
return gfx::kNullAcceleratedWidget; | ||
|
||
aura::WindowTreeHost* host = window->GetHost(); | ||
if (!host) | ||
return gfx::kNullAcceleratedWidget; | ||
|
||
return host->GetAcceleratedWidget(); | ||
} | ||
|
||
} // namespace aura |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2018 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_SCREEN_OZONE_H_ | ||
#define UI_AURA_SCREEN_OZONE_H_ | ||
|
||
#include "base/macros.h" | ||
#include "ui/aura/aura_export.h" | ||
#include "ui/display/screen.h" | ||
#include "ui/ozone/public/platform_screen.h" | ||
|
||
namespace aura { | ||
|
||
// display::Screen implementation on top of ui::PlatformScreen provided by | ||
// Ozone. | ||
class AURA_EXPORT ScreenOzone : public display::Screen { | ||
public: | ||
explicit ScreenOzone(std::unique_ptr<ui::PlatformScreen> platform_screen); | ||
~ScreenOzone() override; | ||
|
||
// display::Screen interface. | ||
gfx::Point GetCursorScreenPoint() override; | ||
bool IsWindowUnderCursor(gfx::NativeWindow window) override; | ||
gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override; | ||
int GetNumDisplays() const override; | ||
const std::vector<display::Display>& GetAllDisplays() const override; | ||
display::Display GetDisplayNearestWindow( | ||
gfx::NativeWindow window) const override; | ||
display::Display GetDisplayNearestView(gfx::NativeView view) const override; | ||
display::Display GetDisplayNearestPoint( | ||
const gfx::Point& point) const override; | ||
display::Display GetDisplayMatching( | ||
const gfx::Rect& match_rect) const override; | ||
display::Display GetPrimaryDisplay() const override; | ||
void AddObserver(display::DisplayObserver* observer) override; | ||
void RemoveObserver(display::DisplayObserver* observer) override; | ||
|
||
private: | ||
gfx::AcceleratedWidget GetAcceleratedWidgetForWindow( | ||
aura::Window* window) const; | ||
|
||
std::unique_ptr<ui::PlatformScreen> platform_screen_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(ScreenOzone); | ||
}; | ||
|
||
} // namespace aura | ||
|
||
#endif // UI_AURA_SCREEN_OZONE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.