#include "ui/ozone/platform/wayland/host/wayland_screen.h"
#include <set>
#include <vector>
#include "base/containers/contains.h"
#include "base/observer_list.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "components/device_event_log/device_event_log.h"
#include "ui/base/linux/linux_desktop.h"
#include "ui/base/pointer/touch_ui_controller.h"
#include "ui/display/display.h"
#include "ui/display/display_finder.h"
#include "ui/display/display_list.h"
#include "ui/display/util/display_util.h"
#include "ui/display/util/gpu_info_util.h"
#include "ui/gfx/buffer_types.h"
#include "ui/gfx/display_color_spaces.h"
#include "ui/gfx/font_render_params.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/ozone/platform/wayland/host/dump_util.h"
#include "ui/ozone/platform/wayland/host/org_kde_kwin_idle.h"
#include "ui/ozone/platform/wayland/host/wayland_buffer_manager_host.h"
#include "ui/ozone/platform/wayland/host/wayland_connection.h"
#include "ui/ozone/platform/wayland/host/wayland_cursor_position.h"
#include "ui/ozone/platform/wayland/host/wayland_output.h"
#include "ui/ozone/platform/wayland/host/wayland_output_manager.h"
#include "ui/ozone/platform/wayland/host/wayland_window.h"
#include "ui/ozone/platform/wayland/host/wayland_zcr_color_management_output.h"
#include "ui/ozone/platform/wayland/host/wayland_zcr_color_manager.h"
#include "ui/ozone/platform/wayland/host/zwp_idle_inhibit_manager.h"
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chromeos/ui/base/display_util.h"
#endif
#if defined(USE_DBUS)
#include "ui/ozone/platform/wayland/host/org_gnome_mutter_idle_monitor.h"
#endif
namespace ui {
namespace {
display::Display::Rotation WaylandTransformToRotation(int32_t transform) { … }
}
WaylandScreen::WaylandScreen(WaylandConnection* connection)
: … { … }
WaylandScreen::~WaylandScreen() = default;
void WaylandScreen::OnOutputAddedOrUpdated(
const WaylandOutput::Metrics& metrics) { … }
void WaylandScreen::OnOutputRemoved(WaylandOutput::Id output_id) { … }
void WaylandScreen::AddOrUpdateDisplay(const WaylandOutput::Metrics& metrics) { … }
WaylandOutput::Id WaylandScreen::GetOutputIdForDisplayId(int64_t display_id) { … }
WaylandOutput* WaylandScreen::GetWaylandOutputForDisplayId(int64_t display_id) { … }
WaylandOutput::Id WaylandScreen::GetOutputIdMatching(const gfx::Rect& bounds) { … }
base::WeakPtr<WaylandScreen> WaylandScreen::GetWeakPtr() { … }
const std::vector<display::Display>& WaylandScreen::GetAllDisplays() const { … }
display::Display WaylandScreen::GetPrimaryDisplay() const { … }
display::Display WaylandScreen::GetDisplayForAcceleratedWidget(
gfx::AcceleratedWidget widget) const { … }
gfx::Point WaylandScreen::GetCursorScreenPoint() const { … }
gfx::AcceleratedWidget WaylandScreen::GetAcceleratedWidgetAtScreenPoint(
const gfx::Point& point) const { … }
gfx::AcceleratedWidget WaylandScreen::GetLocalProcessWidgetAtPoint(
const gfx::Point& point,
const std::set<gfx::AcceleratedWidget>& ignore) const { … }
display::Display WaylandScreen::GetDisplayNearestPoint(
const gfx::Point& point) const { … }
display::Display WaylandScreen::GetDisplayMatching(
const gfx::Rect& match_rect) const { … }
std::unique_ptr<WaylandScreen::WaylandScreenSaverSuspender>
WaylandScreen::WaylandScreenSaverSuspender::Create(WaylandScreen& screen) { … }
WaylandScreen::WaylandScreenSaverSuspender::WaylandScreenSaverSuspender(
WaylandScreen& screen)
: … { … }
WaylandScreen::WaylandScreenSaverSuspender::~WaylandScreenSaverSuspender() { … }
std::unique_ptr<PlatformScreen::PlatformScreenSaverSuspender>
WaylandScreen::SuspendScreenSaver() { … }
bool WaylandScreen::SetScreenSaverSuspended(bool suspend) { … }
bool WaylandScreen::IsScreenSaverActive() const { … }
base::TimeDelta WaylandScreen::CalculateIdleTime() const { … }
void WaylandScreen::AddObserver(display::DisplayObserver* observer) { … }
void WaylandScreen::RemoveObserver(display::DisplayObserver* observer) { … }
base::Value::List WaylandScreen::GetGpuExtraInfo(
const gfx::GpuExtraInfo& gpu_extra_info) { … }
std::optional<float> WaylandScreen::GetPreferredScaleFactorForAcceleratedWidget(
gfx::AcceleratedWidget widget) const { … }
#if BUILDFLAG(IS_CHROMEOS_LACROS)
void WaylandScreen::OnTabletStateChanged(display::TabletState tablet_state) {
tablet_state_ = tablet_state;
ui::TouchUiController::Get()->OnTabletModeToggled(
tablet_state == display::TabletState::kInTabletMode ||
tablet_state == display::TabletState::kEnteringTabletMode);
auto* observer_list = display_list_.observers();
for (auto& observer : *observer_list)
observer.OnDisplayTabletStateChanged(tablet_state);
}
display::TabletState WaylandScreen::GetTabletState() const {
return tablet_state_;
}
#endif
bool WaylandScreen::VerifyOutputStateConsistentForTesting() const { … }
void WaylandScreen::DumpState(std::ostream& out) const { … }
}