KWayland

region.h
1 /*
2  SPDX-FileCopyrightText: 2014 Martin Gräßlin <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 #ifndef WAYLAND_REGION_H
7 #define WAYLAND_REGION_H
8 
9 #include <QObject>
10 
11 #include <KWayland/Client/kwaylandclient_export.h>
12 
13 struct wl_region;
14 
15 namespace KWayland
16 {
17 namespace Client
18 {
19 
20 /**
21  * @short Wrapper for the wl_region interface.
22  *
23  * This class is a convenient wrapper for the wl_region interface.
24  * To create a Region call Compositor::createRegion.
25  *
26  * The main purpose of this class is to provide regions which can be
27  * used to e.g. set the input region on a Surface.
28  *
29  * @see Compositor
30  * @see Surface
31  **/
32 class KWAYLANDCLIENT_EXPORT Region : public QObject
33 {
34  Q_OBJECT
35 public:
36  explicit Region(const QRegion &region, QObject *parent = nullptr);
37  virtual ~Region();
38 
39  /**
40  * Setup this Surface to manage the @p region.
41  * When using Compositor::createRegion there is no need to call this
42  * method.
43  **/
44  void setup(wl_region *region);
45  /**
46  * Releases the wl_region interface.
47  * After the interface has been released the Region instance is no
48  * longer valid and can be setup with another wl_region interface.
49  **/
50  void release();
51  /**
52  * Destroys the data held by this Region.
53  * This method is supposed to be used when the connection to the Wayland
54  * server goes away. If the connection is not valid anymore, it's not
55  * possible to call release anymore as that calls into the Wayland
56  * connection and the call would fail. This method cleans up the data, so
57  * that the instance can be deleted or set up to a new wl_region interface
58  * once there is a new connection available.
59  *
60  * It is suggested to connect this method to ConnectionThread::connectionDied:
61  * @code
62  * connect(connection, &ConnectionThread::connectionDied, region, &Region::destroy);
63  * @endcode
64  *
65  * @see release
66  **/
67  void destroy();
68  /**
69  * @returns @c true if managing a wl_region.
70  **/
71  bool isValid() const;
72 
73  /**
74  * Adds the @p rect to this Region.
75  **/
76  void add(const QRect &rect);
77  /**
78  * Adds the @p region to this Rregion.
79  **/
80  void add(const QRegion &region);
81  /**
82  * Subtracts @p rect from this Region.
83  **/
84  void subtract(const QRect &rect);
85  /**
86  * Subtracts @p region from this Region.
87  **/
88  void subtract(const QRegion &region);
89 
90  /**
91  * The geometry of this Region.
92  **/
93  QRegion region() const;
94 
95  operator wl_region*();
96  operator wl_region*() const;
97 
98 private:
99  class Private;
101 };
102 
103 }
104 }
105 
106 #endif
Wrapper for the wl_region interface.
Definition: region.h:32
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Mar 8 2021 22:50:08 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.