Compare commits
No commits in common. "9968266839936ee91e8a572ea05db1f3d66fbf27" and "10999be3b60cfebf0ade89a5d473c6931e56a038" have entirely different histories.
9968266839
...
10999be3b6
18 changed files with 726 additions and 2796 deletions
|
@ -30,8 +30,6 @@ find_package(ReactPhysics3D REQUIRED)
|
||||||
|
|
||||||
file(MAKE_DIRECTORY bin)
|
file(MAKE_DIRECTORY bin)
|
||||||
|
|
||||||
include_directories("include")
|
|
||||||
|
|
||||||
file(GLOB_RECURSE SOURCES "src/*.cpp" "src/*.h")
|
file(GLOB_RECURSE SOURCES "src/*.cpp" "src/*.h")
|
||||||
add_library(openblocks ${SOURCES})
|
add_library(openblocks ${SOURCES})
|
||||||
set_target_properties(openblocks PROPERTIES OUTPUT_NAME "openblocks")
|
set_target_properties(openblocks PROPERTIES OUTPUT_NAME "openblocks")
|
||||||
|
|
|
@ -29,10 +29,6 @@ set(PROJECT_SOURCES
|
||||||
panes/explorerview.cpp
|
panes/explorerview.cpp
|
||||||
panes/explorermodel.h
|
panes/explorermodel.h
|
||||||
panes/explorermodel.cpp
|
panes/explorermodel.cpp
|
||||||
panes/propertiesview.h
|
|
||||||
panes/propertiesview.cpp
|
|
||||||
panes/propertiesmodel.h
|
|
||||||
panes/propertiesmodel.cpp
|
|
||||||
${TS_FILES}
|
${TS_FILES}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,10 @@
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include <QAbstractItemView>
|
#include <QAbstractItemView>
|
||||||
#include <optional>
|
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "physics/simulation.h"
|
#include "physics/simulation.h"
|
||||||
#include "objects/part.h"
|
#include "objects/part.h"
|
||||||
#include "qitemselectionmodel.h"
|
|
||||||
#include "qobject.h"
|
#include "qobject.h"
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
|
@ -26,15 +24,6 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
timer.start(33, this);
|
timer.start(33, this);
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
|
|
||||||
connect(ui->explorerView->selectionModel(), &QItemSelectionModel::selectionChanged, this, [&](const QItemSelection &selected, const QItemSelection &deselected) {
|
|
||||||
if (selected.count() == 0) return;
|
|
||||||
|
|
||||||
std::optional<InstanceRef> inst = selected.count() == 0 ? std::nullopt
|
|
||||||
: std::make_optional(((Instance*)selected.indexes()[0].internalPointer())->shared_from_this());
|
|
||||||
|
|
||||||
ui->propertiesView->setSelected(inst);
|
|
||||||
});
|
|
||||||
|
|
||||||
// ui->explorerView->Init(ui);
|
// ui->explorerView->Init(ui);
|
||||||
|
|
||||||
simulationInit();
|
simulationInit();
|
||||||
|
|
|
@ -66,28 +66,13 @@
|
||||||
<number>2</number>
|
<number>2</number>
|
||||||
</attribute>
|
</attribute>
|
||||||
<widget class="QWidget" name="dockWidgetContents">
|
<widget class="QWidget" name="dockWidgetContents">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="ExplorerView" name="explorerView"/>
|
<widget class="ExplorerView" name="explorerView"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QDockWidget" name="propertiesWidget">
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Properties</string>
|
|
||||||
</property>
|
|
||||||
<attribute name="dockWidgetArea">
|
|
||||||
<number>2</number>
|
|
||||||
</attribute>
|
|
||||||
<widget class="QWidget" name="dockWidgetContents_2">
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="PropertiesView" name="propertiesView"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
@ -100,11 +85,6 @@
|
||||||
<extends>QTreeView</extends>
|
<extends>QTreeView</extends>
|
||||||
<header>panes/explorerview.h</header>
|
<header>panes/explorerview.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
|
||||||
<class>PropertiesView</class>
|
|
||||||
<extends>QTreeView</extends>
|
|
||||||
<header>panes/propertiesview.h</header>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|
|
@ -112,7 +112,6 @@ QVariant ExplorerModel::data(const QModelIndex &index, int role) const {
|
||||||
Instance *item = static_cast<Instance*>(index.internalPointer());
|
Instance *item = static_cast<Instance*>(index.internalPointer());
|
||||||
|
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Qt::EditRole:
|
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
return QString::fromStdString(item->name);
|
return QString::fromStdString(item->name);
|
||||||
case Qt::DecorationRole:
|
case Qt::DecorationRole:
|
||||||
|
|
|
@ -1,76 +0,0 @@
|
||||||
#include "propertiesmodel.h"
|
|
||||||
#include "qnamespace.h"
|
|
||||||
|
|
||||||
PropertiesModel::PropertiesModel(InstanceRef selectedItem, QWidget *parent)
|
|
||||||
: QAbstractItemModel(parent)
|
|
||||||
, selectedItem(selectedItem) {
|
|
||||||
this->propertiesList = selectedItem->GetProperties();
|
|
||||||
}
|
|
||||||
|
|
||||||
PropertiesModel::~PropertiesModel() = default;
|
|
||||||
|
|
||||||
|
|
||||||
QVariant PropertiesModel::data(const QModelIndex &index, int role) const {
|
|
||||||
if (!index.isValid())
|
|
||||||
return {};
|
|
||||||
|
|
||||||
std::string propertyName = propertiesList[index.row()];
|
|
||||||
|
|
||||||
switch (role) {
|
|
||||||
case Qt::EditRole:
|
|
||||||
case Qt::DisplayRole:
|
|
||||||
if (index.column() == 0)
|
|
||||||
return QString::fromStdString(propertyName);
|
|
||||||
else if (index.column() == 1)
|
|
||||||
return QString::fromStdString(selectedItem->GetPropertyValue(propertyName).value());
|
|
||||||
// case Qt::DecorationRole:
|
|
||||||
// return iconOf(item->GetClass());
|
|
||||||
}
|
|
||||||
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PropertiesModel::setData(const QModelIndex &index, const QVariant &value, int role) {
|
|
||||||
if (index.column() != 1 && role != Qt::EditRole) return false;
|
|
||||||
|
|
||||||
selectedItem->SetPropertyValue(propertiesList[index.row()], value.toString().toStdString());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Qt::ItemFlags PropertiesModel::flags(const QModelIndex &index) const {
|
|
||||||
if (!index.isValid())
|
|
||||||
return Qt::NoItemFlags;
|
|
||||||
|
|
||||||
if (index.column() == 0)
|
|
||||||
return Qt::ItemIsEnabled;
|
|
||||||
|
|
||||||
if (index.column() == 1)
|
|
||||||
return Qt::ItemIsEnabled | Qt::ItemIsEditable;
|
|
||||||
|
|
||||||
return Qt::NoItemFlags;
|
|
||||||
};
|
|
||||||
|
|
||||||
QVariant PropertiesModel::headerData(int section, Qt::Orientation orientation,
|
|
||||||
int role) const {
|
|
||||||
return QString("");
|
|
||||||
}
|
|
||||||
|
|
||||||
QModelIndex PropertiesModel::index(int row, int column,
|
|
||||||
const QModelIndex &parent) const {
|
|
||||||
if (!hasIndex(row, column, parent))
|
|
||||||
return {};
|
|
||||||
|
|
||||||
return createIndex(row, column);
|
|
||||||
}
|
|
||||||
|
|
||||||
QModelIndex PropertiesModel::parent(const QModelIndex &index) const {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
int PropertiesModel::rowCount(const QModelIndex &parent) const {
|
|
||||||
return !parent.isValid() ? selectedItem->GetProperties().size() : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int PropertiesModel::columnCount(const QModelIndex &parent) const {
|
|
||||||
return 2;
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "objects/base/instance.h"
|
|
||||||
#include "objects/part.h"
|
|
||||||
#include "qabstractitemmodel.h"
|
|
||||||
#include "qevent.h"
|
|
||||||
#include "qmenu.h"
|
|
||||||
#include "qnamespace.h"
|
|
||||||
#include "qtreeview.h"
|
|
||||||
#include <QOpenGLWidget>
|
|
||||||
#include <QWidget>
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
class PropertiesModel : public QAbstractItemModel {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
Q_DISABLE_COPY_MOVE(PropertiesModel)
|
|
||||||
|
|
||||||
explicit PropertiesModel(InstanceRef selectedItem, QWidget *parent = nullptr);
|
|
||||||
~PropertiesModel() override;
|
|
||||||
|
|
||||||
QVariant data(const QModelIndex &index, int role) const override;
|
|
||||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
|
||||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
|
||||||
QVariant headerData(int section, Qt::Orientation orientation,
|
|
||||||
int role = Qt::DisplayRole) const override;
|
|
||||||
QModelIndex index(int row, int column,
|
|
||||||
const QModelIndex &parent = {}) const override;
|
|
||||||
QModelIndex parent(const QModelIndex &index) const override;
|
|
||||||
int rowCount(const QModelIndex &parent = {}) const override;
|
|
||||||
int columnCount(const QModelIndex &parent = {}) const override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
InstanceRef selectedItem;
|
|
||||||
std::vector<std::string> propertiesList;
|
|
||||||
};
|
|
|
@ -1,20 +0,0 @@
|
||||||
#include "propertiesview.h"
|
|
||||||
#include "propertiesmodel.h"
|
|
||||||
#include "qaction.h"
|
|
||||||
|
|
||||||
PropertiesView::PropertiesView(QWidget* parent):
|
|
||||||
QTreeView(parent) {
|
|
||||||
this->setStyleSheet(QString("QTreeView::branch { border: none; }"));
|
|
||||||
}
|
|
||||||
|
|
||||||
PropertiesView::~PropertiesView() {
|
|
||||||
}
|
|
||||||
|
|
||||||
void PropertiesView::setSelected(std::optional<InstanceRef> instance) {
|
|
||||||
if (instance.has_value()) {
|
|
||||||
this->setModel(new PropertiesModel(instance.value()));
|
|
||||||
} else {
|
|
||||||
if (this->model()) delete this->model();
|
|
||||||
this->setModel(nullptr);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "objects/base/instance.h"
|
|
||||||
#include "objects/part.h"
|
|
||||||
#include "qevent.h"
|
|
||||||
#include "qmenu.h"
|
|
||||||
#include "qnamespace.h"
|
|
||||||
#include "qtreeview.h"
|
|
||||||
#include <QOpenGLWidget>
|
|
||||||
#include <QWidget>
|
|
||||||
#include <memory>
|
|
||||||
#include "explorermodel.h"
|
|
||||||
|
|
||||||
class Ui_MainWindow;
|
|
||||||
|
|
||||||
class PropertiesView : public QTreeView {
|
|
||||||
public:
|
|
||||||
PropertiesView(QWidget* parent = nullptr);
|
|
||||||
~PropertiesView() override;
|
|
||||||
|
|
||||||
void setSelected(std::optional<InstanceRef> instance);
|
|
||||||
};
|
|
649
editor/wayland-pointer-constraints-unstable-v1-client-protocol.h
Normal file
649
editor/wayland-pointer-constraints-unstable-v1-client-protocol.h
Normal file
|
@ -0,0 +1,649 @@
|
||||||
|
/* Generated by wayland-scanner */
|
||||||
|
|
||||||
|
#ifndef POINTER_CONSTRAINTS_UNSTABLE_V1_CLIENT_PROTOCOL_H
|
||||||
|
#define POINTER_CONSTRAINTS_UNSTABLE_V1_CLIENT_PROTOCOL_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include "wayland-client.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @page page_pointer_constraints_unstable_v1 The pointer_constraints_unstable_v1 protocol
|
||||||
|
* protocol for constraining pointer motions
|
||||||
|
*
|
||||||
|
* @section page_desc_pointer_constraints_unstable_v1 Description
|
||||||
|
*
|
||||||
|
* This protocol specifies a set of interfaces used for adding constraints to
|
||||||
|
* the motion of a pointer. Possible constraints include confining pointer
|
||||||
|
* motions to a given region, or locking it to its current position.
|
||||||
|
*
|
||||||
|
* In order to constrain the pointer, a client must first bind the global
|
||||||
|
* interface "wp_pointer_constraints" which, if a compositor supports pointer
|
||||||
|
* constraints, is exposed by the registry. Using the bound global object, the
|
||||||
|
* client uses the request that corresponds to the type of constraint it wants
|
||||||
|
* to make. See wp_pointer_constraints for more details.
|
||||||
|
*
|
||||||
|
* Warning! The protocol described in this file is experimental and backward
|
||||||
|
* incompatible changes may be made. Backward compatible changes may be added
|
||||||
|
* together with the corresponding interface version bump. Backward
|
||||||
|
* incompatible changes are done by bumping the version number in the protocol
|
||||||
|
* and interface names and resetting the interface version. Once the protocol
|
||||||
|
* is to be declared stable, the 'z' prefix and the version number in the
|
||||||
|
* protocol and interface names are removed and the interface version number is
|
||||||
|
* reset.
|
||||||
|
*
|
||||||
|
* @section page_ifaces_pointer_constraints_unstable_v1 Interfaces
|
||||||
|
* - @subpage page_iface_zwp_pointer_constraints_v1 - constrain the movement of a pointer
|
||||||
|
* - @subpage page_iface_zwp_locked_pointer_v1 - receive relative pointer motion events
|
||||||
|
* - @subpage page_iface_zwp_confined_pointer_v1 - confined pointer object
|
||||||
|
* @section page_copyright_pointer_constraints_unstable_v1 Copyright
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* Copyright © 2014 Jonas Ådahl
|
||||||
|
* Copyright © 2015 Red Hat Inc.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation
|
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice (including the next
|
||||||
|
* paragraph) shall be included in all copies or substantial portions of the
|
||||||
|
* Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
* DEALINGS IN THE SOFTWARE.
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
struct wl_pointer;
|
||||||
|
struct wl_region;
|
||||||
|
struct wl_surface;
|
||||||
|
struct zwp_confined_pointer_v1;
|
||||||
|
struct zwp_locked_pointer_v1;
|
||||||
|
struct zwp_pointer_constraints_v1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @page page_iface_zwp_pointer_constraints_v1 zwp_pointer_constraints_v1
|
||||||
|
* @section page_iface_zwp_pointer_constraints_v1_desc Description
|
||||||
|
*
|
||||||
|
* The global interface exposing pointer constraining functionality. It
|
||||||
|
* exposes two requests: lock_pointer for locking the pointer to its
|
||||||
|
* position, and confine_pointer for locking the pointer to a region.
|
||||||
|
*
|
||||||
|
* The lock_pointer and confine_pointer requests create the objects
|
||||||
|
* wp_locked_pointer and wp_confined_pointer respectively, and the client can
|
||||||
|
* use these objects to interact with the lock.
|
||||||
|
*
|
||||||
|
* For any surface, only one lock or confinement may be active across all
|
||||||
|
* wl_pointer objects of the same seat. If a lock or confinement is requested
|
||||||
|
* when another lock or confinement is active or requested on the same surface
|
||||||
|
* and with any of the wl_pointer objects of the same seat, an
|
||||||
|
* 'already_constrained' error will be raised.
|
||||||
|
* @section page_iface_zwp_pointer_constraints_v1_api API
|
||||||
|
* See @ref iface_zwp_pointer_constraints_v1.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @defgroup iface_zwp_pointer_constraints_v1 The zwp_pointer_constraints_v1 interface
|
||||||
|
*
|
||||||
|
* The global interface exposing pointer constraining functionality. It
|
||||||
|
* exposes two requests: lock_pointer for locking the pointer to its
|
||||||
|
* position, and confine_pointer for locking the pointer to a region.
|
||||||
|
*
|
||||||
|
* The lock_pointer and confine_pointer requests create the objects
|
||||||
|
* wp_locked_pointer and wp_confined_pointer respectively, and the client can
|
||||||
|
* use these objects to interact with the lock.
|
||||||
|
*
|
||||||
|
* For any surface, only one lock or confinement may be active across all
|
||||||
|
* wl_pointer objects of the same seat. If a lock or confinement is requested
|
||||||
|
* when another lock or confinement is active or requested on the same surface
|
||||||
|
* and with any of the wl_pointer objects of the same seat, an
|
||||||
|
* 'already_constrained' error will be raised.
|
||||||
|
*/
|
||||||
|
extern const struct wl_interface zwp_pointer_constraints_v1_interface;
|
||||||
|
/**
|
||||||
|
* @page page_iface_zwp_locked_pointer_v1 zwp_locked_pointer_v1
|
||||||
|
* @section page_iface_zwp_locked_pointer_v1_desc Description
|
||||||
|
*
|
||||||
|
* The wp_locked_pointer interface represents a locked pointer state.
|
||||||
|
*
|
||||||
|
* While the lock of this object is active, the wl_pointer objects of the
|
||||||
|
* associated seat will not emit any wl_pointer.motion events.
|
||||||
|
*
|
||||||
|
* This object will send the event 'locked' when the lock is activated.
|
||||||
|
* Whenever the lock is activated, it is guaranteed that the locked surface
|
||||||
|
* will already have received pointer focus and that the pointer will be
|
||||||
|
* within the region passed to the request creating this object.
|
||||||
|
*
|
||||||
|
* To unlock the pointer, send the destroy request. This will also destroy
|
||||||
|
* the wp_locked_pointer object.
|
||||||
|
*
|
||||||
|
* If the compositor decides to unlock the pointer the unlocked event is
|
||||||
|
* sent. See wp_locked_pointer.unlock for details.
|
||||||
|
*
|
||||||
|
* When unlocking, the compositor may warp the cursor position to the set
|
||||||
|
* cursor position hint. If it does, it will not result in any relative
|
||||||
|
* motion events emitted via wp_relative_pointer.
|
||||||
|
*
|
||||||
|
* If the surface the lock was requested on is destroyed and the lock is not
|
||||||
|
* yet activated, the wp_locked_pointer object is now defunct and must be
|
||||||
|
* destroyed.
|
||||||
|
* @section page_iface_zwp_locked_pointer_v1_api API
|
||||||
|
* See @ref iface_zwp_locked_pointer_v1.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @defgroup iface_zwp_locked_pointer_v1 The zwp_locked_pointer_v1 interface
|
||||||
|
*
|
||||||
|
* The wp_locked_pointer interface represents a locked pointer state.
|
||||||
|
*
|
||||||
|
* While the lock of this object is active, the wl_pointer objects of the
|
||||||
|
* associated seat will not emit any wl_pointer.motion events.
|
||||||
|
*
|
||||||
|
* This object will send the event 'locked' when the lock is activated.
|
||||||
|
* Whenever the lock is activated, it is guaranteed that the locked surface
|
||||||
|
* will already have received pointer focus and that the pointer will be
|
||||||
|
* within the region passed to the request creating this object.
|
||||||
|
*
|
||||||
|
* To unlock the pointer, send the destroy request. This will also destroy
|
||||||
|
* the wp_locked_pointer object.
|
||||||
|
*
|
||||||
|
* If the compositor decides to unlock the pointer the unlocked event is
|
||||||
|
* sent. See wp_locked_pointer.unlock for details.
|
||||||
|
*
|
||||||
|
* When unlocking, the compositor may warp the cursor position to the set
|
||||||
|
* cursor position hint. If it does, it will not result in any relative
|
||||||
|
* motion events emitted via wp_relative_pointer.
|
||||||
|
*
|
||||||
|
* If the surface the lock was requested on is destroyed and the lock is not
|
||||||
|
* yet activated, the wp_locked_pointer object is now defunct and must be
|
||||||
|
* destroyed.
|
||||||
|
*/
|
||||||
|
extern const struct wl_interface zwp_locked_pointer_v1_interface;
|
||||||
|
/**
|
||||||
|
* @page page_iface_zwp_confined_pointer_v1 zwp_confined_pointer_v1
|
||||||
|
* @section page_iface_zwp_confined_pointer_v1_desc Description
|
||||||
|
*
|
||||||
|
* The wp_confined_pointer interface represents a confined pointer state.
|
||||||
|
*
|
||||||
|
* This object will send the event 'confined' when the confinement is
|
||||||
|
* activated. Whenever the confinement is activated, it is guaranteed that
|
||||||
|
* the surface the pointer is confined to will already have received pointer
|
||||||
|
* focus and that the pointer will be within the region passed to the request
|
||||||
|
* creating this object. It is up to the compositor to decide whether this
|
||||||
|
* requires some user interaction and if the pointer will warp to within the
|
||||||
|
* passed region if outside.
|
||||||
|
*
|
||||||
|
* To unconfine the pointer, send the destroy request. This will also destroy
|
||||||
|
* the wp_confined_pointer object.
|
||||||
|
*
|
||||||
|
* If the compositor decides to unconfine the pointer the unconfined event is
|
||||||
|
* sent. The wp_confined_pointer object is at this point defunct and should
|
||||||
|
* be destroyed.
|
||||||
|
* @section page_iface_zwp_confined_pointer_v1_api API
|
||||||
|
* See @ref iface_zwp_confined_pointer_v1.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @defgroup iface_zwp_confined_pointer_v1 The zwp_confined_pointer_v1 interface
|
||||||
|
*
|
||||||
|
* The wp_confined_pointer interface represents a confined pointer state.
|
||||||
|
*
|
||||||
|
* This object will send the event 'confined' when the confinement is
|
||||||
|
* activated. Whenever the confinement is activated, it is guaranteed that
|
||||||
|
* the surface the pointer is confined to will already have received pointer
|
||||||
|
* focus and that the pointer will be within the region passed to the request
|
||||||
|
* creating this object. It is up to the compositor to decide whether this
|
||||||
|
* requires some user interaction and if the pointer will warp to within the
|
||||||
|
* passed region if outside.
|
||||||
|
*
|
||||||
|
* To unconfine the pointer, send the destroy request. This will also destroy
|
||||||
|
* the wp_confined_pointer object.
|
||||||
|
*
|
||||||
|
* If the compositor decides to unconfine the pointer the unconfined event is
|
||||||
|
* sent. The wp_confined_pointer object is at this point defunct and should
|
||||||
|
* be destroyed.
|
||||||
|
*/
|
||||||
|
extern const struct wl_interface zwp_confined_pointer_v1_interface;
|
||||||
|
|
||||||
|
#ifndef ZWP_POINTER_CONSTRAINTS_V1_ERROR_ENUM
|
||||||
|
#define ZWP_POINTER_CONSTRAINTS_V1_ERROR_ENUM
|
||||||
|
/**
|
||||||
|
* @ingroup iface_zwp_pointer_constraints_v1
|
||||||
|
* wp_pointer_constraints error values
|
||||||
|
*
|
||||||
|
* These errors can be emitted in response to wp_pointer_constraints
|
||||||
|
* requests.
|
||||||
|
*/
|
||||||
|
enum zwp_pointer_constraints_v1_error {
|
||||||
|
/**
|
||||||
|
* pointer constraint already requested on that surface
|
||||||
|
*/
|
||||||
|
ZWP_POINTER_CONSTRAINTS_V1_ERROR_ALREADY_CONSTRAINED = 1,
|
||||||
|
};
|
||||||
|
#endif /* ZWP_POINTER_CONSTRAINTS_V1_ERROR_ENUM */
|
||||||
|
|
||||||
|
#ifndef ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_ENUM
|
||||||
|
#define ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_ENUM
|
||||||
|
/**
|
||||||
|
* @ingroup iface_zwp_pointer_constraints_v1
|
||||||
|
* the pointer constraint may reactivate
|
||||||
|
*
|
||||||
|
* A persistent pointer constraint may again reactivate once it has
|
||||||
|
* been deactivated. See the corresponding deactivation event
|
||||||
|
* (wp_locked_pointer.unlocked and wp_confined_pointer.unconfined) for
|
||||||
|
* details.
|
||||||
|
*/
|
||||||
|
enum zwp_pointer_constraints_v1_lifetime {
|
||||||
|
ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_ONESHOT = 1,
|
||||||
|
ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT = 2,
|
||||||
|
};
|
||||||
|
#endif /* ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_ENUM */
|
||||||
|
|
||||||
|
#define ZWP_POINTER_CONSTRAINTS_V1_DESTROY 0
|
||||||
|
#define ZWP_POINTER_CONSTRAINTS_V1_LOCK_POINTER 1
|
||||||
|
#define ZWP_POINTER_CONSTRAINTS_V1_CONFINE_POINTER 2
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup iface_zwp_pointer_constraints_v1
|
||||||
|
*/
|
||||||
|
#define ZWP_POINTER_CONSTRAINTS_V1_DESTROY_SINCE_VERSION 1
|
||||||
|
/**
|
||||||
|
* @ingroup iface_zwp_pointer_constraints_v1
|
||||||
|
*/
|
||||||
|
#define ZWP_POINTER_CONSTRAINTS_V1_LOCK_POINTER_SINCE_VERSION 1
|
||||||
|
/**
|
||||||
|
* @ingroup iface_zwp_pointer_constraints_v1
|
||||||
|
*/
|
||||||
|
#define ZWP_POINTER_CONSTRAINTS_V1_CONFINE_POINTER_SINCE_VERSION 1
|
||||||
|
|
||||||
|
/** @ingroup iface_zwp_pointer_constraints_v1 */
|
||||||
|
static inline void
|
||||||
|
zwp_pointer_constraints_v1_set_user_data(struct zwp_pointer_constraints_v1 *zwp_pointer_constraints_v1, void *user_data)
|
||||||
|
{
|
||||||
|
wl_proxy_set_user_data((struct wl_proxy *) zwp_pointer_constraints_v1, user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @ingroup iface_zwp_pointer_constraints_v1 */
|
||||||
|
static inline void *
|
||||||
|
zwp_pointer_constraints_v1_get_user_data(struct zwp_pointer_constraints_v1 *zwp_pointer_constraints_v1)
|
||||||
|
{
|
||||||
|
return wl_proxy_get_user_data((struct wl_proxy *) zwp_pointer_constraints_v1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t
|
||||||
|
zwp_pointer_constraints_v1_get_version(struct zwp_pointer_constraints_v1 *zwp_pointer_constraints_v1)
|
||||||
|
{
|
||||||
|
return wl_proxy_get_version((struct wl_proxy *) zwp_pointer_constraints_v1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup iface_zwp_pointer_constraints_v1
|
||||||
|
*
|
||||||
|
* Used by the client to notify the server that it will no longer use this
|
||||||
|
* pointer constraints object.
|
||||||
|
*/
|
||||||
|
static inline void
|
||||||
|
zwp_pointer_constraints_v1_destroy(struct zwp_pointer_constraints_v1 *zwp_pointer_constraints_v1)
|
||||||
|
{
|
||||||
|
wl_proxy_marshal((struct wl_proxy *) zwp_pointer_constraints_v1,
|
||||||
|
ZWP_POINTER_CONSTRAINTS_V1_DESTROY);
|
||||||
|
|
||||||
|
wl_proxy_destroy((struct wl_proxy *) zwp_pointer_constraints_v1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup iface_zwp_pointer_constraints_v1
|
||||||
|
*
|
||||||
|
* The lock_pointer request lets the client request to disable movements of
|
||||||
|
* the virtual pointer (i.e. the cursor), effectively locking the pointer
|
||||||
|
* to a position. This request may not take effect immediately; in the
|
||||||
|
* future, when the compositor deems implementation-specific constraints
|
||||||
|
* are satisfied, the pointer lock will be activated and the compositor
|
||||||
|
* sends a locked event.
|
||||||
|
*
|
||||||
|
* The protocol provides no guarantee that the constraints are ever
|
||||||
|
* satisfied, and does not require the compositor to send an error if the
|
||||||
|
* constraints cannot ever be satisfied. It is thus possible to request a
|
||||||
|
* lock that will never activate.
|
||||||
|
*
|
||||||
|
* There may not be another pointer constraint of any kind requested or
|
||||||
|
* active on the surface for any of the wl_pointer objects of the seat of
|
||||||
|
* the passed pointer when requesting a lock. If there is, an error will be
|
||||||
|
* raised. See general pointer lock documentation for more details.
|
||||||
|
*
|
||||||
|
* The intersection of the region passed with this request and the input
|
||||||
|
* region of the surface is used to determine where the pointer must be
|
||||||
|
* in order for the lock to activate. It is up to the compositor whether to
|
||||||
|
* warp the pointer or require some kind of user interaction for the lock
|
||||||
|
* to activate. If the region is null the surface input region is used.
|
||||||
|
*
|
||||||
|
* A surface may receive pointer focus without the lock being activated.
|
||||||
|
*
|
||||||
|
* The request creates a new object wp_locked_pointer which is used to
|
||||||
|
* interact with the lock as well as receive updates about its state. See
|
||||||
|
* the the description of wp_locked_pointer for further information.
|
||||||
|
*
|
||||||
|
* Note that while a pointer is locked, the wl_pointer objects of the
|
||||||
|
* corresponding seat will not emit any wl_pointer.motion events, but
|
||||||
|
* relative motion events will still be emitted via wp_relative_pointer
|
||||||
|
* objects of the same seat. wl_pointer.axis and wl_pointer.button events
|
||||||
|
* are unaffected.
|
||||||
|
*/
|
||||||
|
static inline struct zwp_locked_pointer_v1 *
|
||||||
|
zwp_pointer_constraints_v1_lock_pointer(struct zwp_pointer_constraints_v1 *zwp_pointer_constraints_v1, struct wl_surface *surface, struct wl_pointer *pointer, struct wl_region *region, uint32_t lifetime)
|
||||||
|
{
|
||||||
|
struct wl_proxy *id;
|
||||||
|
|
||||||
|
id = wl_proxy_marshal_constructor((struct wl_proxy *) zwp_pointer_constraints_v1,
|
||||||
|
ZWP_POINTER_CONSTRAINTS_V1_LOCK_POINTER, &zwp_locked_pointer_v1_interface, NULL, surface, pointer, region, lifetime);
|
||||||
|
|
||||||
|
return (struct zwp_locked_pointer_v1 *) id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup iface_zwp_pointer_constraints_v1
|
||||||
|
*
|
||||||
|
* The confine_pointer request lets the client request to confine the
|
||||||
|
* pointer cursor to a given region. This request may not take effect
|
||||||
|
* immediately; in the future, when the compositor deems implementation-
|
||||||
|
* specific constraints are satisfied, the pointer confinement will be
|
||||||
|
* activated and the compositor sends a confined event.
|
||||||
|
*
|
||||||
|
* The intersection of the region passed with this request and the input
|
||||||
|
* region of the surface is used to determine where the pointer must be
|
||||||
|
* in order for the confinement to activate. It is up to the compositor
|
||||||
|
* whether to warp the pointer or require some kind of user interaction for
|
||||||
|
* the confinement to activate. If the region is null the surface input
|
||||||
|
* region is used.
|
||||||
|
*
|
||||||
|
* The request will create a new object wp_confined_pointer which is used
|
||||||
|
* to interact with the confinement as well as receive updates about its
|
||||||
|
* state. See the the description of wp_confined_pointer for further
|
||||||
|
* information.
|
||||||
|
*/
|
||||||
|
static inline struct zwp_confined_pointer_v1 *
|
||||||
|
zwp_pointer_constraints_v1_confine_pointer(struct zwp_pointer_constraints_v1 *zwp_pointer_constraints_v1, struct wl_surface *surface, struct wl_pointer *pointer, struct wl_region *region, uint32_t lifetime)
|
||||||
|
{
|
||||||
|
struct wl_proxy *id;
|
||||||
|
|
||||||
|
id = wl_proxy_marshal_constructor((struct wl_proxy *) zwp_pointer_constraints_v1,
|
||||||
|
ZWP_POINTER_CONSTRAINTS_V1_CONFINE_POINTER, &zwp_confined_pointer_v1_interface, NULL, surface, pointer, region, lifetime);
|
||||||
|
|
||||||
|
return (struct zwp_confined_pointer_v1 *) id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup iface_zwp_locked_pointer_v1
|
||||||
|
* @struct zwp_locked_pointer_v1_listener
|
||||||
|
*/
|
||||||
|
struct zwp_locked_pointer_v1_listener {
|
||||||
|
/**
|
||||||
|
* lock activation event
|
||||||
|
*
|
||||||
|
* Notification that the pointer lock of the seat's pointer is
|
||||||
|
* activated.
|
||||||
|
*/
|
||||||
|
void (*locked)(void *data,
|
||||||
|
struct zwp_locked_pointer_v1 *zwp_locked_pointer_v1);
|
||||||
|
/**
|
||||||
|
* lock deactivation event
|
||||||
|
*
|
||||||
|
* Notification that the pointer lock of the seat's pointer is no
|
||||||
|
* longer active. If this is a oneshot pointer lock (see
|
||||||
|
* wp_pointer_constraints.lifetime) this object is now defunct and
|
||||||
|
* should be destroyed. If this is a persistent pointer lock (see
|
||||||
|
* wp_pointer_constraints.lifetime) this pointer lock may again
|
||||||
|
* reactivate in the future.
|
||||||
|
*/
|
||||||
|
void (*unlocked)(void *data,
|
||||||
|
struct zwp_locked_pointer_v1 *zwp_locked_pointer_v1);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup iface_zwp_locked_pointer_v1
|
||||||
|
*/
|
||||||
|
static inline int
|
||||||
|
zwp_locked_pointer_v1_add_listener(struct zwp_locked_pointer_v1 *zwp_locked_pointer_v1,
|
||||||
|
const struct zwp_locked_pointer_v1_listener *listener, void *data)
|
||||||
|
{
|
||||||
|
return wl_proxy_add_listener((struct wl_proxy *) zwp_locked_pointer_v1,
|
||||||
|
(void (**)(void)) listener, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ZWP_LOCKED_POINTER_V1_DESTROY 0
|
||||||
|
#define ZWP_LOCKED_POINTER_V1_SET_CURSOR_POSITION_HINT 1
|
||||||
|
#define ZWP_LOCKED_POINTER_V1_SET_REGION 2
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup iface_zwp_locked_pointer_v1
|
||||||
|
*/
|
||||||
|
#define ZWP_LOCKED_POINTER_V1_LOCKED_SINCE_VERSION 1
|
||||||
|
/**
|
||||||
|
* @ingroup iface_zwp_locked_pointer_v1
|
||||||
|
*/
|
||||||
|
#define ZWP_LOCKED_POINTER_V1_UNLOCKED_SINCE_VERSION 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup iface_zwp_locked_pointer_v1
|
||||||
|
*/
|
||||||
|
#define ZWP_LOCKED_POINTER_V1_DESTROY_SINCE_VERSION 1
|
||||||
|
/**
|
||||||
|
* @ingroup iface_zwp_locked_pointer_v1
|
||||||
|
*/
|
||||||
|
#define ZWP_LOCKED_POINTER_V1_SET_CURSOR_POSITION_HINT_SINCE_VERSION 1
|
||||||
|
/**
|
||||||
|
* @ingroup iface_zwp_locked_pointer_v1
|
||||||
|
*/
|
||||||
|
#define ZWP_LOCKED_POINTER_V1_SET_REGION_SINCE_VERSION 1
|
||||||
|
|
||||||
|
/** @ingroup iface_zwp_locked_pointer_v1 */
|
||||||
|
static inline void
|
||||||
|
zwp_locked_pointer_v1_set_user_data(struct zwp_locked_pointer_v1 *zwp_locked_pointer_v1, void *user_data)
|
||||||
|
{
|
||||||
|
wl_proxy_set_user_data((struct wl_proxy *) zwp_locked_pointer_v1, user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @ingroup iface_zwp_locked_pointer_v1 */
|
||||||
|
static inline void *
|
||||||
|
zwp_locked_pointer_v1_get_user_data(struct zwp_locked_pointer_v1 *zwp_locked_pointer_v1)
|
||||||
|
{
|
||||||
|
return wl_proxy_get_user_data((struct wl_proxy *) zwp_locked_pointer_v1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t
|
||||||
|
zwp_locked_pointer_v1_get_version(struct zwp_locked_pointer_v1 *zwp_locked_pointer_v1)
|
||||||
|
{
|
||||||
|
return wl_proxy_get_version((struct wl_proxy *) zwp_locked_pointer_v1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup iface_zwp_locked_pointer_v1
|
||||||
|
*
|
||||||
|
* Destroy the locked pointer object. If applicable, the compositor will
|
||||||
|
* unlock the pointer.
|
||||||
|
*/
|
||||||
|
static inline void
|
||||||
|
zwp_locked_pointer_v1_destroy(struct zwp_locked_pointer_v1 *zwp_locked_pointer_v1)
|
||||||
|
{
|
||||||
|
wl_proxy_marshal((struct wl_proxy *) zwp_locked_pointer_v1,
|
||||||
|
ZWP_LOCKED_POINTER_V1_DESTROY);
|
||||||
|
|
||||||
|
wl_proxy_destroy((struct wl_proxy *) zwp_locked_pointer_v1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup iface_zwp_locked_pointer_v1
|
||||||
|
*
|
||||||
|
* Set the cursor position hint relative to the top left corner of the
|
||||||
|
* surface.
|
||||||
|
*
|
||||||
|
* If the client is drawing its own cursor, it should update the position
|
||||||
|
* hint to the position of its own cursor. A compositor may use this
|
||||||
|
* information to warp the pointer upon unlock in order to avoid pointer
|
||||||
|
* jumps.
|
||||||
|
*
|
||||||
|
* The cursor position hint is double buffered. The new hint will only take
|
||||||
|
* effect when the associated surface gets it pending state applied. See
|
||||||
|
* wl_surface.commit for details.
|
||||||
|
*/
|
||||||
|
static inline void
|
||||||
|
zwp_locked_pointer_v1_set_cursor_position_hint(struct zwp_locked_pointer_v1 *zwp_locked_pointer_v1, wl_fixed_t surface_x, wl_fixed_t surface_y)
|
||||||
|
{
|
||||||
|
wl_proxy_marshal((struct wl_proxy *) zwp_locked_pointer_v1,
|
||||||
|
ZWP_LOCKED_POINTER_V1_SET_CURSOR_POSITION_HINT, surface_x, surface_y);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup iface_zwp_locked_pointer_v1
|
||||||
|
*
|
||||||
|
* Set a new region used to lock the pointer.
|
||||||
|
*
|
||||||
|
* The new lock region is double-buffered. The new lock region will
|
||||||
|
* only take effect when the associated surface gets its pending state
|
||||||
|
* applied. See wl_surface.commit for details.
|
||||||
|
*
|
||||||
|
* For details about the lock region, see wp_locked_pointer.
|
||||||
|
*/
|
||||||
|
static inline void
|
||||||
|
zwp_locked_pointer_v1_set_region(struct zwp_locked_pointer_v1 *zwp_locked_pointer_v1, struct wl_region *region)
|
||||||
|
{
|
||||||
|
wl_proxy_marshal((struct wl_proxy *) zwp_locked_pointer_v1,
|
||||||
|
ZWP_LOCKED_POINTER_V1_SET_REGION, region);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup iface_zwp_confined_pointer_v1
|
||||||
|
* @struct zwp_confined_pointer_v1_listener
|
||||||
|
*/
|
||||||
|
struct zwp_confined_pointer_v1_listener {
|
||||||
|
/**
|
||||||
|
* pointer confined
|
||||||
|
*
|
||||||
|
* Notification that the pointer confinement of the seat's
|
||||||
|
* pointer is activated.
|
||||||
|
*/
|
||||||
|
void (*confined)(void *data,
|
||||||
|
struct zwp_confined_pointer_v1 *zwp_confined_pointer_v1);
|
||||||
|
/**
|
||||||
|
* pointer unconfined
|
||||||
|
*
|
||||||
|
* Notification that the pointer confinement of the seat's
|
||||||
|
* pointer is no longer active. If this is a oneshot pointer
|
||||||
|
* confinement (see wp_pointer_constraints.lifetime) this object is
|
||||||
|
* now defunct and should be destroyed. If this is a persistent
|
||||||
|
* pointer confinement (see wp_pointer_constraints.lifetime) this
|
||||||
|
* pointer confinement may again reactivate in the future.
|
||||||
|
*/
|
||||||
|
void (*unconfined)(void *data,
|
||||||
|
struct zwp_confined_pointer_v1 *zwp_confined_pointer_v1);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup iface_zwp_confined_pointer_v1
|
||||||
|
*/
|
||||||
|
static inline int
|
||||||
|
zwp_confined_pointer_v1_add_listener(struct zwp_confined_pointer_v1 *zwp_confined_pointer_v1,
|
||||||
|
const struct zwp_confined_pointer_v1_listener *listener, void *data)
|
||||||
|
{
|
||||||
|
return wl_proxy_add_listener((struct wl_proxy *) zwp_confined_pointer_v1,
|
||||||
|
(void (**)(void)) listener, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ZWP_CONFINED_POINTER_V1_DESTROY 0
|
||||||
|
#define ZWP_CONFINED_POINTER_V1_SET_REGION 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup iface_zwp_confined_pointer_v1
|
||||||
|
*/
|
||||||
|
#define ZWP_CONFINED_POINTER_V1_CONFINED_SINCE_VERSION 1
|
||||||
|
/**
|
||||||
|
* @ingroup iface_zwp_confined_pointer_v1
|
||||||
|
*/
|
||||||
|
#define ZWP_CONFINED_POINTER_V1_UNCONFINED_SINCE_VERSION 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup iface_zwp_confined_pointer_v1
|
||||||
|
*/
|
||||||
|
#define ZWP_CONFINED_POINTER_V1_DESTROY_SINCE_VERSION 1
|
||||||
|
/**
|
||||||
|
* @ingroup iface_zwp_confined_pointer_v1
|
||||||
|
*/
|
||||||
|
#define ZWP_CONFINED_POINTER_V1_SET_REGION_SINCE_VERSION 1
|
||||||
|
|
||||||
|
/** @ingroup iface_zwp_confined_pointer_v1 */
|
||||||
|
static inline void
|
||||||
|
zwp_confined_pointer_v1_set_user_data(struct zwp_confined_pointer_v1 *zwp_confined_pointer_v1, void *user_data)
|
||||||
|
{
|
||||||
|
wl_proxy_set_user_data((struct wl_proxy *) zwp_confined_pointer_v1, user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @ingroup iface_zwp_confined_pointer_v1 */
|
||||||
|
static inline void *
|
||||||
|
zwp_confined_pointer_v1_get_user_data(struct zwp_confined_pointer_v1 *zwp_confined_pointer_v1)
|
||||||
|
{
|
||||||
|
return wl_proxy_get_user_data((struct wl_proxy *) zwp_confined_pointer_v1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t
|
||||||
|
zwp_confined_pointer_v1_get_version(struct zwp_confined_pointer_v1 *zwp_confined_pointer_v1)
|
||||||
|
{
|
||||||
|
return wl_proxy_get_version((struct wl_proxy *) zwp_confined_pointer_v1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup iface_zwp_confined_pointer_v1
|
||||||
|
*
|
||||||
|
* Destroy the confined pointer object. If applicable, the compositor will
|
||||||
|
* unconfine the pointer.
|
||||||
|
*/
|
||||||
|
static inline void
|
||||||
|
zwp_confined_pointer_v1_destroy(struct zwp_confined_pointer_v1 *zwp_confined_pointer_v1)
|
||||||
|
{
|
||||||
|
wl_proxy_marshal((struct wl_proxy *) zwp_confined_pointer_v1,
|
||||||
|
ZWP_CONFINED_POINTER_V1_DESTROY);
|
||||||
|
|
||||||
|
wl_proxy_destroy((struct wl_proxy *) zwp_confined_pointer_v1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup iface_zwp_confined_pointer_v1
|
||||||
|
*
|
||||||
|
* Set a new region used to confine the pointer.
|
||||||
|
*
|
||||||
|
* The new confine region is double-buffered. The new confine region will
|
||||||
|
* only take effect when the associated surface gets its pending state
|
||||||
|
* applied. See wl_surface.commit for details.
|
||||||
|
*
|
||||||
|
* If the confinement is active when the new confinement region is applied
|
||||||
|
* and the pointer ends up outside of newly applied region, the pointer may
|
||||||
|
* warped to a position within the new confinement region. If warped, a
|
||||||
|
* wl_pointer.motion event will be emitted, but no
|
||||||
|
* wp_relative_pointer.relative_motion event.
|
||||||
|
*
|
||||||
|
* The compositor may also, instead of using the new region, unconfine the
|
||||||
|
* pointer.
|
||||||
|
*
|
||||||
|
* For details about the confine region, see wp_confined_pointer.
|
||||||
|
*/
|
||||||
|
static inline void
|
||||||
|
zwp_confined_pointer_v1_set_region(struct zwp_confined_pointer_v1 *zwp_confined_pointer_v1, struct wl_region *region)
|
||||||
|
{
|
||||||
|
wl_proxy_marshal((struct wl_proxy *) zwp_confined_pointer_v1,
|
||||||
|
ZWP_CONFINED_POINTER_V1_SET_REGION, region);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
2476
include/expected.hpp
2476
include/expected.hpp
File diff suppressed because it is too large
Load diff
|
@ -1,11 +1,11 @@
|
||||||
#include "primitives.h"
|
#include "primitives.h"
|
||||||
|
|
||||||
#define IMPL_WRAPPER_CLASS(CLASS_NAME, WRAPPED_TYPE) Data::CLASS_NAME::CLASS_NAME(WRAPPED_TYPE in) : wrapped(in) {}\
|
#define IMPL_WRAPPER_CLASS(CLASS_NAME, WRAPPED_TYPE) CLASS_NAME::CLASS_NAME(WRAPPED_TYPE in) : wrapped(in) {}\
|
||||||
Data::CLASS_NAME::operator WRAPPED_TYPE() { return wrapped; }
|
CLASS_NAME::operator WRAPPED_TYPE() { return wrapped; }
|
||||||
|
|
||||||
Data::Void::Void() {};
|
VoidData::VoidData() {};
|
||||||
|
|
||||||
IMPL_WRAPPER_CLASS(Bool, bool)
|
IMPL_WRAPPER_CLASS(BoolData, bool)
|
||||||
IMPL_WRAPPER_CLASS(Int, int)
|
IMPL_WRAPPER_CLASS(IntData, int)
|
||||||
IMPL_WRAPPER_CLASS(Float, float)
|
IMPL_WRAPPER_CLASS(FloatData, float)
|
||||||
IMPL_WRAPPER_CLASS(String, std::string)
|
IMPL_WRAPPER_CLASS(StringData, std::string)
|
|
@ -9,17 +9,14 @@ public:\
|
||||||
operator WRAPPED_TYPE(); \
|
operator WRAPPED_TYPE(); \
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Data {
|
class VoidData {
|
||||||
class Void {
|
public:
|
||||||
public:
|
VoidData();
|
||||||
Void();
|
|
||||||
};
|
|
||||||
|
|
||||||
DEF_WRAPPER_CLASS(Bool, bool)
|
|
||||||
DEF_WRAPPER_CLASS(Int, int)
|
|
||||||
DEF_WRAPPER_CLASS(Float, float)
|
|
||||||
DEF_WRAPPER_CLASS(String, std::string)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
DEF_WRAPPER_CLASS(BoolData, bool)
|
||||||
|
DEF_WRAPPER_CLASS(IntData, int)
|
||||||
|
DEF_WRAPPER_CLASS(FloatData, float)
|
||||||
|
DEF_WRAPPER_CLASS(StringData, std::string)
|
||||||
|
|
||||||
#undef DEF_WRAPPER_CLASS
|
#undef DEF_WRAPPER_CLASS
|
|
@ -1,3 +1,4 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "base/metadata.h"
|
||||||
#include "base/instance.h"
|
#include "base/instance.h"
|
|
@ -1,8 +1,6 @@
|
||||||
#include "instance.h"
|
#include "instance.h"
|
||||||
#include "../../common.h"
|
#include "../../common.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstddef>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
|
@ -23,13 +21,6 @@ InstanceType* Instance::TYPE = &TYPE_;
|
||||||
|
|
||||||
Instance::Instance(InstanceType* type) {
|
Instance::Instance(InstanceType* type) {
|
||||||
this->name = type->className;
|
this->name = type->className;
|
||||||
|
|
||||||
this->memberMap = {
|
|
||||||
.super = std::nullopt,
|
|
||||||
.members = {
|
|
||||||
{ "Name", { .backingField = &name } }
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Instance::~Instance () {
|
Instance::~Instance () {
|
||||||
|
@ -64,59 +55,4 @@ std::optional<std::shared_ptr<Instance>> Instance::GetParent() {
|
||||||
|
|
||||||
void Instance::OnParentUpdated(std::optional<std::shared_ptr<Instance>> oldParent, std::optional<std::shared_ptr<Instance>> newParent) {
|
void Instance::OnParentUpdated(std::optional<std::shared_ptr<Instance>> oldParent, std::optional<std::shared_ptr<Instance>> newParent) {
|
||||||
// Empty stub
|
// Empty stub
|
||||||
}
|
|
||||||
|
|
||||||
// Properties
|
|
||||||
|
|
||||||
tl::expected<std::string, MemberNotFound> Instance::GetPropertyValue(std::string name) {
|
|
||||||
auto meta = GetPropertyMeta(name);
|
|
||||||
if (!meta) return tl::make_unexpected(MemberNotFound());
|
|
||||||
|
|
||||||
return *(std::string*)meta->backingField;
|
|
||||||
}
|
|
||||||
|
|
||||||
tl::expected<void, MemberNotFound> Instance::SetPropertyValue(std::string name, std::string value) {
|
|
||||||
auto meta = GetPropertyMeta(name);
|
|
||||||
if (!meta) return tl::make_unexpected(MemberNotFound());
|
|
||||||
|
|
||||||
*(std::string*)meta->backingField = value;
|
|
||||||
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
tl::expected<PropertyMeta, MemberNotFound> Instance::GetPropertyMeta(std::string name) {
|
|
||||||
MemberMap* current = &memberMap;
|
|
||||||
while (true) {
|
|
||||||
// We look for the property in current member map
|
|
||||||
auto it = current->members.find(name);
|
|
||||||
|
|
||||||
// It is found, return it
|
|
||||||
if (it != current->members.end())
|
|
||||||
return it->second;
|
|
||||||
|
|
||||||
// It is not found, If there are no other maps to search, return null
|
|
||||||
if (!current->super.has_value())
|
|
||||||
return tl::make_unexpected(MemberNotFound());
|
|
||||||
|
|
||||||
// Search in the parent
|
|
||||||
current = current->super->get();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<std::string> Instance::GetProperties() {
|
|
||||||
if (cachedMemberList.has_value()) return cachedMemberList.value();
|
|
||||||
|
|
||||||
std::vector<std::string> memberList;
|
|
||||||
|
|
||||||
MemberMap* current = &memberMap;
|
|
||||||
do {
|
|
||||||
for (auto const& [key, _] : current->members) {
|
|
||||||
// Don't add it if it's already in the list
|
|
||||||
if (std::find(memberList.begin(), memberList.end(), key) == memberList.end())
|
|
||||||
memberList.push_back(key);
|
|
||||||
}
|
|
||||||
} while (current->super.has_value());
|
|
||||||
|
|
||||||
cachedMemberList = memberList;
|
|
||||||
return memberList;
|
|
||||||
}
|
}
|
|
@ -1,21 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <vector>
|
#include "metadata.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
|
||||||
#include <optional>
|
|
||||||
#include <string>
|
|
||||||
#include <variant>
|
|
||||||
#include <map>
|
|
||||||
#include <vector>
|
|
||||||
#include <../include/expected.hpp>
|
|
||||||
|
|
||||||
#include "member.h"
|
|
||||||
|
|
||||||
class Instance;
|
|
||||||
typedef std::shared_ptr<Instance>(*InstanceConstructor)();
|
|
||||||
|
|
||||||
// Struct describing information about an instance
|
// Struct describing information about an instance
|
||||||
struct InstanceType {
|
struct InstanceType {
|
||||||
|
@ -33,11 +21,7 @@ class Instance : public std::enable_shared_from_this<Instance> {
|
||||||
private:
|
private:
|
||||||
std::optional<std::weak_ptr<Instance>> parent;
|
std::optional<std::weak_ptr<Instance>> parent;
|
||||||
std::vector<std::shared_ptr<Instance>> children;
|
std::vector<std::shared_ptr<Instance>> children;
|
||||||
|
|
||||||
std::optional<std::vector<std::string>> cachedMemberList;
|
|
||||||
protected:
|
protected:
|
||||||
MemberMap memberMap;
|
|
||||||
|
|
||||||
Instance(InstanceType*);
|
Instance(InstanceType*);
|
||||||
virtual ~Instance();
|
virtual ~Instance();
|
||||||
|
|
||||||
|
@ -54,14 +38,6 @@ public:
|
||||||
|
|
||||||
// Utility functions
|
// Utility functions
|
||||||
inline void AddChild(std::shared_ptr<Instance> object) { object->SetParent(this->shared_from_this()); }
|
inline void AddChild(std::shared_ptr<Instance> object) { object->SetParent(this->shared_from_this()); }
|
||||||
|
|
||||||
// Properties
|
|
||||||
// Do I like using expected?
|
|
||||||
tl::expected<std::string, MemberNotFound> GetPropertyValue(std::string name);
|
|
||||||
tl::expected<void, MemberNotFound> SetPropertyValue(std::string name, std::string value);
|
|
||||||
tl::expected<PropertyMeta, MemberNotFound> GetPropertyMeta(std::string name);
|
|
||||||
// Returning a list of property names feels kinda janky. Is this really the way to go?
|
|
||||||
std::vector<std::string> GetProperties();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::shared_ptr<Instance> InstanceRef;
|
typedef std::shared_ptr<Instance> InstanceRef;
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <memory>
|
|
||||||
#include <optional>
|
|
||||||
#include <variant>
|
|
||||||
|
|
||||||
class Instance;
|
|
||||||
|
|
||||||
struct PropertyMeta {
|
|
||||||
void* backingField;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef std::variant<PropertyMeta> MemberMeta;
|
|
||||||
|
|
||||||
struct MemberMap {
|
|
||||||
std::optional<std::unique_ptr<MemberMap>> super;
|
|
||||||
std::map<std::string, PropertyMeta> members;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct MemberNotFound {};
|
|
60
src/objects/base/metadata.h
Normal file
60
src/objects/base/metadata.h
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <optional>
|
||||||
|
#include <string>
|
||||||
|
#include <variant>
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "../../datatype.h"
|
||||||
|
|
||||||
|
class Instance;
|
||||||
|
typedef std::shared_ptr<Instance>(*InstanceConstructor)();
|
||||||
|
|
||||||
|
const uint INST_NOT_CREATABLE = 1;
|
||||||
|
// const uint INST_SINGLETON = 2;
|
||||||
|
|
||||||
|
typedef uint InstanceClassFlags;
|
||||||
|
|
||||||
|
struct InstanceClassDescriptor {
|
||||||
|
std::string className;
|
||||||
|
InstanceConstructor constructor;
|
||||||
|
InstanceClassFlags flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
const uint PROP_READONLY = 1;
|
||||||
|
const uint PROP_NOSCRIPT = 2; // Cannot be read or written to by unpriveleged scripts
|
||||||
|
const uint PROP_NOSAVE = 4; // Property should not be serialized by the engine
|
||||||
|
const uint PROP_CLIENTONLY = 8; // Only accessible by the client
|
||||||
|
|
||||||
|
typedef uint PropertyFlags;
|
||||||
|
|
||||||
|
typedef DataValue(*InstancePropertyGetter)();
|
||||||
|
typedef void(*InstancePropertySetter)(DataValue);
|
||||||
|
|
||||||
|
// Properties may either have a backing field directly accessed by Instance,
|
||||||
|
// or, for more granular control may define a getter (and setter if writable).
|
||||||
|
struct MemberPropertyDescriptor {
|
||||||
|
DataType dataType;
|
||||||
|
PropertyFlags flags;
|
||||||
|
std::optional<DataValue*> backingField;
|
||||||
|
std::optional<InstancePropertyGetter> getter;
|
||||||
|
std::optional<InstancePropertySetter> setter;
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
typedef DataValue(*InstanceMethodHandler)(std::vector<DataValue>);
|
||||||
|
|
||||||
|
struct MemberMethodDescriptor {
|
||||||
|
DataType returnType;
|
||||||
|
// This may need to be converted into a vector in the future for overloaded methods
|
||||||
|
std::vector<DataType> parameters;
|
||||||
|
InstanceMethodHandler handler;
|
||||||
|
};
|
||||||
|
|
||||||
|
// TODO: Add MemberCallbackDescriptor
|
||||||
|
typedef std::map<std::string, std::variant<MemberPropertyDescriptor, MemberMethodDescriptor /*, MemberEventDescriptor */ /* , MemberCallbackDescriptor */>> InstanceMemberTable;
|
Loading…
Add table
Reference in a new issue