File: x11_display_util.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (64 lines) | stat: -rw-r--r-- 2,570 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright 2018 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_BASE_X_X11_DISPLAY_UTIL_H_
#define UI_BASE_X_X11_DISPLAY_UTIL_H_

#include "base/component_export.h"
#include "base/time/time.h"
#include "ui/display/display.h"
#include "ui/display/types/display_config.h"

namespace ui {

// Builds a list of displays for fallback.
COMPONENT_EXPORT(UI_BASE_X)
std::vector<display::Display> GetFallbackDisplayList(
    float scale,
    size_t* primary_display_index_out);

// Builds a list of displays from the current screen information offered by
// the X server.
COMPONENT_EXPORT(UI_BASE_X)
std::vector<display::Display> BuildDisplaysFromXRandRInfo(
    const display::DisplayConfig& display_config,
    size_t* primary_display_index_out);

// Returns the refresh interval of the primary display. If there is no connected
// primary display, returns the refresh interval of the first connected display.
COMPONENT_EXPORT(UI_BASE_X)
base::TimeDelta GetPrimaryDisplayRefreshIntervalFromXrandr();

// A distance metric for ranges [min1, max1), [min2, max2).  Exposed for unit
// testing.
// - Returns 0 if the ranges touch at an endpoint but don't overlap.
//   Eg. [10, 20), [20, 30) -> 0
// - Returns a positive value if the ranges don't overlap.  The value is the
//   space between the ranges.
//   Eg. [10, 20), [30, 40) -> 10
// - Returns a negative value if the ranges overlap.  The value is the
//   amount of overlap between the ranges.
//   Eg. [10, 30), [20, 30) -> -10
// - Returns a negative value if one range fully encompasses the other.  The
//   value will have a magnitude between the size of each range.
//   Eg. [10, 40), [20, 30) -> -20
COMPONENT_EXPORT(UI_BASE_X)
int RangeDistance(int min1, int max1, int min2, int max2);

// A distance metric for rectangles.  Uses `RangeDistance()` along each
// dimension. See the comment for `RangeDistance()` for an explanation of the
// return value for overlapping or encompassing ranges.  The first value of the
// returned pair is the larger of the two distances.
COMPONENT_EXPORT(UI_BASE_X)
std::pair<int, int> RectDistance(const gfx::Rect& p, const gfx::Rect& q);

// Given `displays` with bounds in pixel coordinates, uses each display scale
// factor to update bounds to DIP coordinates.
COMPONENT_EXPORT(UI_BASE_X)
void ConvertDisplayBoundsToDips(std::vector<display::Display>* displays,
                                size_t primary_display_index);

}  // namespace ui

#endif  // UI_BASE_X_X11_DISPLAY_UTIL_H_