chromium/ui/display/screen.h

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_DISPLAY_SCREEN_H_
#define UI_DISPLAY_SCREEN_H_

#include <memory>
#include <optional>
#include <set>
#include <vector>

#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/values.h"
#include "build/build_config.h"
#include "ui/display/display.h"
#include "ui/display/display_export.h"
#include "ui/display/screen_infos.h"
#include "ui/gfx/gpu_extra_info.h"
#include "ui/gfx/native_widget_types.h"

namespace base {
class TimeDelta;
}  // namespace base

namespace gfx {
class Point;
class Rect;
}  // namespace gfx

namespace display {
class DisplayObserver;
enum class TabletState;

// A utility class for getting various info about screen size, displays,
// cursor position, etc.
//
// Also, can notify DisplayObservers about global workspace changes. The
// availability of that functionality depends on a platform.
//
// Note that this class does not represent an individual display connected to a
// computer -- see the Display class for that. A single Screen object exists
// regardless of the number of connected displays.
class DISPLAY_EXPORT Screen {};

#if BUILDFLAG(IS_APPLE)

// TODO(oshima): move this to separate apple specific file.

// TODO(crbug.com/40222482): Make this static private member of
// ScopedNativeScreen.
DISPLAY_EXPORT Screen* CreateNativeScreen();

// ScopedNativeScreen creates a native screen if there is no screen created yet
// (e.g. by a unit test).
class DISPLAY_EXPORT ScopedNativeScreen final {
 public:
  explicit ScopedNativeScreen(const base::Location& location = FROM_HERE);
  ScopedNativeScreen(const ScopedNativeScreen&) = delete;
  ScopedNativeScreen& operator=(const ScopedNativeScreen&) = delete;
  ~ScopedNativeScreen();

 private:
  std::unique_ptr<Screen> screen_;
};

#endif

}  // namespace display

#endif  // UI_DISPLAY_SCREEN_H_