File: wayland_proxy.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 (96 lines) | stat: -rw-r--r-- 3,461 bytes parent folder | download | duplicates (6)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Copyright 2021 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_OZONE_PLATFORM_WAYLAND_HOST_PROXY_WAYLAND_PROXY_H_
#define UI_OZONE_PLATFORM_WAYLAND_HOST_PROXY_WAYLAND_PROXY_H_

#include "base/component_export.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/platform_window/platform_window_init_properties.h"

struct wl_buffer;
struct wl_registry;
struct wl_surface;

namespace gfx {
class Size;
}  // namespace gfx

namespace ui {
class WaylandWindow;
}

namespace wl {

// A proxy interface to Ozone/Wayland that is used by input emulation. The
// reason why this is needed is that input emulation mustn't be part of
// Chromium and only be used and compiled when there is a need to run tests.
// This nicely separates Ozone/Wayland from input emulation and provides just
// core functionality that input emulation needs from Ozone/Wayland.
class COMPONENT_EXPORT(WAYLAND_PROXY) WaylandProxy {
 public:
  class Delegate {
   public:
    // Invoked when a new window is created aka WaylandWindow is added to the
    // list of windows stored by WaylandWindowManager.
    virtual void OnWindowAdded(gfx::AcceleratedWidget widget) = 0;

    // Invoked when an existing surface is removed aka WaylandWindow is removed
    // from the list of windows stored by WaylandWindowManager.
    virtual void OnWindowRemoved(gfx::AcceleratedWidget widget) = 0;

    // Invoked when an existing surface is configured or it's no longer
    // configured (wl_surface lost its role and is going to be reconfigured).
    virtual void OnWindowConfigured(gfx::AcceleratedWidget widget,
                                    bool is_configured) = 0;

    // Invoked when an existing surface is assigned a role.
    virtual void OnWindowRoleAssigned(gfx::AcceleratedWidget widget) = 0;

   protected:
    virtual ~Delegate() = default;
  };

  virtual ~WaylandProxy() = default;

  static WaylandProxy* GetInstance();

  // Sets the delegate that will be notified about the events described above
  // for the Delegate class.
  virtual void SetDelegate(Delegate* delegate) = 0;

  virtual struct wl_registry* GetRegistry() = 0;
  virtual void RoundTripQueue() = 0;

  // Returns wl_surface that backs the |widget|.
  virtual wl_surface* GetWlSurfaceForAcceleratedWidget(
      gfx::AcceleratedWidget widget) = 0;
  // Returns WaylandWindow backed by |widget|.
  virtual ui::WaylandWindow* GetWaylandWindowForAcceleratedWidget(
      gfx::AcceleratedWidget widget) = 0;

  // Creates and returns a shm based wl_buffer with |buffer_size|. The shared
  // memory is hold until DestroyShmForWlBuffer is called.
  virtual wl_buffer* CreateShmBasedWlBuffer(const gfx::Size& buffer_size) = 0;

  // When this is called, |buffer| becomes invalid and mustn't be used any more.
  virtual void DestroyShmForWlBuffer(wl_buffer* buffer) = 0;

  // Immediately flushes pending requests for testing.
  virtual void FlushForTesting() = 0;

  // Returns platform window type of a window backed by the |widget|.
  virtual ui::PlatformWindowType GetWindowType(
      gfx::AcceleratedWidget widget) = 0;

  virtual bool WindowHasPointerFocus(gfx::AcceleratedWidget widget) = 0;
  virtual bool WindowHasKeyboardFocus(gfx::AcceleratedWidget widget) = 0;

 protected:
  static void SetInstance(WaylandProxy* instance);
};

}  // namespace wl

#endif  // UI_OZONE_PLATFORM_WAYLAND_HOST_PROXY_WAYLAND_PROXY_H_