thirdparty,sokol: add wayland support (#26682)
* thirdparty,sokol: add wayland support * review * chore: include headers and sources directly instead of static linking
This commit is contained in:
1 parent
4b29e678e2
commit
5d6de17f70
68 files changed
+31723
-10401
No files matched your search
@@ -39,7 +39,7 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 5
|
||||
env:
|
||||
MOPTIONS: --diff --deprecated --relative-paths --exclude /vlib/v/ --exclude /builtin/linux_bare/ --exclude /testdata/ --exclude /tests/
|
||||
MOPTIONS: --diff --deprecated --relative-paths --exclude /vlib/v/ --exclude /vlib/v2/ --exclude /builtin/linux_bare/ --exclude /testdata/ --exclude /tests/ --exclude /vlib/sokol/ --exclude /vlib/x/
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- name: Build V
|
||||
|
||||
@@ -36,6 +36,9 @@ jobs:
|
||||
- name: Build local v
|
||||
run: make -j4 && ./v symlink
|
||||
|
||||
- name: Clear module cache
|
||||
run: ./v wipe-cache
|
||||
|
||||
- name: Setup dependencies
|
||||
run: |
|
||||
# imagemagick : convert, mogrify
|
||||
@@ -44,9 +47,10 @@ jobs:
|
||||
# libxcursor-dev libxi-dev : V gfx deps
|
||||
# libgl1-mesa-dri : For headless rendering / software DRI driver (LIBGL_ALWAYS_SOFTWARE=true)
|
||||
# freeglut3-dev : Fixes graphic apps compilation with tcc
|
||||
# libx11-dev : X11 headers for clipboard and sokol (default backend on Linux)
|
||||
.github/workflows/disable_azure_mirror.sh
|
||||
./v retry -- sudo apt update
|
||||
./v retry -- sudo apt install imagemagick openimageio-tools libgl1-mesa-dri xvfb libxcursor-dev libxi-dev libxrandr-dev freeglut3-dev xsel xclip
|
||||
./v retry -- sudo apt install imagemagick openimageio-tools libgl1-mesa-dri xvfb libxcursor-dev libxi-dev libxrandr-dev freeglut3-dev xsel xclip libx11-dev
|
||||
./v retry -- ./v download https://raw.githubusercontent.com/tremby/imgur.sh/c98345d/imgur.sh
|
||||
./v retry -- git clone https://github.com/Larpon/gg-regression-images gg-regression-images
|
||||
chmod +x ./imgur.sh
|
||||
|
||||
+7
-1
@@ -55,7 +55,9 @@ fn install_dependencies_for_examples_and_tools_tcc() {
|
||||
}
|
||||
exec('v retry -- sudo apt update')
|
||||
exec('v retry -- sudo apt install --quiet -y libssl-dev sqlite3 libsqlite3-dev valgrind')
|
||||
exec('v retry -- sudo apt install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev libxrandr-dev libasound2-dev')
|
||||
exec('v retry -- sudo apt install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev libxrandr-dev libasound2-dev libegl-dev')
|
||||
// Wayland development libraries for sokol Wayland support
|
||||
exec('v retry -- sudo apt install --quiet -y libwayland-dev libxkbcommon-dev libwayland-egl1-mesa libxkbcommon-x11-dev')
|
||||
// The following is needed for examples/wkhtmltopdf.v
|
||||
exec('v retry -- sudo apt install --quiet -y xfonts-75dpi xfonts-base expect')
|
||||
exec('v retry -- wget --quiet https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.jammy_amd64.deb')
|
||||
@@ -179,6 +181,8 @@ fn install_dependencies_for_examples_and_tools_gcc() {
|
||||
exec('v retry -- sudo apt update')
|
||||
exec('v retry -- sudo apt install --quiet -y postgresql libpq-dev libssl-dev sqlite3 libsqlite3-dev valgrind')
|
||||
exec('v retry -- sudo apt install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev libxrandr-dev libasound2-dev')
|
||||
// Wayland development libraries for sokol Wayland support
|
||||
exec('v retry -- sudo apt install --quiet -y libwayland-dev libxkbcommon-dev libwayland-egl1-mesa libxkbcommon-x11-dev wayland-protocols libegl-dev')
|
||||
}
|
||||
|
||||
fn recompile_v_with_cstrict_gcc() {
|
||||
@@ -301,6 +305,8 @@ fn install_dependencies_for_examples_and_tools_clang() {
|
||||
exec('v retry -- sudo apt update')
|
||||
exec('v retry -- sudo apt install --quiet -y postgresql libpq-dev libssl-dev sqlite3 libsqlite3-dev valgrind')
|
||||
exec('v retry -- sudo apt install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev libxrandr-dev libasound2-dev')
|
||||
// Wayland development libraries for sokol Wayland support
|
||||
exec('v retry -- sudo apt install --quiet -y libwayland-dev libxkbcommon-dev libwayland-egl1-mesa libxkbcommon-x11-dev wayland-protocols libegl-dev')
|
||||
exec('v retry -- sudo apt install --quiet -y clang')
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,6 @@ fn (mut a App) run() {
|
||||
init_userdata_cb: init
|
||||
frame_userdata_cb: frame
|
||||
window_title: &char(title.str)
|
||||
html5_canvas_name: &char(title.str)
|
||||
cleanup_userdata_cb: cleanup
|
||||
sample_count: 4 // Enables MSAA (Multisample anti-aliasing) x4 on rendered output, this can be omitted.
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ fn main() {
|
||||
init_userdata_cb: init
|
||||
frame_userdata_cb: frame
|
||||
window_title: &char(title.str)
|
||||
html5_canvas_name: &char(title.str)
|
||||
}
|
||||
sapp.run(&desc)
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ fn main() {
|
||||
init_userdata_cb: init
|
||||
frame_userdata_cb: frame
|
||||
window_title: &char(title.str)
|
||||
html5_canvas_name: &char(title.str)
|
||||
}
|
||||
sapp.run(&desc)
|
||||
}
|
||||
|
||||
@@ -81,7 +81,6 @@ fn main() {
|
||||
init_userdata_cb: init
|
||||
frame_userdata_cb: frame
|
||||
window_title: &char(title.str)
|
||||
html5_canvas_name: &char(title.str)
|
||||
width: 600
|
||||
height: 700
|
||||
high_dpi: true
|
||||
|
||||
@@ -57,7 +57,6 @@ fn (mut a App) run() {
|
||||
frame_userdata_cb: frame
|
||||
event_userdata_cb: event
|
||||
window_title: &char(title.str)
|
||||
html5_canvas_name: &char(title.str)
|
||||
cleanup_userdata_cb: cleanup
|
||||
}
|
||||
sapp.run(&desc)
|
||||
|
||||
+452
@@ -0,0 +1,452 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
#ifndef CURSOR_SHAPE_V1_CLIENT_PROTOCOL_H
|
||||
#define CURSOR_SHAPE_V1_CLIENT_PROTOCOL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "wayland-client.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @page page_cursor_shape_v1 The cursor_shape_v1 protocol
|
||||
* @section page_ifaces_cursor_shape_v1 Interfaces
|
||||
* - @subpage page_iface_wp_cursor_shape_manager_v1 - cursor shape manager
|
||||
* - @subpage page_iface_wp_cursor_shape_device_v1 - cursor shape for a device
|
||||
* @section page_copyright_cursor_shape_v1 Copyright
|
||||
* <pre>
|
||||
*
|
||||
* Copyright 2018 The Chromium Authors
|
||||
* Copyright 2023 Simon Ser
|
||||
*
|
||||
* 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 wp_cursor_shape_device_v1;
|
||||
struct wp_cursor_shape_manager_v1;
|
||||
struct zwp_tablet_tool_v2;
|
||||
|
||||
#ifndef WP_CURSOR_SHAPE_MANAGER_V1_INTERFACE
|
||||
#define WP_CURSOR_SHAPE_MANAGER_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_wp_cursor_shape_manager_v1 wp_cursor_shape_manager_v1
|
||||
* @section page_iface_wp_cursor_shape_manager_v1_desc Description
|
||||
*
|
||||
* This global offers an alternative, optional way to set cursor images. This
|
||||
* new way uses enumerated cursors instead of a wl_surface like
|
||||
* wl_pointer.set_cursor does.
|
||||
*
|
||||
* Warning! The protocol described in this file is currently in the testing
|
||||
* phase. Backward compatible changes may be added together with the
|
||||
* corresponding interface version bump. Backward incompatible changes can
|
||||
* only be done by creating a new major version of the extension.
|
||||
* @section page_iface_wp_cursor_shape_manager_v1_api API
|
||||
* See @ref iface_wp_cursor_shape_manager_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_wp_cursor_shape_manager_v1 The wp_cursor_shape_manager_v1 interface
|
||||
*
|
||||
* This global offers an alternative, optional way to set cursor images. This
|
||||
* new way uses enumerated cursors instead of a wl_surface like
|
||||
* wl_pointer.set_cursor does.
|
||||
*
|
||||
* Warning! The protocol described in this file is currently in the testing
|
||||
* phase. Backward compatible changes may be added together with the
|
||||
* corresponding interface version bump. Backward incompatible changes can
|
||||
* only be done by creating a new major version of the extension.
|
||||
*/
|
||||
extern const struct wl_interface wp_cursor_shape_manager_v1_interface;
|
||||
#endif
|
||||
#ifndef WP_CURSOR_SHAPE_DEVICE_V1_INTERFACE
|
||||
#define WP_CURSOR_SHAPE_DEVICE_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_wp_cursor_shape_device_v1 wp_cursor_shape_device_v1
|
||||
* @section page_iface_wp_cursor_shape_device_v1_desc Description
|
||||
*
|
||||
* This interface allows clients to set the cursor shape.
|
||||
* @section page_iface_wp_cursor_shape_device_v1_api API
|
||||
* See @ref iface_wp_cursor_shape_device_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_wp_cursor_shape_device_v1 The wp_cursor_shape_device_v1 interface
|
||||
*
|
||||
* This interface allows clients to set the cursor shape.
|
||||
*/
|
||||
extern const struct wl_interface wp_cursor_shape_device_v1_interface;
|
||||
#endif
|
||||
|
||||
#define WP_CURSOR_SHAPE_MANAGER_V1_DESTROY 0
|
||||
#define WP_CURSOR_SHAPE_MANAGER_V1_GET_POINTER 1
|
||||
#define WP_CURSOR_SHAPE_MANAGER_V1_GET_TABLET_TOOL_V2 2
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_cursor_shape_manager_v1
|
||||
*/
|
||||
#define WP_CURSOR_SHAPE_MANAGER_V1_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_wp_cursor_shape_manager_v1
|
||||
*/
|
||||
#define WP_CURSOR_SHAPE_MANAGER_V1_GET_POINTER_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_wp_cursor_shape_manager_v1
|
||||
*/
|
||||
#define WP_CURSOR_SHAPE_MANAGER_V1_GET_TABLET_TOOL_V2_SINCE_VERSION 1
|
||||
|
||||
/** @ingroup iface_wp_cursor_shape_manager_v1 */
|
||||
static inline void
|
||||
wp_cursor_shape_manager_v1_set_user_data(struct wp_cursor_shape_manager_v1 *wp_cursor_shape_manager_v1, void *user_data)
|
||||
{
|
||||
wl_proxy_set_user_data((struct wl_proxy *) wp_cursor_shape_manager_v1, user_data);
|
||||
}
|
||||
|
||||
/** @ingroup iface_wp_cursor_shape_manager_v1 */
|
||||
static inline void *
|
||||
wp_cursor_shape_manager_v1_get_user_data(struct wp_cursor_shape_manager_v1 *wp_cursor_shape_manager_v1)
|
||||
{
|
||||
return wl_proxy_get_user_data((struct wl_proxy *) wp_cursor_shape_manager_v1);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
wp_cursor_shape_manager_v1_get_version(struct wp_cursor_shape_manager_v1 *wp_cursor_shape_manager_v1)
|
||||
{
|
||||
return wl_proxy_get_version((struct wl_proxy *) wp_cursor_shape_manager_v1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_cursor_shape_manager_v1
|
||||
*
|
||||
* Destroy the cursor shape manager.
|
||||
*/
|
||||
static inline void
|
||||
wp_cursor_shape_manager_v1_destroy(struct wp_cursor_shape_manager_v1 *wp_cursor_shape_manager_v1)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) wp_cursor_shape_manager_v1,
|
||||
WP_CURSOR_SHAPE_MANAGER_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wp_cursor_shape_manager_v1), WL_MARSHAL_FLAG_DESTROY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_cursor_shape_manager_v1
|
||||
*
|
||||
* Obtain a wp_cursor_shape_device_v1 for a wl_pointer object.
|
||||
*
|
||||
* When the pointer capability is removed from the wl_seat, the
|
||||
* wp_cursor_shape_device_v1 object becomes inert.
|
||||
*/
|
||||
static inline struct wp_cursor_shape_device_v1 *
|
||||
wp_cursor_shape_manager_v1_get_pointer(struct wp_cursor_shape_manager_v1 *wp_cursor_shape_manager_v1, struct wl_pointer *pointer)
|
||||
{
|
||||
struct wl_proxy *cursor_shape_device;
|
||||
|
||||
cursor_shape_device = wl_proxy_marshal_flags((struct wl_proxy *) wp_cursor_shape_manager_v1,
|
||||
WP_CURSOR_SHAPE_MANAGER_V1_GET_POINTER, &wp_cursor_shape_device_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_cursor_shape_manager_v1), 0, NULL, pointer);
|
||||
|
||||
return (struct wp_cursor_shape_device_v1 *) cursor_shape_device;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_cursor_shape_manager_v1
|
||||
*
|
||||
* Obtain a wp_cursor_shape_device_v1 for a zwp_tablet_tool_v2 object.
|
||||
*
|
||||
* When the zwp_tablet_tool_v2 is removed, the wp_cursor_shape_device_v1
|
||||
* object becomes inert.
|
||||
*/
|
||||
static inline struct wp_cursor_shape_device_v1 *
|
||||
wp_cursor_shape_manager_v1_get_tablet_tool_v2(struct wp_cursor_shape_manager_v1 *wp_cursor_shape_manager_v1, struct zwp_tablet_tool_v2 *tablet_tool)
|
||||
{
|
||||
struct wl_proxy *cursor_shape_device;
|
||||
|
||||
cursor_shape_device = wl_proxy_marshal_flags((struct wl_proxy *) wp_cursor_shape_manager_v1,
|
||||
WP_CURSOR_SHAPE_MANAGER_V1_GET_TABLET_TOOL_V2, &wp_cursor_shape_device_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_cursor_shape_manager_v1), 0, NULL, tablet_tool);
|
||||
|
||||
return (struct wp_cursor_shape_device_v1 *) cursor_shape_device;
|
||||
}
|
||||
|
||||
#ifndef WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ENUM
|
||||
#define WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ENUM
|
||||
/**
|
||||
* @ingroup iface_wp_cursor_shape_device_v1
|
||||
* cursor shapes
|
||||
*
|
||||
* This enum describes cursor shapes.
|
||||
*
|
||||
* The names are taken from the CSS W3C specification:
|
||||
* https://w3c.github.io/csswg-drafts/css-ui/#cursor
|
||||
* with a few additions.
|
||||
*
|
||||
* Note that there are some groups of cursor shapes that are related:
|
||||
* The first group is drag-and-drop cursors which are used to indicate
|
||||
* the selected action during dnd operations. The second group is resize
|
||||
* cursors which are used to indicate resizing and moving possibilities
|
||||
* on window borders. It is recommended that the shapes in these groups
|
||||
* should use visually compatible images and metaphors.
|
||||
*/
|
||||
enum wp_cursor_shape_device_v1_shape {
|
||||
/**
|
||||
* default cursor
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DEFAULT = 1,
|
||||
/**
|
||||
* a context menu is available for the object under the cursor
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_CONTEXT_MENU = 2,
|
||||
/**
|
||||
* help is available for the object under the cursor
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_HELP = 3,
|
||||
/**
|
||||
* pointer that indicates a link or another interactive element
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_POINTER = 4,
|
||||
/**
|
||||
* progress indicator
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_PROGRESS = 5,
|
||||
/**
|
||||
* program is busy, user should wait
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_WAIT = 6,
|
||||
/**
|
||||
* a cell or set of cells may be selected
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_CELL = 7,
|
||||
/**
|
||||
* simple crosshair
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_CROSSHAIR = 8,
|
||||
/**
|
||||
* text may be selected
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_TEXT = 9,
|
||||
/**
|
||||
* vertical text may be selected
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_VERTICAL_TEXT = 10,
|
||||
/**
|
||||
* drag-and-drop: alias of/shortcut to something is to be created
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ALIAS = 11,
|
||||
/**
|
||||
* drag-and-drop: something is to be copied
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_COPY = 12,
|
||||
/**
|
||||
* drag-and-drop: something is to be moved
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_MOVE = 13,
|
||||
/**
|
||||
* drag-and-drop: the dragged item cannot be dropped at the current cursor location
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NO_DROP = 14,
|
||||
/**
|
||||
* drag-and-drop: the requested action will not be carried out
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NOT_ALLOWED = 15,
|
||||
/**
|
||||
* drag-and-drop: something can be grabbed
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_GRAB = 16,
|
||||
/**
|
||||
* drag-and-drop: something is being grabbed
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_GRABBING = 17,
|
||||
/**
|
||||
* resizing: the east border is to be moved
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_E_RESIZE = 18,
|
||||
/**
|
||||
* resizing: the north border is to be moved
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_N_RESIZE = 19,
|
||||
/**
|
||||
* resizing: the north-east corner is to be moved
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NE_RESIZE = 20,
|
||||
/**
|
||||
* resizing: the north-west corner is to be moved
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NW_RESIZE = 21,
|
||||
/**
|
||||
* resizing: the south border is to be moved
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_S_RESIZE = 22,
|
||||
/**
|
||||
* resizing: the south-east corner is to be moved
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_SE_RESIZE = 23,
|
||||
/**
|
||||
* resizing: the south-west corner is to be moved
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_SW_RESIZE = 24,
|
||||
/**
|
||||
* resizing: the west border is to be moved
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_W_RESIZE = 25,
|
||||
/**
|
||||
* resizing: the east and west borders are to be moved
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_EW_RESIZE = 26,
|
||||
/**
|
||||
* resizing: the north and south borders are to be moved
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NS_RESIZE = 27,
|
||||
/**
|
||||
* resizing: the north-east and south-west corners are to be moved
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NESW_RESIZE = 28,
|
||||
/**
|
||||
* resizing: the north-west and south-east corners are to be moved
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NWSE_RESIZE = 29,
|
||||
/**
|
||||
* resizing: that the item/column can be resized horizontally
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_COL_RESIZE = 30,
|
||||
/**
|
||||
* resizing: that the item/row can be resized vertically
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ROW_RESIZE = 31,
|
||||
/**
|
||||
* something can be scrolled in any direction
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ALL_SCROLL = 32,
|
||||
/**
|
||||
* something can be zoomed in
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ZOOM_IN = 33,
|
||||
/**
|
||||
* something can be zoomed out
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ZOOM_OUT = 34,
|
||||
/**
|
||||
* drag-and-drop: the user will select which action will be carried out (non-css value)
|
||||
* @since 2
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DND_ASK = 35,
|
||||
/**
|
||||
* resizing: something can be moved or resized in any direction (non-css value)
|
||||
* @since 2
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ALL_RESIZE = 36,
|
||||
};
|
||||
/**
|
||||
* @ingroup iface_wp_cursor_shape_device_v1
|
||||
*/
|
||||
#define WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DND_ASK_SINCE_VERSION 2
|
||||
/**
|
||||
* @ingroup iface_wp_cursor_shape_device_v1
|
||||
*/
|
||||
#define WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ALL_RESIZE_SINCE_VERSION 2
|
||||
#endif /* WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ENUM */
|
||||
|
||||
#ifndef WP_CURSOR_SHAPE_DEVICE_V1_ERROR_ENUM
|
||||
#define WP_CURSOR_SHAPE_DEVICE_V1_ERROR_ENUM
|
||||
enum wp_cursor_shape_device_v1_error {
|
||||
/**
|
||||
* the specified shape value is invalid
|
||||
*/
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_ERROR_INVALID_SHAPE = 1,
|
||||
};
|
||||
#endif /* WP_CURSOR_SHAPE_DEVICE_V1_ERROR_ENUM */
|
||||
|
||||
#define WP_CURSOR_SHAPE_DEVICE_V1_DESTROY 0
|
||||
#define WP_CURSOR_SHAPE_DEVICE_V1_SET_SHAPE 1
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_cursor_shape_device_v1
|
||||
*/
|
||||
#define WP_CURSOR_SHAPE_DEVICE_V1_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_wp_cursor_shape_device_v1
|
||||
*/
|
||||
#define WP_CURSOR_SHAPE_DEVICE_V1_SET_SHAPE_SINCE_VERSION 1
|
||||
|
||||
/** @ingroup iface_wp_cursor_shape_device_v1 */
|
||||
static inline void
|
||||
wp_cursor_shape_device_v1_set_user_data(struct wp_cursor_shape_device_v1 *wp_cursor_shape_device_v1, void *user_data)
|
||||
{
|
||||
wl_proxy_set_user_data((struct wl_proxy *) wp_cursor_shape_device_v1, user_data);
|
||||
}
|
||||
|
||||
/** @ingroup iface_wp_cursor_shape_device_v1 */
|
||||
static inline void *
|
||||
wp_cursor_shape_device_v1_get_user_data(struct wp_cursor_shape_device_v1 *wp_cursor_shape_device_v1)
|
||||
{
|
||||
return wl_proxy_get_user_data((struct wl_proxy *) wp_cursor_shape_device_v1);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
wp_cursor_shape_device_v1_get_version(struct wp_cursor_shape_device_v1 *wp_cursor_shape_device_v1)
|
||||
{
|
||||
return wl_proxy_get_version((struct wl_proxy *) wp_cursor_shape_device_v1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_cursor_shape_device_v1
|
||||
*
|
||||
* Destroy the cursor shape device.
|
||||
*
|
||||
* The device cursor shape remains unchanged.
|
||||
*/
|
||||
static inline void
|
||||
wp_cursor_shape_device_v1_destroy(struct wp_cursor_shape_device_v1 *wp_cursor_shape_device_v1)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) wp_cursor_shape_device_v1,
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wp_cursor_shape_device_v1), WL_MARSHAL_FLAG_DESTROY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_cursor_shape_device_v1
|
||||
*
|
||||
* Sets the device cursor to the specified shape. The compositor will
|
||||
* change the cursor image based on the specified shape.
|
||||
*
|
||||
* The cursor actually changes only if the input device focus is one of
|
||||
* the requesting client's surfaces. If any, the previous cursor image
|
||||
* (surface or shape) is replaced.
|
||||
*
|
||||
* The "shape" argument must be a valid enum entry, otherwise the
|
||||
* invalid_shape protocol error is raised.
|
||||
*
|
||||
* This is similar to the wl_pointer.set_cursor and
|
||||
* zwp_tablet_tool_v2.set_cursor requests, but this request accepts a
|
||||
* shape instead of contents in the form of a surface. Clients can mix
|
||||
* set_cursor and set_shape requests.
|
||||
*
|
||||
* The serial parameter must match the latest wl_pointer.enter or
|
||||
* zwp_tablet_tool_v2.proximity_in serial number sent to the client.
|
||||
* Otherwise the request will be ignored.
|
||||
*/
|
||||
static inline void
|
||||
wp_cursor_shape_device_v1_set_shape(struct wp_cursor_shape_device_v1 *wp_cursor_shape_device_v1, uint32_t serial, uint32_t shape)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) wp_cursor_shape_device_v1,
|
||||
WP_CURSOR_SHAPE_DEVICE_V1_SET_SHAPE, NULL, wl_proxy_get_version((struct wl_proxy *) wp_cursor_shape_device_v1), 0, serial, shape);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright 2018 The Chromium Authors
|
||||
* Copyright 2023 Simon Ser
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define WL_PRIVATE
|
||||
#endif
|
||||
|
||||
extern const struct wl_interface wl_pointer_interface;
|
||||
extern const struct wl_interface wp_cursor_shape_device_v1_interface;
|
||||
extern const struct wl_interface zwp_tablet_tool_v2_interface;
|
||||
|
||||
static const struct wl_interface *cursor_shape_v1_types[] = {
|
||||
NULL,
|
||||
NULL,
|
||||
&wp_cursor_shape_device_v1_interface,
|
||||
&wl_pointer_interface,
|
||||
&wp_cursor_shape_device_v1_interface,
|
||||
&zwp_tablet_tool_v2_interface,
|
||||
};
|
||||
|
||||
static const struct wl_message wp_cursor_shape_manager_v1_requests[] = {
|
||||
{ "destroy", "", cursor_shape_v1_types + 0 },
|
||||
{ "get_pointer", "no", cursor_shape_v1_types + 2 },
|
||||
{ "get_tablet_tool_v2", "no", cursor_shape_v1_types + 4 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface wp_cursor_shape_manager_v1_interface = {
|
||||
"wp_cursor_shape_manager_v1", 2,
|
||||
3, wp_cursor_shape_manager_v1_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message wp_cursor_shape_device_v1_requests[] = {
|
||||
{ "destroy", "", cursor_shape_v1_types + 0 },
|
||||
{ "set_shape", "uu", cursor_shape_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface wp_cursor_shape_device_v1_interface = {
|
||||
"wp_cursor_shape_device_v1", 2,
|
||||
2, wp_cursor_shape_device_v1_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,264 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
#ifndef FRACTIONAL_SCALE_V1_CLIENT_PROTOCOL_H
|
||||
#define FRACTIONAL_SCALE_V1_CLIENT_PROTOCOL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "wayland-client.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @page page_fractional_scale_v1 The fractional_scale_v1 protocol
|
||||
* Protocol for requesting fractional surface scales
|
||||
*
|
||||
* @section page_desc_fractional_scale_v1 Description
|
||||
*
|
||||
* This protocol allows a compositor to suggest for surfaces to render at
|
||||
* fractional scales.
|
||||
*
|
||||
* A client can submit scaled content by utilizing wp_viewport. This is done by
|
||||
* creating a wp_viewport object for the surface and setting the destination
|
||||
* rectangle to the surface size before the scale factor is applied.
|
||||
*
|
||||
* The buffer size is calculated by multiplying the surface size by the
|
||||
* intended scale.
|
||||
*
|
||||
* The wl_surface buffer scale should remain set to 1.
|
||||
*
|
||||
* If a surface has a surface-local size of 100 px by 50 px and wishes to
|
||||
* submit buffers with a scale of 1.5, then a buffer of 150px by 75 px should
|
||||
* be used and the wp_viewport destination rectangle should be 100 px by 50 px.
|
||||
*
|
||||
* For toplevel surfaces, the size is rounded halfway away from zero. The
|
||||
* rounding algorithm for subsurface position and size is not defined.
|
||||
*
|
||||
* @section page_ifaces_fractional_scale_v1 Interfaces
|
||||
* - @subpage page_iface_wp_fractional_scale_manager_v1 - fractional surface scale information
|
||||
* - @subpage page_iface_wp_fractional_scale_v1 - fractional scale interface to a wl_surface
|
||||
* @section page_copyright_fractional_scale_v1 Copyright
|
||||
* <pre>
|
||||
*
|
||||
* Copyright © 2022 Kenny Levinsen
|
||||
*
|
||||
* 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_surface;
|
||||
struct wp_fractional_scale_manager_v1;
|
||||
struct wp_fractional_scale_v1;
|
||||
|
||||
#ifndef WP_FRACTIONAL_SCALE_MANAGER_V1_INTERFACE
|
||||
#define WP_FRACTIONAL_SCALE_MANAGER_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_wp_fractional_scale_manager_v1 wp_fractional_scale_manager_v1
|
||||
* @section page_iface_wp_fractional_scale_manager_v1_desc Description
|
||||
*
|
||||
* A global interface for requesting surfaces to use fractional scales.
|
||||
* @section page_iface_wp_fractional_scale_manager_v1_api API
|
||||
* See @ref iface_wp_fractional_scale_manager_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_wp_fractional_scale_manager_v1 The wp_fractional_scale_manager_v1 interface
|
||||
*
|
||||
* A global interface for requesting surfaces to use fractional scales.
|
||||
*/
|
||||
extern const struct wl_interface wp_fractional_scale_manager_v1_interface;
|
||||
#endif
|
||||
#ifndef WP_FRACTIONAL_SCALE_V1_INTERFACE
|
||||
#define WP_FRACTIONAL_SCALE_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_wp_fractional_scale_v1 wp_fractional_scale_v1
|
||||
* @section page_iface_wp_fractional_scale_v1_desc Description
|
||||
*
|
||||
* An additional interface to a wl_surface object which allows the compositor
|
||||
* to inform the client of the preferred scale.
|
||||
* @section page_iface_wp_fractional_scale_v1_api API
|
||||
* See @ref iface_wp_fractional_scale_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_wp_fractional_scale_v1 The wp_fractional_scale_v1 interface
|
||||
*
|
||||
* An additional interface to a wl_surface object which allows the compositor
|
||||
* to inform the client of the preferred scale.
|
||||
*/
|
||||
extern const struct wl_interface wp_fractional_scale_v1_interface;
|
||||
#endif
|
||||
|
||||
#ifndef WP_FRACTIONAL_SCALE_MANAGER_V1_ERROR_ENUM
|
||||
#define WP_FRACTIONAL_SCALE_MANAGER_V1_ERROR_ENUM
|
||||
enum wp_fractional_scale_manager_v1_error {
|
||||
/**
|
||||
* the surface already has a fractional_scale object associated
|
||||
*/
|
||||
WP_FRACTIONAL_SCALE_MANAGER_V1_ERROR_FRACTIONAL_SCALE_EXISTS = 0,
|
||||
};
|
||||
#endif /* WP_FRACTIONAL_SCALE_MANAGER_V1_ERROR_ENUM */
|
||||
|
||||
#define WP_FRACTIONAL_SCALE_MANAGER_V1_DESTROY 0
|
||||
#define WP_FRACTIONAL_SCALE_MANAGER_V1_GET_FRACTIONAL_SCALE 1
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_fractional_scale_manager_v1
|
||||
*/
|
||||
#define WP_FRACTIONAL_SCALE_MANAGER_V1_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_wp_fractional_scale_manager_v1
|
||||
*/
|
||||
#define WP_FRACTIONAL_SCALE_MANAGER_V1_GET_FRACTIONAL_SCALE_SINCE_VERSION 1
|
||||
|
||||
/** @ingroup iface_wp_fractional_scale_manager_v1 */
|
||||
static inline void
|
||||
wp_fractional_scale_manager_v1_set_user_data(struct wp_fractional_scale_manager_v1 *wp_fractional_scale_manager_v1, void *user_data)
|
||||
{
|
||||
wl_proxy_set_user_data((struct wl_proxy *) wp_fractional_scale_manager_v1, user_data);
|
||||
}
|
||||
|
||||
/** @ingroup iface_wp_fractional_scale_manager_v1 */
|
||||
static inline void *
|
||||
wp_fractional_scale_manager_v1_get_user_data(struct wp_fractional_scale_manager_v1 *wp_fractional_scale_manager_v1)
|
||||
{
|
||||
return wl_proxy_get_user_data((struct wl_proxy *) wp_fractional_scale_manager_v1);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
wp_fractional_scale_manager_v1_get_version(struct wp_fractional_scale_manager_v1 *wp_fractional_scale_manager_v1)
|
||||
{
|
||||
return wl_proxy_get_version((struct wl_proxy *) wp_fractional_scale_manager_v1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_fractional_scale_manager_v1
|
||||
*
|
||||
* Informs the server that the client will not be using this protocol
|
||||
* object anymore. This does not affect any other objects,
|
||||
* wp_fractional_scale_v1 objects included.
|
||||
*/
|
||||
static inline void
|
||||
wp_fractional_scale_manager_v1_destroy(struct wp_fractional_scale_manager_v1 *wp_fractional_scale_manager_v1)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) wp_fractional_scale_manager_v1,
|
||||
WP_FRACTIONAL_SCALE_MANAGER_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wp_fractional_scale_manager_v1), WL_MARSHAL_FLAG_DESTROY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_fractional_scale_manager_v1
|
||||
*
|
||||
* Create an add-on object for the the wl_surface to let the compositor
|
||||
* request fractional scales. If the given wl_surface already has a
|
||||
* wp_fractional_scale_v1 object associated, the fractional_scale_exists
|
||||
* protocol error is raised.
|
||||
*/
|
||||
static inline struct wp_fractional_scale_v1 *
|
||||
wp_fractional_scale_manager_v1_get_fractional_scale(struct wp_fractional_scale_manager_v1 *wp_fractional_scale_manager_v1, struct wl_surface *surface)
|
||||
{
|
||||
struct wl_proxy *id;
|
||||
|
||||
id = wl_proxy_marshal_flags((struct wl_proxy *) wp_fractional_scale_manager_v1,
|
||||
WP_FRACTIONAL_SCALE_MANAGER_V1_GET_FRACTIONAL_SCALE, &wp_fractional_scale_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_fractional_scale_manager_v1), 0, NULL, surface);
|
||||
|
||||
return (struct wp_fractional_scale_v1 *) id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_fractional_scale_v1
|
||||
* @struct wp_fractional_scale_v1_listener
|
||||
*/
|
||||
struct wp_fractional_scale_v1_listener {
|
||||
/**
|
||||
* notify of new preferred scale
|
||||
*
|
||||
* Notification of a new preferred scale for this surface that
|
||||
* the compositor suggests that the client should use.
|
||||
*
|
||||
* The sent scale is the numerator of a fraction with a denominator
|
||||
* of 120.
|
||||
* @param scale the new preferred scale
|
||||
*/
|
||||
void (*preferred_scale)(void *data,
|
||||
struct wp_fractional_scale_v1 *wp_fractional_scale_v1,
|
||||
uint32_t scale);
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_fractional_scale_v1
|
||||
*/
|
||||
static inline int
|
||||
wp_fractional_scale_v1_add_listener(struct wp_fractional_scale_v1 *wp_fractional_scale_v1,
|
||||
const struct wp_fractional_scale_v1_listener *listener, void *data)
|
||||
{
|
||||
return wl_proxy_add_listener((struct wl_proxy *) wp_fractional_scale_v1,
|
||||
(void (**)(void)) listener, data);
|
||||
}
|
||||
|
||||
#define WP_FRACTIONAL_SCALE_V1_DESTROY 0
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_fractional_scale_v1
|
||||
*/
|
||||
#define WP_FRACTIONAL_SCALE_V1_PREFERRED_SCALE_SINCE_VERSION 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_fractional_scale_v1
|
||||
*/
|
||||
#define WP_FRACTIONAL_SCALE_V1_DESTROY_SINCE_VERSION 1
|
||||
|
||||
/** @ingroup iface_wp_fractional_scale_v1 */
|
||||
static inline void
|
||||
wp_fractional_scale_v1_set_user_data(struct wp_fractional_scale_v1 *wp_fractional_scale_v1, void *user_data)
|
||||
{
|
||||
wl_proxy_set_user_data((struct wl_proxy *) wp_fractional_scale_v1, user_data);
|
||||
}
|
||||
|
||||
/** @ingroup iface_wp_fractional_scale_v1 */
|
||||
static inline void *
|
||||
wp_fractional_scale_v1_get_user_data(struct wp_fractional_scale_v1 *wp_fractional_scale_v1)
|
||||
{
|
||||
return wl_proxy_get_user_data((struct wl_proxy *) wp_fractional_scale_v1);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
wp_fractional_scale_v1_get_version(struct wp_fractional_scale_v1 *wp_fractional_scale_v1)
|
||||
{
|
||||
return wl_proxy_get_version((struct wl_proxy *) wp_fractional_scale_v1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_fractional_scale_v1
|
||||
*
|
||||
* Destroy the fractional scale object. When this object is destroyed,
|
||||
* preferred_scale events will no longer be sent.
|
||||
*/
|
||||
static inline void
|
||||
wp_fractional_scale_v1_destroy(struct wp_fractional_scale_v1 *wp_fractional_scale_v1)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) wp_fractional_scale_v1,
|
||||
WP_FRACTIONAL_SCALE_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wp_fractional_scale_v1), WL_MARSHAL_FLAG_DESTROY);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright © 2022 Kenny Levinsen
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define WL_PRIVATE
|
||||
#endif
|
||||
|
||||
extern const struct wl_interface wl_surface_interface;
|
||||
extern const struct wl_interface wp_fractional_scale_v1_interface;
|
||||
|
||||
static const struct wl_interface *fractional_scale_v1_types[] = {
|
||||
NULL,
|
||||
&wp_fractional_scale_v1_interface,
|
||||
&wl_surface_interface,
|
||||
};
|
||||
|
||||
static const struct wl_message wp_fractional_scale_manager_v1_requests[] = {
|
||||
{ "destroy", "", fractional_scale_v1_types + 0 },
|
||||
{ "get_fractional_scale", "no", fractional_scale_v1_types + 1 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface wp_fractional_scale_manager_v1_interface = {
|
||||
"wp_fractional_scale_manager_v1", 1,
|
||||
2, wp_fractional_scale_manager_v1_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message wp_fractional_scale_v1_requests[] = {
|
||||
{ "destroy", "", fractional_scale_v1_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message wp_fractional_scale_v1_events[] = {
|
||||
{ "preferred_scale", "u", fractional_scale_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface wp_fractional_scale_v1_interface = {
|
||||
"wp_fractional_scale_v1", 1,
|
||||
1, wp_fractional_scale_v1_requests,
|
||||
1, wp_fractional_scale_v1_events,
|
||||
};
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env -S v
|
||||
import log
|
||||
|
||||
fn sh(cmd string) {
|
||||
log.info('Executing: ❯ ${cmd}')
|
||||
print(execute_or_exit(cmd).output)
|
||||
}
|
||||
|
||||
fn gen_protocol(protocols_dir string, output_dir string, name string, path string) {
|
||||
log.info('Generating protocol: ${name}')
|
||||
sh('wayland-scanner client-header ${protocols_dir}/${path} ${output_dir}/${name}-client-protocol.h')
|
||||
sh('wayland-scanner private-code ${protocols_dir}/${path} ${output_dir}/${name}-protocol.c')
|
||||
}
|
||||
|
||||
protocols_dir := '/usr/share/wayland-protocols'
|
||||
output_dir := '.'
|
||||
protocols := {
|
||||
'xdg-shell': '/stable/xdg-shell/xdg-shell.xml'
|
||||
'viewporter': '/stable/viewporter/viewporter.xml'
|
||||
'fractional-scale-v1': '/staging/fractional-scale/fractional-scale-v1.xml'
|
||||
'cursor-shape-v1': '/staging/cursor-shape/cursor-shape-v1.xml'
|
||||
'xdg-toplevel-icon-v1': '/staging/xdg-toplevel-icon/xdg-toplevel-icon-v1.xml'
|
||||
'tablet-unstable-v2': '/unstable/tablet/tablet-unstable-v2.xml'
|
||||
'pointer-constraints-unstable-v1': '/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml'
|
||||
'relative-pointer-unstable-v1': '/unstable/relative-pointer/relative-pointer-unstable-v1.xml'
|
||||
'xdg-decoration-unstable-v1': '/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml'
|
||||
}
|
||||
|
||||
for protocol, path in protocols {
|
||||
gen_protocol(protocols_dir, output_dir, protocol, path)
|
||||
}
|
||||
@@ -0,0 +1,662 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
#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;
|
||||
|
||||
#ifndef ZWP_POINTER_CONSTRAINTS_V1_INTERFACE
|
||||
#define ZWP_POINTER_CONSTRAINTS_V1_INTERFACE
|
||||
/**
|
||||
* @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;
|
||||
#endif
|
||||
#ifndef ZWP_LOCKED_POINTER_V1_INTERFACE
|
||||
#define ZWP_LOCKED_POINTER_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;
|
||||
#endif
|
||||
#ifndef ZWP_CONFINED_POINTER_V1_INTERFACE
|
||||
#define ZWP_CONFINED_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;
|
||||
#endif
|
||||
|
||||
#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
|
||||
* constraint lifetime
|
||||
*
|
||||
* These values represent different lifetime semantics. They are passed
|
||||
* as arguments to the factory requests to specify how the constraint
|
||||
* lifetimes should be managed.
|
||||
*/
|
||||
enum zwp_pointer_constraints_v1_lifetime {
|
||||
/**
|
||||
* the pointer constraint is defunct once deactivated
|
||||
*
|
||||
* A oneshot pointer constraint will never reactivate once it has
|
||||
* been deactivated. See the corresponding deactivation event
|
||||
* (wp_locked_pointer.unlocked and wp_confined_pointer.unconfined)
|
||||
* for details.
|
||||
*/
|
||||
ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_ONESHOT = 1,
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
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_flags((struct wl_proxy *) zwp_pointer_constraints_v1,
|
||||
ZWP_POINTER_CONSTRAINTS_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_pointer_constraints_v1), WL_MARSHAL_FLAG_DESTROY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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_flags((struct wl_proxy *) zwp_pointer_constraints_v1,
|
||||
ZWP_POINTER_CONSTRAINTS_V1_LOCK_POINTER, &zwp_locked_pointer_v1_interface, wl_proxy_get_version((struct wl_proxy *) zwp_pointer_constraints_v1), 0, 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_flags((struct wl_proxy *) zwp_pointer_constraints_v1,
|
||||
ZWP_POINTER_CONSTRAINTS_V1_CONFINE_POINTER, &zwp_confined_pointer_v1_interface, wl_proxy_get_version((struct wl_proxy *) zwp_pointer_constraints_v1), 0, 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_flags((struct wl_proxy *) zwp_locked_pointer_v1,
|
||||
ZWP_LOCKED_POINTER_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_locked_pointer_v1), WL_MARSHAL_FLAG_DESTROY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 state, see
|
||||
* wl_surface.commit.
|
||||
*/
|
||||
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_flags((struct wl_proxy *) zwp_locked_pointer_v1,
|
||||
ZWP_LOCKED_POINTER_V1_SET_CURSOR_POSITION_HINT, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_locked_pointer_v1), 0, 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, see wl_surface.commit.
|
||||
*
|
||||
* 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_flags((struct wl_proxy *) zwp_locked_pointer_v1,
|
||||
ZWP_LOCKED_POINTER_V1_SET_REGION, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_locked_pointer_v1), 0, 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_flags((struct wl_proxy *) zwp_confined_pointer_v1,
|
||||
ZWP_CONFINED_POINTER_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_confined_pointer_v1), WL_MARSHAL_FLAG_DESTROY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_confined_pointer_v1
|
||||
*
|
||||
* Set a new region used to confine the pointer.
|
||||
*
|
||||
* The new confine region is double-buffered, see wl_surface.commit.
|
||||
*
|
||||
* 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_flags((struct wl_proxy *) zwp_confined_pointer_v1,
|
||||
ZWP_CONFINED_POINTER_V1_SET_REGION, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_confined_pointer_v1), 0, region);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,109 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define WL_PRIVATE
|
||||
#endif
|
||||
|
||||
extern const struct wl_interface wl_pointer_interface;
|
||||
extern const struct wl_interface wl_region_interface;
|
||||
extern const struct wl_interface wl_surface_interface;
|
||||
extern const struct wl_interface zwp_confined_pointer_v1_interface;
|
||||
extern const struct wl_interface zwp_locked_pointer_v1_interface;
|
||||
|
||||
static const struct wl_interface *pointer_constraints_unstable_v1_types[] = {
|
||||
NULL,
|
||||
NULL,
|
||||
&zwp_locked_pointer_v1_interface,
|
||||
&wl_surface_interface,
|
||||
&wl_pointer_interface,
|
||||
&wl_region_interface,
|
||||
NULL,
|
||||
&zwp_confined_pointer_v1_interface,
|
||||
&wl_surface_interface,
|
||||
&wl_pointer_interface,
|
||||
&wl_region_interface,
|
||||
NULL,
|
||||
&wl_region_interface,
|
||||
&wl_region_interface,
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_pointer_constraints_v1_requests[] = {
|
||||
{ "destroy", "", pointer_constraints_unstable_v1_types + 0 },
|
||||
{ "lock_pointer", "noo?ou", pointer_constraints_unstable_v1_types + 2 },
|
||||
{ "confine_pointer", "noo?ou", pointer_constraints_unstable_v1_types + 7 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwp_pointer_constraints_v1_interface = {
|
||||
"zwp_pointer_constraints_v1", 1,
|
||||
3, zwp_pointer_constraints_v1_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_locked_pointer_v1_requests[] = {
|
||||
{ "destroy", "", pointer_constraints_unstable_v1_types + 0 },
|
||||
{ "set_cursor_position_hint", "ff", pointer_constraints_unstable_v1_types + 0 },
|
||||
{ "set_region", "?o", pointer_constraints_unstable_v1_types + 12 },
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_locked_pointer_v1_events[] = {
|
||||
{ "locked", "", pointer_constraints_unstable_v1_types + 0 },
|
||||
{ "unlocked", "", pointer_constraints_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwp_locked_pointer_v1_interface = {
|
||||
"zwp_locked_pointer_v1", 1,
|
||||
3, zwp_locked_pointer_v1_requests,
|
||||
2, zwp_locked_pointer_v1_events,
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_confined_pointer_v1_requests[] = {
|
||||
{ "destroy", "", pointer_constraints_unstable_v1_types + 0 },
|
||||
{ "set_region", "?o", pointer_constraints_unstable_v1_types + 13 },
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_confined_pointer_v1_events[] = {
|
||||
{ "confined", "", pointer_constraints_unstable_v1_types + 0 },
|
||||
{ "unconfined", "", pointer_constraints_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwp_confined_pointer_v1_interface = {
|
||||
"zwp_confined_pointer_v1", 1,
|
||||
2, zwp_confined_pointer_v1_requests,
|
||||
2, zwp_confined_pointer_v1_events,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,297 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
#ifndef RELATIVE_POINTER_UNSTABLE_V1_CLIENT_PROTOCOL_H
|
||||
#define RELATIVE_POINTER_UNSTABLE_V1_CLIENT_PROTOCOL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "wayland-client.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @page page_relative_pointer_unstable_v1 The relative_pointer_unstable_v1 protocol
|
||||
* protocol for relative pointer motion events
|
||||
*
|
||||
* @section page_desc_relative_pointer_unstable_v1 Description
|
||||
*
|
||||
* This protocol specifies a set of interfaces used for making clients able to
|
||||
* receive relative pointer events not obstructed by barriers (such as the
|
||||
* monitor edge or other pointer barriers).
|
||||
*
|
||||
* To start receiving relative pointer events, a client must first bind the
|
||||
* global interface "wp_relative_pointer_manager" which, if a compositor
|
||||
* supports relative pointer motion events, is exposed by the registry. After
|
||||
* having created the relative pointer manager proxy object, the client uses
|
||||
* it to create the actual relative pointer object using the
|
||||
* "get_relative_pointer" request given a wl_pointer. The relative pointer
|
||||
* motion events will then, when applicable, be transmitted via the proxy of
|
||||
* the newly created relative pointer object. See the documentation of the
|
||||
* relative pointer interface 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_relative_pointer_unstable_v1 Interfaces
|
||||
* - @subpage page_iface_zwp_relative_pointer_manager_v1 - get relative pointer objects
|
||||
* - @subpage page_iface_zwp_relative_pointer_v1 - relative pointer object
|
||||
* @section page_copyright_relative_pointer_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 zwp_relative_pointer_manager_v1;
|
||||
struct zwp_relative_pointer_v1;
|
||||
|
||||
#ifndef ZWP_RELATIVE_POINTER_MANAGER_V1_INTERFACE
|
||||
#define ZWP_RELATIVE_POINTER_MANAGER_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_zwp_relative_pointer_manager_v1 zwp_relative_pointer_manager_v1
|
||||
* @section page_iface_zwp_relative_pointer_manager_v1_desc Description
|
||||
*
|
||||
* A global interface used for getting the relative pointer object for a
|
||||
* given pointer.
|
||||
* @section page_iface_zwp_relative_pointer_manager_v1_api API
|
||||
* See @ref iface_zwp_relative_pointer_manager_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_zwp_relative_pointer_manager_v1 The zwp_relative_pointer_manager_v1 interface
|
||||
*
|
||||
* A global interface used for getting the relative pointer object for a
|
||||
* given pointer.
|
||||
*/
|
||||
extern const struct wl_interface zwp_relative_pointer_manager_v1_interface;
|
||||
#endif
|
||||
#ifndef ZWP_RELATIVE_POINTER_V1_INTERFACE
|
||||
#define ZWP_RELATIVE_POINTER_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_zwp_relative_pointer_v1 zwp_relative_pointer_v1
|
||||
* @section page_iface_zwp_relative_pointer_v1_desc Description
|
||||
*
|
||||
* A wp_relative_pointer object is an extension to the wl_pointer interface
|
||||
* used for emitting relative pointer events. It shares the same focus as
|
||||
* wl_pointer objects of the same seat and will only emit events when it has
|
||||
* focus.
|
||||
* @section page_iface_zwp_relative_pointer_v1_api API
|
||||
* See @ref iface_zwp_relative_pointer_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_zwp_relative_pointer_v1 The zwp_relative_pointer_v1 interface
|
||||
*
|
||||
* A wp_relative_pointer object is an extension to the wl_pointer interface
|
||||
* used for emitting relative pointer events. It shares the same focus as
|
||||
* wl_pointer objects of the same seat and will only emit events when it has
|
||||
* focus.
|
||||
*/
|
||||
extern const struct wl_interface zwp_relative_pointer_v1_interface;
|
||||
#endif
|
||||
|
||||
#define ZWP_RELATIVE_POINTER_MANAGER_V1_DESTROY 0
|
||||
#define ZWP_RELATIVE_POINTER_MANAGER_V1_GET_RELATIVE_POINTER 1
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_relative_pointer_manager_v1
|
||||
*/
|
||||
#define ZWP_RELATIVE_POINTER_MANAGER_V1_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zwp_relative_pointer_manager_v1
|
||||
*/
|
||||
#define ZWP_RELATIVE_POINTER_MANAGER_V1_GET_RELATIVE_POINTER_SINCE_VERSION 1
|
||||
|
||||
/** @ingroup iface_zwp_relative_pointer_manager_v1 */
|
||||
static inline void
|
||||
zwp_relative_pointer_manager_v1_set_user_data(struct zwp_relative_pointer_manager_v1 *zwp_relative_pointer_manager_v1, void *user_data)
|
||||
{
|
||||
wl_proxy_set_user_data((struct wl_proxy *) zwp_relative_pointer_manager_v1, user_data);
|
||||
}
|
||||
|
||||
/** @ingroup iface_zwp_relative_pointer_manager_v1 */
|
||||
static inline void *
|
||||
zwp_relative_pointer_manager_v1_get_user_data(struct zwp_relative_pointer_manager_v1 *zwp_relative_pointer_manager_v1)
|
||||
{
|
||||
return wl_proxy_get_user_data((struct wl_proxy *) zwp_relative_pointer_manager_v1);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
zwp_relative_pointer_manager_v1_get_version(struct zwp_relative_pointer_manager_v1 *zwp_relative_pointer_manager_v1)
|
||||
{
|
||||
return wl_proxy_get_version((struct wl_proxy *) zwp_relative_pointer_manager_v1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_relative_pointer_manager_v1
|
||||
*
|
||||
* Used by the client to notify the server that it will no longer use this
|
||||
* relative pointer manager object.
|
||||
*/
|
||||
static inline void
|
||||
zwp_relative_pointer_manager_v1_destroy(struct zwp_relative_pointer_manager_v1 *zwp_relative_pointer_manager_v1)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) zwp_relative_pointer_manager_v1,
|
||||
ZWP_RELATIVE_POINTER_MANAGER_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_relative_pointer_manager_v1), WL_MARSHAL_FLAG_DESTROY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_relative_pointer_manager_v1
|
||||
*
|
||||
* Create a relative pointer interface given a wl_pointer object. See the
|
||||
* wp_relative_pointer interface for more details.
|
||||
*/
|
||||
static inline struct zwp_relative_pointer_v1 *
|
||||
zwp_relative_pointer_manager_v1_get_relative_pointer(struct zwp_relative_pointer_manager_v1 *zwp_relative_pointer_manager_v1, struct wl_pointer *pointer)
|
||||
{
|
||||
struct wl_proxy *id;
|
||||
|
||||
id = wl_proxy_marshal_flags((struct wl_proxy *) zwp_relative_pointer_manager_v1,
|
||||
ZWP_RELATIVE_POINTER_MANAGER_V1_GET_RELATIVE_POINTER, &zwp_relative_pointer_v1_interface, wl_proxy_get_version((struct wl_proxy *) zwp_relative_pointer_manager_v1), 0, NULL, pointer);
|
||||
|
||||
return (struct zwp_relative_pointer_v1 *) id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_relative_pointer_v1
|
||||
* @struct zwp_relative_pointer_v1_listener
|
||||
*/
|
||||
struct zwp_relative_pointer_v1_listener {
|
||||
/**
|
||||
* relative pointer motion
|
||||
*
|
||||
* Relative x/y pointer motion from the pointer of the seat
|
||||
* associated with this object.
|
||||
*
|
||||
* A relative motion is in the same dimension as regular wl_pointer
|
||||
* motion events, except they do not represent an absolute
|
||||
* position. For example, moving a pointer from (x, y) to (x', y')
|
||||
* would have the equivalent relative motion (x' - x, y' - y). If a
|
||||
* pointer motion caused the absolute pointer position to be
|
||||
* clipped by for example the edge of the monitor, the relative
|
||||
* motion is unaffected by the clipping and will represent the
|
||||
* unclipped motion.
|
||||
*
|
||||
* This event also contains non-accelerated motion deltas. The
|
||||
* non-accelerated delta is, when applicable, the regular pointer
|
||||
* motion delta as it was before having applied motion acceleration
|
||||
* and other transformations such as normalization.
|
||||
*
|
||||
* Note that the non-accelerated delta does not represent 'raw'
|
||||
* events as they were read from some device. Pointer motion
|
||||
* acceleration is device- and configuration-specific and
|
||||
* non-accelerated deltas and accelerated deltas may have the same
|
||||
* value on some devices.
|
||||
*
|
||||
* Relative motions are not coupled to wl_pointer.motion events,
|
||||
* and can be sent in combination with such events, but also
|
||||
* independently. There may also be scenarios where
|
||||
* wl_pointer.motion is sent, but there is no relative motion. The
|
||||
* order of an absolute and relative motion event originating from
|
||||
* the same physical motion is not guaranteed.
|
||||
*
|
||||
* If the client needs button events or focus state, it can receive
|
||||
* them from a wl_pointer object of the same seat that the
|
||||
* wp_relative_pointer object is associated with.
|
||||
* @param utime_hi high 32 bits of a 64 bit timestamp with microsecond granularity
|
||||
* @param utime_lo low 32 bits of a 64 bit timestamp with microsecond granularity
|
||||
* @param dx the x component of the motion vector
|
||||
* @param dy the y component of the motion vector
|
||||
* @param dx_unaccel the x component of the unaccelerated motion vector
|
||||
* @param dy_unaccel the y component of the unaccelerated motion vector
|
||||
*/
|
||||
void (*relative_motion)(void *data,
|
||||
struct zwp_relative_pointer_v1 *zwp_relative_pointer_v1,
|
||||
uint32_t utime_hi,
|
||||
uint32_t utime_lo,
|
||||
wl_fixed_t dx,
|
||||
wl_fixed_t dy,
|
||||
wl_fixed_t dx_unaccel,
|
||||
wl_fixed_t dy_unaccel);
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_relative_pointer_v1
|
||||
*/
|
||||
static inline int
|
||||
zwp_relative_pointer_v1_add_listener(struct zwp_relative_pointer_v1 *zwp_relative_pointer_v1,
|
||||
const struct zwp_relative_pointer_v1_listener *listener, void *data)
|
||||
{
|
||||
return wl_proxy_add_listener((struct wl_proxy *) zwp_relative_pointer_v1,
|
||||
(void (**)(void)) listener, data);
|
||||
}
|
||||
|
||||
#define ZWP_RELATIVE_POINTER_V1_DESTROY 0
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_relative_pointer_v1
|
||||
*/
|
||||
#define ZWP_RELATIVE_POINTER_V1_RELATIVE_MOTION_SINCE_VERSION 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_relative_pointer_v1
|
||||
*/
|
||||
#define ZWP_RELATIVE_POINTER_V1_DESTROY_SINCE_VERSION 1
|
||||
|
||||
/** @ingroup iface_zwp_relative_pointer_v1 */
|
||||
static inline void
|
||||
zwp_relative_pointer_v1_set_user_data(struct zwp_relative_pointer_v1 *zwp_relative_pointer_v1, void *user_data)
|
||||
{
|
||||
wl_proxy_set_user_data((struct wl_proxy *) zwp_relative_pointer_v1, user_data);
|
||||
}
|
||||
|
||||
/** @ingroup iface_zwp_relative_pointer_v1 */
|
||||
static inline void *
|
||||
zwp_relative_pointer_v1_get_user_data(struct zwp_relative_pointer_v1 *zwp_relative_pointer_v1)
|
||||
{
|
||||
return wl_proxy_get_user_data((struct wl_proxy *) zwp_relative_pointer_v1);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
zwp_relative_pointer_v1_get_version(struct zwp_relative_pointer_v1 *zwp_relative_pointer_v1)
|
||||
{
|
||||
return wl_proxy_get_version((struct wl_proxy *) zwp_relative_pointer_v1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zwp_relative_pointer_v1
|
||||
*/
|
||||
static inline void
|
||||
zwp_relative_pointer_v1_destroy(struct zwp_relative_pointer_v1 *zwp_relative_pointer_v1)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) zwp_relative_pointer_v1,
|
||||
ZWP_RELATIVE_POINTER_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_relative_pointer_v1), WL_MARSHAL_FLAG_DESTROY);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,80 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define WL_PRIVATE
|
||||
#endif
|
||||
|
||||
extern const struct wl_interface wl_pointer_interface;
|
||||
extern const struct wl_interface zwp_relative_pointer_v1_interface;
|
||||
|
||||
static const struct wl_interface *relative_pointer_unstable_v1_types[] = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&zwp_relative_pointer_v1_interface,
|
||||
&wl_pointer_interface,
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_relative_pointer_manager_v1_requests[] = {
|
||||
{ "destroy", "", relative_pointer_unstable_v1_types + 0 },
|
||||
{ "get_relative_pointer", "no", relative_pointer_unstable_v1_types + 6 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwp_relative_pointer_manager_v1_interface = {
|
||||
"zwp_relative_pointer_manager_v1", 1,
|
||||
2, zwp_relative_pointer_manager_v1_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_relative_pointer_v1_requests[] = {
|
||||
{ "destroy", "", relative_pointer_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_relative_pointer_v1_events[] = {
|
||||
{ "relative_motion", "uuffff", relative_pointer_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwp_relative_pointer_v1_interface = {
|
||||
"zwp_relative_pointer_v1", 1,
|
||||
1, zwp_relative_pointer_v1_requests,
|
||||
1, zwp_relative_pointer_v1_events,
|
||||
};
|
||||
|
||||
Vendored
+14518
-9371
File diff suppressed because it is too large.
Load diff
Vendored
+334
@@ -0,0 +1,334 @@
|
||||
#if defined(SOKOL_IMPL) && !defined(SOKOL_LOG_IMPL)
|
||||
#define SOKOL_LOG_IMPL
|
||||
#endif
|
||||
#ifndef SOKOL_LOG_INCLUDED
|
||||
/*
|
||||
sokol_log.h -- common logging callback for sokol headers
|
||||
|
||||
Project URL: https://github.com/floooh/sokol
|
||||
|
||||
Example code: https://github.com/floooh/sokol-samples
|
||||
|
||||
Do this:
|
||||
#define SOKOL_IMPL or
|
||||
#define SOKOL_LOG_IMPL
|
||||
before you include this file in *one* C or C++ file to create the
|
||||
implementation.
|
||||
|
||||
Optionally provide the following defines when building the implementation:
|
||||
|
||||
SOKOL_ASSERT(c) - your own assert macro (default: assert(c))
|
||||
SOKOL_UNREACHABLE() - a guard macro for unreachable code (default: assert(false))
|
||||
SOKOL_LOG_API_DECL - public function declaration prefix (default: extern)
|
||||
SOKOL_API_DECL - same as SOKOL_GFX_API_DECL
|
||||
SOKOL_API_IMPL - public function implementation prefix (default: -)
|
||||
|
||||
Optionally define the following for verbose output:
|
||||
|
||||
SOKOL_DEBUG - by default this is defined if NDEBUG is not defined
|
||||
|
||||
|
||||
OVERVIEW
|
||||
========
|
||||
sokol_log.h provides a default logging callback for other sokol headers.
|
||||
|
||||
To use the default log callback, just include sokol_log.h and provide
|
||||
a function pointer to the 'slog_func' function when setting up the
|
||||
sokol library:
|
||||
|
||||
For instance with sokol_audio.h:
|
||||
|
||||
#include "sokol_log.h"
|
||||
...
|
||||
saudio_setup(&(saudio_desc){ .logger.func = slog_func });
|
||||
|
||||
Logging output goes to stderr and/or a platform specific logging subsystem
|
||||
(which means that in some scenarios you might see logging messages duplicated):
|
||||
|
||||
- Windows: stderr + OutputDebugStringA()
|
||||
- macOS/iOS/Linux: stderr + syslog()
|
||||
- Emscripten: console.info()/warn()/error()
|
||||
- Android: __android_log_write()
|
||||
|
||||
On Windows with sokol_app.h also note the runtime config items to make
|
||||
stdout/stderr output visible on the console for WinMain() applications
|
||||
via sapp_desc.win32.console_attach or sapp_desc.win32.console_create,
|
||||
however when running in a debugger on Windows, the logging output should
|
||||
show up on the debug output UI panel.
|
||||
|
||||
In debug mode, a log message might look like this:
|
||||
|
||||
[sspine][error][id:12] /Users/floh/projects/sokol/util/sokol_spine.h:3472:0:
|
||||
SKELETON_DESC_NO_ATLAS: no atlas object provided in sspine_skeleton_desc.atlas
|
||||
|
||||
The source path and line number is formatted like compiler errors, in some IDEs (like VSCode)
|
||||
such error messages are clickable.
|
||||
|
||||
In release mode, logging is less verbose as to not bloat the executable with string data, but you still get
|
||||
enough information to identify the type and location of an error:
|
||||
|
||||
[sspine][error][id:12][line:3472]
|
||||
|
||||
RULES FOR WRITING YOUR OWN LOGGING FUNCTION
|
||||
===========================================
|
||||
- must be re-entrant because it might be called from different threads
|
||||
- must treat **all** provided string pointers as optional (can be null)
|
||||
- don't store the string pointers, copy the string data instead
|
||||
- must not return for log level panic
|
||||
|
||||
LICENSE
|
||||
=======
|
||||
zlib/libpng license
|
||||
|
||||
Copyright (c) 2023 Andre Weissflog
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the
|
||||
use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software in a
|
||||
product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not
|
||||
be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*/
|
||||
#define SOKOL_LOG_INCLUDED (1)
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(SOKOL_API_DECL) && !defined(SOKOL_LOG_API_DECL)
|
||||
#define SOKOL_LOG_API_DECL SOKOL_API_DECL
|
||||
#endif
|
||||
#ifndef SOKOL_LOG_API_DECL
|
||||
#if defined(_WIN32) && defined(SOKOL_DLL) && defined(SOKOL_LOG_IMPL)
|
||||
#define SOKOL_LOG_API_DECL __declspec(dllexport)
|
||||
#elif defined(_WIN32) && defined(SOKOL_DLL)
|
||||
#define SOKOL_LOG_API_DECL __declspec(dllimport)
|
||||
#else
|
||||
#define SOKOL_LOG_API_DECL extern
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
Plug this function into the 'logger.func' struct item when initializing any of the sokol
|
||||
headers. For instance for sokol_audio.h it would look like this:
|
||||
|
||||
saudio_setup(&(saudio_desc){
|
||||
.logger = {
|
||||
.func = slog_func
|
||||
}
|
||||
});
|
||||
*/
|
||||
SOKOL_LOG_API_DECL void slog_func(const char* tag, uint32_t log_level, uint32_t log_item, const char* message, uint32_t line_nr, const char* filename, void* user_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
#endif // SOKOL_LOG_INCLUDED
|
||||
|
||||
// ██ ███ ███ ██████ ██ ███████ ███ ███ ███████ ███ ██ ████████ █████ ████████ ██ ██████ ███ ██
|
||||
// ██ ████ ████ ██ ██ ██ ██ ████ ████ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██
|
||||
// ██ ██ ████ ██ ██████ ██ █████ ██ ████ ██ █████ ██ ██ ██ ██ ███████ ██ ██ ██ ██ ██ ██ ██
|
||||
// ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
||||
// ██ ██ ██ ██ ███████ ███████ ██ ██ ███████ ██ ████ ██ ██ ██ ██ ██ ██████ ██ ████
|
||||
//
|
||||
// >>implementation
|
||||
#ifdef SOKOL_LOG_IMPL
|
||||
#define SOKOL_LOG_IMPL_INCLUDED (1)
|
||||
|
||||
#ifndef SOKOL_API_IMPL
|
||||
#define SOKOL_API_IMPL
|
||||
#endif
|
||||
#ifndef SOKOL_DEBUG
|
||||
#ifndef NDEBUG
|
||||
#define SOKOL_DEBUG
|
||||
#endif
|
||||
#endif
|
||||
#ifndef SOKOL_ASSERT
|
||||
#include <assert.h>
|
||||
#define SOKOL_ASSERT(c) assert(c)
|
||||
#endif
|
||||
|
||||
#ifndef _SOKOL_PRIVATE
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#define _SOKOL_PRIVATE __attribute__((unused)) static
|
||||
#else
|
||||
#define _SOKOL_PRIVATE static
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef _SOKOL_UNUSED
|
||||
#define _SOKOL_UNUSED(x) (void)(x)
|
||||
#endif
|
||||
|
||||
// platform detection
|
||||
#if defined(__APPLE__)
|
||||
#define _SLOG_APPLE (1)
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
#define _SLOG_EMSCRIPTEN (1)
|
||||
#elif defined(_WIN32)
|
||||
#define _SLOG_WINDOWS (1)
|
||||
#elif defined(__ANDROID__)
|
||||
#define _SLOG_ANDROID (1)
|
||||
#elif defined(__linux__) || defined(__unix__)
|
||||
#define _SLOG_LINUX (1)
|
||||
#else
|
||||
#error "sokol_log.h: unknown platform"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h> // abort
|
||||
#include <stdio.h> // fputs
|
||||
#include <stddef.h> // size_t
|
||||
|
||||
#if defined(_SLOG_EMSCRIPTEN)
|
||||
#include <emscripten/emscripten.h>
|
||||
#elif defined(_SLOG_WINDOWS)
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#ifndef NOMINMAX
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#elif defined(_SLOG_ANDROID)
|
||||
#include <android/log.h>
|
||||
#elif defined(_SLOG_LINUX) || defined(_SLOG_APPLE)
|
||||
#include <syslog.h>
|
||||
#endif
|
||||
|
||||
// size of line buffer (on stack!) in bytes including terminating zero
|
||||
#define _SLOG_LINE_LENGTH (512)
|
||||
|
||||
_SOKOL_PRIVATE char* _slog_append(const char* str, char* dst, char* end) {
|
||||
if (str) {
|
||||
char c;
|
||||
while (((c = *str++) != 0) && (dst < (end - 1))) {
|
||||
*dst++ = c;
|
||||
}
|
||||
}
|
||||
*dst = 0;
|
||||
return dst;
|
||||
}
|
||||
|
||||
_SOKOL_PRIVATE char* _slog_itoa(uint32_t x, char* buf, size_t buf_size) {
|
||||
const size_t max_digits_and_null = 11;
|
||||
if (buf_size < max_digits_and_null) {
|
||||
return 0;
|
||||
}
|
||||
char* p = buf + max_digits_and_null;
|
||||
*--p = 0;
|
||||
do {
|
||||
*--p = '0' + (x % 10);
|
||||
x /= 10;
|
||||
} while (x != 0);
|
||||
return p;
|
||||
}
|
||||
|
||||
#if defined(_SLOG_EMSCRIPTEN)
|
||||
EM_JS(void, slog_js_log, (uint32_t level, const char* c_str), {
|
||||
const str = UTF8ToString(c_str);
|
||||
switch (level) {
|
||||
case 0: console.error(str); break;
|
||||
case 1: console.error(str); break;
|
||||
case 2: console.warn(str); break;
|
||||
default: console.info(str); break;
|
||||
}
|
||||
})
|
||||
#endif
|
||||
|
||||
SOKOL_API_IMPL void slog_func(const char* tag, uint32_t log_level, uint32_t log_item, const char* message, uint32_t line_nr, const char* filename, void* user_data) {
|
||||
_SOKOL_UNUSED(user_data);
|
||||
|
||||
const char* log_level_str;
|
||||
switch (log_level) {
|
||||
case 0: log_level_str = "panic"; break;
|
||||
case 1: log_level_str = "error"; break;
|
||||
case 2: log_level_str = "warning"; break;
|
||||
default: log_level_str = "info"; break;
|
||||
}
|
||||
|
||||
// build log output line
|
||||
char line_buf[_SLOG_LINE_LENGTH];
|
||||
char* str = line_buf;
|
||||
char* end = line_buf + sizeof(line_buf);
|
||||
char num_buf[32];
|
||||
if (tag) {
|
||||
str = _slog_append("[", str, end);
|
||||
str = _slog_append(tag, str, end);
|
||||
str = _slog_append("]", str, end);
|
||||
}
|
||||
str = _slog_append("[", str, end);
|
||||
str = _slog_append(log_level_str, str, end);
|
||||
str = _slog_append("]", str, end);
|
||||
str = _slog_append("[id:", str, end);
|
||||
str = _slog_append(_slog_itoa(log_item, num_buf, sizeof(num_buf)), str, end);
|
||||
str = _slog_append("]", str, end);
|
||||
// if a filename is provided, build a clickable log message that's compatible with compiler error messages
|
||||
if (filename) {
|
||||
str = _slog_append(" ", str, end);
|
||||
#if defined(_MSC_VER)
|
||||
// MSVC compiler error format
|
||||
str = _slog_append(filename, str, end);
|
||||
str = _slog_append("(", str, end);
|
||||
str = _slog_append(_slog_itoa(line_nr, num_buf, sizeof(num_buf)), str, end);
|
||||
str = _slog_append("): ", str, end);
|
||||
#else
|
||||
// gcc/clang compiler error format
|
||||
str = _slog_append(filename, str, end);
|
||||
str = _slog_append(":", str, end);
|
||||
str = _slog_append(_slog_itoa(line_nr, num_buf, sizeof(num_buf)), str, end);
|
||||
str = _slog_append(":0: ", str, end);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
str = _slog_append("[line:", str, end);
|
||||
str = _slog_append(_slog_itoa(line_nr, num_buf, sizeof(num_buf)), str, end);
|
||||
str = _slog_append("] ", str, end);
|
||||
}
|
||||
if (message) {
|
||||
str = _slog_append("\n\t", str, end);
|
||||
str = _slog_append(message, str, end);
|
||||
}
|
||||
str = _slog_append("\n\n", str, end);
|
||||
if (0 == log_level) {
|
||||
str = _slog_append("ABORTING because of [panic]\n", str, end);
|
||||
(void)str;
|
||||
}
|
||||
|
||||
// print to stderr?
|
||||
#if defined(_SLOG_LINUX) || defined(_SLOG_WINDOWS) || defined(_SLOG_APPLE)
|
||||
fputs(line_buf, stderr);
|
||||
#endif
|
||||
|
||||
// platform specific logging calls
|
||||
#if defined(_SLOG_WINDOWS)
|
||||
OutputDebugStringA(line_buf);
|
||||
#elif defined(_SLOG_ANDROID)
|
||||
int prio;
|
||||
switch (log_level) {
|
||||
case 0: prio = ANDROID_LOG_FATAL; break;
|
||||
case 1: prio = ANDROID_LOG_ERROR; break;
|
||||
case 2: prio = ANDROID_LOG_WARN; break;
|
||||
default: prio = ANDROID_LOG_INFO; break;
|
||||
}
|
||||
__android_log_write(prio, "SOKOL", line_buf);
|
||||
#elif defined(_SLOG_EMSCRIPTEN)
|
||||
slog_js_log(log_level, line_buf);
|
||||
#endif
|
||||
if (0 == log_level) {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
#endif // SOKOL_LOG_IMPL
|
||||
+2252
File diff suppressed because it is too large.
Load diff
+234
@@ -0,0 +1,234 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright 2014 © Stephen "Lyude" Chandler Paul
|
||||
* Copyright 2015-2016 © 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.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define WL_PRIVATE
|
||||
#endif
|
||||
|
||||
extern const struct wl_interface wl_seat_interface;
|
||||
extern const struct wl_interface wl_surface_interface;
|
||||
extern const struct wl_interface zwp_tablet_pad_group_v2_interface;
|
||||
extern const struct wl_interface zwp_tablet_pad_ring_v2_interface;
|
||||
extern const struct wl_interface zwp_tablet_pad_strip_v2_interface;
|
||||
extern const struct wl_interface zwp_tablet_pad_v2_interface;
|
||||
extern const struct wl_interface zwp_tablet_seat_v2_interface;
|
||||
extern const struct wl_interface zwp_tablet_tool_v2_interface;
|
||||
extern const struct wl_interface zwp_tablet_v2_interface;
|
||||
|
||||
static const struct wl_interface *tablet_unstable_v2_types[] = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&zwp_tablet_seat_v2_interface,
|
||||
&wl_seat_interface,
|
||||
&zwp_tablet_v2_interface,
|
||||
&zwp_tablet_tool_v2_interface,
|
||||
&zwp_tablet_pad_v2_interface,
|
||||
NULL,
|
||||
&wl_surface_interface,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&zwp_tablet_v2_interface,
|
||||
&wl_surface_interface,
|
||||
&zwp_tablet_pad_ring_v2_interface,
|
||||
&zwp_tablet_pad_strip_v2_interface,
|
||||
&zwp_tablet_pad_group_v2_interface,
|
||||
NULL,
|
||||
&zwp_tablet_v2_interface,
|
||||
&wl_surface_interface,
|
||||
NULL,
|
||||
&wl_surface_interface,
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_tablet_manager_v2_requests[] = {
|
||||
{ "get_tablet_seat", "no", tablet_unstable_v2_types + 3 },
|
||||
{ "destroy", "", tablet_unstable_v2_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwp_tablet_manager_v2_interface = {
|
||||
"zwp_tablet_manager_v2", 1,
|
||||
2, zwp_tablet_manager_v2_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_tablet_seat_v2_requests[] = {
|
||||
{ "destroy", "", tablet_unstable_v2_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_tablet_seat_v2_events[] = {
|
||||
{ "tablet_added", "n", tablet_unstable_v2_types + 5 },
|
||||
{ "tool_added", "n", tablet_unstable_v2_types + 6 },
|
||||
{ "pad_added", "n", tablet_unstable_v2_types + 7 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwp_tablet_seat_v2_interface = {
|
||||
"zwp_tablet_seat_v2", 1,
|
||||
1, zwp_tablet_seat_v2_requests,
|
||||
3, zwp_tablet_seat_v2_events,
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_tablet_tool_v2_requests[] = {
|
||||
{ "set_cursor", "u?oii", tablet_unstable_v2_types + 8 },
|
||||
{ "destroy", "", tablet_unstable_v2_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_tablet_tool_v2_events[] = {
|
||||
{ "type", "u", tablet_unstable_v2_types + 0 },
|
||||
{ "hardware_serial", "uu", tablet_unstable_v2_types + 0 },
|
||||
{ "hardware_id_wacom", "uu", tablet_unstable_v2_types + 0 },
|
||||
{ "capability", "u", tablet_unstable_v2_types + 0 },
|
||||
{ "done", "", tablet_unstable_v2_types + 0 },
|
||||
{ "removed", "", tablet_unstable_v2_types + 0 },
|
||||
{ "proximity_in", "uoo", tablet_unstable_v2_types + 12 },
|
||||
{ "proximity_out", "", tablet_unstable_v2_types + 0 },
|
||||
{ "down", "u", tablet_unstable_v2_types + 0 },
|
||||
{ "up", "", tablet_unstable_v2_types + 0 },
|
||||
{ "motion", "ff", tablet_unstable_v2_types + 0 },
|
||||
{ "pressure", "u", tablet_unstable_v2_types + 0 },
|
||||
{ "distance", "u", tablet_unstable_v2_types + 0 },
|
||||
{ "tilt", "ff", tablet_unstable_v2_types + 0 },
|
||||
{ "rotation", "f", tablet_unstable_v2_types + 0 },
|
||||
{ "slider", "i", tablet_unstable_v2_types + 0 },
|
||||
{ "wheel", "fi", tablet_unstable_v2_types + 0 },
|
||||
{ "button", "uuu", tablet_unstable_v2_types + 0 },
|
||||
{ "frame", "u", tablet_unstable_v2_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwp_tablet_tool_v2_interface = {
|
||||
"zwp_tablet_tool_v2", 1,
|
||||
2, zwp_tablet_tool_v2_requests,
|
||||
19, zwp_tablet_tool_v2_events,
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_tablet_v2_requests[] = {
|
||||
{ "destroy", "", tablet_unstable_v2_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_tablet_v2_events[] = {
|
||||
{ "name", "s", tablet_unstable_v2_types + 0 },
|
||||
{ "id", "uu", tablet_unstable_v2_types + 0 },
|
||||
{ "path", "s", tablet_unstable_v2_types + 0 },
|
||||
{ "done", "", tablet_unstable_v2_types + 0 },
|
||||
{ "removed", "", tablet_unstable_v2_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwp_tablet_v2_interface = {
|
||||
"zwp_tablet_v2", 1,
|
||||
1, zwp_tablet_v2_requests,
|
||||
5, zwp_tablet_v2_events,
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_tablet_pad_ring_v2_requests[] = {
|
||||
{ "set_feedback", "su", tablet_unstable_v2_types + 0 },
|
||||
{ "destroy", "", tablet_unstable_v2_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_tablet_pad_ring_v2_events[] = {
|
||||
{ "source", "u", tablet_unstable_v2_types + 0 },
|
||||
{ "angle", "f", tablet_unstable_v2_types + 0 },
|
||||
{ "stop", "", tablet_unstable_v2_types + 0 },
|
||||
{ "frame", "u", tablet_unstable_v2_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwp_tablet_pad_ring_v2_interface = {
|
||||
"zwp_tablet_pad_ring_v2", 1,
|
||||
2, zwp_tablet_pad_ring_v2_requests,
|
||||
4, zwp_tablet_pad_ring_v2_events,
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_tablet_pad_strip_v2_requests[] = {
|
||||
{ "set_feedback", "su", tablet_unstable_v2_types + 0 },
|
||||
{ "destroy", "", tablet_unstable_v2_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_tablet_pad_strip_v2_events[] = {
|
||||
{ "source", "u", tablet_unstable_v2_types + 0 },
|
||||
{ "position", "u", tablet_unstable_v2_types + 0 },
|
||||
{ "stop", "", tablet_unstable_v2_types + 0 },
|
||||
{ "frame", "u", tablet_unstable_v2_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwp_tablet_pad_strip_v2_interface = {
|
||||
"zwp_tablet_pad_strip_v2", 1,
|
||||
2, zwp_tablet_pad_strip_v2_requests,
|
||||
4, zwp_tablet_pad_strip_v2_events,
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_tablet_pad_group_v2_requests[] = {
|
||||
{ "destroy", "", tablet_unstable_v2_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_tablet_pad_group_v2_events[] = {
|
||||
{ "buttons", "a", tablet_unstable_v2_types + 0 },
|
||||
{ "ring", "n", tablet_unstable_v2_types + 15 },
|
||||
{ "strip", "n", tablet_unstable_v2_types + 16 },
|
||||
{ "modes", "u", tablet_unstable_v2_types + 0 },
|
||||
{ "done", "", tablet_unstable_v2_types + 0 },
|
||||
{ "mode_switch", "uuu", tablet_unstable_v2_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwp_tablet_pad_group_v2_interface = {
|
||||
"zwp_tablet_pad_group_v2", 1,
|
||||
1, zwp_tablet_pad_group_v2_requests,
|
||||
6, zwp_tablet_pad_group_v2_events,
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_tablet_pad_v2_requests[] = {
|
||||
{ "set_feedback", "usu", tablet_unstable_v2_types + 0 },
|
||||
{ "destroy", "", tablet_unstable_v2_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message zwp_tablet_pad_v2_events[] = {
|
||||
{ "group", "n", tablet_unstable_v2_types + 17 },
|
||||
{ "path", "s", tablet_unstable_v2_types + 0 },
|
||||
{ "buttons", "u", tablet_unstable_v2_types + 0 },
|
||||
{ "done", "", tablet_unstable_v2_types + 0 },
|
||||
{ "button", "uuu", tablet_unstable_v2_types + 0 },
|
||||
{ "enter", "uoo", tablet_unstable_v2_types + 18 },
|
||||
{ "leave", "uo", tablet_unstable_v2_types + 21 },
|
||||
{ "removed", "", tablet_unstable_v2_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwp_tablet_pad_v2_interface = {
|
||||
"zwp_tablet_pad_v2", 1,
|
||||
2, zwp_tablet_pad_v2_requests,
|
||||
8, zwp_tablet_pad_v2_events,
|
||||
};
|
||||
|
||||
+394
@@ -0,0 +1,394 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
#ifndef VIEWPORTER_CLIENT_PROTOCOL_H
|
||||
#define VIEWPORTER_CLIENT_PROTOCOL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "wayland-client.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @page page_viewporter The viewporter protocol
|
||||
* @section page_ifaces_viewporter Interfaces
|
||||
* - @subpage page_iface_wp_viewporter - surface cropping and scaling
|
||||
* - @subpage page_iface_wp_viewport - crop and scale interface to a wl_surface
|
||||
* @section page_copyright_viewporter Copyright
|
||||
* <pre>
|
||||
*
|
||||
* Copyright © 2013-2016 Collabora, Ltd.
|
||||
*
|
||||
* 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_surface;
|
||||
struct wp_viewport;
|
||||
struct wp_viewporter;
|
||||
|
||||
#ifndef WP_VIEWPORTER_INTERFACE
|
||||
#define WP_VIEWPORTER_INTERFACE
|
||||
/**
|
||||
* @page page_iface_wp_viewporter wp_viewporter
|
||||
* @section page_iface_wp_viewporter_desc Description
|
||||
*
|
||||
* The global interface exposing surface cropping and scaling
|
||||
* capabilities is used to instantiate an interface extension for a
|
||||
* wl_surface object. This extended interface will then allow
|
||||
* cropping and scaling the surface contents, effectively
|
||||
* disconnecting the direct relationship between the buffer and the
|
||||
* surface size.
|
||||
* @section page_iface_wp_viewporter_api API
|
||||
* See @ref iface_wp_viewporter.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_wp_viewporter The wp_viewporter interface
|
||||
*
|
||||
* The global interface exposing surface cropping and scaling
|
||||
* capabilities is used to instantiate an interface extension for a
|
||||
* wl_surface object. This extended interface will then allow
|
||||
* cropping and scaling the surface contents, effectively
|
||||
* disconnecting the direct relationship between the buffer and the
|
||||
* surface size.
|
||||
*/
|
||||
extern const struct wl_interface wp_viewporter_interface;
|
||||
#endif
|
||||
#ifndef WP_VIEWPORT_INTERFACE
|
||||
#define WP_VIEWPORT_INTERFACE
|
||||
/**
|
||||
* @page page_iface_wp_viewport wp_viewport
|
||||
* @section page_iface_wp_viewport_desc Description
|
||||
*
|
||||
* An additional interface to a wl_surface object, which allows the
|
||||
* client to specify the cropping and scaling of the surface
|
||||
* contents.
|
||||
*
|
||||
* This interface works with two concepts: the source rectangle (src_x,
|
||||
* src_y, src_width, src_height), and the destination size (dst_width,
|
||||
* dst_height). The contents of the source rectangle are scaled to the
|
||||
* destination size, and content outside the source rectangle is ignored.
|
||||
* This state is double-buffered, see wl_surface.commit.
|
||||
*
|
||||
* The two parts of crop and scale state are independent: the source
|
||||
* rectangle, and the destination size. Initially both are unset, that
|
||||
* is, no scaling is applied. The whole of the current wl_buffer is
|
||||
* used as the source, and the surface size is as defined in
|
||||
* wl_surface.attach.
|
||||
*
|
||||
* If the destination size is set, it causes the surface size to become
|
||||
* dst_width, dst_height. The source (rectangle) is scaled to exactly
|
||||
* this size. This overrides whatever the attached wl_buffer size is,
|
||||
* unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface
|
||||
* has no content and therefore no size. Otherwise, the size is always
|
||||
* at least 1x1 in surface local coordinates.
|
||||
*
|
||||
* If the source rectangle is set, it defines what area of the wl_buffer is
|
||||
* taken as the source. If the source rectangle is set and the destination
|
||||
* size is not set, then src_width and src_height must be integers, and the
|
||||
* surface size becomes the source rectangle size. This results in cropping
|
||||
* without scaling. If src_width or src_height are not integers and
|
||||
* destination size is not set, the bad_size protocol error is raised when
|
||||
* the surface state is applied.
|
||||
*
|
||||
* The coordinate transformations from buffer pixel coordinates up to
|
||||
* the surface-local coordinates happen in the following order:
|
||||
* 1. buffer_transform (wl_surface.set_buffer_transform)
|
||||
* 2. buffer_scale (wl_surface.set_buffer_scale)
|
||||
* 3. crop and scale (wp_viewport.set*)
|
||||
* This means, that the source rectangle coordinates of crop and scale
|
||||
* are given in the coordinates after the buffer transform and scale,
|
||||
* i.e. in the coordinates that would be the surface-local coordinates
|
||||
* if the crop and scale was not applied.
|
||||
*
|
||||
* If src_x or src_y are negative, the bad_value protocol error is raised.
|
||||
* Otherwise, if the source rectangle is partially or completely outside of
|
||||
* the non-NULL wl_buffer, then the out_of_buffer protocol error is raised
|
||||
* when the surface state is applied. A NULL wl_buffer does not raise the
|
||||
* out_of_buffer error.
|
||||
*
|
||||
* If the wl_surface associated with the wp_viewport is destroyed,
|
||||
* all wp_viewport requests except 'destroy' raise the protocol error
|
||||
* no_surface.
|
||||
*
|
||||
* If the wp_viewport object is destroyed, the crop and scale
|
||||
* state is removed from the wl_surface. The change will be applied
|
||||
* on the next wl_surface.commit.
|
||||
* @section page_iface_wp_viewport_api API
|
||||
* See @ref iface_wp_viewport.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_wp_viewport The wp_viewport interface
|
||||
*
|
||||
* An additional interface to a wl_surface object, which allows the
|
||||
* client to specify the cropping and scaling of the surface
|
||||
* contents.
|
||||
*
|
||||
* This interface works with two concepts: the source rectangle (src_x,
|
||||
* src_y, src_width, src_height), and the destination size (dst_width,
|
||||
* dst_height). The contents of the source rectangle are scaled to the
|
||||
* destination size, and content outside the source rectangle is ignored.
|
||||
* This state is double-buffered, see wl_surface.commit.
|
||||
*
|
||||
* The two parts of crop and scale state are independent: the source
|
||||
* rectangle, and the destination size. Initially both are unset, that
|
||||
* is, no scaling is applied. The whole of the current wl_buffer is
|
||||
* used as the source, and the surface size is as defined in
|
||||
* wl_surface.attach.
|
||||
*
|
||||
* If the destination size is set, it causes the surface size to become
|
||||
* dst_width, dst_height. The source (rectangle) is scaled to exactly
|
||||
* this size. This overrides whatever the attached wl_buffer size is,
|
||||
* unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface
|
||||
* has no content and therefore no size. Otherwise, the size is always
|
||||
* at least 1x1 in surface local coordinates.
|
||||
*
|
||||
* If the source rectangle is set, it defines what area of the wl_buffer is
|
||||
* taken as the source. If the source rectangle is set and the destination
|
||||
* size is not set, then src_width and src_height must be integers, and the
|
||||
* surface size becomes the source rectangle size. This results in cropping
|
||||
* without scaling. If src_width or src_height are not integers and
|
||||
* destination size is not set, the bad_size protocol error is raised when
|
||||
* the surface state is applied.
|
||||
*
|
||||
* The coordinate transformations from buffer pixel coordinates up to
|
||||
* the surface-local coordinates happen in the following order:
|
||||
* 1. buffer_transform (wl_surface.set_buffer_transform)
|
||||
* 2. buffer_scale (wl_surface.set_buffer_scale)
|
||||
* 3. crop and scale (wp_viewport.set*)
|
||||
* This means, that the source rectangle coordinates of crop and scale
|
||||
* are given in the coordinates after the buffer transform and scale,
|
||||
* i.e. in the coordinates that would be the surface-local coordinates
|
||||
* if the crop and scale was not applied.
|
||||
*
|
||||
* If src_x or src_y are negative, the bad_value protocol error is raised.
|
||||
* Otherwise, if the source rectangle is partially or completely outside of
|
||||
* the non-NULL wl_buffer, then the out_of_buffer protocol error is raised
|
||||
* when the surface state is applied. A NULL wl_buffer does not raise the
|
||||
* out_of_buffer error.
|
||||
*
|
||||
* If the wl_surface associated with the wp_viewport is destroyed,
|
||||
* all wp_viewport requests except 'destroy' raise the protocol error
|
||||
* no_surface.
|
||||
*
|
||||
* If the wp_viewport object is destroyed, the crop and scale
|
||||
* state is removed from the wl_surface. The change will be applied
|
||||
* on the next wl_surface.commit.
|
||||
*/
|
||||
extern const struct wl_interface wp_viewport_interface;
|
||||
#endif
|
||||
|
||||
#ifndef WP_VIEWPORTER_ERROR_ENUM
|
||||
#define WP_VIEWPORTER_ERROR_ENUM
|
||||
enum wp_viewporter_error {
|
||||
/**
|
||||
* the surface already has a viewport object associated
|
||||
*/
|
||||
WP_VIEWPORTER_ERROR_VIEWPORT_EXISTS = 0,
|
||||
};
|
||||
#endif /* WP_VIEWPORTER_ERROR_ENUM */
|
||||
|
||||
#define WP_VIEWPORTER_DESTROY 0
|
||||
#define WP_VIEWPORTER_GET_VIEWPORT 1
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_viewporter
|
||||
*/
|
||||
#define WP_VIEWPORTER_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_wp_viewporter
|
||||
*/
|
||||
#define WP_VIEWPORTER_GET_VIEWPORT_SINCE_VERSION 1
|
||||
|
||||
/** @ingroup iface_wp_viewporter */
|
||||
static inline void
|
||||
wp_viewporter_set_user_data(struct wp_viewporter *wp_viewporter, void *user_data)
|
||||
{
|
||||
wl_proxy_set_user_data((struct wl_proxy *) wp_viewporter, user_data);
|
||||
}
|
||||
|
||||
/** @ingroup iface_wp_viewporter */
|
||||
static inline void *
|
||||
wp_viewporter_get_user_data(struct wp_viewporter *wp_viewporter)
|
||||
{
|
||||
return wl_proxy_get_user_data((struct wl_proxy *) wp_viewporter);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
wp_viewporter_get_version(struct wp_viewporter *wp_viewporter)
|
||||
{
|
||||
return wl_proxy_get_version((struct wl_proxy *) wp_viewporter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_viewporter
|
||||
*
|
||||
* Informs the server that the client will not be using this
|
||||
* protocol object anymore. This does not affect any other objects,
|
||||
* wp_viewport objects included.
|
||||
*/
|
||||
static inline void
|
||||
wp_viewporter_destroy(struct wp_viewporter *wp_viewporter)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) wp_viewporter,
|
||||
WP_VIEWPORTER_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wp_viewporter), WL_MARSHAL_FLAG_DESTROY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_viewporter
|
||||
*
|
||||
* Instantiate an interface extension for the given wl_surface to
|
||||
* crop and scale its content. If the given wl_surface already has
|
||||
* a wp_viewport object associated, the viewport_exists
|
||||
* protocol error is raised.
|
||||
*/
|
||||
static inline struct wp_viewport *
|
||||
wp_viewporter_get_viewport(struct wp_viewporter *wp_viewporter, struct wl_surface *surface)
|
||||
{
|
||||
struct wl_proxy *id;
|
||||
|
||||
id = wl_proxy_marshal_flags((struct wl_proxy *) wp_viewporter,
|
||||
WP_VIEWPORTER_GET_VIEWPORT, &wp_viewport_interface, wl_proxy_get_version((struct wl_proxy *) wp_viewporter), 0, NULL, surface);
|
||||
|
||||
return (struct wp_viewport *) id;
|
||||
}
|
||||
|
||||
#ifndef WP_VIEWPORT_ERROR_ENUM
|
||||
#define WP_VIEWPORT_ERROR_ENUM
|
||||
enum wp_viewport_error {
|
||||
/**
|
||||
* negative or zero values in width or height
|
||||
*/
|
||||
WP_VIEWPORT_ERROR_BAD_VALUE = 0,
|
||||
/**
|
||||
* destination size is not integer
|
||||
*/
|
||||
WP_VIEWPORT_ERROR_BAD_SIZE = 1,
|
||||
/**
|
||||
* source rectangle extends outside of the content area
|
||||
*/
|
||||
WP_VIEWPORT_ERROR_OUT_OF_BUFFER = 2,
|
||||
/**
|
||||
* the wl_surface was destroyed
|
||||
*/
|
||||
WP_VIEWPORT_ERROR_NO_SURFACE = 3,
|
||||
};
|
||||
#endif /* WP_VIEWPORT_ERROR_ENUM */
|
||||
|
||||
#define WP_VIEWPORT_DESTROY 0
|
||||
#define WP_VIEWPORT_SET_SOURCE 1
|
||||
#define WP_VIEWPORT_SET_DESTINATION 2
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_viewport
|
||||
*/
|
||||
#define WP_VIEWPORT_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_wp_viewport
|
||||
*/
|
||||
#define WP_VIEWPORT_SET_SOURCE_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_wp_viewport
|
||||
*/
|
||||
#define WP_VIEWPORT_SET_DESTINATION_SINCE_VERSION 1
|
||||
|
||||
/** @ingroup iface_wp_viewport */
|
||||
static inline void
|
||||
wp_viewport_set_user_data(struct wp_viewport *wp_viewport, void *user_data)
|
||||
{
|
||||
wl_proxy_set_user_data((struct wl_proxy *) wp_viewport, user_data);
|
||||
}
|
||||
|
||||
/** @ingroup iface_wp_viewport */
|
||||
static inline void *
|
||||
wp_viewport_get_user_data(struct wp_viewport *wp_viewport)
|
||||
{
|
||||
return wl_proxy_get_user_data((struct wl_proxy *) wp_viewport);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
wp_viewport_get_version(struct wp_viewport *wp_viewport)
|
||||
{
|
||||
return wl_proxy_get_version((struct wl_proxy *) wp_viewport);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_viewport
|
||||
*
|
||||
* The associated wl_surface's crop and scale state is removed.
|
||||
* The change is applied on the next wl_surface.commit.
|
||||
*/
|
||||
static inline void
|
||||
wp_viewport_destroy(struct wp_viewport *wp_viewport)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) wp_viewport,
|
||||
WP_VIEWPORT_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wp_viewport), WL_MARSHAL_FLAG_DESTROY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_viewport
|
||||
*
|
||||
* Set the source rectangle of the associated wl_surface. See
|
||||
* wp_viewport for the description, and relation to the wl_buffer
|
||||
* size.
|
||||
*
|
||||
* If all of x, y, width and height are -1.0, the source rectangle is
|
||||
* unset instead. Any other set of values where width or height are zero
|
||||
* or negative, or x or y are negative, raise the bad_value protocol
|
||||
* error.
|
||||
*
|
||||
* The crop and scale state is double-buffered, see wl_surface.commit.
|
||||
*/
|
||||
static inline void
|
||||
wp_viewport_set_source(struct wp_viewport *wp_viewport, wl_fixed_t x, wl_fixed_t y, wl_fixed_t width, wl_fixed_t height)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) wp_viewport,
|
||||
WP_VIEWPORT_SET_SOURCE, NULL, wl_proxy_get_version((struct wl_proxy *) wp_viewport), 0, x, y, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_viewport
|
||||
*
|
||||
* Set the destination size of the associated wl_surface. See
|
||||
* wp_viewport for the description, and relation to the wl_buffer
|
||||
* size.
|
||||
*
|
||||
* If width is -1 and height is -1, the destination size is unset
|
||||
* instead. Any other pair of values for width and height that
|
||||
* contains zero or negative values raises the bad_value protocol
|
||||
* error.
|
||||
*
|
||||
* The crop and scale state is double-buffered, see wl_surface.commit.
|
||||
*/
|
||||
static inline void
|
||||
wp_viewport_set_destination(struct wp_viewport *wp_viewport, int32_t width, int32_t height)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) wp_viewport,
|
||||
WP_VIEWPORT_SET_DESTINATION, NULL, wl_proxy_get_version((struct wl_proxy *) wp_viewport), 0, width, height);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright © 2013-2016 Collabora, Ltd.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define WL_PRIVATE
|
||||
#endif
|
||||
|
||||
extern const struct wl_interface wl_surface_interface;
|
||||
extern const struct wl_interface wp_viewport_interface;
|
||||
|
||||
static const struct wl_interface *viewporter_types[] = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&wp_viewport_interface,
|
||||
&wl_surface_interface,
|
||||
};
|
||||
|
||||
static const struct wl_message wp_viewporter_requests[] = {
|
||||
{ "destroy", "", viewporter_types + 0 },
|
||||
{ "get_viewport", "no", viewporter_types + 4 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface wp_viewporter_interface = {
|
||||
"wp_viewporter", 1,
|
||||
2, wp_viewporter_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message wp_viewport_requests[] = {
|
||||
{ "destroy", "", viewporter_types + 0 },
|
||||
{ "set_source", "ffff", viewporter_types + 0 },
|
||||
{ "set_destination", "ii", viewporter_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface wp_viewport_interface = {
|
||||
"wp_viewport", 1,
|
||||
3, wp_viewport_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,384 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
#ifndef XDG_DECORATION_UNSTABLE_V1_CLIENT_PROTOCOL_H
|
||||
#define XDG_DECORATION_UNSTABLE_V1_CLIENT_PROTOCOL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "wayland-client.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @page page_xdg_decoration_unstable_v1 The xdg_decoration_unstable_v1 protocol
|
||||
* @section page_ifaces_xdg_decoration_unstable_v1 Interfaces
|
||||
* - @subpage page_iface_zxdg_decoration_manager_v1 - window decoration manager
|
||||
* - @subpage page_iface_zxdg_toplevel_decoration_v1 - decoration object for a toplevel surface
|
||||
* @section page_copyright_xdg_decoration_unstable_v1 Copyright
|
||||
* <pre>
|
||||
*
|
||||
* Copyright © 2018 Simon Ser
|
||||
*
|
||||
* 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 xdg_toplevel;
|
||||
struct zxdg_decoration_manager_v1;
|
||||
struct zxdg_toplevel_decoration_v1;
|
||||
|
||||
#ifndef ZXDG_DECORATION_MANAGER_V1_INTERFACE
|
||||
#define ZXDG_DECORATION_MANAGER_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_zxdg_decoration_manager_v1 zxdg_decoration_manager_v1
|
||||
* @section page_iface_zxdg_decoration_manager_v1_desc Description
|
||||
*
|
||||
* This interface allows a compositor to announce support for server-side
|
||||
* decorations.
|
||||
*
|
||||
* A window decoration is a set of window controls as deemed appropriate by
|
||||
* the party managing them, such as user interface components used to move,
|
||||
* resize and change a window's state.
|
||||
*
|
||||
* A client can use this protocol to request being decorated by a supporting
|
||||
* compositor.
|
||||
*
|
||||
* If compositor and client do not negotiate the use of a server-side
|
||||
* decoration using this protocol, clients continue to self-decorate as they
|
||||
* see fit.
|
||||
*
|
||||
* 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_iface_zxdg_decoration_manager_v1_api API
|
||||
* See @ref iface_zxdg_decoration_manager_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_zxdg_decoration_manager_v1 The zxdg_decoration_manager_v1 interface
|
||||
*
|
||||
* This interface allows a compositor to announce support for server-side
|
||||
* decorations.
|
||||
*
|
||||
* A window decoration is a set of window controls as deemed appropriate by
|
||||
* the party managing them, such as user interface components used to move,
|
||||
* resize and change a window's state.
|
||||
*
|
||||
* A client can use this protocol to request being decorated by a supporting
|
||||
* compositor.
|
||||
*
|
||||
* If compositor and client do not negotiate the use of a server-side
|
||||
* decoration using this protocol, clients continue to self-decorate as they
|
||||
* see fit.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
extern const struct wl_interface zxdg_decoration_manager_v1_interface;
|
||||
#endif
|
||||
#ifndef ZXDG_TOPLEVEL_DECORATION_V1_INTERFACE
|
||||
#define ZXDG_TOPLEVEL_DECORATION_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_zxdg_toplevel_decoration_v1 zxdg_toplevel_decoration_v1
|
||||
* @section page_iface_zxdg_toplevel_decoration_v1_desc Description
|
||||
*
|
||||
* The decoration object allows the compositor to toggle server-side window
|
||||
* decorations for a toplevel surface. The client can request to switch to
|
||||
* another mode.
|
||||
*
|
||||
* The xdg_toplevel_decoration object must be destroyed before its
|
||||
* xdg_toplevel.
|
||||
* @section page_iface_zxdg_toplevel_decoration_v1_api API
|
||||
* See @ref iface_zxdg_toplevel_decoration_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_zxdg_toplevel_decoration_v1 The zxdg_toplevel_decoration_v1 interface
|
||||
*
|
||||
* The decoration object allows the compositor to toggle server-side window
|
||||
* decorations for a toplevel surface. The client can request to switch to
|
||||
* another mode.
|
||||
*
|
||||
* The xdg_toplevel_decoration object must be destroyed before its
|
||||
* xdg_toplevel.
|
||||
*/
|
||||
extern const struct wl_interface zxdg_toplevel_decoration_v1_interface;
|
||||
#endif
|
||||
|
||||
#define ZXDG_DECORATION_MANAGER_V1_DESTROY 0
|
||||
#define ZXDG_DECORATION_MANAGER_V1_GET_TOPLEVEL_DECORATION 1
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_decoration_manager_v1
|
||||
*/
|
||||
#define ZXDG_DECORATION_MANAGER_V1_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zxdg_decoration_manager_v1
|
||||
*/
|
||||
#define ZXDG_DECORATION_MANAGER_V1_GET_TOPLEVEL_DECORATION_SINCE_VERSION 1
|
||||
|
||||
/** @ingroup iface_zxdg_decoration_manager_v1 */
|
||||
static inline void
|
||||
zxdg_decoration_manager_v1_set_user_data(struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1, void *user_data)
|
||||
{
|
||||
wl_proxy_set_user_data((struct wl_proxy *) zxdg_decoration_manager_v1, user_data);
|
||||
}
|
||||
|
||||
/** @ingroup iface_zxdg_decoration_manager_v1 */
|
||||
static inline void *
|
||||
zxdg_decoration_manager_v1_get_user_data(struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1)
|
||||
{
|
||||
return wl_proxy_get_user_data((struct wl_proxy *) zxdg_decoration_manager_v1);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
zxdg_decoration_manager_v1_get_version(struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1)
|
||||
{
|
||||
return wl_proxy_get_version((struct wl_proxy *) zxdg_decoration_manager_v1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_decoration_manager_v1
|
||||
*
|
||||
* Destroy the decoration manager. This doesn't destroy objects created
|
||||
* with the manager.
|
||||
*/
|
||||
static inline void
|
||||
zxdg_decoration_manager_v1_destroy(struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) zxdg_decoration_manager_v1,
|
||||
ZXDG_DECORATION_MANAGER_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zxdg_decoration_manager_v1), WL_MARSHAL_FLAG_DESTROY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_decoration_manager_v1
|
||||
*
|
||||
* Create a new decoration object associated with the given toplevel.
|
||||
*
|
||||
* Creating an xdg_toplevel_decoration from an xdg_toplevel which has a
|
||||
* buffer attached or committed is a client error, and any attempts by a
|
||||
* client to attach or manipulate a buffer prior to the first
|
||||
* xdg_toplevel_decoration.configure event must also be treated as
|
||||
* errors.
|
||||
*/
|
||||
static inline struct zxdg_toplevel_decoration_v1 *
|
||||
zxdg_decoration_manager_v1_get_toplevel_decoration(struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1, struct xdg_toplevel *toplevel)
|
||||
{
|
||||
struct wl_proxy *id;
|
||||
|
||||
id = wl_proxy_marshal_flags((struct wl_proxy *) zxdg_decoration_manager_v1,
|
||||
ZXDG_DECORATION_MANAGER_V1_GET_TOPLEVEL_DECORATION, &zxdg_toplevel_decoration_v1_interface, wl_proxy_get_version((struct wl_proxy *) zxdg_decoration_manager_v1), 0, NULL, toplevel);
|
||||
|
||||
return (struct zxdg_toplevel_decoration_v1 *) id;
|
||||
}
|
||||
|
||||
#ifndef ZXDG_TOPLEVEL_DECORATION_V1_ERROR_ENUM
|
||||
#define ZXDG_TOPLEVEL_DECORATION_V1_ERROR_ENUM
|
||||
enum zxdg_toplevel_decoration_v1_error {
|
||||
/**
|
||||
* xdg_toplevel has a buffer attached before configure
|
||||
*/
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_ERROR_UNCONFIGURED_BUFFER = 0,
|
||||
/**
|
||||
* xdg_toplevel already has a decoration object
|
||||
*/
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_ERROR_ALREADY_CONSTRUCTED = 1,
|
||||
/**
|
||||
* xdg_toplevel destroyed before the decoration object
|
||||
*/
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_ERROR_ORPHANED = 2,
|
||||
/**
|
||||
* invalid mode
|
||||
*/
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_ERROR_INVALID_MODE = 3,
|
||||
};
|
||||
#endif /* ZXDG_TOPLEVEL_DECORATION_V1_ERROR_ENUM */
|
||||
|
||||
#ifndef ZXDG_TOPLEVEL_DECORATION_V1_MODE_ENUM
|
||||
#define ZXDG_TOPLEVEL_DECORATION_V1_MODE_ENUM
|
||||
/**
|
||||
* @ingroup iface_zxdg_toplevel_decoration_v1
|
||||
* window decoration modes
|
||||
*
|
||||
* These values describe window decoration modes.
|
||||
*/
|
||||
enum zxdg_toplevel_decoration_v1_mode {
|
||||
/**
|
||||
* no server-side window decoration
|
||||
*/
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE = 1,
|
||||
/**
|
||||
* server-side window decoration
|
||||
*/
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE = 2,
|
||||
};
|
||||
#endif /* ZXDG_TOPLEVEL_DECORATION_V1_MODE_ENUM */
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_toplevel_decoration_v1
|
||||
* @struct zxdg_toplevel_decoration_v1_listener
|
||||
*/
|
||||
struct zxdg_toplevel_decoration_v1_listener {
|
||||
/**
|
||||
* notify a decoration mode change
|
||||
*
|
||||
* The configure event configures the effective decoration mode.
|
||||
* The configured state should not be applied immediately. Clients
|
||||
* must send an ack_configure in response to this event. See
|
||||
* xdg_surface.configure and xdg_surface.ack_configure for details.
|
||||
*
|
||||
* A configure event can be sent at any time. The specified mode
|
||||
* must be obeyed by the client.
|
||||
* @param mode the decoration mode
|
||||
*/
|
||||
void (*configure)(void *data,
|
||||
struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1,
|
||||
uint32_t mode);
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_toplevel_decoration_v1
|
||||
*/
|
||||
static inline int
|
||||
zxdg_toplevel_decoration_v1_add_listener(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1,
|
||||
const struct zxdg_toplevel_decoration_v1_listener *listener, void *data)
|
||||
{
|
||||
return wl_proxy_add_listener((struct wl_proxy *) zxdg_toplevel_decoration_v1,
|
||||
(void (**)(void)) listener, data);
|
||||
}
|
||||
|
||||
#define ZXDG_TOPLEVEL_DECORATION_V1_DESTROY 0
|
||||
#define ZXDG_TOPLEVEL_DECORATION_V1_SET_MODE 1
|
||||
#define ZXDG_TOPLEVEL_DECORATION_V1_UNSET_MODE 2
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_toplevel_decoration_v1
|
||||
*/
|
||||
#define ZXDG_TOPLEVEL_DECORATION_V1_CONFIGURE_SINCE_VERSION 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_toplevel_decoration_v1
|
||||
*/
|
||||
#define ZXDG_TOPLEVEL_DECORATION_V1_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zxdg_toplevel_decoration_v1
|
||||
*/
|
||||
#define ZXDG_TOPLEVEL_DECORATION_V1_SET_MODE_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zxdg_toplevel_decoration_v1
|
||||
*/
|
||||
#define ZXDG_TOPLEVEL_DECORATION_V1_UNSET_MODE_SINCE_VERSION 1
|
||||
|
||||
/** @ingroup iface_zxdg_toplevel_decoration_v1 */
|
||||
static inline void
|
||||
zxdg_toplevel_decoration_v1_set_user_data(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1, void *user_data)
|
||||
{
|
||||
wl_proxy_set_user_data((struct wl_proxy *) zxdg_toplevel_decoration_v1, user_data);
|
||||
}
|
||||
|
||||
/** @ingroup iface_zxdg_toplevel_decoration_v1 */
|
||||
static inline void *
|
||||
zxdg_toplevel_decoration_v1_get_user_data(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1)
|
||||
{
|
||||
return wl_proxy_get_user_data((struct wl_proxy *) zxdg_toplevel_decoration_v1);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
zxdg_toplevel_decoration_v1_get_version(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1)
|
||||
{
|
||||
return wl_proxy_get_version((struct wl_proxy *) zxdg_toplevel_decoration_v1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_toplevel_decoration_v1
|
||||
*
|
||||
* Switch back to a mode without any server-side decorations at the next
|
||||
* commit.
|
||||
*/
|
||||
static inline void
|
||||
zxdg_toplevel_decoration_v1_destroy(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) zxdg_toplevel_decoration_v1,
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zxdg_toplevel_decoration_v1), WL_MARSHAL_FLAG_DESTROY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_toplevel_decoration_v1
|
||||
*
|
||||
* Set the toplevel surface decoration mode. This informs the compositor
|
||||
* that the client prefers the provided decoration mode.
|
||||
*
|
||||
* After requesting a decoration mode, the compositor will respond by
|
||||
* emitting an xdg_surface.configure event. The client should then update
|
||||
* its content, drawing it without decorations if the received mode is
|
||||
* server-side decorations. The client must also acknowledge the configure
|
||||
* when committing the new content (see xdg_surface.ack_configure).
|
||||
*
|
||||
* The compositor can decide not to use the client's mode and enforce a
|
||||
* different mode instead.
|
||||
*
|
||||
* Clients whose decoration mode depend on the xdg_toplevel state may send
|
||||
* a set_mode request in response to an xdg_surface.configure event and wait
|
||||
* for the next xdg_surface.configure event to prevent unwanted state.
|
||||
* Such clients are responsible for preventing configure loops and must
|
||||
* make sure not to send multiple successive set_mode requests with the
|
||||
* same decoration mode.
|
||||
*
|
||||
* If an invalid mode is supplied by the client, the invalid_mode protocol
|
||||
* error is raised by the compositor.
|
||||
*/
|
||||
static inline void
|
||||
zxdg_toplevel_decoration_v1_set_mode(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1, uint32_t mode)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) zxdg_toplevel_decoration_v1,
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_SET_MODE, NULL, wl_proxy_get_version((struct wl_proxy *) zxdg_toplevel_decoration_v1), 0, mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_toplevel_decoration_v1
|
||||
*
|
||||
* Unset the toplevel surface decoration mode. This informs the compositor
|
||||
* that the client doesn't prefer a particular decoration mode.
|
||||
*
|
||||
* This request has the same semantics as set_mode.
|
||||
*/
|
||||
static inline void
|
||||
zxdg_toplevel_decoration_v1_unset_mode(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) zxdg_toplevel_decoration_v1,
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_UNSET_MODE, NULL, wl_proxy_get_version((struct wl_proxy *) zxdg_toplevel_decoration_v1), 0);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,76 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright © 2018 Simon Ser
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define WL_PRIVATE
|
||||
#endif
|
||||
|
||||
extern const struct wl_interface xdg_toplevel_interface;
|
||||
extern const struct wl_interface zxdg_toplevel_decoration_v1_interface;
|
||||
|
||||
static const struct wl_interface *xdg_decoration_unstable_v1_types[] = {
|
||||
NULL,
|
||||
&zxdg_toplevel_decoration_v1_interface,
|
||||
&xdg_toplevel_interface,
|
||||
};
|
||||
|
||||
static const struct wl_message zxdg_decoration_manager_v1_requests[] = {
|
||||
{ "destroy", "", xdg_decoration_unstable_v1_types + 0 },
|
||||
{ "get_toplevel_decoration", "no", xdg_decoration_unstable_v1_types + 1 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zxdg_decoration_manager_v1_interface = {
|
||||
"zxdg_decoration_manager_v1", 1,
|
||||
2, zxdg_decoration_manager_v1_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message zxdg_toplevel_decoration_v1_requests[] = {
|
||||
{ "destroy", "", xdg_decoration_unstable_v1_types + 0 },
|
||||
{ "set_mode", "u", xdg_decoration_unstable_v1_types + 0 },
|
||||
{ "unset_mode", "", xdg_decoration_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message zxdg_toplevel_decoration_v1_events[] = {
|
||||
{ "configure", "u", xdg_decoration_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zxdg_toplevel_decoration_v1_interface = {
|
||||
"zxdg_toplevel_decoration_v1", 1,
|
||||
3, zxdg_toplevel_decoration_v1_requests,
|
||||
1, zxdg_toplevel_decoration_v1_events,
|
||||
};
|
||||
|
||||
+2384
File diff suppressed because it is too large.
Load diff
+184
@@ -0,0 +1,184 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright © 2008-2013 Kristian Høgsberg
|
||||
* Copyright © 2013 Rafael Antognolli
|
||||
* Copyright © 2013 Jasper St. Pierre
|
||||
* Copyright © 2010-2013 Intel Corporation
|
||||
* Copyright © 2015-2017 Samsung Electronics Co., Ltd
|
||||
* Copyright © 2015-2017 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.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define WL_PRIVATE
|
||||
#endif
|
||||
|
||||
extern const struct wl_interface wl_output_interface;
|
||||
extern const struct wl_interface wl_seat_interface;
|
||||
extern const struct wl_interface wl_surface_interface;
|
||||
extern const struct wl_interface xdg_popup_interface;
|
||||
extern const struct wl_interface xdg_positioner_interface;
|
||||
extern const struct wl_interface xdg_surface_interface;
|
||||
extern const struct wl_interface xdg_toplevel_interface;
|
||||
|
||||
static const struct wl_interface *xdg_shell_types[] = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&xdg_positioner_interface,
|
||||
&xdg_surface_interface,
|
||||
&wl_surface_interface,
|
||||
&xdg_toplevel_interface,
|
||||
&xdg_popup_interface,
|
||||
&xdg_surface_interface,
|
||||
&xdg_positioner_interface,
|
||||
&xdg_toplevel_interface,
|
||||
&wl_seat_interface,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&wl_seat_interface,
|
||||
NULL,
|
||||
&wl_seat_interface,
|
||||
NULL,
|
||||
NULL,
|
||||
&wl_output_interface,
|
||||
&wl_seat_interface,
|
||||
NULL,
|
||||
&xdg_positioner_interface,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_wm_base_requests[] = {
|
||||
{ "destroy", "", xdg_shell_types + 0 },
|
||||
{ "create_positioner", "n", xdg_shell_types + 4 },
|
||||
{ "get_xdg_surface", "no", xdg_shell_types + 5 },
|
||||
{ "pong", "u", xdg_shell_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_wm_base_events[] = {
|
||||
{ "ping", "u", xdg_shell_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface xdg_wm_base_interface = {
|
||||
"xdg_wm_base", 7,
|
||||
4, xdg_wm_base_requests,
|
||||
1, xdg_wm_base_events,
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_positioner_requests[] = {
|
||||
{ "destroy", "", xdg_shell_types + 0 },
|
||||
{ "set_size", "ii", xdg_shell_types + 0 },
|
||||
{ "set_anchor_rect", "iiii", xdg_shell_types + 0 },
|
||||
{ "set_anchor", "u", xdg_shell_types + 0 },
|
||||
{ "set_gravity", "u", xdg_shell_types + 0 },
|
||||
{ "set_constraint_adjustment", "u", xdg_shell_types + 0 },
|
||||
{ "set_offset", "ii", xdg_shell_types + 0 },
|
||||
{ "set_reactive", "3", xdg_shell_types + 0 },
|
||||
{ "set_parent_size", "3ii", xdg_shell_types + 0 },
|
||||
{ "set_parent_configure", "3u", xdg_shell_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface xdg_positioner_interface = {
|
||||
"xdg_positioner", 7,
|
||||
10, xdg_positioner_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_surface_requests[] = {
|
||||
{ "destroy", "", xdg_shell_types + 0 },
|
||||
{ "get_toplevel", "n", xdg_shell_types + 7 },
|
||||
{ "get_popup", "n?oo", xdg_shell_types + 8 },
|
||||
{ "set_window_geometry", "iiii", xdg_shell_types + 0 },
|
||||
{ "ack_configure", "u", xdg_shell_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_surface_events[] = {
|
||||
{ "configure", "u", xdg_shell_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface xdg_surface_interface = {
|
||||
"xdg_surface", 7,
|
||||
5, xdg_surface_requests,
|
||||
1, xdg_surface_events,
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_toplevel_requests[] = {
|
||||
{ "destroy", "", xdg_shell_types + 0 },
|
||||
{ "set_parent", "?o", xdg_shell_types + 11 },
|
||||
{ "set_title", "s", xdg_shell_types + 0 },
|
||||
{ "set_app_id", "s", xdg_shell_types + 0 },
|
||||
{ "show_window_menu", "ouii", xdg_shell_types + 12 },
|
||||
{ "move", "ou", xdg_shell_types + 16 },
|
||||
{ "resize", "ouu", xdg_shell_types + 18 },
|
||||
{ "set_max_size", "ii", xdg_shell_types + 0 },
|
||||
{ "set_min_size", "ii", xdg_shell_types + 0 },
|
||||
{ "set_maximized", "", xdg_shell_types + 0 },
|
||||
{ "unset_maximized", "", xdg_shell_types + 0 },
|
||||
{ "set_fullscreen", "?o", xdg_shell_types + 21 },
|
||||
{ "unset_fullscreen", "", xdg_shell_types + 0 },
|
||||
{ "set_minimized", "", xdg_shell_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_toplevel_events[] = {
|
||||
{ "configure", "iia", xdg_shell_types + 0 },
|
||||
{ "close", "", xdg_shell_types + 0 },
|
||||
{ "configure_bounds", "4ii", xdg_shell_types + 0 },
|
||||
{ "wm_capabilities", "5a", xdg_shell_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface xdg_toplevel_interface = {
|
||||
"xdg_toplevel", 7,
|
||||
14, xdg_toplevel_requests,
|
||||
4, xdg_toplevel_events,
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_popup_requests[] = {
|
||||
{ "destroy", "", xdg_shell_types + 0 },
|
||||
{ "grab", "ou", xdg_shell_types + 22 },
|
||||
{ "reposition", "3ou", xdg_shell_types + 24 },
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_popup_events[] = {
|
||||
{ "configure", "iiii", xdg_shell_types + 0 },
|
||||
{ "popup_done", "", xdg_shell_types + 0 },
|
||||
{ "repositioned", "3u", xdg_shell_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface xdg_popup_interface = {
|
||||
"xdg_popup", 7,
|
||||
3, xdg_popup_requests,
|
||||
3, xdg_popup_events,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,410 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
#ifndef XDG_TOPLEVEL_ICON_V1_CLIENT_PROTOCOL_H
|
||||
#define XDG_TOPLEVEL_ICON_V1_CLIENT_PROTOCOL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "wayland-client.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @page page_xdg_toplevel_icon_v1 The xdg_toplevel_icon_v1 protocol
|
||||
* protocol to assign icons to toplevels
|
||||
*
|
||||
* @section page_desc_xdg_toplevel_icon_v1 Description
|
||||
*
|
||||
* This protocol allows clients to set icons for their toplevel surfaces
|
||||
* either via the XDG icon stock (using an icon name), or from pixel data.
|
||||
*
|
||||
* A toplevel icon represents the individual toplevel (unlike the application
|
||||
* or launcher icon, which represents the application as a whole), and may be
|
||||
* shown in window switchers, window overviews and taskbars that list
|
||||
* individual windows.
|
||||
*
|
||||
* This document adheres to RFC 2119 when using words like "must",
|
||||
* "should", "may", etc.
|
||||
*
|
||||
* Warning! The protocol described in this file is currently in the testing
|
||||
* phase. Backward compatible changes may be added together with the
|
||||
* corresponding interface version bump. Backward incompatible changes can
|
||||
* only be done by creating a new major version of the extension.
|
||||
*
|
||||
* @section page_ifaces_xdg_toplevel_icon_v1 Interfaces
|
||||
* - @subpage page_iface_xdg_toplevel_icon_manager_v1 - interface to manage toplevel icons
|
||||
* - @subpage page_iface_xdg_toplevel_icon_v1 - a toplevel window icon
|
||||
* @section page_copyright_xdg_toplevel_icon_v1 Copyright
|
||||
* <pre>
|
||||
*
|
||||
* Copyright © 2023-2024 Matthias Klumpp
|
||||
* Copyright © 2024 David Edmundson
|
||||
*
|
||||
* 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_buffer;
|
||||
struct xdg_toplevel;
|
||||
struct xdg_toplevel_icon_manager_v1;
|
||||
struct xdg_toplevel_icon_v1;
|
||||
|
||||
#ifndef XDG_TOPLEVEL_ICON_MANAGER_V1_INTERFACE
|
||||
#define XDG_TOPLEVEL_ICON_MANAGER_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_xdg_toplevel_icon_manager_v1 xdg_toplevel_icon_manager_v1
|
||||
* @section page_iface_xdg_toplevel_icon_manager_v1_desc Description
|
||||
*
|
||||
* This interface allows clients to create toplevel window icons and set
|
||||
* them on toplevel windows to be displayed to the user.
|
||||
* @section page_iface_xdg_toplevel_icon_manager_v1_api API
|
||||
* See @ref iface_xdg_toplevel_icon_manager_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_xdg_toplevel_icon_manager_v1 The xdg_toplevel_icon_manager_v1 interface
|
||||
*
|
||||
* This interface allows clients to create toplevel window icons and set
|
||||
* them on toplevel windows to be displayed to the user.
|
||||
*/
|
||||
extern const struct wl_interface xdg_toplevel_icon_manager_v1_interface;
|
||||
#endif
|
||||
#ifndef XDG_TOPLEVEL_ICON_V1_INTERFACE
|
||||
#define XDG_TOPLEVEL_ICON_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_xdg_toplevel_icon_v1 xdg_toplevel_icon_v1
|
||||
* @section page_iface_xdg_toplevel_icon_v1_desc Description
|
||||
*
|
||||
* This interface defines a toplevel icon.
|
||||
* An icon can have a name, and multiple buffers.
|
||||
* In order to be applied, the icon must have either a name, or at least
|
||||
* one buffer assigned. Applying an empty icon (with no buffer or name) to
|
||||
* a toplevel should reset its icon to the default icon.
|
||||
*
|
||||
* It is up to compositor policy whether to prefer using a buffer or loading
|
||||
* an icon via its name. See 'set_name' and 'add_buffer' for details.
|
||||
* @section page_iface_xdg_toplevel_icon_v1_api API
|
||||
* See @ref iface_xdg_toplevel_icon_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_xdg_toplevel_icon_v1 The xdg_toplevel_icon_v1 interface
|
||||
*
|
||||
* This interface defines a toplevel icon.
|
||||
* An icon can have a name, and multiple buffers.
|
||||
* In order to be applied, the icon must have either a name, or at least
|
||||
* one buffer assigned. Applying an empty icon (with no buffer or name) to
|
||||
* a toplevel should reset its icon to the default icon.
|
||||
*
|
||||
* It is up to compositor policy whether to prefer using a buffer or loading
|
||||
* an icon via its name. See 'set_name' and 'add_buffer' for details.
|
||||
*/
|
||||
extern const struct wl_interface xdg_toplevel_icon_v1_interface;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup iface_xdg_toplevel_icon_manager_v1
|
||||
* @struct xdg_toplevel_icon_manager_v1_listener
|
||||
*/
|
||||
struct xdg_toplevel_icon_manager_v1_listener {
|
||||
/**
|
||||
* describes a supported & preferred icon size
|
||||
*
|
||||
* This event indicates an icon size the compositor prefers to be
|
||||
* available if the client has scalable icons and can render to any
|
||||
* size.
|
||||
*
|
||||
* When the 'xdg_toplevel_icon_manager_v1' object is created, the
|
||||
* compositor may send one or more 'icon_size' events to describe
|
||||
* the list of preferred icon sizes. If the compositor has no size
|
||||
* preference, it may not send any 'icon_size' event, and it is up
|
||||
* to the client to decide a suitable icon size.
|
||||
*
|
||||
* A sequence of 'icon_size' events must be finished with a 'done'
|
||||
* event. If the compositor has no size preferences, it must still
|
||||
* send the 'done' event, without any preceding 'icon_size' events.
|
||||
* @param size the edge size of the square icon in surface-local coordinates, e.g. 64
|
||||
*/
|
||||
void (*icon_size)(void *data,
|
||||
struct xdg_toplevel_icon_manager_v1 *xdg_toplevel_icon_manager_v1,
|
||||
int32_t size);
|
||||
/**
|
||||
* all information has been sent
|
||||
*
|
||||
* This event is sent after all 'icon_size' events have been
|
||||
* sent.
|
||||
*/
|
||||
void (*done)(void *data,
|
||||
struct xdg_toplevel_icon_manager_v1 *xdg_toplevel_icon_manager_v1);
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup iface_xdg_toplevel_icon_manager_v1
|
||||
*/
|
||||
static inline int
|
||||
xdg_toplevel_icon_manager_v1_add_listener(struct xdg_toplevel_icon_manager_v1 *xdg_toplevel_icon_manager_v1,
|
||||
const struct xdg_toplevel_icon_manager_v1_listener *listener, void *data)
|
||||
{
|
||||
return wl_proxy_add_listener((struct wl_proxy *) xdg_toplevel_icon_manager_v1,
|
||||
(void (**)(void)) listener, data);
|
||||
}
|
||||
|
||||
#define XDG_TOPLEVEL_ICON_MANAGER_V1_DESTROY 0
|
||||
#define XDG_TOPLEVEL_ICON_MANAGER_V1_CREATE_ICON 1
|
||||
#define XDG_TOPLEVEL_ICON_MANAGER_V1_SET_ICON 2
|
||||
|
||||
/**
|
||||
* @ingroup iface_xdg_toplevel_icon_manager_v1
|
||||
*/
|
||||
#define XDG_TOPLEVEL_ICON_MANAGER_V1_ICON_SIZE_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_xdg_toplevel_icon_manager_v1
|
||||
*/
|
||||
#define XDG_TOPLEVEL_ICON_MANAGER_V1_DONE_SINCE_VERSION 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_xdg_toplevel_icon_manager_v1
|
||||
*/
|
||||
#define XDG_TOPLEVEL_ICON_MANAGER_V1_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_xdg_toplevel_icon_manager_v1
|
||||
*/
|
||||
#define XDG_TOPLEVEL_ICON_MANAGER_V1_CREATE_ICON_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_xdg_toplevel_icon_manager_v1
|
||||
*/
|
||||
#define XDG_TOPLEVEL_ICON_MANAGER_V1_SET_ICON_SINCE_VERSION 1
|
||||
|
||||
/** @ingroup iface_xdg_toplevel_icon_manager_v1 */
|
||||
static inline void
|
||||
xdg_toplevel_icon_manager_v1_set_user_data(struct xdg_toplevel_icon_manager_v1 *xdg_toplevel_icon_manager_v1, void *user_data)
|
||||
{
|
||||
wl_proxy_set_user_data((struct wl_proxy *) xdg_toplevel_icon_manager_v1, user_data);
|
||||
}
|
||||
|
||||
/** @ingroup iface_xdg_toplevel_icon_manager_v1 */
|
||||
static inline void *
|
||||
xdg_toplevel_icon_manager_v1_get_user_data(struct xdg_toplevel_icon_manager_v1 *xdg_toplevel_icon_manager_v1)
|
||||
{
|
||||
return wl_proxy_get_user_data((struct wl_proxy *) xdg_toplevel_icon_manager_v1);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
xdg_toplevel_icon_manager_v1_get_version(struct xdg_toplevel_icon_manager_v1 *xdg_toplevel_icon_manager_v1)
|
||||
{
|
||||
return wl_proxy_get_version((struct wl_proxy *) xdg_toplevel_icon_manager_v1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_xdg_toplevel_icon_manager_v1
|
||||
*
|
||||
* Destroy the toplevel icon manager.
|
||||
* This does not destroy objects created with the manager.
|
||||
*/
|
||||
static inline void
|
||||
xdg_toplevel_icon_manager_v1_destroy(struct xdg_toplevel_icon_manager_v1 *xdg_toplevel_icon_manager_v1)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel_icon_manager_v1,
|
||||
XDG_TOPLEVEL_ICON_MANAGER_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel_icon_manager_v1), WL_MARSHAL_FLAG_DESTROY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_xdg_toplevel_icon_manager_v1
|
||||
*
|
||||
* Creates a new icon object. This icon can then be attached to a
|
||||
* xdg_toplevel via the 'set_icon' request.
|
||||
*/
|
||||
static inline struct xdg_toplevel_icon_v1 *
|
||||
xdg_toplevel_icon_manager_v1_create_icon(struct xdg_toplevel_icon_manager_v1 *xdg_toplevel_icon_manager_v1)
|
||||
{
|
||||
struct wl_proxy *id;
|
||||
|
||||
id = wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel_icon_manager_v1,
|
||||
XDG_TOPLEVEL_ICON_MANAGER_V1_CREATE_ICON, &xdg_toplevel_icon_v1_interface, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel_icon_manager_v1), 0, NULL);
|
||||
|
||||
return (struct xdg_toplevel_icon_v1 *) id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_xdg_toplevel_icon_manager_v1
|
||||
*
|
||||
* This request assigns the icon 'icon' to 'toplevel', or clears the
|
||||
* toplevel icon if 'icon' was null.
|
||||
* This state is double-buffered and is applied on the next
|
||||
* wl_surface.commit of the toplevel.
|
||||
*
|
||||
* After making this call, the xdg_toplevel_icon_v1 provided as 'icon'
|
||||
* can be destroyed by the client without 'toplevel' losing its icon.
|
||||
* The xdg_toplevel_icon_v1 is immutable from this point, and any
|
||||
* future attempts to change it must raise the
|
||||
* 'xdg_toplevel_icon_v1.immutable' protocol error.
|
||||
*
|
||||
* The compositor must set the toplevel icon from either the pixel data
|
||||
* the icon provides, or by loading a stock icon using the icon name.
|
||||
* See the description of 'xdg_toplevel_icon_v1' for details.
|
||||
*
|
||||
* If 'icon' is set to null, the icon of the respective toplevel is reset
|
||||
* to its default icon (usually the icon of the application, derived from
|
||||
* its desktop-entry file, or a placeholder icon).
|
||||
* If this request is passed an icon with no pixel buffers or icon name
|
||||
* assigned, the icon must be reset just like if 'icon' was null.
|
||||
*/
|
||||
static inline void
|
||||
xdg_toplevel_icon_manager_v1_set_icon(struct xdg_toplevel_icon_manager_v1 *xdg_toplevel_icon_manager_v1, struct xdg_toplevel *toplevel, struct xdg_toplevel_icon_v1 *icon)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel_icon_manager_v1,
|
||||
XDG_TOPLEVEL_ICON_MANAGER_V1_SET_ICON, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel_icon_manager_v1), 0, toplevel, icon);
|
||||
}
|
||||
|
||||
#ifndef XDG_TOPLEVEL_ICON_V1_ERROR_ENUM
|
||||
#define XDG_TOPLEVEL_ICON_V1_ERROR_ENUM
|
||||
enum xdg_toplevel_icon_v1_error {
|
||||
/**
|
||||
* the provided buffer does not satisfy requirements
|
||||
*/
|
||||
XDG_TOPLEVEL_ICON_V1_ERROR_INVALID_BUFFER = 1,
|
||||
/**
|
||||
* the icon has already been assigned to a toplevel and must not be changed
|
||||
*/
|
||||
XDG_TOPLEVEL_ICON_V1_ERROR_IMMUTABLE = 2,
|
||||
/**
|
||||
* the provided buffer has been destroyed before the toplevel icon
|
||||
*/
|
||||
XDG_TOPLEVEL_ICON_V1_ERROR_NO_BUFFER = 3,
|
||||
};
|
||||
#endif /* XDG_TOPLEVEL_ICON_V1_ERROR_ENUM */
|
||||
|
||||
#define XDG_TOPLEVEL_ICON_V1_DESTROY 0
|
||||
#define XDG_TOPLEVEL_ICON_V1_SET_NAME 1
|
||||
#define XDG_TOPLEVEL_ICON_V1_ADD_BUFFER 2
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup iface_xdg_toplevel_icon_v1
|
||||
*/
|
||||
#define XDG_TOPLEVEL_ICON_V1_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_xdg_toplevel_icon_v1
|
||||
*/
|
||||
#define XDG_TOPLEVEL_ICON_V1_SET_NAME_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_xdg_toplevel_icon_v1
|
||||
*/
|
||||
#define XDG_TOPLEVEL_ICON_V1_ADD_BUFFER_SINCE_VERSION 1
|
||||
|
||||
/** @ingroup iface_xdg_toplevel_icon_v1 */
|
||||
static inline void
|
||||
xdg_toplevel_icon_v1_set_user_data(struct xdg_toplevel_icon_v1 *xdg_toplevel_icon_v1, void *user_data)
|
||||
{
|
||||
wl_proxy_set_user_data((struct wl_proxy *) xdg_toplevel_icon_v1, user_data);
|
||||
}
|
||||
|
||||
/** @ingroup iface_xdg_toplevel_icon_v1 */
|
||||
static inline void *
|
||||
xdg_toplevel_icon_v1_get_user_data(struct xdg_toplevel_icon_v1 *xdg_toplevel_icon_v1)
|
||||
{
|
||||
return wl_proxy_get_user_data((struct wl_proxy *) xdg_toplevel_icon_v1);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
xdg_toplevel_icon_v1_get_version(struct xdg_toplevel_icon_v1 *xdg_toplevel_icon_v1)
|
||||
{
|
||||
return wl_proxy_get_version((struct wl_proxy *) xdg_toplevel_icon_v1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_xdg_toplevel_icon_v1
|
||||
*
|
||||
* Destroys the 'xdg_toplevel_icon_v1' object.
|
||||
* The icon must still remain set on every toplevel it was assigned to,
|
||||
* until the toplevel icon is reset explicitly.
|
||||
*/
|
||||
static inline void
|
||||
xdg_toplevel_icon_v1_destroy(struct xdg_toplevel_icon_v1 *xdg_toplevel_icon_v1)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel_icon_v1,
|
||||
XDG_TOPLEVEL_ICON_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel_icon_v1), WL_MARSHAL_FLAG_DESTROY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_xdg_toplevel_icon_v1
|
||||
*
|
||||
* This request assigns an icon name to this icon.
|
||||
* Any previously set name is overridden.
|
||||
*
|
||||
* The compositor must resolve 'icon_name' according to the lookup rules
|
||||
* described in the XDG icon theme specification[1] using the
|
||||
* environment's current icon theme.
|
||||
*
|
||||
* If the compositor does not support icon names or cannot resolve
|
||||
* 'icon_name' according to the XDG icon theme specification it must
|
||||
* fall back to using pixel buffer data instead.
|
||||
*
|
||||
* If this request is made after the icon has been assigned to a toplevel
|
||||
* via 'set_icon', a 'immutable' error must be raised.
|
||||
*
|
||||
* [1]: https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html
|
||||
*/
|
||||
static inline void
|
||||
xdg_toplevel_icon_v1_set_name(struct xdg_toplevel_icon_v1 *xdg_toplevel_icon_v1, const char *icon_name)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel_icon_v1,
|
||||
XDG_TOPLEVEL_ICON_V1_SET_NAME, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel_icon_v1), 0, icon_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_xdg_toplevel_icon_v1
|
||||
*
|
||||
* This request adds pixel data supplied as wl_buffer to the icon.
|
||||
*
|
||||
* The client should add pixel data for all icon sizes and scales that
|
||||
* it can provide, or which are explicitly requested by the compositor
|
||||
* via 'icon_size' events on xdg_toplevel_icon_manager_v1.
|
||||
*
|
||||
* The wl_buffer supplying pixel data as 'buffer' must be backed by wl_shm
|
||||
* and must be a square (width and height being equal).
|
||||
* If any of these buffer requirements are not fulfilled, a 'invalid_buffer'
|
||||
* error must be raised.
|
||||
*
|
||||
* If this icon instance already has a buffer of the same size and scale
|
||||
* from a previous 'add_buffer' request, data from the last request
|
||||
* overrides the preexisting pixel data.
|
||||
*
|
||||
* The wl_buffer must be kept alive for as long as the xdg_toplevel_icon
|
||||
* it is associated with is not destroyed, otherwise a 'no_buffer' error
|
||||
* is raised. The buffer contents must not be modified after it was
|
||||
* assigned to the icon. As a result, the region of the wl_shm_pool's
|
||||
* backing storage used for the wl_buffer must not be modified after this
|
||||
* request is sent. The wl_buffer.release event is unused.
|
||||
*
|
||||
* If this request is made after the icon has been assigned to a toplevel
|
||||
* via 'set_icon', a 'immutable' error must be raised.
|
||||
*/
|
||||
static inline void
|
||||
xdg_toplevel_icon_v1_add_buffer(struct xdg_toplevel_icon_v1 *xdg_toplevel_icon_v1, struct wl_buffer *buffer, int32_t scale)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel_icon_v1,
|
||||
XDG_TOPLEVEL_ICON_V1_ADD_BUFFER, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel_icon_v1), 0, buffer, scale);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,83 @@
|
||||
/* Generated by wayland-scanner 1.24.0 */
|
||||
|
||||
/*
|
||||
* Copyright © 2023-2024 Matthias Klumpp
|
||||
* Copyright © 2024 David Edmundson
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define WL_PRIVATE
|
||||
#endif
|
||||
|
||||
extern const struct wl_interface wl_buffer_interface;
|
||||
extern const struct wl_interface xdg_toplevel_interface;
|
||||
extern const struct wl_interface xdg_toplevel_icon_v1_interface;
|
||||
|
||||
static const struct wl_interface *xdg_toplevel_icon_v1_types[] = {
|
||||
NULL,
|
||||
&xdg_toplevel_icon_v1_interface,
|
||||
&xdg_toplevel_interface,
|
||||
&xdg_toplevel_icon_v1_interface,
|
||||
&wl_buffer_interface,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_toplevel_icon_manager_v1_requests[] = {
|
||||
{ "destroy", "", xdg_toplevel_icon_v1_types + 0 },
|
||||
{ "create_icon", "n", xdg_toplevel_icon_v1_types + 1 },
|
||||
{ "set_icon", "o?o", xdg_toplevel_icon_v1_types + 2 },
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_toplevel_icon_manager_v1_events[] = {
|
||||
{ "icon_size", "i", xdg_toplevel_icon_v1_types + 0 },
|
||||
{ "done", "", xdg_toplevel_icon_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface xdg_toplevel_icon_manager_v1_interface = {
|
||||
"xdg_toplevel_icon_manager_v1", 1,
|
||||
3, xdg_toplevel_icon_manager_v1_requests,
|
||||
2, xdg_toplevel_icon_manager_v1_events,
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_toplevel_icon_v1_requests[] = {
|
||||
{ "destroy", "", xdg_toplevel_icon_v1_types + 0 },
|
||||
{ "set_name", "s", xdg_toplevel_icon_v1_types + 0 },
|
||||
{ "add_buffer", "oi", xdg_toplevel_icon_v1_types + 4 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface xdg_toplevel_icon_v1_interface = {
|
||||
"xdg_toplevel_icon_v1", 1,
|
||||
3, xdg_toplevel_icon_v1_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
@@ -4,14 +4,14 @@ module builtin
|
||||
// The C string is expected to be a &u8 pointer.
|
||||
@[inline; unsafe]
|
||||
pub fn vstrlen(s &u8) int {
|
||||
return unsafe { C.strlen(&char(s)) }
|
||||
return int(unsafe { C.strlen(&char(s)) })
|
||||
}
|
||||
|
||||
// vstrlen_char returns the V length of the C string `s` (0 terminator is not counted).
|
||||
// The C string is expected to be a &char pointer.
|
||||
@[inline; unsafe]
|
||||
pub fn vstrlen_char(s &char) int {
|
||||
return unsafe { C.strlen(s) }
|
||||
return int(unsafe { C.strlen(s) })
|
||||
}
|
||||
|
||||
// vmemcpy copies n bytes from memory area src to memory area dest.
|
||||
|
||||
@@ -132,7 +132,7 @@ pub fn c_error_number_str(errnum int) string {
|
||||
c_msg := C.strerror(errnum)
|
||||
err_msg = string{
|
||||
str: &u8(c_msg)
|
||||
len: unsafe { C.strlen(c_msg) }
|
||||
len: int(unsafe { C.strlen(c_msg) })
|
||||
is_lit: 1
|
||||
}
|
||||
}
|
||||
|
||||
+109
-104
@@ -14,19 +14,61 @@ $if freebsd {
|
||||
}
|
||||
#flag -lX11
|
||||
|
||||
#include <X11/Xlib.h> # Please install a package with the X11 development headers, for example: `apt install libx11-dev`
|
||||
// X11
|
||||
// Include X11 headers BEFORE any type definitions to avoid incomplete type errors
|
||||
#preinclude <X11/Xlib.h>
|
||||
#preinclude <X11/Xatom.h>
|
||||
#preinclude <X11/Xutil.h>
|
||||
|
||||
// X11 types are defined by X11 headers
|
||||
// For V check mode, we need to define C.Display
|
||||
@[typedef]
|
||||
pub struct C.Display {}
|
||||
|
||||
fn (d &C.Display) str() string {
|
||||
return 'C.Display{}'
|
||||
pub struct C.Display {
|
||||
pub mut:
|
||||
_ int // opaque - actual definition from X11 headers
|
||||
}
|
||||
|
||||
// Local type aliases for convenience
|
||||
type Window = u64
|
||||
type Atom = u64
|
||||
|
||||
// Forward declarations for V type checking (actual types from X11 headers)
|
||||
@[typedef]
|
||||
pub struct C.XSelectionEvent {
|
||||
pub mut:
|
||||
type int
|
||||
display voidptr
|
||||
requestor Window
|
||||
selection Atom
|
||||
target Atom
|
||||
property Atom
|
||||
time int
|
||||
}
|
||||
|
||||
@[typedef]
|
||||
pub struct C.XSelectionClearEvent {
|
||||
pub mut:
|
||||
window Window
|
||||
selection Atom
|
||||
}
|
||||
|
||||
@[typedef]
|
||||
pub struct C.XSelectionRequestEvent {
|
||||
pub mut:
|
||||
display voidptr
|
||||
owner Window
|
||||
requestor Window
|
||||
selection Atom
|
||||
target Atom
|
||||
property Atom
|
||||
time int
|
||||
}
|
||||
|
||||
@[typedef]
|
||||
pub struct C.XDestroyWindowEvent {
|
||||
pub mut:
|
||||
window Window
|
||||
}
|
||||
|
||||
fn C.XInitThreads() i32
|
||||
|
||||
fn C.XCloseDisplay(d &C.Display)
|
||||
@@ -74,46 +116,12 @@ fn C.XFree(data voidptr)
|
||||
|
||||
fn todo_del() {}
|
||||
|
||||
@[typedef]
|
||||
pub struct C.XSelectionRequestEvent {
|
||||
mut:
|
||||
display &C.Display = unsafe { nil } // Display the event was read from
|
||||
owner Window
|
||||
requestor Window
|
||||
selection Atom
|
||||
target Atom
|
||||
property Atom
|
||||
time int
|
||||
}
|
||||
|
||||
@[typedef]
|
||||
pub struct C.XSelectionEvent {
|
||||
mut:
|
||||
type int
|
||||
display &C.Display = unsafe { nil } // Display the event was read from
|
||||
requestor Window
|
||||
selection Atom
|
||||
target Atom
|
||||
property Atom
|
||||
time int
|
||||
}
|
||||
|
||||
@[typedef]
|
||||
pub struct C.XSelectionClearEvent {
|
||||
mut:
|
||||
window Window
|
||||
selection Atom
|
||||
}
|
||||
|
||||
@[typedef]
|
||||
pub struct C.XDestroyWindowEvent {
|
||||
mut:
|
||||
window Window
|
||||
}
|
||||
// X11 event types are defined in vlib/x/x11/x11.v
|
||||
// XEvent union is defined here since it's used by clipboard
|
||||
|
||||
@[typedef]
|
||||
union C.XEvent {
|
||||
mut:
|
||||
pub mut:
|
||||
type int
|
||||
xdestroywindow C.XDestroyWindowEvent
|
||||
xselectionclear C.XSelectionClearEvent
|
||||
@@ -281,17 +289,19 @@ pub fn (mut cb Clipboard) get_text() string {
|
||||
// transmit_selection is crucial to handling all the different data types.
|
||||
// If we ever support other mimetypes they should be handled here.
|
||||
fn (mut cb Clipboard) transmit_selection(xse &C.XSelectionEvent) bool {
|
||||
if xse.target == cb.get_atom(.targets) {
|
||||
targets := cb.get_supported_targets()
|
||||
C.XChangeProperty(xse.display, xse.requestor, xse.property, cb.get_atom(.xa_atom),
|
||||
32, C.PropModeReplace, targets.data, targets.len)
|
||||
} else if cb.is_supported_target(xse.target) && cb.is_owner && cb.text != '' {
|
||||
cb.mutex.lock()
|
||||
C.XChangeProperty(xse.display, xse.requestor, xse.property, xse.target, 8, C.PropModeReplace,
|
||||
cb.text.str, cb.text.len)
|
||||
cb.mutex.unlock()
|
||||
} else {
|
||||
return false
|
||||
unsafe {
|
||||
if xse.target == cb.get_atom(.targets) {
|
||||
targets := cb.get_supported_targets()
|
||||
C.XChangeProperty(xse.display, xse.requestor, xse.property, cb.get_atom(.xa_atom),
|
||||
32, C.PropModeReplace, targets.data, targets.len)
|
||||
} else if cb.is_supported_target(xse.target) && cb.is_owner && cb.text != '' {
|
||||
cb.mutex.lock()
|
||||
C.XChangeProperty(xse.display, xse.requestor, xse.property, xse.target, 8,
|
||||
C.PropModeReplace, cb.text.str, cb.text.len)
|
||||
cb.mutex.unlock()
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -315,70 +325,65 @@ fn (mut cb Clipboard) start_listener() {
|
||||
}
|
||||
}
|
||||
C.SelectionClear {
|
||||
if unsafe { event.xselectionclear.window == cb.window } && unsafe {
|
||||
event.xselectionclear.selection == cb.selection
|
||||
} {
|
||||
cb.mutex.lock()
|
||||
cb.is_owner = false
|
||||
cb.text = ''
|
||||
cb.mutex.unlock()
|
||||
unsafe {
|
||||
if event.xselectionclear.window == cb.window
|
||||
&& event.xselectionclear.selection == cb.selection {
|
||||
cb.mutex.lock()
|
||||
cb.is_owner = false
|
||||
cb.text = ''
|
||||
cb.mutex.unlock()
|
||||
}
|
||||
}
|
||||
}
|
||||
C.SelectionRequest {
|
||||
if unsafe { event.xselectionrequest.selection == cb.selection } {
|
||||
mut xsre := &C.XSelectionRequestEvent{
|
||||
display: 0
|
||||
}
|
||||
xsre = unsafe { &event.xselectionrequest }
|
||||
unsafe {
|
||||
if event.xselectionrequest.selection == cb.selection {
|
||||
xsre := &event.xselectionrequest
|
||||
|
||||
mut xse := C.XSelectionEvent{
|
||||
type: C.SelectionNotify // 31
|
||||
display: xsre.display
|
||||
requestor: xsre.requestor
|
||||
selection: xsre.selection
|
||||
time: xsre.time
|
||||
target: xsre.target
|
||||
property: xsre.property
|
||||
xse := C.XSelectionEvent{
|
||||
type: C.SelectionNotify // 31
|
||||
display: xsre.display
|
||||
requestor: xsre.requestor
|
||||
selection: xsre.selection
|
||||
time: xsre.time
|
||||
target: xsre.target
|
||||
property: xsre.property
|
||||
}
|
||||
if !cb.transmit_selection(&xse) {
|
||||
xse.property = Atom(0)
|
||||
}
|
||||
C.XSendEvent(cb.display, xse.requestor, 0, C.PropertyChangeMask,
|
||||
voidptr(&xse))
|
||||
C.XFlush(cb.display)
|
||||
}
|
||||
if !cb.transmit_selection(&xse) {
|
||||
xse.property = Atom(0)
|
||||
}
|
||||
C.XSendEvent(cb.display, xse.requestor, 0, C.PropertyChangeMask, voidptr(&xse))
|
||||
C.XFlush(cb.display)
|
||||
}
|
||||
}
|
||||
C.SelectionNotify {
|
||||
if unsafe {
|
||||
event.xselection.selection == cb.selection
|
||||
&& event.xselection.property != Atom(0)
|
||||
} {
|
||||
if unsafe { event.xselection.target == cb.get_atom(.targets) && !sent_request } {
|
||||
sent_request = true
|
||||
prop := read_property(cb.display, cb.window, cb.selection)
|
||||
to_be_requested = cb.pick_target(prop)
|
||||
if to_be_requested != Atom(0) {
|
||||
C.XConvertSelection(cb.display, cb.selection, to_be_requested,
|
||||
cb.selection, cb.window, C.CurrentTime)
|
||||
}
|
||||
} else if unsafe { event.xselection.target == to_be_requested } {
|
||||
sent_request = false
|
||||
to_be_requested = Atom(0)
|
||||
cb.mutex.lock()
|
||||
prop := unsafe {
|
||||
read_property(event.xselection.display, event.xselection.requestor,
|
||||
unsafe {
|
||||
if event.xselection.selection == cb.selection
|
||||
&& event.xselection.property != Atom(0) {
|
||||
if event.xselection.target == cb.get_atom(.targets) && !sent_request {
|
||||
sent_request = true
|
||||
prop := read_property(cb.display, cb.window, cb.selection)
|
||||
to_be_requested = cb.pick_target(prop)
|
||||
if to_be_requested != Atom(0) {
|
||||
C.XConvertSelection(cb.display, cb.selection, to_be_requested,
|
||||
cb.selection, cb.window, C.CurrentTime)
|
||||
}
|
||||
} else if event.xselection.target == to_be_requested {
|
||||
sent_request = false
|
||||
to_be_requested = Atom(0)
|
||||
cb.mutex.lock()
|
||||
prop := read_property(event.xselection.display, event.xselection.requestor,
|
||||
event.xselection.property)
|
||||
}
|
||||
unsafe {
|
||||
C.XDeleteProperty(event.xselection.display, event.xselection.requestor,
|
||||
event.xselection.property)
|
||||
}
|
||||
if cb.is_supported_target(prop.actual_type) {
|
||||
cb.got_text = true
|
||||
unsafe {
|
||||
if cb.is_supported_target(prop.actual_type) {
|
||||
cb.got_text = true
|
||||
cb.text = prop.data.vstring() // TODO: return byteptr to support other mimetypes
|
||||
}
|
||||
cb.mutex.unlock()
|
||||
}
|
||||
cb.mutex.unlock()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,4 +48,10 @@ pub struct C.FONStextIter {
|
||||
|
||||
pub struct C.FONSfont {}
|
||||
|
||||
pub struct C.FONScontext {}
|
||||
pub struct C.FONScontext {
|
||||
pub:
|
||||
params C.FONSparams
|
||||
itw f32
|
||||
ith f32
|
||||
texData &u8 = unsafe { nil }
|
||||
}
|
||||
+3
-1
@@ -553,7 +553,9 @@ pub fn new_context(cfg Config) &Context {
|
||||
cleanup_userdata_cb: gg_cleanup_fn
|
||||
window_title: &char(cfg.window_title.str)
|
||||
icon: cfg.icon
|
||||
html5_canvas_name: &char(cfg.html5_canvas_name.str)
|
||||
html5: sapp.Html5Desc{
|
||||
canvas_selector: &char(cfg.html5_canvas_name.str)
|
||||
}
|
||||
width: cfg.width
|
||||
height: cfg.height
|
||||
sample_count: cfg.sample_count
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#include <Cocoa/Cocoa.h>
|
||||
|
||||
// Global view variable
|
||||
static NSView *g_view = nil;
|
||||
|
||||
NSColor* nscolor(gg__Color c) {
|
||||
float red = (float)c.r / 255.0f;
|
||||
float green = (float)c.g / 255.0f;
|
||||
@@ -109,6 +112,9 @@ void darwin_draw_rect(float x, float y, float width, float height, gg__Color c)
|
||||
void darwin_window_refresh() {
|
||||
//[g_view setNeedsDisplay:YES];
|
||||
// update UI on the main thread TODO separate fn
|
||||
if (g_view == nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[g_view setNeedsDisplay:YES];
|
||||
|
||||
@@ -1,13 +1,26 @@
|
||||
module c
|
||||
|
||||
import sokol.memory as _
|
||||
|
||||
#flag -I @VEXEROOT/thirdparty/sokol
|
||||
#flag -I @VEXEROOT/thirdparty/sokol/util
|
||||
#flag freebsd -I /usr/local/include
|
||||
#flag darwin -fobjc-arc
|
||||
|
||||
#flag linux -lX11 -lGL -lXcursor -lXi -lpthread
|
||||
// Platform-specific library linking
|
||||
// X11 is the default on Linux
|
||||
// Use `-d sokol_wayland` to enable Wayland support
|
||||
#flag linux -DSOKOL_GLCORE
|
||||
$if sokol_wayland ? {
|
||||
#flag linux -lwayland-client -lwayland-egl -lxkbcommon -lxkbcommon-x11 -lEGL -lGL -lpthread -lm -ldl -lX11 -lXi -lXcursor
|
||||
} $else {
|
||||
#flag linux -lX11 -lXi -lXcursor -lGL -lpthread -lm -ldl
|
||||
}
|
||||
#flag freebsd -DSOKOL_GLCORE
|
||||
#flag freebsd -L/usr/local/lib -lX11 -lGL -lXcursor -lXi
|
||||
#flag openbsd -DSOKOL_GLCORE
|
||||
#flag openbsd -I/usr/X11R6/include -L/usr/X11R6/lib -lX11 -lGL -lXcursor -lXi
|
||||
#flag windows -DSOKOL_GLCORE
|
||||
#flag windows -lgdi32
|
||||
|
||||
$if windows {
|
||||
@@ -54,14 +67,10 @@ $if emscripten ? {
|
||||
// #flag -s MODULARIZE
|
||||
}
|
||||
|
||||
// OPENGL
|
||||
#flag linux -DSOKOL_GLCORE
|
||||
#flag freebsd -DSOKOL_GLCORE
|
||||
#flag openbsd -DSOKOL_GLCORE
|
||||
//#flag darwin -framework OpenGL -framework Cocoa -framework QuartzCore
|
||||
// D3D
|
||||
#flag windows -DSOKOL_GLCORE
|
||||
//#flag windows -DSOKOL_D3D11
|
||||
#flag windows -DSOKOL_GLCORE
|
||||
|
||||
// for simplicity, all header includes are here because import order matters and we dont have any way
|
||||
// to ensure import order with V yet
|
||||
|
||||
@@ -83,6 +92,16 @@ $if emscripten ? {
|
||||
// To allow for thirdparty initializing window / acceleration contexts
|
||||
// but still be able to use sokol.gfx e.g. SDL+sokol_gfx
|
||||
$if !no_sokol_app ? {
|
||||
$if linux && sokol_wayland ? {
|
||||
// Enable Wayland on Linux (when explicitly enabled with -d sokol_wayland)
|
||||
#define SOKOL_WAYLAND
|
||||
#flag -I@VEXEROOT/thirdparty/sokol
|
||||
} $else $if linux {
|
||||
// Explicitly disable Wayland on Linux when not using sokol_wayland
|
||||
#define SOKOL_DISABLE_WAYLAND
|
||||
}
|
||||
|
||||
@[use_once]
|
||||
#include "sokol_app.h"
|
||||
}
|
||||
|
||||
@@ -91,7 +110,4 @@ $if !no_sokol_app ? {
|
||||
#define SOKOL_NO_DEPRECATED
|
||||
#include "sokol_gfx.h"
|
||||
|
||||
@[use_once]
|
||||
#define SOKOL_GL_IMPL
|
||||
#include "util/sokol_gl.h"
|
||||
#include "sokol_v.post.h"
|
||||
@@ -1,12 +0,0 @@
|
||||
module f
|
||||
|
||||
import fontstash as _
|
||||
import sokol.c as _
|
||||
|
||||
#flag linux -I.
|
||||
|
||||
//#include "ft2build.h"
|
||||
|
||||
@[use_once]
|
||||
#define SOKOL_FONTSTASH_IMPL
|
||||
#include "util/sokol_fontstash.h"
|
||||
@@ -36,17 +36,33 @@ pub enum MouseButton {
|
||||
}
|
||||
|
||||
pub enum MouseCursor {
|
||||
default = C.SAPP_MOUSECURSOR_DEFAULT
|
||||
arrow = C.SAPP_MOUSECURSOR_ARROW
|
||||
ibeam = C.SAPP_MOUSECURSOR_IBEAM
|
||||
crosshair = C.SAPP_MOUSECURSOR_CROSSHAIR
|
||||
pointing_hand = C.SAPP_MOUSECURSOR_POINTING_HAND
|
||||
resize_ew = C.SAPP_MOUSECURSOR_RESIZE_EW
|
||||
resize_ns = C.SAPP_MOUSECURSOR_RESIZE_NS
|
||||
resize_nwse = C.SAPP_MOUSECURSOR_RESIZE_NWSE
|
||||
resize_nesw = C.SAPP_MOUSECURSOR_RESIZE_NESW
|
||||
resize_all = C.SAPP_MOUSECURSOR_RESIZE_ALL
|
||||
not_allowed = C.SAPP_MOUSECURSOR_NOT_ALLOWED
|
||||
default = 0
|
||||
arrow = 1
|
||||
ibeam = 2
|
||||
crosshair = 3
|
||||
pointing_hand = 4
|
||||
resize_ew = 5
|
||||
resize_ns = 6
|
||||
resize_nwse = 7
|
||||
resize_nesw = 8
|
||||
resize_all = 9
|
||||
not_allowed = 10
|
||||
custom_0 = 11
|
||||
custom_1 = 12
|
||||
custom_2 = 13
|
||||
custom_3 = 14
|
||||
custom_4 = 15
|
||||
custom_5 = 16
|
||||
custom_6 = 17
|
||||
custom_7 = 18
|
||||
custom_8 = 19
|
||||
custom_9 = 20
|
||||
custom_10 = 21
|
||||
custom_11 = 22
|
||||
custom_12 = 23
|
||||
custom_13 = 24
|
||||
custom_14 = 25
|
||||
custom_15 = 26
|
||||
}
|
||||
|
||||
pub enum Modifier {
|
||||
@@ -5,8 +5,9 @@ import sokol.gfx
|
||||
import sokol.memory
|
||||
|
||||
// Android needs a global reference to `g_desc`
|
||||
__global g_desc C.sapp_desc
|
||||
__global g_desc Desc
|
||||
|
||||
// create_desc creates a default `gfx.Desc` configured for use with `sapp`.
|
||||
pub fn create_desc() gfx.Desc {
|
||||
return gfx.Desc{
|
||||
environment: glue_environment()
|
||||
@@ -22,52 +23,71 @@ pub fn create_default_pass(action gfx.PassAction) gfx.Pass {
|
||||
}
|
||||
}
|
||||
|
||||
// sapp_to_gfx_pixel_format translates sapp_pixel_format to gfx.PixelFormat.
|
||||
// sokol_app.h uses a compact pixel format enum (sapp_pixel_format) that does NOT
|
||||
// match the sg_pixel_format numbering used by sokol_gfx.h.
|
||||
fn sapp_to_gfx_pixel_format(sapp_fmt int) gfx.PixelFormat {
|
||||
return match sapp_fmt {
|
||||
0 { gfx.PixelFormat._default } // _SAPP_PIXELFORMAT_DEFAULT
|
||||
1 { gfx.PixelFormat.none } // SAPP_PIXELFORMAT_NONE
|
||||
2 { gfx.PixelFormat.rgba8 } // SAPP_PIXELFORMAT_RGBA8
|
||||
3 { gfx.PixelFormat.srgb8a8 } // SAPP_PIXELFORMAT_SRGB8A8
|
||||
4 { gfx.PixelFormat.bgra8 } // SAPP_PIXELFORMAT_BGRA8
|
||||
5 { gfx.PixelFormat.bgra8 } // SAPP_PIXELFORMAT_SBGRA8 (no exact sg match, use bgra8)
|
||||
6 { gfx.PixelFormat.depth } // SAPP_PIXELFORMAT_DEPTH
|
||||
7 { gfx.PixelFormat.depth_stencil } // SAPP_PIXELFORMAT_DEPTH_STENCIL
|
||||
else { gfx.PixelFormat.none }
|
||||
}
|
||||
}
|
||||
|
||||
// glue_environment returns a `gfx.Environment` compatible for use with `sapp` specific `gfx.Pass`es.
|
||||
// The retuned `gfx.Environment` can be used when rendering via `sapp`.
|
||||
// The returned `gfx.Environment` can be used when rendering via `sapp`.
|
||||
// See also: documentation at the top of thirdparty/sokol/sokol_gfx.h
|
||||
pub fn glue_environment() gfx.Environment {
|
||||
sapp_env := C.sapp_get_environment()
|
||||
mut env := gfx.Environment{}
|
||||
unsafe { vmemset(&env, 0, int(sizeof(env))) }
|
||||
env.defaults.color_format = gfx.PixelFormat.from(color_format()) or { gfx.PixelFormat.none }
|
||||
env.defaults.depth_format = gfx.PixelFormat.from(depth_format()) or { gfx.PixelFormat.none }
|
||||
env.defaults.sample_count = sample_count()
|
||||
env.defaults.color_format = sapp_to_gfx_pixel_format(sapp_env.defaults.color_format)
|
||||
env.defaults.depth_format = sapp_to_gfx_pixel_format(sapp_env.defaults.depth_format)
|
||||
env.defaults.sample_count = sapp_env.defaults.sample_count
|
||||
$if macos && !darwin_sokol_glcore33 ? {
|
||||
env.metal.device = metal_get_device()
|
||||
env.metal.device = sapp_env.metal.device
|
||||
}
|
||||
// if windows and dx3d11
|
||||
// env.d3d11.device = d3d11_get_device()
|
||||
// env.d3d11.device_context = d3d11_get_device_context()
|
||||
// env.d3d11.device = sapp_env.d3d11.device
|
||||
// env.d3d11.device_context = sapp_env.d3d11.device_context
|
||||
// if webgpu
|
||||
// env.wgpu.device = wgpu_get_device()
|
||||
// env.wgpu.device = sapp_env.wgpu.device
|
||||
return env
|
||||
}
|
||||
|
||||
// glue_swapchain returns a `gfx.Swapchain` compatible for use with `sapp` specific display/rendering `gfx.Pass`es.
|
||||
// The retuned `gfx.Swapchain` can be used when rendering via `sapp`.
|
||||
// The returned `gfx.Swapchain` can be used when rendering via `sapp`.
|
||||
// See also: documentation at the top of thirdparty/sokol/sokol_gfx.h
|
||||
pub fn glue_swapchain() gfx.Swapchain {
|
||||
sapp_sc := C.sapp_get_swapchain()
|
||||
mut swapchain := gfx.Swapchain{}
|
||||
unsafe { vmemset(&swapchain, 0, int(sizeof(swapchain))) }
|
||||
swapchain.width = width()
|
||||
swapchain.height = height()
|
||||
swapchain.sample_count = sample_count()
|
||||
swapchain.color_format = gfx.PixelFormat.from(color_format()) or { gfx.PixelFormat.none }
|
||||
swapchain.depth_format = gfx.PixelFormat.from(depth_format()) or { gfx.PixelFormat.none }
|
||||
swapchain.width = sapp_sc.width
|
||||
swapchain.height = sapp_sc.height
|
||||
swapchain.sample_count = sapp_sc.sample_count
|
||||
swapchain.color_format = sapp_to_gfx_pixel_format(sapp_sc.color_format)
|
||||
swapchain.depth_format = sapp_to_gfx_pixel_format(sapp_sc.depth_format)
|
||||
$if macos && !darwin_sokol_glcore33 ? {
|
||||
swapchain.metal.current_drawable = metal_get_current_drawable()
|
||||
swapchain.metal.depth_stencil_texture = metal_get_depth_stencil_texture()
|
||||
swapchain.metal.msaa_color_texture = metal_get_msaa_color_texture()
|
||||
swapchain.metal.current_drawable = sapp_sc.metal.current_drawable
|
||||
swapchain.metal.depth_stencil_texture = sapp_sc.metal.depth_stencil_texture
|
||||
swapchain.metal.msaa_color_texture = sapp_sc.metal.msaa_color_texture
|
||||
}
|
||||
// if windows and dx3d11
|
||||
// swapchain.d3d11.render_view = d3d11_get_render_view()
|
||||
// swapchain.d3d11.resolve_view = d3d11_get_resolve_view()
|
||||
// swapchain.d3d11.depth_stencil_view = d3d11_get_depth_stencil_view()
|
||||
// swapchain.d3d11.render_view = sapp_sc.d3d11.render_view
|
||||
// swapchain.d3d11.resolve_view = sapp_sc.d3d11.resolve_view
|
||||
// swapchain.d3d11.depth_stencil_view = sapp_sc.d3d11.depth_stencil_view
|
||||
// if webgpu
|
||||
// swapchain.wgpu.render_view = wgpu_get_render_view()
|
||||
// swapchain.wgpu.resolve_view = wgpu_get_resolve_view()
|
||||
// swapchain.wgpu.depth_stencil_view = wgpu_get_depth_stencil_view()
|
||||
// swapchain.wgpu.render_view = sapp_sc.wgpu.render_view
|
||||
// swapchain.wgpu.resolve_view = sapp_sc.wgpu.resolve_view
|
||||
// swapchain.wgpu.depth_stencil_view = sapp_sc.wgpu.depth_stencil_view
|
||||
$else {
|
||||
swapchain.gl.framebuffer = gl_get_framebuffer()
|
||||
swapchain.gl.framebuffer = sapp_sc.gl.framebuffer
|
||||
}
|
||||
return swapchain
|
||||
}
|
||||
@@ -144,17 +164,37 @@ pub fn set_mouse_cursor(cursor MouseCursor) {
|
||||
C.sapp_set_mouse_cursor(cursor)
|
||||
}
|
||||
|
||||
// get current mouse cursor type
|
||||
@[inline]
|
||||
pub fn get_mouse_cursor() MouseCursor {
|
||||
return C.sapp_get_mouse_cursor()
|
||||
}
|
||||
|
||||
// bind a custom mouse cursor image to a cursor type
|
||||
@[inline]
|
||||
pub fn bind_mouse_cursor_image(cursor MouseCursor, desc &ImageDesc) MouseCursor {
|
||||
return C.sapp_bind_mouse_cursor_image(cursor, desc)
|
||||
}
|
||||
|
||||
// unbind a custom mouse cursor image
|
||||
@[inline]
|
||||
pub fn unbind_mouse_cursor_image(cursor MouseCursor) {
|
||||
C.sapp_unbind_mouse_cursor_image(cursor)
|
||||
}
|
||||
|
||||
// show or hide the mouse cursor
|
||||
@[inline]
|
||||
pub fn mouse_shown() bool {
|
||||
return C.sapp_mouse_shown()
|
||||
}
|
||||
|
||||
// lock_mouse locks or unlocks the mouse cursor, confining it to the window.
|
||||
@[inline]
|
||||
pub fn lock_mouse(locked bool) {
|
||||
C.sapp_lock_mouse(locked)
|
||||
}
|
||||
|
||||
// mouse_locked returns true if the mouse is currently locked to the window.
|
||||
@[inline]
|
||||
pub fn mouse_locked() bool {
|
||||
return C.sapp_mouse_locked()
|
||||
@@ -220,6 +260,12 @@ pub fn get_clipboard_string() &char {
|
||||
return &char(C.sapp_get_clipboard_string())
|
||||
}
|
||||
|
||||
// set the window icon (only on Windows and Linux)
|
||||
@[inline]
|
||||
pub fn set_icon(icon_desc &IconDesc) {
|
||||
C.sapp_set_icon(icon_desc)
|
||||
}
|
||||
|
||||
// special run-function for SOKOL_NO_ENTRY (in standard mode this is an empty stub)
|
||||
pub fn run(desc &Desc) {
|
||||
if desc.allocator.alloc_fn == unsafe { nil } && desc.allocator.free_fn == unsafe { nil } {
|
||||
@@ -238,31 +284,40 @@ pub fn run(desc &Desc) {
|
||||
C.sapp_run(desc)
|
||||
}
|
||||
|
||||
// get runtime environment information
|
||||
@[inline]
|
||||
pub fn get_environment() Environment {
|
||||
return C.sapp_get_environment()
|
||||
}
|
||||
|
||||
// get current frame's swapchain information (call once per frame!)
|
||||
@[inline]
|
||||
pub fn get_swapchain() Swapchain {
|
||||
return C.sapp_get_swapchain()
|
||||
}
|
||||
|
||||
// HTML5: enable or disable the hardwired "Leave Site?" dialog box
|
||||
@[inline]
|
||||
pub fn html5_ask_leave_site(ask bool) {
|
||||
C.sapp_html5_ask_leave_site(ask)
|
||||
}
|
||||
|
||||
// Metal: get ARC-bridged pointer to Metal device object
|
||||
// HTML5: get byte size of a dropped file
|
||||
@[inline]
|
||||
pub fn metal_get_device() voidptr {
|
||||
return voidptr(C.sapp_metal_get_device())
|
||||
pub fn html5_get_dropped_file_size(index int) u32 {
|
||||
return C.sapp_html5_get_dropped_file_size(index)
|
||||
}
|
||||
|
||||
// Metal: get ARC-bridged pointer to current drawable
|
||||
pub fn metal_get_current_drawable() voidptr {
|
||||
return voidptr(C.sapp_metal_get_current_drawable())
|
||||
// EGL: get EGLDisplay object
|
||||
@[inline]
|
||||
pub fn egl_get_display() voidptr {
|
||||
return C.sapp_egl_get_display()
|
||||
}
|
||||
|
||||
// Metal: get bridged pointer to MTKView's depth-stencil texture of type MTLTexture
|
||||
pub fn metal_get_depth_stencil_texture() voidptr {
|
||||
return voidptr(C.sapp_metal_get_depth_stencil_texture())
|
||||
}
|
||||
|
||||
// Metal: get bridged pointer to MTKView's msaa-color-texture of type MTLTexture (may be null)
|
||||
pub fn metal_get_msaa_color_texture() voidptr {
|
||||
return voidptr(C.sapp_metal_get_msaa_color_texture())
|
||||
// EGL: get EGLContext object
|
||||
@[inline]
|
||||
pub fn egl_get_context() voidptr {
|
||||
return C.sapp_egl_get_context()
|
||||
}
|
||||
|
||||
// macOS: get ARC-bridged pointer to macOS NSWindow
|
||||
@@ -277,34 +332,10 @@ pub fn ios_get_window() voidptr {
|
||||
return voidptr(C.sapp_ios_get_window())
|
||||
}
|
||||
|
||||
// D3D11: get pointer to ID3D11Device object
|
||||
// D3D11: get pointer to IDXGISwapChain object
|
||||
@[inline]
|
||||
pub fn d3d11_get_device() voidptr {
|
||||
return voidptr(C.sapp_d3d11_get_device())
|
||||
}
|
||||
|
||||
// D3D11: get pointer to ID3D11DeviceContext object
|
||||
@[inline]
|
||||
pub fn d3d11_get_device_context() voidptr {
|
||||
return voidptr(C.sapp_d3d11_get_device_context())
|
||||
}
|
||||
|
||||
// D3D11: get pointer to ID3D11RenderView object
|
||||
@[inline]
|
||||
pub fn d3d11_get_render_view() voidptr {
|
||||
return voidptr(C.sapp_d3d11_get_render_view())
|
||||
}
|
||||
|
||||
// D3D11: get pointer ID3D11RenderTargetView object for msaa-resolve (may return null)
|
||||
@[inline]
|
||||
pub fn d3d11_get_resolve_view() voidptr {
|
||||
return voidptr(C.sapp_d3d11_get_resolve_view())
|
||||
}
|
||||
|
||||
// D3D11: get pointer to ID3D11DepthStencilView
|
||||
@[inline]
|
||||
pub fn d3d11_get_depth_stencil_view() voidptr {
|
||||
return voidptr(C.sapp_d3d11_get_depth_stencil_view())
|
||||
pub fn d3d11_get_swap_chain() voidptr {
|
||||
return voidptr(C.sapp_d3d11_get_swap_chain())
|
||||
}
|
||||
|
||||
// Win32: get the HWND window handle
|
||||
@@ -313,24 +344,22 @@ pub fn win32_get_hwnd() voidptr {
|
||||
return voidptr(C.sapp_win32_get_hwnd())
|
||||
}
|
||||
|
||||
// WebGPU: get WGPUDevice handle
|
||||
pub fn wgpu_get_device() voidptr {
|
||||
return voidptr(C.sapp_wgpu_get_device())
|
||||
// GL: get major version
|
||||
@[inline]
|
||||
pub fn gl_get_major_version() int {
|
||||
return C.sapp_gl_get_major_version()
|
||||
}
|
||||
|
||||
// WebGPU: get swapchain's WGPUTextureView handle for rendering
|
||||
pub fn wgpu_get_render_view() voidptr {
|
||||
return voidptr(C.sapp_wgpu_get_render_view())
|
||||
// GL: get minor version
|
||||
@[inline]
|
||||
pub fn gl_get_minor_version() int {
|
||||
return C.sapp_gl_get_minor_version()
|
||||
}
|
||||
|
||||
// WebGPU: get swapchain's MSAA-resolve WGPUTextureView (may return null)
|
||||
pub fn wgpu_get_resolve_view() voidptr {
|
||||
return voidptr(C.sapp_wgpu_get_resolve_view())
|
||||
}
|
||||
|
||||
// WebGPU: get swapchain's WGPUTextureView for the depth-stencil surface
|
||||
pub fn wgpu_get_depth_stencil_view() voidptr {
|
||||
return voidptr(C.sapp_wgpu_get_depth_stencil_view())
|
||||
// GL: return true if the context is GLES
|
||||
@[inline]
|
||||
pub fn gl_is_gles() bool {
|
||||
return C.sapp_gl_is_gles()
|
||||
}
|
||||
|
||||
// GL: get framebuffer object
|
||||
@@ -339,10 +368,16 @@ pub fn gl_get_framebuffer() u32 {
|
||||
return C.sapp_gl_get_framebuffer()
|
||||
}
|
||||
|
||||
// Android: get native activity handle
|
||||
// X11: get Window
|
||||
@[inline]
|
||||
pub fn android_get_native_activity() voidptr {
|
||||
return voidptr(C.sapp_android_get_native_activity())
|
||||
pub fn x11_get_window() voidptr {
|
||||
return voidptr(C.sapp_x11_get_window())
|
||||
}
|
||||
|
||||
// X11: get Display
|
||||
@[inline]
|
||||
pub fn x11_get_display() voidptr {
|
||||
return voidptr(C.sapp_x11_get_display())
|
||||
}
|
||||
|
||||
// Toggle full screen
|
||||
@@ -357,14 +392,22 @@ pub fn is_fullscreen() bool {
|
||||
return C.sapp_is_fullscreen()
|
||||
}
|
||||
|
||||
// get_num_dropped_files returns the number of files dropped onto the window.
|
||||
@[inline]
|
||||
pub fn get_num_dropped_files() int {
|
||||
return C.sapp_get_num_dropped_files()
|
||||
}
|
||||
|
||||
// get_dropped_file_path returns the path of a dropped file by index.
|
||||
@[inline]
|
||||
pub fn get_dropped_file_path(index int) string {
|
||||
unsafe {
|
||||
return cstring_to_vstring(C.sapp_get_dropped_file_path(index))
|
||||
}
|
||||
}
|
||||
|
||||
// Android: get native activity handle
|
||||
@[inline]
|
||||
pub fn android_get_native_activity() voidptr {
|
||||
return voidptr(C.sapp_android_get_native_activity())
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
module sapp
|
||||
|
||||
import sokol.memory
|
||||
|
||||
@[typedef]
|
||||
pub struct C.sapp_allocator {
|
||||
pub mut:
|
||||
alloc_fn memory.FnAllocatorAlloc = unsafe { nil }
|
||||
free_fn memory.FnAllocatorFree = unsafe { nil }
|
||||
user_data voidptr
|
||||
}
|
||||
|
||||
@[typedef]
|
||||
pub struct C.sapp_logger {
|
||||
pub mut:
|
||||
func memory.FnLogCb = unsafe { nil }
|
||||
user_data voidptr
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
module sapp
|
||||
|
||||
// EGL initialization and teardown.
|
||||
// Shared between Wayland and X11 backends.
|
||||
|
||||
fn sapp_egl_choose_config() EGLConfig {
|
||||
sample_count := if g_sapp_state.desc.sample_count > 1 {
|
||||
EGLint(g_sapp_state.desc.sample_count)
|
||||
} else {
|
||||
EGLint(0)
|
||||
}
|
||||
alpha_size := if g_sapp_state.desc.alpha { EGLint(8) } else { EGLint(0) }
|
||||
sample_buffers := if g_sapp_state.desc.sample_count > 1 { EGLint(1) } else { EGLint(0) }
|
||||
|
||||
config_attrs := [
|
||||
egl_surface_type,
|
||||
egl_window_bit,
|
||||
egl_renderable_type,
|
||||
egl_opengl_bit,
|
||||
egl_red_size,
|
||||
EGLint(8),
|
||||
egl_green_size,
|
||||
EGLint(8),
|
||||
egl_blue_size,
|
||||
EGLint(8),
|
||||
egl_alpha_size,
|
||||
alpha_size,
|
||||
egl_depth_size,
|
||||
EGLint(24),
|
||||
egl_stencil_size,
|
||||
EGLint(8),
|
||||
egl_sample_buffers,
|
||||
sample_buffers,
|
||||
egl_samples,
|
||||
sample_count,
|
||||
egl_none,
|
||||
]!
|
||||
|
||||
mut egl_configs := unsafe { [32]EGLConfig{} }
|
||||
mut config_count := EGLint(0)
|
||||
if C.eglChooseConfig(g_sapp_state.egl.display, &config_attrs[0], &egl_configs[0], 32, &config_count) == 0
|
||||
|| config_count == 0 {
|
||||
eprintln('sokol_app: EGL: no configs found')
|
||||
return egl_configs[0]
|
||||
}
|
||||
|
||||
mut config := egl_configs[0]
|
||||
for i in 0 .. int(config_count) {
|
||||
c := egl_configs[i]
|
||||
mut r := EGLint(0)
|
||||
mut g := EGLint(0)
|
||||
mut b := EGLint(0)
|
||||
mut a := EGLint(0)
|
||||
mut d := EGLint(0)
|
||||
mut s := EGLint(0)
|
||||
mut n := EGLint(0)
|
||||
if C.eglGetConfigAttrib(g_sapp_state.egl.display, c, egl_red_size, &r) != 0
|
||||
&& C.eglGetConfigAttrib(g_sapp_state.egl.display, c, egl_green_size, &g) != 0
|
||||
&& C.eglGetConfigAttrib(g_sapp_state.egl.display, c, egl_blue_size, &b) != 0
|
||||
&& C.eglGetConfigAttrib(g_sapp_state.egl.display, c, egl_alpha_size, &a) != 0
|
||||
&& C.eglGetConfigAttrib(g_sapp_state.egl.display, c, egl_depth_size, &d) != 0
|
||||
&& C.eglGetConfigAttrib(g_sapp_state.egl.display, c, egl_stencil_size, &s) != 0
|
||||
&& C.eglGetConfigAttrib(g_sapp_state.egl.display, c, egl_samples, &n) != 0 && r == 8
|
||||
&& g == 8 && b == 8 && a == alpha_size && d == 24 && s == 8 && n == sample_count {
|
||||
config = c
|
||||
break
|
||||
}
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
fn sapp_egl_create_context(config EGLConfig) {
|
||||
gl_major := if g_sapp_state.desc.gl.major_version != 0 {
|
||||
g_sapp_state.desc.gl.major_version
|
||||
} else {
|
||||
4
|
||||
}
|
||||
gl_minor := if g_sapp_state.desc.gl.minor_version != 0 {
|
||||
g_sapp_state.desc.gl.minor_version
|
||||
} else {
|
||||
1
|
||||
}
|
||||
|
||||
ctx_attrs := [
|
||||
egl_context_major_version,
|
||||
EGLint(gl_major),
|
||||
egl_context_minor_version,
|
||||
EGLint(gl_minor),
|
||||
egl_context_opengl_profile_mask,
|
||||
egl_context_opengl_core_profile_bit,
|
||||
egl_none,
|
||||
]!
|
||||
|
||||
g_sapp_state.egl.context = C.eglCreateContext(g_sapp_state.egl.display, config, unsafe { nil },
|
||||
&ctx_attrs[0])
|
||||
if g_sapp_state.egl.context == unsafe { nil } {
|
||||
eprintln('sokol_app: EGL: failed to create context')
|
||||
}
|
||||
}
|
||||
|
||||
fn sapp_egl_create_surface(native_window voidptr) {
|
||||
config := sapp_egl_choose_config()
|
||||
g_sapp_state.egl.config = config
|
||||
g_sapp_state.egl.surface = C.eglCreateWindowSurface(g_sapp_state.egl.display, config,
|
||||
native_window, unsafe { nil })
|
||||
if g_sapp_state.egl.surface == unsafe { nil } {
|
||||
eprintln('sokol_app: EGL: failed to create window surface')
|
||||
}
|
||||
if g_sapp_state.egl.context == unsafe { nil } {
|
||||
sapp_egl_create_context(config)
|
||||
}
|
||||
}
|
||||
|
||||
fn sapp_egl_make_current() {
|
||||
if C.eglMakeCurrent(g_sapp_state.egl.display, g_sapp_state.egl.surface, g_sapp_state.egl.surface,
|
||||
g_sapp_state.egl.context) == 0 {
|
||||
eprintln('sokol_app: EGL: eglMakeCurrent failed')
|
||||
}
|
||||
mut fb := i32(0)
|
||||
C.glGetIntegerv(gl_framebuffer_binding, &fb)
|
||||
g_sapp_state.gl.framebuffer = u32(fb)
|
||||
C.eglSwapInterval(g_sapp_state.egl.display, EGLint(g_sapp_state.swap_interval))
|
||||
}
|
||||
|
||||
$if sokol_wayland ? {
|
||||
fn sapp_egl_init_wayland() {
|
||||
if C.eglBindAPI(egl_opengl_api) == 0 {
|
||||
eprintln('sokol_app: EGL: failed to bind OpenGL API')
|
||||
}
|
||||
|
||||
g_sapp_state.egl.display = C.eglGetDisplay(voidptr(g_sapp_state.wl.display))
|
||||
if g_sapp_state.egl.display == unsafe { nil } {
|
||||
eprintln('sokol_app: EGL: failed to get display')
|
||||
}
|
||||
|
||||
mut major := EGLint(0)
|
||||
mut minor := EGLint(0)
|
||||
if C.eglInitialize(g_sapp_state.egl.display, &major, &minor) == 0 {
|
||||
eprintln('sokol_app: EGL: failed to initialize')
|
||||
}
|
||||
g_sapp_state.gl.major = int(major)
|
||||
g_sapp_state.gl.minor = int(minor)
|
||||
}
|
||||
}
|
||||
|
||||
fn sapp_egl_init_x11() {
|
||||
if C.eglBindAPI(egl_opengl_api) == 0 {
|
||||
eprintln('sokol_app: EGL: failed to bind OpenGL API')
|
||||
}
|
||||
|
||||
g_sapp_state.egl.display = C.eglGetDisplay(voidptr(g_sapp_state.x11.display))
|
||||
if g_sapp_state.egl.display == unsafe { nil } {
|
||||
eprintln('sokol_app: EGL: failed to get display')
|
||||
}
|
||||
|
||||
mut major := EGLint(0)
|
||||
mut minor := EGLint(0)
|
||||
if C.eglInitialize(g_sapp_state.egl.display, &major, &minor) == 0 {
|
||||
eprintln('sokol_app: EGL: failed to initialize')
|
||||
}
|
||||
g_sapp_state.gl.major = int(major)
|
||||
g_sapp_state.gl.minor = int(minor)
|
||||
|
||||
config := sapp_egl_choose_config()
|
||||
|
||||
mut visual_id := EGLint(0)
|
||||
if C.eglGetConfigAttrib(g_sapp_state.egl.display, config, EGLint(0x302E), &visual_id) == 0 {
|
||||
eprintln('sokol_app: EGL: failed to get native visual ID')
|
||||
}
|
||||
|
||||
mut visual_info_template := C.XVisualInfo{}
|
||||
visual_info_template.visualid = VisualID(visual_id)
|
||||
|
||||
mut num_visuals := 0
|
||||
visual_info := C.XGetVisualInfo(g_sapp_state.x11.display, visual_id_mask, &visual_info_template,
|
||||
&num_visuals)
|
||||
if visual_info == unsafe { nil } {
|
||||
eprintln('sokol_app: EGL: failed to get visual info')
|
||||
}
|
||||
|
||||
x11_create_window(visual_info.visual, visual_info.depth)
|
||||
C.XFree(visual_info)
|
||||
|
||||
g_sapp_state.egl.surface = C.eglCreateWindowSurface(g_sapp_state.egl.display, config,
|
||||
EGLNativeWindowType(g_sapp_state.x11.window), unsafe { nil })
|
||||
if g_sapp_state.egl.surface == unsafe { nil } {
|
||||
eprintln('sokol_app: EGL: failed to create window surface')
|
||||
}
|
||||
|
||||
sapp_egl_create_context(config)
|
||||
sapp_egl_make_current()
|
||||
}
|
||||
|
||||
fn sapp_egl_destroy() {
|
||||
if g_sapp_state.egl.display != unsafe { nil } {
|
||||
C.eglMakeCurrent(g_sapp_state.egl.display, unsafe { nil }, unsafe { nil }, unsafe { nil })
|
||||
|
||||
if g_sapp_state.egl.context != unsafe { nil } {
|
||||
C.eglDestroyContext(g_sapp_state.egl.display, g_sapp_state.egl.context)
|
||||
g_sapp_state.egl.context = unsafe { nil }
|
||||
}
|
||||
|
||||
if g_sapp_state.egl.surface != unsafe { nil } {
|
||||
C.eglDestroySurface(g_sapp_state.egl.display, g_sapp_state.egl.surface)
|
||||
g_sapp_state.egl.surface = unsafe { nil }
|
||||
}
|
||||
|
||||
C.eglTerminate(g_sapp_state.egl.display)
|
||||
g_sapp_state.egl.display = unsafe { nil }
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
module sapp
|
||||
|
||||
#define SOKOL_VALIDATE_NON_FATAL 1
|
||||
|
||||
// returns true after sokol-app has been initialized
|
||||
fn C.sapp_isvalid() bool
|
||||
|
||||
@@ -47,6 +49,15 @@ fn C.sapp_mouse_shown() bool
|
||||
// set mouse cursor
|
||||
fn C.sapp_set_mouse_cursor(cursor MouseCursor)
|
||||
|
||||
// get current mouse cursor type
|
||||
fn C.sapp_get_mouse_cursor() MouseCursor
|
||||
|
||||
// bind a custom mouse cursor image to a cursor type, returns the cursor type
|
||||
fn C.sapp_bind_mouse_cursor_image(cursor MouseCursor, desc &ImageDesc) MouseCursor
|
||||
|
||||
// unbind a custom mouse cursor image
|
||||
fn C.sapp_unbind_mouse_cursor_image(cursor MouseCursor)
|
||||
|
||||
// lock or unlock the mouse cursor
|
||||
fn C.sapp_lock_mouse(locked bool)
|
||||
|
||||
@@ -87,7 +98,7 @@ fn C.sapp_get_clipboard_string() &char
|
||||
fn C.sapp_set_window_title(&char)
|
||||
|
||||
// set the window icon (only on Windows and Linux)
|
||||
// SOKOL_APP_API_DECL void sapp_set_icon(const sapp_icon_desc* icon_desc);
|
||||
fn C.sapp_set_icon(icon_desc &IconDesc)
|
||||
|
||||
// Get number of dropped files
|
||||
fn C.sapp_get_num_dropped_files() i32
|
||||
@@ -98,26 +109,23 @@ fn C.sapp_get_dropped_file_path(i32) &char
|
||||
// special run-function for SOKOL_NO_ENTRY (in standard mode this is an empty stub)
|
||||
fn C.sapp_run(desc &Desc) i32
|
||||
|
||||
// get runtime environment information
|
||||
fn C.sapp_get_environment() Environment
|
||||
|
||||
// get current frame's swapchain information (call once per frame!)
|
||||
fn C.sapp_get_swapchain() Swapchain
|
||||
|
||||
// EGL: get EGLDisplay object
|
||||
fn C.sapp_egl_get_display() voidptr
|
||||
|
||||
// EGL: get EGLContext object
|
||||
fn C.sapp_egl_get_context() voidptr
|
||||
|
||||
// HTML5: enable or disable the hardwired "Leave Site?" dialog box
|
||||
fn C.sapp_html5_ask_leave_site(ask bool)
|
||||
|
||||
// HTML5: get byte size of a dropped file
|
||||
// SOKOL_APP_API_DECL uint32_t sapp_html5_get_dropped_file_size(int index);
|
||||
|
||||
// HTML5: asynchronously load the content of a dropped file
|
||||
// SOKOL_APP_API_DECL void sapp_html5_fetch_dropped_file(const sapp_html5_fetch_request* request);
|
||||
|
||||
// Metal: get ARC-bridged pointer to Metal device object
|
||||
fn C.sapp_metal_get_device() voidptr
|
||||
|
||||
// Metal: get ARC-bridged pointer to current drawable
|
||||
fn C.sapp_metal_get_current_drawable() voidptr
|
||||
|
||||
// Metal: get bridged pointer to MTKView's depth-stencil texture of type MTLTexture
|
||||
fn C.sapp_metal_get_depth_stencil_texture() voidptr
|
||||
|
||||
// Metal: get bridged pointer to MTKView's msaa-color-texture of type MTLTexture (may be null)
|
||||
fn C.sapp_metal_get_msaa_color_texture() voidptr
|
||||
fn C.sapp_html5_get_dropped_file_size(index i32) u32
|
||||
|
||||
// macOS: get ARC-bridged pointer to macOS NSWindow
|
||||
fn C.sapp_macos_get_window() voidptr
|
||||
@@ -125,41 +133,32 @@ fn C.sapp_macos_get_window() voidptr
|
||||
// iOS: get ARC-bridged pointer to iOS UIWindow
|
||||
fn C.sapp_ios_get_window() voidptr
|
||||
|
||||
// D3D11: get pointer to ID3D11Device object
|
||||
fn C.sapp_d3d11_get_device() voidptr
|
||||
|
||||
// D3D11: get pointer to ID3D11DeviceContext object
|
||||
fn C.sapp_d3d11_get_device_context() voidptr
|
||||
|
||||
// D3D11: get pointer to IDXGISwapChain object
|
||||
fn C.sapp_d3d11_get_swap_chain() voidptr
|
||||
|
||||
// D3D11: get pointer to ID3D11RenderView object
|
||||
fn C.sapp_d3d11_get_render_view() voidptr
|
||||
|
||||
// D3D11: get pointer ID3D11RenderTargetView object for msaa-resolve (may return null)
|
||||
fn C.sapp_d3d11_get_resolve_view() voidptr
|
||||
|
||||
// D3D11: get pointer to ID3D11DepthStencilView
|
||||
fn C.sapp_d3d11_get_depth_stencil_view() voidptr
|
||||
|
||||
// Win32: get the HWND window handle
|
||||
fn C.sapp_win32_get_hwnd() voidptr
|
||||
|
||||
// WebGPU: get WGPUDevice handle
|
||||
fn C.sapp_wgpu_get_device() voidptr
|
||||
// GL: get major version
|
||||
fn C.sapp_gl_get_major_version() i32
|
||||
|
||||
// WebGPU: get swapchain's WGPUTextureView handle for rendering
|
||||
fn C.sapp_wgpu_get_render_view() voidptr
|
||||
// GL: get minor version
|
||||
fn C.sapp_gl_get_minor_version() i32
|
||||
|
||||
// WebGPU: get swapchain's MSAA-resolve WGPUTextureView (may return null)
|
||||
fn C.sapp_wgpu_get_resolve_view() voidptr
|
||||
|
||||
// WebGPU: get swapchain's WGPUTextureView for the depth-stencil surface
|
||||
fn C.sapp_wgpu_get_depth_stencil_view() voidptr
|
||||
// GL: return true if the context is GLES
|
||||
fn C.sapp_gl_is_gles() bool
|
||||
|
||||
// GL: get framebuffer object
|
||||
fn C.sapp_gl_get_framebuffer() u32
|
||||
|
||||
// X11: get Window
|
||||
fn C.sapp_x11_get_window() voidptr
|
||||
|
||||
// X11: get Display
|
||||
fn C.sapp_x11_get_display() voidptr
|
||||
|
||||
// Android: get native activity handle
|
||||
fn C.sapp_android_get_native_activity() voidptr
|
||||
|
||||
// V-specific: read RGBA pixels from the OpenGL framebuffer
|
||||
fn C.v_sapp_gl_read_rgba_pixels(x i32, y i32, width i32, height i32, pixels charptr)
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,62 @@
|
||||
module sapp
|
||||
|
||||
// Shared state structs for the V sokol_app backends.
|
||||
// Platform-specific state (SappState, g_sapp_state, SappWayland, SappWin32, etc.)
|
||||
// lives in sapp_state_linux.v / sapp_state_windows.v respectively.
|
||||
|
||||
const ring_num_slots = 256
|
||||
const max_title_length = 128
|
||||
const mousecursor_num = 27
|
||||
|
||||
// Timing state for frame duration averaging
|
||||
struct SappTiming {
|
||||
mut:
|
||||
last f64
|
||||
accum f64
|
||||
avg f64
|
||||
spike_count int
|
||||
num int
|
||||
ring_head int
|
||||
ring_tail int
|
||||
ring_buf [ring_num_slots]f64
|
||||
}
|
||||
|
||||
// Mouse state
|
||||
struct SappMouse {
|
||||
mut:
|
||||
x f32
|
||||
y f32
|
||||
dx f32
|
||||
dy f32
|
||||
shown bool
|
||||
locked bool
|
||||
pos_valid bool
|
||||
current_cursor MouseCursor
|
||||
}
|
||||
|
||||
// Clipboard state
|
||||
struct SappClipboard {
|
||||
mut:
|
||||
enabled bool
|
||||
buf_size int
|
||||
buffer &char = unsafe { nil }
|
||||
}
|
||||
|
||||
// Drag and drop state
|
||||
struct SappDrop {
|
||||
mut:
|
||||
enabled bool
|
||||
max_files int
|
||||
max_path_length int
|
||||
num_files int
|
||||
buf_size int
|
||||
buffer &char = unsafe { nil }
|
||||
}
|
||||
|
||||
// GL state
|
||||
struct SappGl {
|
||||
mut:
|
||||
framebuffer u32
|
||||
major int
|
||||
minor int
|
||||
}
|
||||
@@ -0,0 +1,393 @@
|
||||
@[has_globals]
|
||||
module sapp
|
||||
|
||||
// Linux-specific state structs for the V sokol_app backend.
|
||||
// Shared state (SappTiming, SappMouse, etc.) is in sapp_state.v.
|
||||
|
||||
// Wayland-specific state (only compiled when -d sokol_wayland is used)
|
||||
$if sokol_wayland ? {
|
||||
struct SappWayland {
|
||||
mut:
|
||||
// Core Wayland objects
|
||||
display &C.wl_display = unsafe { nil }
|
||||
registry &C.wl_registry = unsafe { nil }
|
||||
compositor &C.wl_compositor = unsafe { nil }
|
||||
surface &C.wl_surface = unsafe { nil }
|
||||
egl_window &C.wl_egl_window = unsafe { nil }
|
||||
shm &C.wl_shm = unsafe { nil }
|
||||
// XDG shell
|
||||
xdg_wm_base &C.xdg_wm_base = unsafe { nil }
|
||||
xdg_surface &C.xdg_surface = unsafe { nil }
|
||||
xdg_toplevel &C.xdg_toplevel = unsafe { nil }
|
||||
// Input
|
||||
seat &C.wl_seat = unsafe { nil }
|
||||
pointer &C.wl_pointer = unsafe { nil }
|
||||
keyboard &C.wl_keyboard = unsafe { nil }
|
||||
touch &C.wl_touch = unsafe { nil }
|
||||
seat_version u32
|
||||
// Pointer constraints
|
||||
pointer_constraints &C.zwp_pointer_constraints_v1 = unsafe { nil }
|
||||
locked_pointer &C.zwp_locked_pointer_v1 = unsafe { nil }
|
||||
relative_pointer_mgr &C.zwp_relative_pointer_manager_v1 = unsafe { nil }
|
||||
relative_pointer &C.zwp_relative_pointer_v1 = unsafe { nil }
|
||||
// XKB keyboard handling
|
||||
xkb_context &C.xkb_context = unsafe { nil }
|
||||
xkb_keymap &C.xkb_keymap = unsafe { nil }
|
||||
xkb_state &C.xkb_state = unsafe { nil }
|
||||
xkb_compose_table &C.xkb_compose_table = unsafe { nil }
|
||||
xkb_compose_state &C.xkb_compose_state = unsafe { nil }
|
||||
// Cursor
|
||||
cursor_shape_manager &C.wp_cursor_shape_manager_v1 = unsafe { nil }
|
||||
cursor_shape_device &C.wp_cursor_shape_device_v1 = unsafe { nil }
|
||||
cursor_theme &C.wl_cursor_theme = unsafe { nil }
|
||||
cursor_default &C.wl_cursor = unsafe { nil }
|
||||
cursor_surface &C.wl_surface = unsafe { nil }
|
||||
cursor_size int
|
||||
// Fractional scale
|
||||
fractional_scale_mgr &C.wp_fractional_scale_manager_v1 = unsafe { nil }
|
||||
fractional_scale &C.wp_fractional_scale_v1 = unsafe { nil }
|
||||
scale_numerator u32
|
||||
// Viewporter
|
||||
viewporter &C.wp_viewporter = unsafe { nil }
|
||||
viewport &C.wp_viewport = unsafe { nil }
|
||||
// Decorations
|
||||
decoration_manager &C.zxdg_decoration_manager_v1 = unsafe { nil }
|
||||
toplevel_decoration &C.zxdg_toplevel_decoration_v1 = unsafe { nil }
|
||||
// Clipboard / data device
|
||||
data_device_manager &C.wl_data_device_manager = unsafe { nil }
|
||||
data_device &C.wl_data_device = unsafe { nil }
|
||||
data_source &C.wl_data_source = unsafe { nil }
|
||||
data_offer &C.wl_data_offer = unsafe { nil }
|
||||
clipboard_string &char = unsafe { nil }
|
||||
clipboard_size int
|
||||
// Window state
|
||||
width int
|
||||
height int
|
||||
fb_width int
|
||||
fb_height int
|
||||
scale f32 = 1.0
|
||||
configured bool
|
||||
closed bool
|
||||
fullscreen bool
|
||||
maximized bool
|
||||
focused bool
|
||||
// Pointer state
|
||||
pointer_x f32
|
||||
pointer_y f32
|
||||
pointer_enter_serial u32
|
||||
// Key repeat
|
||||
key_repeat_rate int = 25
|
||||
key_repeat_delay int = 600
|
||||
key_repeat_timer_fd int = -1
|
||||
key_repeat_keycode u32
|
||||
}
|
||||
} $else {
|
||||
// Dummy struct for non-Wayland builds
|
||||
struct SappWayland {}
|
||||
}
|
||||
|
||||
// X11 XInput extension state
|
||||
struct SappXi {
|
||||
mut:
|
||||
available bool
|
||||
major_opcode int
|
||||
event_base int
|
||||
error_base int
|
||||
major int
|
||||
minor int
|
||||
}
|
||||
|
||||
// X11 XDnD state
|
||||
struct SappXdnd {
|
||||
mut:
|
||||
version i64
|
||||
source Window
|
||||
format Atom
|
||||
xdnd_aware Atom
|
||||
xdnd_enter Atom
|
||||
xdnd_position Atom
|
||||
xdnd_status Atom
|
||||
xdnd_action_copy Atom
|
||||
xdnd_drop Atom
|
||||
xdnd_finished Atom
|
||||
xdnd_selection Atom
|
||||
xdnd_type_list Atom
|
||||
text_uri_list Atom
|
||||
}
|
||||
|
||||
// X11-specific state
|
||||
struct SappX11 {
|
||||
mut:
|
||||
mouse_buttons u8
|
||||
display &C.Display = unsafe { nil }
|
||||
screen int
|
||||
root Window
|
||||
colormap Colormap
|
||||
window Window
|
||||
hidden_cursor Cursor
|
||||
standard_cursors [mousecursor_num]Cursor
|
||||
custom_cursors [mousecursor_num]Cursor
|
||||
window_state int
|
||||
dpi f32
|
||||
error_code u8
|
||||
// X atoms
|
||||
utf8_string Atom
|
||||
clipboard_atom Atom
|
||||
targets Atom
|
||||
wm_protocols Atom
|
||||
wm_delete_window Atom
|
||||
wm_state Atom
|
||||
net_wm_name Atom
|
||||
net_wm_icon_name Atom
|
||||
net_wm_icon Atom
|
||||
net_wm_state Atom
|
||||
net_wm_state_fullscreen Atom
|
||||
// Extensions
|
||||
xi SappXi
|
||||
xdnd SappXdnd
|
||||
// Key repeat tracking (keycodes 0..255)
|
||||
key_repeat [256]bool
|
||||
}
|
||||
|
||||
// EGL state
|
||||
struct SappEgl {
|
||||
mut:
|
||||
display EGLDisplay
|
||||
context EGLContext
|
||||
surface EGLSurface
|
||||
config EGLConfig
|
||||
}
|
||||
|
||||
// Main application state - Linux version with Wayland/X11/EGL backends
|
||||
struct SappState {
|
||||
mut:
|
||||
desc Desc
|
||||
valid bool
|
||||
fullscreen bool
|
||||
first_frame bool
|
||||
init_called bool
|
||||
cleanup_called bool
|
||||
quit_requested bool
|
||||
quit_ordered bool
|
||||
event_consumed bool
|
||||
html5_ask_leave_site bool
|
||||
onscreen_keyboard_shown bool
|
||||
window_width int
|
||||
window_height int
|
||||
framebuffer_width int
|
||||
framebuffer_height int
|
||||
sample_count int
|
||||
swap_interval int
|
||||
dpi_scale f32 = 1.0
|
||||
frame_count u64
|
||||
timing SappTiming
|
||||
event Event
|
||||
mouse SappMouse
|
||||
clipboard SappClipboard
|
||||
drop SappDrop
|
||||
// Platform-specific state
|
||||
wl SappWayland
|
||||
x11 SappX11
|
||||
egl SappEgl
|
||||
gl SappGl
|
||||
// Keycode translation table
|
||||
keycodes [max_keycodes]KeyCode
|
||||
// Window title
|
||||
window_title [max_title_length]u8
|
||||
// V patch
|
||||
v_native_render bool
|
||||
// Custom cursors
|
||||
custom_cursor_bound [mousecursor_num]bool
|
||||
}
|
||||
|
||||
// The global state instance
|
||||
__global g_sapp_state = SappState{}
|
||||
|
||||
// === Shared helper functions ===
|
||||
|
||||
// init_sapp_event initializes an event struct with common fields.
|
||||
fn init_sapp_event(event_type EventType) {
|
||||
unsafe { C.memset(&g_sapp_state.event, 0, int(sizeof(g_sapp_state.event))) }
|
||||
g_sapp_state.event.@type = event_type
|
||||
g_sapp_state.event.frame_count = g_sapp_state.frame_count
|
||||
g_sapp_state.event.mouse_button = .invalid
|
||||
g_sapp_state.event.window_width = g_sapp_state.window_width
|
||||
g_sapp_state.event.window_height = g_sapp_state.window_height
|
||||
g_sapp_state.event.framebuffer_width = g_sapp_state.framebuffer_width
|
||||
g_sapp_state.event.framebuffer_height = g_sapp_state.framebuffer_height
|
||||
g_sapp_state.event.mouse_x = g_sapp_state.mouse.x
|
||||
g_sapp_state.event.mouse_y = g_sapp_state.mouse.y
|
||||
g_sapp_state.event.mouse_dx = g_sapp_state.mouse.dx
|
||||
g_sapp_state.event.mouse_dy = g_sapp_state.mouse.dy
|
||||
}
|
||||
|
||||
// call_sapp_event dispatches the event to the user's callback.
|
||||
fn call_sapp_event(e &Event) bool {
|
||||
if !g_sapp_state.cleanup_called {
|
||||
if g_sapp_state.desc.event_cb != unsafe { nil } {
|
||||
g_sapp_state.desc.event_cb(e)
|
||||
} else if g_sapp_state.desc.event_userdata_cb != unsafe { nil } {
|
||||
g_sapp_state.desc.event_userdata_cb(e, g_sapp_state.desc.user_data)
|
||||
}
|
||||
}
|
||||
if g_sapp_state.event_consumed {
|
||||
g_sapp_state.event_consumed = false
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// sapp_call_init calls the user's init callback.
|
||||
fn sapp_call_init() {
|
||||
if g_sapp_state.desc.init_cb != unsafe { nil } {
|
||||
g_sapp_state.desc.init_cb()
|
||||
} else if g_sapp_state.desc.init_userdata_cb != unsafe { nil } {
|
||||
g_sapp_state.desc.init_userdata_cb(g_sapp_state.desc.user_data)
|
||||
}
|
||||
g_sapp_state.init_called = true
|
||||
}
|
||||
|
||||
// sapp_call_frame calls the user's frame callback.
|
||||
fn sapp_call_frame() {
|
||||
if g_sapp_state.desc.frame_cb != unsafe { nil } {
|
||||
g_sapp_state.desc.frame_cb()
|
||||
} else if g_sapp_state.desc.frame_userdata_cb != unsafe { nil } {
|
||||
g_sapp_state.desc.frame_userdata_cb(g_sapp_state.desc.user_data)
|
||||
}
|
||||
}
|
||||
|
||||
// sapp_call_cleanup calls the user's cleanup callback.
|
||||
fn sapp_call_cleanup() {
|
||||
if !g_sapp_state.cleanup_called {
|
||||
if g_sapp_state.desc.cleanup_cb != unsafe { nil } {
|
||||
g_sapp_state.desc.cleanup_cb()
|
||||
} else if g_sapp_state.desc.cleanup_userdata_cb != unsafe { nil } {
|
||||
g_sapp_state.desc.cleanup_userdata_cb(g_sapp_state.desc.user_data)
|
||||
}
|
||||
g_sapp_state.cleanup_called = true
|
||||
}
|
||||
}
|
||||
|
||||
// sapp_do_frame handles the per-frame logic.
|
||||
fn sapp_do_frame() {
|
||||
if g_sapp_state.first_frame {
|
||||
g_sapp_state.first_frame = false
|
||||
sapp_call_init()
|
||||
}
|
||||
sapp_call_frame()
|
||||
g_sapp_state.frame_count++
|
||||
}
|
||||
|
||||
// === Timing helpers ===
|
||||
|
||||
fn sapp_timing_reset(t &SappTiming) {
|
||||
unsafe {
|
||||
mut mt := t
|
||||
mt.last = 0.0
|
||||
mt.accum = 0.0
|
||||
mt.avg = 0.0
|
||||
mt.spike_count = 0
|
||||
mt.num = 0
|
||||
mt.ring_head = 0
|
||||
mt.ring_tail = 0
|
||||
}
|
||||
}
|
||||
|
||||
fn sapp_timing_get_avg(t &SappTiming) f64 {
|
||||
return t.avg
|
||||
}
|
||||
|
||||
// === Drop file helpers ===
|
||||
|
||||
fn sapp_dropped_file_path_ptr(index int) &char {
|
||||
assert g_sapp_state.drop.buffer != unsafe { nil }
|
||||
assert index >= 0 && index <= g_sapp_state.drop.max_files
|
||||
offset := index * g_sapp_state.drop.max_path_length
|
||||
assert offset < g_sapp_state.drop.buf_size
|
||||
return unsafe { &char(g_sapp_state.drop.buffer + offset) }
|
||||
}
|
||||
|
||||
// === State initialization ===
|
||||
|
||||
fn sapp_desc_defaults(desc &Desc) Desc {
|
||||
mut res := *desc
|
||||
if res.sample_count == 0 {
|
||||
res.sample_count = 1
|
||||
}
|
||||
if res.swap_interval == 0 {
|
||||
res.swap_interval = 1
|
||||
}
|
||||
if res.gl.major_version == 0 {
|
||||
res.gl.major_version = 4
|
||||
res.gl.minor_version = 3
|
||||
}
|
||||
if res.clipboard_size == 0 {
|
||||
res.clipboard_size = 8192
|
||||
}
|
||||
if res.max_dropped_files == 0 {
|
||||
res.max_dropped_files = 1
|
||||
}
|
||||
if res.max_dropped_file_path_length == 0 {
|
||||
res.max_dropped_file_path_length = 2048
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
fn sapp_init_state(desc &Desc) {
|
||||
unsafe { C.memset(&g_sapp_state, 0, int(sizeof(g_sapp_state))) }
|
||||
g_sapp_state.desc = sapp_desc_defaults(desc)
|
||||
g_sapp_state.first_frame = true
|
||||
g_sapp_state.window_width = g_sapp_state.desc.width
|
||||
g_sapp_state.window_height = g_sapp_state.desc.height
|
||||
g_sapp_state.framebuffer_width = g_sapp_state.window_width
|
||||
g_sapp_state.framebuffer_height = g_sapp_state.window_height
|
||||
g_sapp_state.sample_count = g_sapp_state.desc.sample_count
|
||||
g_sapp_state.swap_interval = g_sapp_state.desc.swap_interval
|
||||
g_sapp_state.clipboard.enabled = g_sapp_state.desc.enable_clipboard
|
||||
if g_sapp_state.clipboard.enabled {
|
||||
g_sapp_state.clipboard.buf_size = g_sapp_state.desc.clipboard_size
|
||||
g_sapp_state.clipboard.buffer = unsafe { &char(C.calloc(1, usize(g_sapp_state.clipboard.buf_size))) }
|
||||
}
|
||||
g_sapp_state.drop.enabled = g_sapp_state.desc.enable_dragndrop
|
||||
if g_sapp_state.drop.enabled {
|
||||
g_sapp_state.drop.max_files = g_sapp_state.desc.max_dropped_files
|
||||
g_sapp_state.drop.max_path_length = g_sapp_state.desc.max_dropped_file_path_length
|
||||
g_sapp_state.drop.buf_size = g_sapp_state.drop.max_files * g_sapp_state.drop.max_path_length
|
||||
g_sapp_state.drop.buffer = unsafe { &char(C.calloc(1, usize(g_sapp_state.drop.buf_size))) }
|
||||
}
|
||||
// Copy window title
|
||||
if g_sapp_state.desc.window_title != unsafe { nil }
|
||||
&& unsafe { C.strlen(g_sapp_state.desc.window_title) } > 0 {
|
||||
title := g_sapp_state.desc.window_title
|
||||
mut i := 0
|
||||
for i < max_title_length - 1 {
|
||||
ch := unsafe { title[i] }
|
||||
if ch == 0 {
|
||||
break
|
||||
}
|
||||
g_sapp_state.window_title[i] = u8(ch)
|
||||
i++
|
||||
}
|
||||
g_sapp_state.window_title[i] = 0
|
||||
} else {
|
||||
// Default title
|
||||
g_sapp_state.window_title[0] = `s`
|
||||
g_sapp_state.window_title[1] = `o`
|
||||
g_sapp_state.window_title[2] = `k`
|
||||
g_sapp_state.window_title[3] = `o`
|
||||
g_sapp_state.window_title[4] = `l`
|
||||
g_sapp_state.window_title[5] = 0
|
||||
}
|
||||
g_sapp_state.dpi_scale = 1.0
|
||||
g_sapp_state.fullscreen = g_sapp_state.desc.fullscreen
|
||||
g_sapp_state.mouse.shown = true
|
||||
}
|
||||
|
||||
fn sapp_discard_state() {
|
||||
if g_sapp_state.clipboard.enabled && g_sapp_state.clipboard.buffer != unsafe { nil } {
|
||||
unsafe { C.free(g_sapp_state.clipboard.buffer) }
|
||||
}
|
||||
if g_sapp_state.drop.enabled && g_sapp_state.drop.buffer != unsafe { nil } {
|
||||
unsafe { C.free(g_sapp_state.drop.buffer) }
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,31 @@
|
||||
module sapp
|
||||
|
||||
import sokol.memory
|
||||
|
||||
const max_touchpoints = 8
|
||||
const max_mousebuttons = 3
|
||||
const max_keycodes = 512
|
||||
const max_iconimages = 8
|
||||
|
||||
@[typedef]
|
||||
pub struct C.sapp_allocator {
|
||||
pub mut:
|
||||
alloc_fn memory.FnAllocatorAlloc = unsafe { nil }
|
||||
free_fn memory.FnAllocatorFree = unsafe { nil }
|
||||
user_data voidptr
|
||||
}
|
||||
|
||||
pub type Allocator = C.sapp_allocator
|
||||
|
||||
@[typedef]
|
||||
pub struct C.sapp_logger {
|
||||
pub mut:
|
||||
func memory.FnLogCb = unsafe { nil }
|
||||
user_data voidptr
|
||||
}
|
||||
|
||||
pub type Logger = C.sapp_logger
|
||||
|
||||
// sapp_range is a general pointer/size-pair struct for passing binary blobs into sokol_app.h
|
||||
@[typedef]
|
||||
pub struct C.sapp_range {
|
||||
@@ -18,9 +39,11 @@ pub type Range = C.sapp_range
|
||||
@[typedef]
|
||||
pub struct C.sapp_image_desc {
|
||||
pub:
|
||||
width int
|
||||
height int
|
||||
pixels Range
|
||||
width int
|
||||
height int
|
||||
cursor_hotspot_x int
|
||||
cursor_hotspot_y int
|
||||
pixels Range
|
||||
}
|
||||
|
||||
pub type ImageDesc = C.sapp_image_desc
|
||||
@@ -35,60 +58,225 @@ pub:
|
||||
pub type IconDesc = C.sapp_icon_desc
|
||||
|
||||
@[typedef]
|
||||
pub struct C.sapp_desc {
|
||||
pub struct C.sapp_gl_desc {
|
||||
pub mut:
|
||||
major_version int // override GL/GLES major version
|
||||
minor_version int // override GL/GLES minor version
|
||||
}
|
||||
|
||||
pub type GlDesc = C.sapp_gl_desc
|
||||
|
||||
@[typedef]
|
||||
pub struct C.sapp_win32_desc {
|
||||
pub:
|
||||
console_utf8 bool // if true, set the output console codepage to UTF-8
|
||||
console_create bool // if true, attach stdout/stderr to a new console window
|
||||
console_attach bool // if true, attach stdout/stderr to parent process
|
||||
}
|
||||
|
||||
pub type Win32Desc = C.sapp_win32_desc
|
||||
|
||||
@[typedef]
|
||||
pub struct C.sapp_html5_desc {
|
||||
pub:
|
||||
canvas_selector &char = c'#canvas' // css selector of the HTML5 canvas element, default is "#canvas"
|
||||
canvas_resize bool // if true, the HTML5 canvas size is set to sapp_desc.width/height
|
||||
preserve_drawing_buffer bool // HTML5 only: whether to preserve default framebuffer content between frames
|
||||
premultiplied_alpha bool // HTML5 only: whether the rendered pixels use premultiplied alpha convention
|
||||
ask_leave_site bool // initial state of the internal html5_ask_leave_site flag
|
||||
update_document_title bool // if true, update the HTML document.title with sapp_desc.window_title
|
||||
bubble_mouse_events bool // if true, mouse events will bubble up to the web page
|
||||
bubble_touch_events bool // same for touch events
|
||||
bubble_wheel_events bool // same for wheel events
|
||||
bubble_key_events bool // if true, bubble up *all* key events to browser
|
||||
bubble_char_events bool // if true, bubble up character events to browser
|
||||
use_emsc_set_main_loop bool // if true, use emscripten_set_main_loop() instead of emscripten_request_animation_frame_loop()
|
||||
emsc_set_main_loop_simulate_infinite_loop bool // this will be passed as the simulate_infinite_loop arg to emscripten_set_main_loop()
|
||||
}
|
||||
|
||||
pub type Html5Desc = C.sapp_html5_desc
|
||||
|
||||
@[typedef]
|
||||
pub struct C.sapp_ios_desc {
|
||||
pub:
|
||||
keyboard_resizes_canvas bool // if true, showing the iOS keyboard shrinks the canvas
|
||||
}
|
||||
|
||||
pub type IosDesc = C.sapp_ios_desc
|
||||
|
||||
// --- environment structs (returned by sapp_get_environment) ---
|
||||
|
||||
@[typedef]
|
||||
pub struct C.sapp_environment_defaults {
|
||||
pub:
|
||||
color_format int
|
||||
depth_format int
|
||||
sample_count int
|
||||
}
|
||||
|
||||
pub type EnvironmentDefaults = C.sapp_environment_defaults
|
||||
|
||||
@[typedef]
|
||||
pub struct C.sapp_metal_environment {
|
||||
pub:
|
||||
device voidptr
|
||||
}
|
||||
|
||||
@[typedef]
|
||||
pub struct C.sapp_d3d11_environment {
|
||||
pub:
|
||||
device voidptr
|
||||
device_context voidptr
|
||||
}
|
||||
|
||||
@[typedef]
|
||||
pub struct C.sapp_wgpu_environment {
|
||||
pub:
|
||||
device voidptr
|
||||
}
|
||||
|
||||
@[typedef]
|
||||
pub struct C.sapp_vulkan_environment {
|
||||
pub:
|
||||
instance voidptr
|
||||
physical_device voidptr
|
||||
device voidptr
|
||||
queue voidptr
|
||||
queue_family_index u32
|
||||
}
|
||||
|
||||
pub type MetalEnvironment = C.sapp_metal_environment
|
||||
pub type D3d11Environment = C.sapp_d3d11_environment
|
||||
pub type WgpuEnvironment = C.sapp_wgpu_environment
|
||||
pub type VulkanEnvironment = C.sapp_vulkan_environment
|
||||
|
||||
@[typedef]
|
||||
pub struct C.sapp_environment {
|
||||
pub:
|
||||
defaults EnvironmentDefaults
|
||||
metal MetalEnvironment
|
||||
d3d11 D3d11Environment
|
||||
wgpu WgpuEnvironment
|
||||
vulkan VulkanEnvironment
|
||||
}
|
||||
|
||||
pub type Environment = C.sapp_environment
|
||||
|
||||
// --- swapchain structs (returned by sapp_get_swapchain) ---
|
||||
|
||||
@[typedef]
|
||||
pub struct C.sapp_metal_swapchain {
|
||||
pub:
|
||||
current_drawable voidptr
|
||||
depth_stencil_texture voidptr
|
||||
msaa_color_texture voidptr
|
||||
}
|
||||
|
||||
@[typedef]
|
||||
pub struct C.sapp_d3d11_swapchain {
|
||||
pub:
|
||||
render_view voidptr
|
||||
resolve_view voidptr
|
||||
depth_stencil_view voidptr
|
||||
}
|
||||
|
||||
@[typedef]
|
||||
pub struct C.sapp_wgpu_swapchain {
|
||||
pub:
|
||||
render_view voidptr
|
||||
resolve_view voidptr
|
||||
depth_stencil_view voidptr
|
||||
}
|
||||
|
||||
@[typedef]
|
||||
pub struct C.sapp_vulkan_swapchain {
|
||||
pub:
|
||||
render_image voidptr
|
||||
render_view voidptr
|
||||
resolve_image voidptr
|
||||
resolve_view voidptr
|
||||
depth_stencil_image voidptr
|
||||
depth_stencil_view voidptr
|
||||
render_finished_semaphore voidptr
|
||||
present_complete_semaphore voidptr
|
||||
}
|
||||
|
||||
@[typedef]
|
||||
pub struct C.sapp_gl_swapchain {
|
||||
pub:
|
||||
framebuffer u32
|
||||
}
|
||||
|
||||
pub type MetalSwapchain = C.sapp_metal_swapchain
|
||||
pub type D3d11Swapchain = C.sapp_d3d11_swapchain
|
||||
pub type WgpuSwapchain = C.sapp_wgpu_swapchain
|
||||
pub type VulkanSwapchain = C.sapp_vulkan_swapchain
|
||||
pub type GlSwapchain = C.sapp_gl_swapchain
|
||||
|
||||
@[typedef]
|
||||
pub struct C.sapp_swapchain {
|
||||
pub:
|
||||
width int
|
||||
height int
|
||||
sample_count int
|
||||
color_format int
|
||||
depth_format int
|
||||
metal MetalSwapchain
|
||||
d3d11 D3d11Swapchain
|
||||
wgpu WgpuSwapchain
|
||||
vulkan VulkanSwapchain
|
||||
gl GlSwapchain
|
||||
}
|
||||
|
||||
pub type Swapchain = C.sapp_swapchain
|
||||
|
||||
@[typedef]
|
||||
pub struct C.sapp_desc {
|
||||
pub mut:
|
||||
// these are the user-provided callbacks without user data
|
||||
init_cb fn () = unsafe { nil }
|
||||
frame_cb fn () = unsafe { nil }
|
||||
cleanup_cb fn () = unsafe { nil }
|
||||
event_cb fn (&Event) = unsafe { nil } // &sapp_event
|
||||
// fail_cb fn (&u8) = unsafe { nil }
|
||||
|
||||
user_data voidptr // these are the user-provided callbacks with user data
|
||||
init_userdata_cb fn (voidptr) = unsafe { nil }
|
||||
frame_userdata_cb fn (voidptr) = unsafe { nil }
|
||||
cleanup_userdata_cb fn (voidptr) = unsafe { nil }
|
||||
event_userdata_cb fn (&Event, voidptr) = unsafe { nil }
|
||||
// fail_userdata_cb fn (&char, voidptr) = unsafe { nil }
|
||||
|
||||
width int // the preferred width of the window / canvas
|
||||
height int // the preferred height of the window / canvas
|
||||
sample_count int // MSAA sample count
|
||||
swap_interval int // the preferred swap interval (ignored on some platforms)
|
||||
high_dpi bool // whether the rendering canvas is full-resolution on HighDPI displays
|
||||
fullscreen bool // whether the window should be created in fullscreen mode
|
||||
alpha bool // whether the framebuffer should have an alpha channel (ignored on some platforms)
|
||||
window_title &char // the window title as UTF-8 encoded string
|
||||
enable_clipboard bool // enable clipboard access, default is false
|
||||
clipboard_size int // max size of clipboard content in bytes
|
||||
enable_dragndrop bool // enable file dropping (drag'n'drop), default is false
|
||||
max_dropped_files int // max number of dropped files to process (default: 1)
|
||||
max_dropped_file_path_length int // max length in bytes of a dropped UTF-8 file path (default: 2048)
|
||||
icon IconDesc // the initial window icon to set
|
||||
width int // the preferred width of the window / canvas
|
||||
height int // the preferred height of the window / canvas
|
||||
sample_count int // MSAA sample count
|
||||
swap_interval int // the preferred swap interval (ignored on some platforms)
|
||||
high_dpi bool // whether the rendering canvas is full-resolution on HighDPI displays
|
||||
fullscreen bool // whether the window should be created in fullscreen mode
|
||||
alpha bool // whether the framebuffer should have an alpha channel (ignored on some platforms)
|
||||
window_title &char // the window title as UTF-8 encoded string
|
||||
enable_clipboard bool // enable clipboard access, default is false
|
||||
clipboard_size int // max size of clipboard content in bytes
|
||||
enable_dragndrop bool // enable file dropping (drag'n'drop), default is false
|
||||
max_dropped_files int // max number of dropped files to process (default: 1)
|
||||
max_dropped_file_path_length int // max length in bytes of a dropped UTF-8 file path (default: 2048)
|
||||
icon IconDesc // the initial window icon to set
|
||||
allocator Allocator // optional memory allocation overrides (default: malloc/free)
|
||||
logger Logger // logging callback override (default: NO LOGGING!)
|
||||
// backend-specific options
|
||||
win32_console_utf8 bool // if true, set the output console codepage to UTF-8
|
||||
win32_console_create bool // if true, attach stdout/stderr to a new console window
|
||||
win32_console_attach bool // if true, attach stdout/stderr to parent process
|
||||
html5_canvas_name &char // the name (id) of the HTML5 canvas element, default is "canvas"
|
||||
html5_canvas_resize bool // if true, the HTML5 canvas size is set to sapp_desc.width/height, otherwise canvas size is tracked
|
||||
html5_preserve_drawing_buffer bool // HTML5 only: whether to preserve default framebuffer content between frames
|
||||
html5_premultiplied_alpha bool // HTML5 only: whether the rendered pixels use premultiplied alpha convention
|
||||
html5_ask_leave_site bool // initial state of the internal html5_ask_leave_site flag (see sapp_html5_ask_leave_site())
|
||||
ios_keyboard_resizes_canvas bool // if true, showing the iOS keyboard shrinks the canvas
|
||||
gl GlDesc // OpenGL specific options
|
||||
win32 Win32Desc // Win32 specific options
|
||||
html5 Html5Desc // HTML5 specific options
|
||||
ios IosDesc // iOS specific options
|
||||
// V patches
|
||||
__v_native_render bool // V patch to allow for native rendering
|
||||
min_width int // V patch to allow for min window width
|
||||
min_height int // V patch to allow for min window height
|
||||
pub mut:
|
||||
allocator C.sapp_allocator // optional memory allocation overrides (default: malloc/free)
|
||||
logger C.sapp_logger // optional log callback overrides (default: SAPP_LOG(message))
|
||||
}
|
||||
|
||||
pub type Desc = C.sapp_desc
|
||||
|
||||
@[typedef]
|
||||
pub struct C.sapp_event {
|
||||
pub:
|
||||
pub mut:
|
||||
frame_count u64 // current frame counter, always valid, useful for checking if two events were issued in the same frame
|
||||
type EventType // the event type, always valid
|
||||
key_code KeyCode // the virtual key code, only valid in KEY_UP, KEY_DOWN
|
||||
@@ -112,7 +300,7 @@ pub:
|
||||
|
||||
pub type Event = C.sapp_event
|
||||
|
||||
pub fn (e &C.sapp_event) str() string {
|
||||
pub fn (e &Event) str() string {
|
||||
return 'evt: frame_count=${e.frame_count}, type=${e.type}'
|
||||
}
|
||||
|
||||
|
||||
@@ -3,11 +3,6 @@ module sapp
|
||||
import os
|
||||
import stbi
|
||||
|
||||
#define SOKOL_VALIDATE_NON_FATAL 1
|
||||
|
||||
// v_sapp_gl_read_rgba_pixels reads pixles from the OpenGL buffer into `pixels`.
|
||||
fn C.v_sapp_gl_read_rgba_pixels(x i32, y i32, width i32, height i32, pixels charptr)
|
||||
|
||||
// screenshot takes a screenshot of the current window and
|
||||
// saves it to `path`. The format is inferred from the extension
|
||||
// of the file name in `path`.
|
||||
@@ -47,6 +42,7 @@ pub fn screenshot_png(path string) ! {
|
||||
}
|
||||
|
||||
// write_rgba_to_ppm writes `pixels` data in RGBA format to PPM3 format.
|
||||
@[direct_array_access]
|
||||
fn write_rgba_to_ppm(path string, w int, h int, components int, pixels &u8) ! {
|
||||
mut f_out := os.create(path)!
|
||||
defer {
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -9,6 +9,7 @@ mut:
|
||||
pixels &u8 = unsafe { nil }
|
||||
}
|
||||
|
||||
// screenshot_window captures a screenshot of the current window.
|
||||
@[manualfree]
|
||||
pub fn screenshot_window() &Screenshot {
|
||||
img_width := width()
|
||||
@@ -1,42 +0,0 @@
|
||||
module sfons
|
||||
|
||||
import fontstash
|
||||
import sokol.f as _
|
||||
import sokol.memory
|
||||
|
||||
// create a new Context/font atlas, for rendering glyphs, given its dimensions `width` and `height`
|
||||
@[inline]
|
||||
pub fn create(width int, height int, flags int) &fontstash.Context {
|
||||
assert is_power_of_two(width)
|
||||
assert is_power_of_two(height)
|
||||
allocator := C.sfons_allocator_t{
|
||||
alloc_fn: memory.salloc
|
||||
free_fn: memory.sfree
|
||||
user_data: voidptr(0x100005f0)
|
||||
}
|
||||
desc := C.sfons_desc_t{
|
||||
width: width
|
||||
height: height
|
||||
allocator: allocator
|
||||
}
|
||||
return C.sfons_create(&desc)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn destroy(ctx &fontstash.Context) {
|
||||
C.sfons_destroy(ctx)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn rgba(r u8, g u8, b u8, a u8) u32 {
|
||||
return C.sfons_rgba(r, g, b, a)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn flush(ctx &fontstash.Context) {
|
||||
C.sfons_flush(ctx)
|
||||
}
|
||||
|
||||
fn is_power_of_two(x int) bool {
|
||||
return x in [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]
|
||||
}
|
||||
@@ -0,0 +1,341 @@
|
||||
module sfons
|
||||
|
||||
import fontstash
|
||||
import sokol.gfx
|
||||
import sokol.sgl
|
||||
import sokol.memory
|
||||
|
||||
// Fontstash-specific fragment shaders.
|
||||
// These differ from sgl's shaders: they read the .r channel for alpha,
|
||||
// producing: frag_color = vec4(1.0, 1.0, 1.0, texture(tex_smp, uv).r) * color
|
||||
// The vertex shader is identical to sgl's.
|
||||
|
||||
const fs_source_glsl410 = '#version 410
|
||||
|
||||
uniform sampler2D tex_smp;
|
||||
in vec2 uv;
|
||||
in vec4 color;
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
frag_color = vec4(1.0, 1.0, 1.0, texture(tex_smp, uv).r) * color;
|
||||
}
|
||||
'
|
||||
|
||||
const fs_source_glsl300es = '#version 300 es
|
||||
precision mediump float;
|
||||
precision highp int;
|
||||
|
||||
uniform highp sampler2D tex_smp;
|
||||
in highp vec2 uv;
|
||||
in highp vec4 color;
|
||||
layout(location = 0) out highp vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
frag_color = vec4(1.0, 1.0, 1.0, texture(tex_smp, uv).r) * color;
|
||||
}
|
||||
'
|
||||
|
||||
// The vertex shader is the same as sgl's
|
||||
const vs_source_glsl410 = '#version 410
|
||||
|
||||
uniform vec4 vs_params[8];
|
||||
layout(location = 0) in vec4 position;
|
||||
layout(location = 1) in vec2 texcoord0;
|
||||
layout(location = 2) in vec4 color0;
|
||||
layout(location = 3) in float psize;
|
||||
out vec2 uv;
|
||||
out vec4 color;
|
||||
|
||||
void main() {
|
||||
gl_Position = mat4(vs_params[0], vs_params[1], vs_params[2], vs_params[3]) * position;
|
||||
gl_PointSize = psize;
|
||||
uv = (mat4(vs_params[4], vs_params[5], vs_params[6], vs_params[7]) * vec4(texcoord0, 0.0, 1.0)).xy;
|
||||
color = color0;
|
||||
}
|
||||
'
|
||||
|
||||
const vs_source_glsl300es = '#version 300 es
|
||||
|
||||
uniform vec4 vs_params[8];
|
||||
layout(location = 0) in vec4 position;
|
||||
layout(location = 1) in vec2 texcoord0;
|
||||
layout(location = 2) in vec4 color0;
|
||||
layout(location = 3) in float psize;
|
||||
out vec2 uv;
|
||||
out vec4 color;
|
||||
|
||||
void main() {
|
||||
gl_Position = mat4(vs_params[0], vs_params[1], vs_params[2], vs_params[3]) * position;
|
||||
gl_PointSize = psize;
|
||||
uv = (mat4(vs_params[4], vs_params[5], vs_params[6], vs_params[7]) * vec4(texcoord0, 0.0, 1.0)).xy;
|
||||
color = color0;
|
||||
}
|
||||
'
|
||||
|
||||
// Internal state for sokol-fontstash
|
||||
struct SFons {
|
||||
mut:
|
||||
shd gfx.Shader
|
||||
pip sgl.Pipeline
|
||||
img gfx.Image
|
||||
smp gfx.Sampler
|
||||
cur_width int
|
||||
cur_height int
|
||||
img_dirty bool
|
||||
alloc_fn memory.FnAllocatorAlloc = unsafe { nil }
|
||||
free_fn memory.FnAllocatorFree = unsafe { nil }
|
||||
user_data voidptr
|
||||
}
|
||||
|
||||
fn make_shader_desc() gfx.ShaderDesc {
|
||||
mut desc := gfx.ShaderDesc{}
|
||||
desc.attrs[0].name = c'position'
|
||||
desc.attrs[1].name = c'texcoord0'
|
||||
desc.attrs[2].name = c'color0'
|
||||
desc.attrs[3].name = c'psize'
|
||||
desc.attrs[0].sem_name = c'TEXCOORD'
|
||||
desc.attrs[0].sem_index = 0
|
||||
desc.attrs[1].sem_name = c'TEXCOORD'
|
||||
desc.attrs[1].sem_index = 1
|
||||
desc.attrs[2].sem_name = c'TEXCOORD'
|
||||
desc.attrs[2].sem_index = 2
|
||||
desc.attrs[3].sem_name = c'TEXCOORD'
|
||||
desc.attrs[3].sem_index = 3
|
||||
desc.vs.uniform_blocks[0].size = 128 // 2 mat4 = 8 vec4 = 128 bytes
|
||||
desc.vs.uniform_blocks[0].uniforms[0].name = c'vs_params'
|
||||
desc.vs.uniform_blocks[0].uniforms[0].@type = .float4
|
||||
desc.vs.uniform_blocks[0].uniforms[0].array_count = 8
|
||||
desc.fs.images[0].used = true
|
||||
desc.fs.images[0].image_type = ._2d
|
||||
desc.fs.images[0].sample_type = .float
|
||||
desc.fs.samplers[0].used = true
|
||||
desc.fs.samplers[0].sampler_type = .filtering
|
||||
desc.fs.image_sampler_pairs[0].used = true
|
||||
desc.fs.image_sampler_pairs[0].image_slot = 0
|
||||
desc.fs.image_sampler_pairs[0].sampler_slot = 0
|
||||
desc.fs.image_sampler_pairs[0].glsl_name = c'tex_smp'
|
||||
desc.label = c'sfons-shader'
|
||||
|
||||
backend := gfx.query_backend()
|
||||
match backend {
|
||||
.glcore33 {
|
||||
desc.vs.source = vs_source_glsl410.str
|
||||
desc.fs.source = fs_source_glsl410.str
|
||||
}
|
||||
.gles3 {
|
||||
desc.vs.source = vs_source_glsl300es.str
|
||||
desc.fs.source = fs_source_glsl300es.str
|
||||
}
|
||||
.metal_macos, .metal_ios, .metal_simulator {
|
||||
// TODO: embed Metal shader bytecode
|
||||
desc.vs.source = vs_source_glsl410.str
|
||||
desc.fs.source = fs_source_glsl410.str
|
||||
}
|
||||
.d3d11 {
|
||||
// TODO: embed HLSL shader bytecode
|
||||
desc.vs.source = vs_source_glsl410.str
|
||||
desc.fs.source = fs_source_glsl410.str
|
||||
}
|
||||
.wgpu {
|
||||
// TODO: embed WGSL shader source
|
||||
desc.vs.source = vs_source_glsl410.str
|
||||
desc.fs.source = fs_source_glsl410.str
|
||||
}
|
||||
.dummy {
|
||||
desc.vs.source = c''
|
||||
desc.fs.source = c''
|
||||
}
|
||||
}
|
||||
return desc
|
||||
}
|
||||
|
||||
// Rendering callbacks for fontstash
|
||||
|
||||
fn sfons_render_create(user_ptr voidptr, width int, height int) int {
|
||||
assert user_ptr != unsafe { nil }
|
||||
assert width > 8
|
||||
assert height > 8
|
||||
mut sf := unsafe { &SFons(user_ptr) }
|
||||
|
||||
// Create shader if not yet created
|
||||
if sf.shd.id == 0 {
|
||||
shd_desc := make_shader_desc()
|
||||
sf.shd = gfx.make_shader(&shd_desc)
|
||||
$if trace_sfons ? {
|
||||
eprintln('[sfons] shader created: id=${sf.shd.id}')
|
||||
}
|
||||
}
|
||||
|
||||
// Create sgl pipeline if not yet created
|
||||
if sf.pip.id == 0 {
|
||||
mut pip_desc := gfx.PipelineDesc{}
|
||||
pip_desc.shader = sf.shd
|
||||
pip_desc.colors[0].blend.enabled = true
|
||||
pip_desc.colors[0].blend.src_factor_rgb = .src_alpha
|
||||
pip_desc.colors[0].blend.dst_factor_rgb = .one_minus_src_alpha
|
||||
sf.pip = sgl.make_pipeline(&pip_desc)
|
||||
$if trace_sfons ? {
|
||||
eprintln('[sfons] pipeline created: id=${sf.pip.id}')
|
||||
}
|
||||
}
|
||||
|
||||
// Create sampler if not yet created
|
||||
if sf.smp.id == 0 {
|
||||
smp_desc := gfx.SamplerDesc{
|
||||
min_filter: .linear
|
||||
mag_filter: .linear
|
||||
mipmap_filter: .none
|
||||
}
|
||||
sf.smp = gfx.make_sampler(&smp_desc)
|
||||
}
|
||||
|
||||
// Destroy and recreate font atlas texture
|
||||
if sf.img.id != 0 {
|
||||
gfx.destroy_image(sf.img)
|
||||
sf.img = gfx.Image{}
|
||||
}
|
||||
sf.cur_width = width
|
||||
sf.cur_height = height
|
||||
|
||||
img_desc := gfx.ImageDesc{
|
||||
width: sf.cur_width
|
||||
height: sf.cur_height
|
||||
usage: .dynamic
|
||||
pixel_format: .r8
|
||||
}
|
||||
sf.img = gfx.make_image(&img_desc)
|
||||
$if trace_sfons ? {
|
||||
eprintln('[sfons] render_create: ${width}x${height} img.id=${sf.img.id} smp.id=${sf.smp.id} pip.id=${sf.pip.id} shd.id=${sf.shd.id}')
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
fn sfons_render_resize(user_ptr voidptr, width int, height int) int {
|
||||
return sfons_render_create(user_ptr, width, height)
|
||||
}
|
||||
|
||||
fn sfons_render_update(user_ptr voidptr, rect &int, data &u8) {
|
||||
assert user_ptr != unsafe { nil }
|
||||
mut sf := unsafe { &SFons(user_ptr) }
|
||||
sf.img_dirty = true
|
||||
}
|
||||
|
||||
fn sfons_render_draw(user_ptr voidptr, verts &f32, tcoords &f32, colors &u32, nverts int) {
|
||||
assert user_ptr != unsafe { nil }
|
||||
assert nverts > 0
|
||||
sf := unsafe { &SFons(user_ptr) }
|
||||
$if trace_sfons ? {
|
||||
eprintln('[sfons] render_draw: nverts=${nverts} img.id=${sf.img.id} smp.id=${sf.smp.id} pip.id=${sf.pip.id}')
|
||||
if nverts > 0 {
|
||||
unsafe {
|
||||
eprintln('[sfons] vert[0]: pos=(${verts[0]}, ${verts[1]}) uv=(${tcoords[0]}, ${tcoords[1]}) col=0x${colors[0]:08x}')
|
||||
}
|
||||
}
|
||||
}
|
||||
sgl.enable_texture()
|
||||
sgl.texture(sf.img, sf.smp)
|
||||
sgl.push_pipeline()
|
||||
sgl.load_pipeline(sf.pip)
|
||||
sgl.begin_triangles()
|
||||
for i in 0 .. nverts {
|
||||
unsafe {
|
||||
sgl.v2f_t2f_c1i(verts[2 * i], verts[2 * i + 1], tcoords[2 * i], tcoords[2 * i + 1],
|
||||
colors[i])
|
||||
}
|
||||
}
|
||||
sgl.end()
|
||||
sgl.pop_pipeline()
|
||||
sgl.disable_texture()
|
||||
}
|
||||
|
||||
fn sfons_render_delete(user_ptr voidptr) {
|
||||
assert user_ptr != unsafe { nil }
|
||||
mut sf := unsafe { &SFons(user_ptr) }
|
||||
if sf.img.id != 0 {
|
||||
gfx.destroy_image(sf.img)
|
||||
sf.img = gfx.Image{}
|
||||
}
|
||||
if sf.smp.id != 0 {
|
||||
gfx.destroy_sampler(sf.smp)
|
||||
sf.smp = gfx.Sampler{}
|
||||
}
|
||||
if sf.pip.id != 0 {
|
||||
sgl.destroy_pipeline(sf.pip)
|
||||
sf.pip = sgl.Pipeline{}
|
||||
}
|
||||
if sf.shd.id != 0 {
|
||||
gfx.destroy_shader(sf.shd)
|
||||
sf.shd = gfx.Shader{}
|
||||
}
|
||||
}
|
||||
|
||||
// Public API
|
||||
|
||||
// create a new Context/font atlas, for rendering glyphs, given its dimensions `width` and `height`
|
||||
pub fn create(width int, height int, flags int) &fontstash.Context {
|
||||
assert is_power_of_two(width)
|
||||
assert is_power_of_two(height)
|
||||
|
||||
w := if width == 0 { 512 } else { width }
|
||||
h := if height == 0 { 512 } else { height }
|
||||
|
||||
// Allocate the internal state
|
||||
sf := unsafe { &SFons(C.calloc(1, sizeof(SFons))) }
|
||||
|
||||
params := C.FONSparams{
|
||||
width: w
|
||||
height: h
|
||||
flags: char(flags)
|
||||
userPtr: voidptr(sf)
|
||||
renderCreate: sfons_render_create
|
||||
renderResize: sfons_render_resize
|
||||
renderUpdate: sfons_render_update
|
||||
renderDraw: sfons_render_draw
|
||||
renderDelete: sfons_render_delete
|
||||
}
|
||||
return fontstash.create_internal(¶ms)
|
||||
}
|
||||
|
||||
// destroy frees the font stash context and associated resources.
|
||||
pub fn destroy(ctx &fontstash.Context) {
|
||||
// Get the SFons pointer from the context's params before destroying
|
||||
sfons_ptr := unsafe { (&C.FONScontext(ctx)).params.userPtr }
|
||||
fontstash.delete_internal(ctx)
|
||||
unsafe { C.free(sfons_ptr) }
|
||||
}
|
||||
|
||||
// rgba packs RGBA color components into a single u32 value.
|
||||
pub fn rgba(r u8, g u8, b u8, a u8) u32 {
|
||||
return u32(r) | (u32(g) << 8) | (u32(b) << 16) | (u32(a) << 24)
|
||||
}
|
||||
|
||||
// flush uploads the font texture to the GPU and renders any pending text.
|
||||
pub fn flush(ctx &fontstash.Context) {
|
||||
fctx := unsafe { &C.FONScontext(ctx) }
|
||||
sf := unsafe { &SFons(fctx.params.userPtr) }
|
||||
if sf.img_dirty {
|
||||
unsafe {
|
||||
mut s := &SFons(fctx.params.userPtr)
|
||||
s.img_dirty = false
|
||||
}
|
||||
mut img_data := gfx.ImageData{}
|
||||
img_data.subimage[0][0] = gfx.Range{
|
||||
ptr: unsafe { fctx.texData }
|
||||
size: usize(sf.cur_width * sf.cur_height)
|
||||
}
|
||||
$if trace_sfons ? {
|
||||
eprintln('[sfons] flush: uploading texture ${sf.cur_width}x${sf.cur_height} to img.id=${sf.img.id} texData=${voidptr(fctx.texData)}')
|
||||
}
|
||||
gfx.update_image(sf.img, &img_data)
|
||||
}
|
||||
$if trace_sfons ? {
|
||||
if !sf.img_dirty {
|
||||
eprintln('[sfons] flush: not dirty')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn is_power_of_two(x int) bool {
|
||||
return x in [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
module sfons
|
||||
|
||||
import fontstash
|
||||
import sokol.memory
|
||||
|
||||
@[typedef]
|
||||
pub struct C.sfons_allocator_t {
|
||||
pub:
|
||||
alloc_fn memory.FnAllocatorAlloc = unsafe { nil }
|
||||
free_fn memory.FnAllocatorFree = unsafe { nil }
|
||||
user_data voidptr
|
||||
}
|
||||
|
||||
@[typedef]
|
||||
pub struct C.sfons_desc_t {
|
||||
pub:
|
||||
width int // initial width of font atlas texture (default: 512, must be power of 2)
|
||||
height int // initial height of font atlas texture (default: 512, must be power of 2)
|
||||
allocator C.sfons_allocator_t // optional memory allocation overrides
|
||||
}
|
||||
|
||||
fn C.sfons_create(desc &C.sfons_desc_t) &fontstash.Context
|
||||
fn C.sfons_destroy(ctx &fontstash.Context)
|
||||
fn C.sfons_flush(ctx &fontstash.Context)
|
||||
|
||||
fn C.sfons_rgba(r u8, g u8, b u8, a u8) u32
|
||||
@@ -1,12 +0,0 @@
|
||||
module sgl
|
||||
|
||||
// SglError is C.sgl_error_t
|
||||
pub enum SglError {
|
||||
no_error = C.SGL_NO_ERROR // 0
|
||||
vertices_full = C.SGL_ERROR_VERTICES_FULL
|
||||
uniforms_full = C.SGL_ERROR_UNIFORMS_FULL
|
||||
commands_full = C.SGL_ERROR_COMMANDS_FULL
|
||||
stack_overflow = C.SGL_ERROR_STACK_OVERFLOW
|
||||
stack_underflow = C.SGL_ERROR_STACK_UNDERFLOW
|
||||
no_context = C.SGL_ERROR_NO_CONTEXT
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
module sgl
|
||||
|
||||
pub enum SglError {
|
||||
no_error
|
||||
vertices_full
|
||||
uniforms_full
|
||||
commands_full
|
||||
stack_overflow
|
||||
stack_underflow
|
||||
no_context
|
||||
}
|
||||
|
||||
enum PrimitiveType {
|
||||
points
|
||||
lines
|
||||
line_strip
|
||||
triangles
|
||||
triangle_strip
|
||||
quads
|
||||
}
|
||||
|
||||
const num_primitive_types = 6
|
||||
|
||||
enum CommandType {
|
||||
draw
|
||||
viewport
|
||||
scissor_rect
|
||||
}
|
||||
|
||||
enum MatrixMode {
|
||||
modelview
|
||||
projection
|
||||
texture
|
||||
}
|
||||
|
||||
const num_matrixmodes = 3
|
||||
@@ -0,0 +1,242 @@
|
||||
module sgl
|
||||
|
||||
import math
|
||||
|
||||
@[direct_array_access]
|
||||
fn mat4_identity(mut m Matrix) {
|
||||
for c in 0 .. 4 {
|
||||
for r in 0 .. 4 {
|
||||
m.v[c][r] = if r == c { f32(1.0) } else { f32(0.0) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@[direct_array_access]
|
||||
fn mat4_transpose(mut dst Matrix, m &Matrix) {
|
||||
for c in 0 .. 4 {
|
||||
for r in 0 .. 4 {
|
||||
dst.v[r][c] = m.v[c][r]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// mat4_mul multiplies two 4x4 matrices: p = a * b
|
||||
@[direct_array_access]
|
||||
fn mat4_mul(mut p Matrix, a &Matrix, b &Matrix) {
|
||||
for r in 0 .. 4 {
|
||||
ai0 := a.v[0][r]
|
||||
ai1 := a.v[1][r]
|
||||
ai2 := a.v[2][r]
|
||||
ai3 := a.v[3][r]
|
||||
p.v[0][r] = ai0 * b.v[0][0] + ai1 * b.v[0][1] + ai2 * b.v[0][2] + ai3 * b.v[0][3]
|
||||
p.v[1][r] = ai0 * b.v[1][0] + ai1 * b.v[1][1] + ai2 * b.v[1][2] + ai3 * b.v[1][3]
|
||||
p.v[2][r] = ai0 * b.v[2][0] + ai1 * b.v[2][1] + ai2 * b.v[2][2] + ai3 * b.v[2][3]
|
||||
p.v[3][r] = ai0 * b.v[3][0] + ai1 * b.v[3][1] + ai2 * b.v[3][2] + ai3 * b.v[3][3]
|
||||
}
|
||||
}
|
||||
|
||||
// mat4_mul_inplace multiplies dst by m in place: dst = dst * m
|
||||
fn mat4_mul_inplace(mut dst Matrix, m &Matrix) {
|
||||
mut tmp := Matrix{}
|
||||
mat4_mul(mut tmp, dst, m)
|
||||
unsafe {
|
||||
*dst = tmp
|
||||
}
|
||||
}
|
||||
|
||||
@[direct_array_access]
|
||||
fn mat4_rotate(mut dst Matrix, a f32, x_ f32, y_ f32, z_ f32) {
|
||||
mut x := x_
|
||||
mut y := y_
|
||||
mut z := z_
|
||||
s := math.sinf(a)
|
||||
c := math.cosf(a)
|
||||
|
||||
mag := math.sqrtf(x * x + y * y + z * z)
|
||||
if mag < 1.0e-4 {
|
||||
return
|
||||
}
|
||||
x /= mag
|
||||
y /= mag
|
||||
z /= mag
|
||||
xx := x * x
|
||||
yy := y * y
|
||||
zz := z * z
|
||||
xy := x * y
|
||||
yz := y * z
|
||||
zx := z * x
|
||||
xs := x * s
|
||||
ys := y * s
|
||||
zs := z * s
|
||||
one_c := f32(1.0) - c
|
||||
|
||||
mut m := Matrix{}
|
||||
m.v[0][0] = (one_c * xx) + c
|
||||
m.v[1][0] = (one_c * xy) - zs
|
||||
m.v[2][0] = (one_c * zx) + ys
|
||||
m.v[3][0] = 0.0
|
||||
m.v[0][1] = (one_c * xy) + zs
|
||||
m.v[1][1] = (one_c * yy) + c
|
||||
m.v[2][1] = (one_c * yz) - xs
|
||||
m.v[3][1] = 0.0
|
||||
m.v[0][2] = (one_c * zx) - ys
|
||||
m.v[1][2] = (one_c * yz) + xs
|
||||
m.v[2][2] = (one_c * zz) + c
|
||||
m.v[3][2] = 0.0
|
||||
m.v[0][3] = 0.0
|
||||
m.v[1][3] = 0.0
|
||||
m.v[2][3] = 0.0
|
||||
m.v[3][3] = 1.0
|
||||
mat4_mul_inplace(mut dst, &m)
|
||||
}
|
||||
|
||||
@[direct_array_access]
|
||||
fn mat4_scale(mut dst Matrix, x f32, y f32, z f32) {
|
||||
for r in 0 .. 4 {
|
||||
dst.v[0][r] *= x
|
||||
dst.v[1][r] *= y
|
||||
dst.v[2][r] *= z
|
||||
}
|
||||
}
|
||||
|
||||
@[direct_array_access]
|
||||
fn mat4_translate(mut dst Matrix, x f32, y f32, z f32) {
|
||||
for r in 0 .. 4 {
|
||||
dst.v[3][r] = dst.v[0][r] * x + dst.v[1][r] * y + dst.v[2][r] * z + dst.v[3][r]
|
||||
}
|
||||
}
|
||||
|
||||
@[direct_array_access]
|
||||
fn mat4_frustum(mut dst Matrix, left f32, right f32, bottom f32, top f32, znear f32, zfar f32) {
|
||||
x := (2.0 * znear) / (right - left)
|
||||
y := (2.0 * znear) / (top - bottom)
|
||||
a := (right + left) / (right - left)
|
||||
b := (top + bottom) / (top - bottom)
|
||||
c := -(zfar + znear) / (zfar - znear)
|
||||
d := -(2.0 * zfar * znear) / (zfar - znear)
|
||||
mut m := Matrix{}
|
||||
m.v[0][0] = x
|
||||
m.v[0][1] = 0.0
|
||||
m.v[0][2] = 0.0
|
||||
m.v[0][3] = 0.0
|
||||
m.v[1][0] = 0.0
|
||||
m.v[1][1] = y
|
||||
m.v[1][2] = 0.0
|
||||
m.v[1][3] = 0.0
|
||||
m.v[2][0] = a
|
||||
m.v[2][1] = b
|
||||
m.v[2][2] = c
|
||||
m.v[2][3] = -1.0
|
||||
m.v[3][0] = 0.0
|
||||
m.v[3][1] = 0.0
|
||||
m.v[3][2] = d
|
||||
m.v[3][3] = 0.0
|
||||
mat4_mul_inplace(mut dst, &m)
|
||||
}
|
||||
|
||||
@[direct_array_access]
|
||||
fn mat4_ortho(mut dst Matrix, left f32, right f32, bottom f32, top f32, znear f32, zfar f32) {
|
||||
mut m := Matrix{}
|
||||
m.v[0][0] = 2.0 / (right - left)
|
||||
m.v[1][0] = 0.0
|
||||
m.v[2][0] = 0.0
|
||||
m.v[3][0] = -(right + left) / (right - left)
|
||||
m.v[0][1] = 0.0
|
||||
m.v[1][1] = 2.0 / (top - bottom)
|
||||
m.v[2][1] = 0.0
|
||||
m.v[3][1] = -(top + bottom) / (top - bottom)
|
||||
m.v[0][2] = 0.0
|
||||
m.v[1][2] = 0.0
|
||||
m.v[2][2] = -2.0 / (zfar - znear)
|
||||
m.v[3][2] = -(zfar + znear) / (zfar - znear)
|
||||
m.v[0][3] = 0.0
|
||||
m.v[1][3] = 0.0
|
||||
m.v[2][3] = 0.0
|
||||
m.v[3][3] = 1.0
|
||||
mat4_mul_inplace(mut dst, &m)
|
||||
}
|
||||
|
||||
@[direct_array_access]
|
||||
fn mat4_perspective(mut dst Matrix, fovy f32, aspect f32, znear f32, zfar f32) {
|
||||
sine := math.sinf(fovy / 2.0)
|
||||
delta_z := zfar - znear
|
||||
if delta_z == 0.0 || sine == 0.0 || aspect == 0.0 {
|
||||
return
|
||||
}
|
||||
cotan := math.cosf(fovy / 2.0) / sine
|
||||
mut m := Matrix{}
|
||||
mat4_identity(mut m)
|
||||
m.v[0][0] = cotan / aspect
|
||||
m.v[1][1] = cotan
|
||||
m.v[2][2] = -(zfar + znear) / delta_z
|
||||
m.v[2][3] = -1.0
|
||||
m.v[3][2] = -2.0 * znear * zfar / delta_z
|
||||
m.v[3][3] = 0.0
|
||||
mat4_mul_inplace(mut dst, &m)
|
||||
}
|
||||
|
||||
@[direct_array_access]
|
||||
fn vec3_normalize(mut v [3]f32) {
|
||||
r := math.sqrtf(v[0] * v[0] + v[1] * v[1] + v[2] * v[2])
|
||||
if r == 0.0 {
|
||||
return
|
||||
}
|
||||
v[0] /= r
|
||||
v[1] /= r
|
||||
v[2] /= r
|
||||
}
|
||||
|
||||
@[direct_array_access]
|
||||
fn vec3_cross(v1 [3]f32, v2 [3]f32) [3]f32 {
|
||||
return [
|
||||
v1[1] * v2[2] - v1[2] * v2[1],
|
||||
v1[2] * v2[0] - v1[0] * v2[2],
|
||||
v1[0] * v2[1] - v1[1] * v2[0],
|
||||
]!
|
||||
}
|
||||
|
||||
@[direct_array_access]
|
||||
fn mat4_lookat(mut dst Matrix, eye_x f32, eye_y f32, eye_z f32, center_x f32, center_y f32, center_z f32, up_x f32, up_y f32, up_z f32) {
|
||||
mut fwd := [center_x - eye_x, center_y - eye_y, center_z - eye_z]!
|
||||
mut up := [up_x, up_y, up_z]!
|
||||
vec3_normalize(mut fwd)
|
||||
mut side := vec3_cross(fwd, up)
|
||||
vec3_normalize(mut side)
|
||||
up = vec3_cross(side, fwd)
|
||||
|
||||
mut m := Matrix{}
|
||||
mat4_identity(mut m)
|
||||
m.v[0][0] = side[0]
|
||||
m.v[1][0] = side[1]
|
||||
m.v[2][0] = side[2]
|
||||
m.v[0][1] = up[0]
|
||||
m.v[1][1] = up[1]
|
||||
m.v[2][1] = up[2]
|
||||
m.v[0][2] = -fwd[0]
|
||||
m.v[1][2] = -fwd[1]
|
||||
m.v[2][2] = -fwd[2]
|
||||
mat4_mul_inplace(mut dst, &m)
|
||||
mat4_translate(mut dst, -eye_x, -eye_y, -eye_z)
|
||||
}
|
||||
|
||||
// Matrix stack access helpers for ContextInternal
|
||||
|
||||
fn (ctx &ContextInternal) matrix_projection() &Matrix {
|
||||
return &ctx.matrix_stack[int(MatrixMode.projection)][ctx.matrix_tos[int(MatrixMode.projection)]]
|
||||
}
|
||||
|
||||
fn (ctx &ContextInternal) matrix_modelview() &Matrix {
|
||||
return &ctx.matrix_stack[int(MatrixMode.modelview)][ctx.matrix_tos[int(MatrixMode.modelview)]]
|
||||
}
|
||||
|
||||
fn (ctx &ContextInternal) matrix_texture() &Matrix {
|
||||
return &ctx.matrix_stack[int(MatrixMode.texture)][ctx.matrix_tos[int(MatrixMode.texture)]]
|
||||
}
|
||||
|
||||
fn (ctx &ContextInternal) current_matrix() &Matrix {
|
||||
return &ctx.matrix_stack[int(ctx.cur_matrix_mode)][ctx.matrix_tos[int(ctx.cur_matrix_mode)]]
|
||||
}
|
||||
|
||||
fn (mut ctx ContextInternal) current_matrix_mut() &Matrix {
|
||||
return &ctx.matrix_stack[int(ctx.cur_matrix_mode)][ctx.matrix_tos[int(ctx.cur_matrix_mode)]]
|
||||
}
|
||||
@@ -1,443 +0,0 @@
|
||||
module sgl
|
||||
|
||||
import sokol.gfx
|
||||
import sokol.memory
|
||||
|
||||
pub const version = gfx.version + 1
|
||||
|
||||
pub const context = Context{0x00010001} // C.SGL_DEFAULT_CONTEXT = { 0x00010001 }
|
||||
|
||||
// setup/shutdown/misc
|
||||
pub fn setup(desc &Desc) {
|
||||
if desc.allocator.alloc_fn == unsafe { nil } && desc.allocator.free_fn == unsafe { nil } {
|
||||
unsafe {
|
||||
desc.allocator.alloc_fn = memory.salloc
|
||||
desc.allocator.free_fn = memory.sfree
|
||||
desc.allocator.user_data = voidptr(0x10000561)
|
||||
}
|
||||
}
|
||||
if desc.logger.func == unsafe { nil } {
|
||||
unsafe {
|
||||
desc.logger.func = memory.slog
|
||||
}
|
||||
}
|
||||
C.sgl_setup(desc)
|
||||
}
|
||||
|
||||
pub fn shutdown() {
|
||||
C.sgl_shutdown()
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn error() SglError {
|
||||
return unsafe { SglError(int(C.sgl_error())) }
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn context_error(ctx Context) SglError {
|
||||
return unsafe { SglError(int(C.sgl_context_error(ctx))) }
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn rad(deg f32) f32 {
|
||||
return C.sgl_rad(deg)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn deg(rad f32) f32 {
|
||||
return C.sgl_deg(rad)
|
||||
}
|
||||
|
||||
// context functions
|
||||
@[inline]
|
||||
pub fn make_context(desc &ContextDesc) Context {
|
||||
return C.sgl_make_context(desc)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn destroy_context(ctx Context) {
|
||||
C.sgl_destroy_context(ctx)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn set_context(ctx Context) {
|
||||
C.sgl_set_context(ctx)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn get_context() Context {
|
||||
return C.sgl_get_context()
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn default_context() Context {
|
||||
return C.sgl_default_context()
|
||||
}
|
||||
|
||||
// create and destroy pipeline objects
|
||||
@[inline]
|
||||
pub fn make_pipeline(desc &gfx.PipelineDesc) Pipeline {
|
||||
return C.sgl_make_pipeline(desc)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn context_make_pipeline(ctx Context, desc &gfx.PipelineDesc) Pipeline {
|
||||
return C.sgl_context_make_pipeline(ctx, desc)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn destroy_pipeline(pip Pipeline) {
|
||||
C.sgl_destroy_pipeline(pip)
|
||||
}
|
||||
|
||||
// render state functions
|
||||
@[inline]
|
||||
pub fn defaults() {
|
||||
C.sgl_defaults()
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn viewport(x int, y int, w int, h int, origin_top_left bool) {
|
||||
C.sgl_viewport(x, y, w, h, origin_top_left)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn scissor_rect(x int, y int, w int, h int, origin_top_left bool) {
|
||||
C.sgl_scissor_rect(x, y, w, h, origin_top_left)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn scissor_rectf(x f32, y f32, w f32, h f32, origin_top_left bool) {
|
||||
C.sgl_scissor_rectf(x, y, w, h, origin_top_left)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn enable_texture() {
|
||||
C.sgl_enable_texture()
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn disable_texture() {
|
||||
C.sgl_disable_texture()
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn texture(img gfx.Image, smp gfx.Sampler) {
|
||||
C.sgl_texture(img, smp)
|
||||
}
|
||||
|
||||
// pipeline stack functions
|
||||
@[inline]
|
||||
pub fn load_default_pipeline() {
|
||||
C.sgl_load_default_pipeline()
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn default_pipeline() {
|
||||
C.sgl_load_default_pipeline()
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn load_pipeline(pip Pipeline) {
|
||||
C.sgl_load_pipeline(pip)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn push_pipeline() {
|
||||
C.sgl_push_pipeline()
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn pop_pipeline() {
|
||||
C.sgl_pop_pipeline()
|
||||
}
|
||||
|
||||
// matrix stack functions
|
||||
@[inline]
|
||||
pub fn matrix_mode_modelview() {
|
||||
C.sgl_matrix_mode_modelview()
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn matrix_mode_projection() {
|
||||
C.sgl_matrix_mode_projection()
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn matrix_mode_texture() {
|
||||
C.sgl_matrix_mode_texture()
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn load_identity() {
|
||||
C.sgl_load_identity()
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn load_matrix(m []f32) {
|
||||
C.sgl_load_matrix(m.data)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn load_transpose_matrix(m []f32) {
|
||||
C.sgl_load_transpose_matrix(m.data)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn mult_matrix(m []f32) {
|
||||
C.sgl_mult_matrix(m.data)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn mult_transpose_matrix(m []f32) {
|
||||
C.sgl_mult_transpose_matrix(m.data)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn rotate(angle_rad f32, x f32, y f32, z f32) {
|
||||
C.sgl_rotate(angle_rad, x, y, z)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn scale(x f32, y f32, z f32) {
|
||||
C.sgl_scale(x, y, z)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn translate(x f32, y f32, z f32) {
|
||||
C.sgl_translate(x, y, z)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn frustum(l f32, r f32, b f32, t f32, n f32, f f32) {
|
||||
C.sgl_frustum(l, r, b, t, n, f)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn ortho(l f32, r f32, b f32, t f32, n f32, f f32) {
|
||||
C.sgl_ortho(l, r, b, t, n, f)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn perspective(fov_y f32, aspect f32, z_near f32, z_far f32) {
|
||||
C.sgl_perspective(fov_y, aspect, z_near, z_far)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn lookat(eye_x f32, eye_y f32, eye_z f32, center_x f32, center_y f32, center_z f32, up_x f32, up_y f32,
|
||||
up_z f32) {
|
||||
C.sgl_lookat(eye_x, eye_y, eye_z, center_x, center_y, center_z, up_x, up_y, up_z)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn push_matrix() {
|
||||
C.sgl_push_matrix()
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn pop_matrix() {
|
||||
C.sgl_pop_matrix()
|
||||
}
|
||||
|
||||
// these functions only set the internal 'current texcoord / color' (valid inside or outside begin/end)
|
||||
@[inline]
|
||||
pub fn t2f(u f32, v f32) {
|
||||
C.sgl_t2f(u, v)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn c3f(r f32, g f32, b f32) {
|
||||
C.sgl_c3f(r, g, b)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn c4f(r f32, g f32, b f32, a f32) {
|
||||
C.sgl_c4f(r, g, b, a)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn c3b(r u8, g u8, b u8) {
|
||||
C.sgl_c3b(r, g, b)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn c4b(r u8, g u8, b u8, a u8) {
|
||||
C.sgl_c4b(r, g, b, a)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn c1i(rgba u32) {
|
||||
C.sgl_c1i(rgba)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn point_size(s f32) {
|
||||
C.sgl_point_size(s)
|
||||
}
|
||||
|
||||
// define primitives, each begin/end is one draw command
|
||||
@[inline]
|
||||
pub fn begin_points() {
|
||||
C.sgl_begin_points()
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn begin_lines() {
|
||||
C.sgl_begin_lines()
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn begin_line_strip() {
|
||||
C.sgl_begin_line_strip()
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn begin_triangles() {
|
||||
C.sgl_begin_triangles()
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn begin_triangle_strip() {
|
||||
C.sgl_begin_triangle_strip()
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn begin_quads() {
|
||||
C.sgl_begin_quads()
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn v2f(x f32, y f32) {
|
||||
C.sgl_v2f(x, y)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn v3f(x f32, y f32, z f32) {
|
||||
C.sgl_v3f(x, y, z)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn v2f_t2f(x f32, y f32, u f32, v f32) {
|
||||
C.sgl_v2f_t2f(x, y, u, v)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn v3f_t2f(x f32, y f32, z f32, u f32, v f32) {
|
||||
C.sgl_v3f_t2f(x, y, z, u, v)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn v2f_c3f(x f32, y f32, r f32, g f32, b f32) {
|
||||
C.sgl_v2f_c3f(x, y, r, g, b)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn v2f_c3b(x f32, y f32, r u8, g u8, b u8) {
|
||||
C.sgl_v2f_c3b(x, y, r, g, b)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn v2f_c4f(x f32, y f32, r f32, g f32, b f32, a f32) {
|
||||
C.sgl_v2f_c4f(x, y, r, g, b, a)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn v2f_c4b(x f32, y f32, r u8, g u8, b u8, a u8) {
|
||||
C.sgl_v2f_c4b(x, y, r, g, b, a)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn v2f_c1i(x f32, y f32, rgba u32) {
|
||||
C.sgl_v2f_c1i(x, y, rgba)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn v3f_c3f(x f32, y f32, z f32, r f32, g f32, b f32) {
|
||||
C.sgl_v3f_c3f(x, y, z, r, g, b)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn v3f_c3b(x f32, y f32, z f32, r u8, g u8, b u8) {
|
||||
C.sgl_v3f_c3b(x, y, z, r, g, b)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn v3f_c4f(x f32, y f32, z f32, r f32, g f32, b f32, a f32) {
|
||||
C.sgl_v3f_c4f(x, y, z, r, g, b, a)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn v3f_c4b(x f32, y f32, z f32, r u8, g u8, b u8, a u8) {
|
||||
C.sgl_v3f_c4b(x, y, z, r, g, b, a)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn v3f_c1i(x f32, y f32, z f32, rgba u32) {
|
||||
C.sgl_v3f_c1i(x, y, z, rgba)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn v2f_t2f_c3f(x f32, y f32, u f32, v f32, r f32, g f32, b f32) {
|
||||
C.sgl_v2f_t2f_c3f(x, y, u, v, r, g, b)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn v2f_t2f_c3b(x f32, y f32, u f32, v f32, r u8, g u8, b u8) {
|
||||
C.sgl_v2f_t2f_c3b(x, y, u, v, r, g, b)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn v2f_t2f_c4f(x f32, y f32, u f32, v f32, r f32, g f32, b f32, a f32) {
|
||||
C.sgl_v2f_t2f_c4f(x, y, u, v, r, g, b, a)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn v2f_t2f_c4b(x f32, y f32, u f32, v f32, r u8, g u8, b u8, a u8) {
|
||||
C.sgl_v2f_t2f_c4b(x, y, u, v, r, g, b, a)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn v2f_t2f_c1i(x f32, y f32, u f32, v f32, rgba u32) {
|
||||
C.sgl_v2f_t2f_c1i(x, y, u, v, rgba)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn v3f_t2f_c3f(x f32, y f32, z f32, u f32, v f32, r f32, g f32, b f32) {
|
||||
C.sgl_v3f_t2f_c3f(x, y, z, u, v, r, g, b)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn v3f_t2f_c3b(x f32, y f32, z f32, u f32, v f32, r u8, g u8, b u8) {
|
||||
C.sgl_v3f_t2f_c3b(x, y, z, u, v, r, g, b)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn v3f_t2f_c4f(x f32, y f32, z f32, u f32, v f32, r f32, g f32, b f32, a f32) {
|
||||
C.sgl_v3f_t2f_c4f(x, y, z, u, v, r, g, b, a)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn v3f_t2f_c4b(x f32, y f32, z f32, u f32, v f32, r u8, g u8, b u8, a u8) {
|
||||
C.sgl_v3f_t2f_c4b(x, y, z, u, v, r, g, b, a)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn v3f_t2f_c1i(x f32, y f32, z f32, u f32, v f32, rgba u32) {
|
||||
C.sgl_v3f_t2f_c1i(x, y, z, u, v, rgba)
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn end() {
|
||||
C.sgl_end()
|
||||
}
|
||||
|
||||
// render recorded commands
|
||||
@[inline]
|
||||
pub fn draw() {
|
||||
C.sgl_draw()
|
||||
}
|
||||
|
||||
@[inline]
|
||||
pub fn context_draw(ctx Context) {
|
||||
C.sgl_context_draw(ctx)
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,18 +0,0 @@
|
||||
module sgl
|
||||
|
||||
import sokol.memory
|
||||
|
||||
@[typedef]
|
||||
pub struct C.sgl_allocator_t {
|
||||
pub mut:
|
||||
alloc_fn memory.FnAllocatorAlloc = unsafe { nil }
|
||||
free_fn memory.FnAllocatorFree = unsafe { nil }
|
||||
user_data voidptr
|
||||
}
|
||||
|
||||
@[typedef]
|
||||
pub struct C.sgl_logger_t {
|
||||
pub mut:
|
||||
func memory.FnLogCb = unsafe { nil }
|
||||
user_data voidptr
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
module sgl
|
||||
|
||||
// setup/shutdown/misc
|
||||
fn C.sgl_setup(desc &C.sgl_desc_t)
|
||||
fn C.sgl_shutdown()
|
||||
fn C.sgl_error() SglError
|
||||
fn C.sgl_context_error(ctx C.sgl_context) SglError
|
||||
fn C.sgl_rad(deg f32) f32
|
||||
fn C.sgl_deg(rad f32) f32
|
||||
|
||||
// context functions
|
||||
fn C.sgl_make_context(desc &C.sgl_context_desc_t) C.sgl_context
|
||||
fn C.sgl_destroy_context(ctx C.sgl_context)
|
||||
fn C.sgl_set_context(ctx C.sgl_context)
|
||||
fn C.sgl_get_context() C.sgl_context
|
||||
fn C.sgl_default_context() C.sgl_context
|
||||
|
||||
// create and destroy pipeline objects
|
||||
fn C.sgl_make_pipeline(desc &C.sg_pipeline_desc) C.sgl_pipeline
|
||||
fn C.sgl_context_make_pipeline(ctx C.sgl_context, desc &C.sg_pipeline_desc) C.sgl_pipeline
|
||||
fn C.sgl_destroy_pipeline(pip C.sgl_pipeline)
|
||||
|
||||
// render state functions
|
||||
fn C.sgl_defaults()
|
||||
fn C.sgl_viewport(x i32, y i32, w i32, h i32, origin_top_left bool)
|
||||
fn C.sgl_viewportf(x f32, y f32, w f32, h f32, origin_top_left bool)
|
||||
fn C.sgl_scissor_rect(x i32, y i32, w i32, h i32, origin_top_left bool)
|
||||
fn C.sgl_scissor_rectf(x f32, y f32, w f32, h f32, origin_top_left bool)
|
||||
fn C.sgl_enable_texture()
|
||||
fn C.sgl_disable_texture()
|
||||
fn C.sgl_texture(img C.sg_image, sampler C.sg_sampler)
|
||||
|
||||
// pipeline stack functions
|
||||
fn C.sgl_load_default_pipeline()
|
||||
fn C.sgl_load_pipeline(pip C.sgl_pipeline)
|
||||
fn C.sgl_push_pipeline()
|
||||
fn C.sgl_pop_pipeline()
|
||||
|
||||
// matrix stack functions
|
||||
fn C.sgl_matrix_mode_modelview()
|
||||
fn C.sgl_matrix_mode_projection()
|
||||
fn C.sgl_matrix_mode_texture()
|
||||
fn C.sgl_load_identity()
|
||||
fn C.sgl_load_matrix(m [16]f32)
|
||||
fn C.sgl_load_transpose_matrix(m [16]f32)
|
||||
fn C.sgl_mult_matrix(m [16]f32)
|
||||
fn C.sgl_mult_transpose_matrix(m [16]f32)
|
||||
fn C.sgl_rotate(angle_rad f32, x f32, y f32, z f32)
|
||||
fn C.sgl_scale(x f32, y f32, z f32)
|
||||
fn C.sgl_translate(x f32, y f32, z f32)
|
||||
fn C.sgl_frustum(l f32, r f32, b f32, t f32, n f32, f f32)
|
||||
fn C.sgl_ortho(l f32, r f32, b f32, t f32, n f32, f f32)
|
||||
fn C.sgl_perspective(fov_y f32, aspect f32, z_near f32, z_far f32)
|
||||
fn C.sgl_lookat(eye_x f32, eye_y f32, eye_z f32, center_x f32, center_y f32, center_z f32, up_x f32, up_y f32,
|
||||
up_z f32)
|
||||
fn C.sgl_push_matrix()
|
||||
fn C.sgl_pop_matrix()
|
||||
|
||||
// these functions only set the internal 'current texcoord / color' (valid inside or outside begin/end)
|
||||
fn C.sgl_t2f(u f32, v f32)
|
||||
fn C.sgl_c3f(r f32, g f32, b f32)
|
||||
fn C.sgl_c4f(r f32, g f32, b f32, a f32)
|
||||
fn C.sgl_c3b(r u8, g u8, b u8)
|
||||
fn C.sgl_c4b(r u8, g u8, b u8, a u8)
|
||||
fn C.sgl_c1i(rgba u32)
|
||||
fn C.sgl_point_size(s f32)
|
||||
|
||||
// define primitives, each begin/end is one draw command
|
||||
fn C.sgl_begin_points()
|
||||
fn C.sgl_begin_lines()
|
||||
fn C.sgl_begin_line_strip()
|
||||
fn C.sgl_begin_triangles()
|
||||
fn C.sgl_begin_triangle_strip()
|
||||
fn C.sgl_begin_quads()
|
||||
fn C.sgl_v2f(x f32, y f32)
|
||||
fn C.sgl_v3f(x f32, y f32, z f32)
|
||||
fn C.sgl_v2f_t2f(x f32, y f32, u f32, v f32)
|
||||
fn C.sgl_v3f_t2f(x f32, y f32, z f32, u f32, v f32)
|
||||
fn C.sgl_v2f_c3f(x f32, y f32, r f32, g f32, b f32)
|
||||
fn C.sgl_v2f_c3b(x f32, y f32, r u8, g u8, b u8)
|
||||
fn C.sgl_v2f_c4f(x f32, y f32, r f32, g f32, b f32, a f32)
|
||||
fn C.sgl_v2f_c4b(x f32, y f32, r u8, g u8, b u8, a u8)
|
||||
fn C.sgl_v2f_c1i(x f32, y f32, rgba u32)
|
||||
fn C.sgl_v3f_c3f(x f32, y f32, z f32, r f32, g f32, b f32)
|
||||
fn C.sgl_v3f_c3b(x f32, y f32, z f32, r u8, g u8, b u8)
|
||||
fn C.sgl_v3f_c4f(x f32, y f32, z f32, r f32, g f32, b f32, a f32)
|
||||
fn C.sgl_v3f_c4b(x f32, y f32, z f32, r u8, g u8, b u8, a u8)
|
||||
fn C.sgl_v3f_c1i(x f32, y f32, z f32, rgba u32)
|
||||
fn C.sgl_v2f_t2f_c3f(x f32, y f32, u f32, v f32, r f32, g f32, b f32)
|
||||
fn C.sgl_v2f_t2f_c3b(x f32, y f32, u f32, v f32, r u8, g u8, b u8)
|
||||
fn C.sgl_v2f_t2f_c4f(x f32, y f32, u f32, v f32, r f32, g f32, b f32, a f32)
|
||||
fn C.sgl_v2f_t2f_c4b(x f32, y f32, u f32, v f32, r u8, g u8, b u8, a u8)
|
||||
fn C.sgl_v2f_t2f_c1i(x f32, y f32, u f32, v f32, rgba u32)
|
||||
fn C.sgl_v3f_t2f_c3f(x f32, y f32, z f32, u f32, v f32, r f32, g f32, b f32)
|
||||
fn C.sgl_v3f_t2f_c3b(x f32, y f32, z f32, u f32, v f32, r u8, g u8, b u8)
|
||||
fn C.sgl_v3f_t2f_c4f(x f32, y f32, z f32, u f32, v f32, r f32, g f32, b f32, a f32)
|
||||
fn C.sgl_v3f_t2f_c4b(x f32, y f32, z f32, u f32, v f32, r u8, g u8, b u8, a u8)
|
||||
fn C.sgl_v3f_t2f_c1i(x f32, y f32, z f32, u f32, v f32, rgba u32)
|
||||
fn C.sgl_end()
|
||||
|
||||
// render recorded commands
|
||||
fn C.sgl_draw()
|
||||
fn C.sgl_context_draw(ctx C.sgl_context)
|
||||
@@ -1,52 +0,0 @@
|
||||
module sgl
|
||||
|
||||
import sokol.gfx
|
||||
|
||||
@[typedef]
|
||||
pub struct C.sgl_pipeline {
|
||||
id u32
|
||||
}
|
||||
|
||||
pub type Pipeline = C.sgl_pipeline
|
||||
|
||||
@[typedef]
|
||||
pub struct C.sgl_context {
|
||||
id u32
|
||||
}
|
||||
|
||||
pub type Context = C.sgl_context
|
||||
|
||||
// ContextDesc
|
||||
//
|
||||
// Describes the initialization parameters of a rendering context.
|
||||
// Creating additional contexts is useful if you want to render
|
||||
// in separate sokol-gfx passes.
|
||||
// ContextDesc is sgl_context_desc_t
|
||||
pub type ContextDesc = C.sgl_context_desc_t
|
||||
|
||||
@[typedef]
|
||||
pub struct C.sgl_context_desc_t {
|
||||
max_vertices int // default: 64k
|
||||
max_commands int // default: 16k
|
||||
color_format gfx.PixelFormat // C.sg_pixel_format
|
||||
depth_format gfx.PixelFormat // C.sg_pixel_format
|
||||
sample_count int
|
||||
}
|
||||
|
||||
pub type Desc = C.sgl_desc_t
|
||||
|
||||
@[typedef]
|
||||
pub struct C.sgl_desc_t {
|
||||
pub:
|
||||
max_vertices int // size for vertex buffer
|
||||
max_commands int // size of uniform- and command-buffers
|
||||
context_pool_size int // max number of contexts (including default context), default: 4
|
||||
pipeline_pool_size int // size of internal pipeline pool, default: 64
|
||||
color_format gfx.PixelFormat // C.sg_pixel_format
|
||||
depth_format gfx.PixelFormat // C.sg_pixel_format
|
||||
sample_count int
|
||||
face_winding gfx.FaceWinding // C.sg_face_winding // default front face winding is CCW
|
||||
pub mut:
|
||||
allocator C.sgl_allocator_t // optional memory allocation overrides (default: malloc/free)
|
||||
logger C.sgl_logger_t // optional memory allocation overrides (default: SOKOL_LOG(message))
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
module sgl
|
||||
|
||||
import sokol.gfx
|
||||
import sokol.memory
|
||||
|
||||
// Public types
|
||||
|
||||
pub struct Pipeline {
|
||||
pub:
|
||||
id u32
|
||||
}
|
||||
|
||||
pub struct Context {
|
||||
pub:
|
||||
id u32
|
||||
}
|
||||
|
||||
pub struct ContextDesc {
|
||||
pub mut:
|
||||
max_vertices int
|
||||
max_commands int
|
||||
color_format gfx.PixelFormat
|
||||
depth_format gfx.PixelFormat
|
||||
sample_count int
|
||||
}
|
||||
|
||||
pub struct Allocator {
|
||||
pub mut:
|
||||
alloc_fn memory.FnAllocatorAlloc = unsafe { nil }
|
||||
free_fn memory.FnAllocatorFree = unsafe { nil }
|
||||
user_data voidptr
|
||||
}
|
||||
|
||||
pub struct Logger {
|
||||
pub mut:
|
||||
func memory.FnLogCb = unsafe { nil }
|
||||
user_data voidptr
|
||||
}
|
||||
|
||||
pub struct Desc {
|
||||
pub mut:
|
||||
max_vertices int
|
||||
max_commands int
|
||||
context_pool_size int
|
||||
pipeline_pool_size int
|
||||
color_format gfx.PixelFormat
|
||||
depth_format gfx.PixelFormat
|
||||
sample_count int
|
||||
face_winding gfx.FaceWinding
|
||||
allocator Allocator
|
||||
logger Logger
|
||||
}
|
||||
|
||||
// Internal structs used by the pure V implementation.
|
||||
|
||||
struct Vertex {
|
||||
mut:
|
||||
pos [3]f32
|
||||
uv [2]f32
|
||||
rgba u32
|
||||
psize f32
|
||||
}
|
||||
|
||||
struct Matrix {
|
||||
mut:
|
||||
v [4][4]f32
|
||||
}
|
||||
|
||||
struct Uniform {
|
||||
mut:
|
||||
mvp Matrix
|
||||
tm Matrix
|
||||
}
|
||||
|
||||
struct DrawArgs {
|
||||
mut:
|
||||
pip gfx.Pipeline
|
||||
img gfx.Image
|
||||
smp gfx.Sampler
|
||||
base_vertex int
|
||||
num_vertices int
|
||||
uniform_index int
|
||||
}
|
||||
|
||||
struct ViewportArgs {
|
||||
mut:
|
||||
x int
|
||||
y int
|
||||
w int
|
||||
h int
|
||||
origin_top_left bool
|
||||
}
|
||||
|
||||
struct ScissorRectArgs {
|
||||
mut:
|
||||
x int
|
||||
y int
|
||||
w int
|
||||
h int
|
||||
origin_top_left bool
|
||||
}
|
||||
|
||||
union CommandArgs {
|
||||
draw DrawArgs
|
||||
viewport ViewportArgs
|
||||
scissor_rect ScissorRectArgs
|
||||
}
|
||||
|
||||
struct Command {
|
||||
mut:
|
||||
cmd CommandType
|
||||
layer_id int
|
||||
args CommandArgs
|
||||
}
|
||||
|
||||
struct Slot {
|
||||
mut:
|
||||
id u32
|
||||
state gfx.ResourceState
|
||||
}
|
||||
|
||||
struct Pool {
|
||||
mut:
|
||||
size int
|
||||
queue_top int
|
||||
gen_ctrs &u32 = unsafe { nil }
|
||||
free_queue &int = unsafe { nil }
|
||||
}
|
||||
|
||||
struct PipelineInternal {
|
||||
mut:
|
||||
slot Slot
|
||||
pip [num_primitive_types]gfx.Pipeline
|
||||
}
|
||||
|
||||
struct PipelinePool {
|
||||
mut:
|
||||
pool Pool
|
||||
pips &PipelineInternal = unsafe { nil }
|
||||
}
|
||||
|
||||
const max_stack_depth = 64
|
||||
|
||||
struct ContextInternal {
|
||||
mut:
|
||||
slot Slot
|
||||
desc ContextDesc
|
||||
frame_id u32
|
||||
update_frame_id u32
|
||||
// vertex buffer
|
||||
vertices_cap int
|
||||
vertices_next int
|
||||
vertices_ptr &Vertex = unsafe { nil }
|
||||
// uniform buffer
|
||||
uniforms_cap int
|
||||
uniforms_next int
|
||||
uniforms_ptr &Uniform = unsafe { nil }
|
||||
// command buffer
|
||||
commands_cap int
|
||||
commands_next int
|
||||
commands_ptr &Command = unsafe { nil }
|
||||
// state tracking
|
||||
base_vertex int
|
||||
vtx_count int
|
||||
error SglError
|
||||
in_begin bool
|
||||
layer_id int
|
||||
u f32
|
||||
v f32
|
||||
rgba u32
|
||||
point_size f32
|
||||
cur_prim_type PrimitiveType
|
||||
cur_img gfx.Image
|
||||
cur_smp gfx.Sampler
|
||||
texturing_enabled bool
|
||||
matrix_dirty bool
|
||||
// sokol-gfx resources
|
||||
vbuf gfx.Buffer
|
||||
def_pip Pipeline
|
||||
bind gfx.Bindings
|
||||
// pipeline stack
|
||||
pip_tos int
|
||||
pip_stack [max_stack_depth]Pipeline
|
||||
// matrix stacks
|
||||
cur_matrix_mode MatrixMode
|
||||
matrix_tos [num_matrixmodes]int
|
||||
matrix_stack [num_matrixmodes][max_stack_depth]Matrix
|
||||
}
|
||||
|
||||
struct ContextPool {
|
||||
mut:
|
||||
pool Pool
|
||||
contexts &ContextInternal = unsafe { nil }
|
||||
}
|
||||
|
||||
// Global state
|
||||
struct SglState {
|
||||
mut:
|
||||
init_cookie u32
|
||||
desc Desc
|
||||
def_img gfx.Image
|
||||
def_smp gfx.Sampler
|
||||
shd gfx.Shader
|
||||
def_ctx_id Context
|
||||
cur_ctx_id Context
|
||||
cur_ctx &ContextInternal = unsafe { nil }
|
||||
pip_pool PipelinePool
|
||||
context_pool ContextPool
|
||||
}
|
||||
|
||||
const invalid_slot_index = 0
|
||||
const default_context_pool_size = 4
|
||||
const default_pipeline_pool_size = 64
|
||||
const default_max_vertices = (1 << 17)
|
||||
const default_max_commands = (1 << 15)
|
||||
const slot_shift = 16
|
||||
const max_pool_size = (1 << slot_shift)
|
||||
const slot_mask = (max_pool_size - 1)
|
||||
const init_cookie = u32(0xABCDABCD)
|
||||
@@ -0,0 +1,133 @@
|
||||
module sgl
|
||||
|
||||
import sokol.gfx
|
||||
|
||||
// GLSL 410 vertex shader (for SOKOL_GLCORE - Linux/macOS/FreeBSD/OpenBSD/Windows)
|
||||
const vs_source_glsl410 = '#version 410
|
||||
|
||||
uniform vec4 vs_params[8];
|
||||
layout(location = 0) in vec4 position;
|
||||
layout(location = 1) in vec2 texcoord0;
|
||||
layout(location = 2) in vec4 color0;
|
||||
layout(location = 3) in float psize;
|
||||
out vec2 uv;
|
||||
out vec4 color;
|
||||
|
||||
void main() {
|
||||
gl_Position = mat4(vs_params[0], vs_params[1], vs_params[2], vs_params[3]) * position;
|
||||
gl_PointSize = psize;
|
||||
uv = (mat4(vs_params[4], vs_params[5], vs_params[6], vs_params[7]) * vec4(texcoord0, 0.0, 1.0)).xy;
|
||||
color = color0;
|
||||
}
|
||||
'
|
||||
|
||||
// GLSL 410 fragment shader
|
||||
const fs_source_glsl410 = '#version 410
|
||||
|
||||
uniform sampler2D tex_smp;
|
||||
in vec2 uv;
|
||||
in vec4 color;
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
frag_color = texture(tex_smp, uv) * color;
|
||||
}
|
||||
'
|
||||
|
||||
// GLES3 vertex shader (for SOKOL_GLES3 - Emscripten/mobile)
|
||||
const vs_source_glsl300es = '#version 300 es
|
||||
|
||||
uniform vec4 vs_params[8];
|
||||
layout(location = 0) in vec4 position;
|
||||
layout(location = 1) in vec2 texcoord0;
|
||||
layout(location = 2) in vec4 color0;
|
||||
layout(location = 3) in float psize;
|
||||
out vec2 uv;
|
||||
out vec4 color;
|
||||
|
||||
void main() {
|
||||
gl_Position = mat4(vs_params[0], vs_params[1], vs_params[2], vs_params[3]) * position;
|
||||
gl_PointSize = psize;
|
||||
uv = (mat4(vs_params[4], vs_params[5], vs_params[6], vs_params[7]) * vec4(texcoord0, 0.0, 1.0)).xy;
|
||||
color = color0;
|
||||
}
|
||||
'
|
||||
|
||||
// GLES3 fragment shader
|
||||
const fs_source_glsl300es = '#version 300 es
|
||||
precision mediump float;
|
||||
precision highp int;
|
||||
|
||||
uniform highp sampler2D tex_smp;
|
||||
in highp vec2 uv;
|
||||
in highp vec4 color;
|
||||
layout(location = 0) out highp vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
frag_color = texture(tex_smp, uv) * color;
|
||||
}
|
||||
'
|
||||
|
||||
// Builds and returns the shader descriptor for the sgl shader.
|
||||
// Selects the correct shader source/bytecode based on the active graphics backend.
|
||||
fn make_shader_desc() gfx.ShaderDesc {
|
||||
mut desc := gfx.ShaderDesc{}
|
||||
desc.attrs[0].name = c'position'
|
||||
desc.attrs[1].name = c'texcoord0'
|
||||
desc.attrs[2].name = c'color0'
|
||||
desc.attrs[3].name = c'psize'
|
||||
desc.attrs[0].sem_name = c'TEXCOORD'
|
||||
desc.attrs[0].sem_index = 0
|
||||
desc.attrs[1].sem_name = c'TEXCOORD'
|
||||
desc.attrs[1].sem_index = 1
|
||||
desc.attrs[2].sem_name = c'TEXCOORD'
|
||||
desc.attrs[2].sem_index = 2
|
||||
desc.attrs[3].sem_name = c'TEXCOORD'
|
||||
desc.attrs[3].sem_index = 3
|
||||
desc.vs.uniform_blocks[0].size = sizeof(Uniform)
|
||||
desc.vs.uniform_blocks[0].uniforms[0].name = c'vs_params'
|
||||
desc.vs.uniform_blocks[0].uniforms[0].@type = .float4
|
||||
desc.vs.uniform_blocks[0].uniforms[0].array_count = 8
|
||||
desc.fs.images[0].used = true
|
||||
desc.fs.images[0].image_type = ._2d
|
||||
desc.fs.images[0].sample_type = .float
|
||||
desc.fs.samplers[0].used = true
|
||||
desc.fs.samplers[0].sampler_type = .filtering
|
||||
desc.fs.image_sampler_pairs[0].used = true
|
||||
desc.fs.image_sampler_pairs[0].image_slot = 0
|
||||
desc.fs.image_sampler_pairs[0].sampler_slot = 0
|
||||
desc.fs.image_sampler_pairs[0].glsl_name = c'tex_smp'
|
||||
desc.label = c'sgl-shader'
|
||||
|
||||
backend := gfx.query_backend()
|
||||
match backend {
|
||||
.glcore33 {
|
||||
desc.vs.source = vs_source_glsl410.str
|
||||
desc.fs.source = fs_source_glsl410.str
|
||||
}
|
||||
.gles3 {
|
||||
desc.vs.source = vs_source_glsl300es.str
|
||||
desc.fs.source = fs_source_glsl300es.str
|
||||
}
|
||||
.metal_macos, .metal_ios, .metal_simulator {
|
||||
// Metal backends - TODO: embed Metal shader bytecode
|
||||
desc.vs.source = vs_source_glsl410.str
|
||||
desc.fs.source = fs_source_glsl410.str
|
||||
}
|
||||
.d3d11 {
|
||||
// D3D11 backend - TODO: embed HLSL shader bytecode
|
||||
desc.vs.source = vs_source_glsl410.str
|
||||
desc.fs.source = fs_source_glsl410.str
|
||||
}
|
||||
.wgpu {
|
||||
// WebGPU - TODO: embed WGSL shader source
|
||||
desc.vs.source = vs_source_glsl410.str
|
||||
desc.fs.source = fs_source_glsl410.str
|
||||
}
|
||||
.dummy {
|
||||
desc.vs.source = c''
|
||||
desc.fs.source = c''
|
||||
}
|
||||
}
|
||||
return desc
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
module sokol
|
||||
|
||||
import sokol.c as _
|
||||
import sokol.f as _
|
||||
|
||||
/* pub enum Key {
|
||||
up = C.SAPP_KEYCODE_UP
|
||||
|
||||
+2
-1
@@ -983,7 +983,8 @@ pub fn (mut g Gen) init() {
|
||||
}
|
||||
if g.pref.os == .linux {
|
||||
// For gettid() declaration (and other GNU-specific bits).
|
||||
g.cheaders.writeln('#define _GNU_SOURCE')
|
||||
// Must come before any C declarations that use GNU extensions.
|
||||
g.preincludes.writeln('#define _GNU_SOURCE')
|
||||
}
|
||||
if g.pref.os == .wasm32 {
|
||||
g.cheaders.writeln('#define VWASM 1')
|
||||
|
||||
@@ -20,5 +20,7 @@ fn test_c_struct_fields_are_pub() {
|
||||
}
|
||||
|
||||
context := fontstash.create_internal(params)
|
||||
assert context.str() == 'fontstash.Context(C.FONScontext{})'
|
||||
// After porting sfons/fontstash to V, C.FONScontext now has public fields
|
||||
// so the string representation shows the fields instead of being empty
|
||||
assert context.str().starts_with('fontstash.Context(C.FONScontext{')
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
Module {
|
||||
name: 'x11'
|
||||
description: 'Shared X11 type definitions for V modules'
|
||||
author: 'V language'
|
||||
version: '0.0.1'
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
// X11 type definitions - shared across all V modules
|
||||
// Import this module instead of defining X11 types yourself
|
||||
module x11
|
||||
|
||||
// Basic X11 types
|
||||
pub type Window = u64
|
||||
pub type Atom = u64
|
||||
pub type VisualID = usize
|
||||
pub type Time = u64
|
||||
pub type Colormap = u64
|
||||
|
||||
// Forward declarations
|
||||
pub struct C.Display {}
|
||||
|
||||
// X11 event types
|
||||
@[typedef]
|
||||
pub struct C.XSelectionRequestEvent {
|
||||
pub mut:
|
||||
display &C.Display = unsafe { nil }
|
||||
owner Window
|
||||
requestor Window
|
||||
selection Atom
|
||||
target Atom
|
||||
property Atom
|
||||
time int
|
||||
}
|
||||
|
||||
@[typedef]
|
||||
pub struct C.XSelectionEvent {
|
||||
pub mut:
|
||||
type int
|
||||
display &C.Display = unsafe { nil }
|
||||
requestor Window
|
||||
selection Atom
|
||||
target Atom
|
||||
property Atom
|
||||
time int
|
||||
}
|
||||
|
||||
@[typedef]
|
||||
pub struct C.XSelectionClearEvent {
|
||||
pub mut:
|
||||
window Window
|
||||
selection Atom
|
||||
}
|
||||
|
||||
@[typedef]
|
||||
pub struct C.XDestroyWindowEvent {
|
||||
pub mut:
|
||||
window Window
|
||||
}
|
||||
|
||||
@[typedef]
|
||||
pub struct C.XPropertyEvent {
|
||||
pub mut:
|
||||
state int
|
||||
atom Atom
|
||||
}
|
||||
|
||||
@[typedef]
|
||||
pub struct C.XClientMessageEvent {
|
||||
pub mut:
|
||||
window Window
|
||||
format int
|
||||
message_type Atom
|
||||
data C.XClientMessageData
|
||||
}
|
||||
|
||||
@[typedef]
|
||||
pub union C.XClientMessageData {
|
||||
pub mut:
|
||||
b [20]u8
|
||||
s [10]i16
|
||||
l [5]i64
|
||||
}
|
||||
|
||||
@[typedef]
|
||||
pub struct C.XGenericEventCookie {
|
||||
pub mut:
|
||||
extension int
|
||||
evtype int
|
||||
data voidptr
|
||||
}
|
||||
|
||||
@[typedef]
|
||||
pub struct C.XKeyEvent {
|
||||
pub mut:
|
||||
keycode u32
|
||||
state u32
|
||||
}
|
||||
|
||||
@[typedef]
|
||||
pub struct C.XButtonEvent {
|
||||
pub mut:
|
||||
button u32
|
||||
state u32
|
||||
x int
|
||||
y int
|
||||
}
|
||||
|
||||
@[typedef]
|
||||
pub struct C.XMotionEvent {
|
||||
pub mut:
|
||||
x int
|
||||
y int
|
||||
state u32
|
||||
}
|
||||
|
||||
@[typedef]
|
||||
pub struct C.XCrossingEvent {
|
||||
pub mut:
|
||||
x int
|
||||
y int
|
||||
state u32
|
||||
}
|
||||
|
||||
@[typedef]
|
||||
pub struct C.XFocusChangeEvent {
|
||||
pub mut:
|
||||
mode int
|
||||
}
|
||||
|
||||
// Main XEvent union - each module should define this themselves based on their needs
|
||||
// pub union C.XEvent { ... }
|
||||
|
||||
// X11 function declarations
|
||||
pub fn C.XNextEvent(display &C.Display, event &C.XEvent) int
|
||||
pub fn C.XCheckTypedWindowEvent(display &C.Display, window Window, event_type int, event &C.XEvent) int
|
||||
pub fn C.XSendEvent(display &C.Display, window Window, propagate int, event_mask i64, event &C.XEvent) int
|
||||
pub fn C.XFilterEvent(event &C.XEvent, window Window) int
|
||||
pub fn C.XChangeProperty(display &C.Display, window Window, property Atom, type_ Atom, format int, mode int, data &u8, nitems int) int
|
||||
pub fn C.XConvertSelection(display &C.Display, selection Atom, target Atom, property Atom, requestor Window, time Time) int
|
||||
pub fn C.XSetSelectionOwner(display &C.Display, selection Atom, window Window, time Time) Window
|
||||
pub fn C.XGetSelectionOwner(display &C.Display, selection Atom) Window
|
||||
pub fn C.XDeleteProperty(display &C.Display, window Window, property Atom) int
|
||||
pub fn C.XGetWindowProperty(display &C.Display, window Window, property Atom, offset i64, length i64, delete int, req_type Atom, actual_type &Atom, actual_format &int, nitems &u64, bytes_after &u64, data &&u8) int
|
||||
Reference in new issue
Block a user