[Bf-blender-cvs] [18d1ef46f24] master: Cleanup: rename internal types for GHOST/Wayland
Campbell Barton
noreply at git.blender.org
Wed Sep 7 06:12:07 CEST 2022
Commit: 18d1ef46f24ff52668d1d1e31cf804c47ca62a0a
Author: Campbell Barton
Date: Wed Sep 7 14:04:01 2022 +1000
Branches: master
https://developer.blender.org/rB18d1ef46f24ff52668d1d1e31cf804c47ca62a0a
Cleanup: rename internal types for GHOST/Wayland
- Use pascel-case type names, instead of snake-case with `_t` suffix.
- Use `GWL_` prefix (short for GhostWayLand), to distinguish these
types from ghost (`GHOST_*`) and wayland (`wl_*`) types.
- Rename `input` to `seat` (following wayland's own terminology).
- Use `wl_` prefix for wayland native variables which have locally
defined equivalents so `GWL_Output *output` isn't confused with
`struct wl_output *wl_output`. As the locally defined types are used
more often this is less verbose overall.
===================================================================
M intern/ghost/intern/GHOST_SystemWayland.cpp
M intern/ghost/intern/GHOST_SystemWayland.h
M intern/ghost/intern/GHOST_WindowWayland.cpp
M intern/ghost/intern/GHOST_WindowWayland.h
===================================================================
diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp
index 8792ee239a8..4c663e98824 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -64,7 +64,7 @@
/* Logging, use `ghost.wl.*` prefix. */
#include "CLG_log.h"
-static void keyboard_handle_key_repeat_cancel(struct input_t *input);
+static void keyboard_handle_key_repeat_cancel(struct GWL_Seat *seat);
static void output_handle_done(void *data, struct wl_output *wl_output);
@@ -136,7 +136,7 @@ static bool use_gnome_confine_hack = false;
*/
#define EVDEV_OFFSET 8
-struct cursor_t {
+struct GWL_Cursor {
bool visible = false;
/**
* When false, hide the hardware cursor, while the cursor is still considered to be `visible`,
@@ -163,28 +163,28 @@ struct cursor_t {
* WAYLAND exposes tools via #zwp_tablet_tool_v2.
* Since are no API's to access properties of the tool, store the values here.
*/
-struct tablet_tool_input_t {
- struct input_t *input = nullptr;
- struct wl_surface *cursor_surface = nullptr;
- /** Used to delay clearing tablet focused surface until the frame is handled. */
+struct GWL_TabletTool {
+ struct GWL_Seat *seat = nullptr;
+ struct wl_surface *wl_surface_cursor = nullptr;
+ /** Used to delay clearing tablet focused wl_surface until the frame is handled. */
bool proximity = false;
GHOST_TabletData data = GHOST_TABLET_DATA_NONE;
};
-struct data_offer_t {
+struct GWL_DataOffer {
std::unordered_set<std::string> types;
uint32_t source_actions = 0;
uint32_t dnd_action = 0;
struct wl_data_offer *id = nullptr;
std::atomic<bool> in_use = false;
struct {
- /** Compatible with #input_t.xy coordinates. */
+ /** Compatible with #GWL_Seat.xy coordinates. */
wl_fixed_t xy[2] = {0, 0};
} dnd;
};
-struct data_source_t {
+struct GWL_DataSource {
struct wl_data_source *data_source = nullptr;
char *buffer_out = nullptr;
};
@@ -194,11 +194,11 @@ struct data_source_t {
*
* \note it's important not to store the target window here
* as it can be closed while the key is repeating,
- * instead use the focused keyboard from #intput_t which is cleared when windows are closed.
+ * instead use the focused keyboard from #GWL_Seat which is cleared when windows are closed.
* Therefor keyboard events must always check the window has not been cleared.
*/
-struct key_repeat_payload_t {
- struct input_t *input = nullptr;
+struct GWL_KeyRepeatPlayload {
+ struct GWL_Seat *seat = nullptr;
xkb_keycode_t key_code;
@@ -212,7 +212,7 @@ struct key_repeat_payload_t {
};
/** Internal variables used to track grab-state. */
-struct input_grab_state_t {
+struct GWL_SeatStateGrab {
bool use_lock = false;
bool use_confine = false;
};
@@ -220,7 +220,7 @@ struct input_grab_state_t {
/**
* State of the pointing device (tablet or mouse).
*/
-struct input_state_pointer_t {
+struct GWL_SeatStatePointer {
/**
* High precision coordinates.
*
@@ -229,15 +229,15 @@ struct input_state_pointer_t {
* \code{.cc}
* const wl_fixed_t scale = win->scale();
* const int event_xy[2] = {
- * wl_fixed_to_int(scale * input_state->xy[0]),
- * wl_fixed_to_int(scale * input_state->xy[1]),
+ * wl_fixed_to_int(scale * seat_state_pointer->xy[0]),
+ * wl_fixed_to_int(scale * seat_state_pointer->xy[1]),
* };
* \endcode
*/
wl_fixed_t xy[2] = {0, 0};
/** Outputs on which the cursor is visible. */
- std::unordered_set<const output_t *> outputs;
+ std::unordered_set<const GWL_Output *> outputs;
int theme_scale = 1;
@@ -245,7 +245,7 @@ struct input_state_pointer_t {
uint32_t serial = 0;
/**
- * The surface last used with this pointing device
+ * The wl_surface last used with this pointing device
* (events with this pointing device will be sent here).
*/
struct wl_surface *wl_surface = nullptr;
@@ -254,20 +254,20 @@ struct input_state_pointer_t {
};
/**
- * State of the keyboard.
+ * State of the keyboard (in #GWL_Seat).
*/
-struct input_state_keyboard_t {
+struct GWL_SeatStateKeyboard {
/** The serial of the last used pointer or tablet. */
uint32_t serial = 0;
/**
- * The surface last used with this pointing device
+ * The wl_surface last used with this pointing device
* (events with this pointing device will be sent here).
*/
struct wl_surface *wl_surface = nullptr;
};
-struct input_t {
+struct GWL_Seat {
GHOST_SystemWayland *system = nullptr;
std::string name;
@@ -282,12 +282,12 @@ struct input_t {
/** Use to check if the last cursor input was tablet or pointer. */
uint32_t cursor_source_serial = 0;
- input_state_pointer_t pointer;
+ GWL_SeatStatePointer pointer;
/** Mostly this can be interchanged with `pointer` however it can't be locked/confined. */
- input_state_pointer_t tablet;
+ GWL_SeatStatePointer tablet;
- input_state_keyboard_t keyboard;
+ GWL_SeatStateKeyboard keyboard;
#ifdef USE_GNOME_CONFINE_HACK
bool use_pointer_software_confine = false;
@@ -295,7 +295,7 @@ struct input_t {
/** The cursor location (in pixel-space) when hidden grab started (#GHOST_kGrabHide). */
wl_fixed_t grab_lock_xy[2] = {0, 0};
- struct cursor_t cursor;
+ struct GWL_Cursor cursor;
struct zwp_relative_pointer_v1 *relative_pointer = nullptr;
struct zwp_locked_pointer_v1 *locked_pointer = nullptr;
@@ -337,25 +337,25 @@ struct input_t {
GHOST_ITimerTask *timer = nullptr;
} key_repeat;
- struct wl_surface *focus_dnd = nullptr;
+ struct wl_surface *wl_surface_focus_dnd = nullptr;
struct wl_data_device *data_device = nullptr;
/** Drag & Drop. */
- struct data_offer_t *data_offer_dnd = nullptr;
+ struct GWL_DataOffer *data_offer_dnd = nullptr;
std::mutex data_offer_dnd_mutex;
/** Copy & Paste. */
- struct data_offer_t *data_offer_copy_paste = nullptr;
+ struct GWL_DataOffer *data_offer_copy_paste = nullptr;
std::mutex data_offer_copy_paste_mutex;
- struct data_source_t *data_source = nullptr;
+ struct GWL_DataSource *data_source = nullptr;
std::mutex data_source_mutex;
/** Last device that was active. */
uint32_t data_source_serial = 0;
};
-struct display_t {
+struct GWL_Display {
GHOST_SystemWayland *system = nullptr;
struct wl_display *display = nullptr;
@@ -370,8 +370,8 @@ struct display_t {
struct zxdg_output_manager_v1 *xdg_output_manager = nullptr;
struct wl_shm *shm = nullptr;
- std::vector<output_t *> outputs;
- std::vector<input_t *> inputs;
+ std::vector<GWL_Output *> outputs;
+ std::vector<GWL_Seat *> seats;
struct wl_data_device_manager *data_device_manager = nullptr;
struct zwp_tablet_manager_v2 *tablet_manager = nullptr;
@@ -409,31 +409,31 @@ static void ghost_wayland_log_handler(const char *msg, va_list arg)
}
}
-static input_state_pointer_t *input_state_pointer_active(input_t *input)
+static GWL_SeatStatePointer *seat_state_pointer_active(GWL_Seat *seat)
{
- if (input->pointer.serial == input->cursor_source_serial) {
- return &input->pointer;
+ if (seat->pointer.serial == seat->cursor_source_serial) {
+ return &seat->pointer;
}
- if (input->tablet.serial == input->cursor_source_serial) {
- return &input->tablet;
+ if (seat->tablet.serial == seat->cursor_source_serial) {
+ return &seat->tablet;
}
return nullptr;
}
-static input_state_pointer_t *input_state_pointer_from_cursor_surface(input_t *input,
- const wl_surface *wl_surface)
+static GWL_SeatStatePointer *seat_state_pointer_from_cursor_surface(GWL_Seat *seat,
+ const wl_surface *wl_surface)
{
if (ghost_wl_surface_own_cursor_pointer(wl_surface)) {
- return &input->pointer;
+ return &seat->pointer;
}
if (ghost_wl_surface_own_cursor_tablet(wl_surface)) {
- return &input->tablet;
+ return &seat->tablet;
}
GHOST_ASSERT(0, "Surface found without pointer/tablet tag");
return nullptr;
}
-static void display_destroy(display_t *d)
+static void display_destroy(GWL_Display *d)
{
if (d->data_device_manager) {
wl_data_device_manager_destroy(d->data_device_manager);
@@ -443,77 +443,77 @@ static void display_destroy(display_t *d)
zwp_tablet_manager_v2_destroy(d->tablet_manager);
}
- for (output_t *output : d->outputs) {
+ for (GWL_Output *output : d->outputs) {
wl_output_destroy(output->wl_output);
delete output;
}
- for (input_t *input : d->inputs) {
+ for (GWL_Seat *seat : d->seats) {
/* First handle members that require locking.
* While highly unlikely, it's possible they are being used while this function runs. */
{
- std::lock_guard lock{input->data_source_mutex};
- if (input->data_source) {
- free(input->data_source->buffer_out);
- if (input->data_source->data_source) {
- wl_data_source_destroy(input->data_source->data_source);
+ std::lock_guard lock{seat->data_source_mutex};
+ if (seat->data_source) {
+ free(seat->data_source->buffer_out);
+ if (seat->data_source->data_source) {
+ wl_data_source_destroy(seat->data_source->data_source);
}
- delete input->data_source;
+ delete seat->data_source;
}
}
{
- std::lock_guard lock{input->data_offer_dnd_mutex};
- if (input->data_offer_dnd) {
- wl_data_offer_destroy(input->data_offer_dnd->id);
- delete input->data_offer_dnd;
+ std::lock_guard lock{seat->data_offer_dnd_mutex};
+ if (seat->data_offer_dnd) {
+ wl_data_offer_destroy(seat->data_offer_dnd->id);
+ delete seat->data_offer_dnd;
}
}
{
- std::lock_guard lock{input->data_offer_copy_paste_mutex};
- if (input->data_offer_copy_paste) {
- wl_data_offer_destroy(input->data_offer_copy_paste->id);
- delete input->data_offer_copy_paste;
+ std::lock_guard lock{seat->data_offer_copy_paste_mutex};
+ if (seat->data_offer_copy_paste) {
+ wl_data_offer_destroy(seat->data_offer_copy_paste->id);
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list