[Bf-blender-cvs] [94ce176e754] master: Cleanup: renaming GHOST/Wayland functions & private members
Campbell Barton
noreply at git.blender.org
Mon Oct 17 03:26:53 CEST 2022
Commit: 94ce176e754d47831638c50dfd54f5068048e950
Author: Campbell Barton
Date: Mon Oct 17 12:18:16 2022 +1100
Branches: master
https://developer.blender.org/rB94ce176e754d47831638c50dfd54f5068048e950
Cleanup: renaming GHOST/Wayland functions & private members
- Use `_` suffix for private members.
- Use `wl_` prefix for Wayland native types to help distinguish
them from local types.
- Replace single character names `d` & `w` with `display` `window`.
- Rename `selection` to `clipboard`. Using the primary selection as a
clipboard is a separate and as yet unsupported feature.
===================================================================
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 250c7a48899..0778938a8e4 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -504,8 +504,8 @@ struct GWL_Seat {
struct GWL_Display {
GHOST_SystemWayland *system = nullptr;
- struct wl_display *display = nullptr;
- struct wl_compositor *compositor = nullptr;
+ struct wl_display *wl_display = nullptr;
+ struct wl_compositor *wl_compositor = nullptr;
#ifdef WITH_GHOST_WAYLAND_LIBDECOR
WGL_LibDecor_System *libdecor = nullptr;
@@ -514,7 +514,7 @@ struct GWL_Display {
WGL_XDG_Decor_System *xdg_decor = nullptr;
struct zxdg_output_manager_v1 *xdg_output_manager = nullptr;
- struct wl_shm *shm = nullptr;
+ struct wl_shm *wl_shm = nullptr;
std::vector<GWL_Output *> outputs;
std::vector<GWL_Seat *> seats;
@@ -535,7 +535,7 @@ struct GWL_Display {
static GHOST_WindowManager *window_manager = nullptr;
/** Check this lock before accessing `GHOST_SystemWayland::selection` from a thread. */
-static std::mutex system_selection_mutex;
+static std::mutex system_clipboard_mutex;
/**
* Callback for WAYLAND to run when there is an error.
@@ -578,22 +578,22 @@ static GWL_SeatStatePointer *seat_state_pointer_from_cursor_surface(GWL_Seat *se
return nullptr;
}
-static void display_destroy(GWL_Display *d)
+static void display_destroy(GWL_Display *display)
{
- if (d->data_device_manager) {
- wl_data_device_manager_destroy(d->data_device_manager);
+ if (display->data_device_manager) {
+ wl_data_device_manager_destroy(display->data_device_manager);
}
- if (d->tablet_manager) {
- zwp_tablet_manager_v2_destroy(d->tablet_manager);
+ if (display->tablet_manager) {
+ zwp_tablet_manager_v2_destroy(display->tablet_manager);
}
- for (GWL_Output *output : d->outputs) {
+ for (GWL_Output *output : display->outputs) {
wl_output_destroy(output->wl_output);
delete output;
}
- for (GWL_Seat *seat : d->seats) {
+ for (GWL_Seat *seat : display->seats) {
/* First handle members that require locking.
* While highly unlikely, it's possible they are being used while this function runs. */
@@ -661,45 +661,45 @@ static void display_destroy(GWL_Display *d)
delete seat;
}
- if (d->shm) {
- wl_shm_destroy(d->shm);
+ if (display->wl_shm) {
+ wl_shm_destroy(display->wl_shm);
}
- if (d->relative_pointer_manager) {
- zwp_relative_pointer_manager_v1_destroy(d->relative_pointer_manager);
+ if (display->relative_pointer_manager) {
+ zwp_relative_pointer_manager_v1_destroy(display->relative_pointer_manager);
}
- if (d->pointer_constraints) {
- zwp_pointer_constraints_v1_destroy(d->pointer_constraints);
+ if (display->pointer_constraints) {
+ zwp_pointer_constraints_v1_destroy(display->pointer_constraints);
}
- if (d->compositor) {
- wl_compositor_destroy(d->compositor);
+ if (display->wl_compositor) {
+ wl_compositor_destroy(display->wl_compositor);
}
#ifdef WITH_GHOST_WAYLAND_LIBDECOR
if (use_libdecor) {
- if (d->libdecor) {
- wgl_libdecor_system_destroy(d->libdecor);
+ if (display->libdecor) {
+ wgl_libdecor_system_destroy(display->libdecor);
}
}
else
#endif
{
- if (d->xdg_decor) {
- wgl_xdg_decor_system_destroy(d->xdg_decor);
+ if (display->xdg_decor) {
+ wgl_xdg_decor_system_destroy(display->xdg_decor);
}
}
if (eglGetDisplay) {
- ::eglTerminate(eglGetDisplay(EGLNativeDisplayType(d->display)));
+ ::eglTerminate(eglGetDisplay(EGLNativeDisplayType(display->wl_display)));
}
- if (d->display) {
- wl_display_disconnect(d->display);
+ if (display->wl_display) {
+ wl_display_disconnect(display->wl_display);
}
- delete d;
+ delete display;
}
static GHOST_TKey xkb_map_gkey(const xkb_keysym_t sym)
@@ -1518,7 +1518,7 @@ static void data_device_handle_drop(void *data, struct wl_data_device * /*wl_dat
* 'text_update_edited' to behave like dropped text was pasted. */
CLOG_INFO(LOG, 2, "drop_read_uris_fn (text_plain, text_utf8), unhandled!");
}
- wl_display_roundtrip(system->display());
+ wl_display_roundtrip(system->wl_display());
};
/* Pass in `seat->wl_surface_focus_dnd` instead of accessing it from `seat` since the leave
@@ -1551,7 +1551,6 @@ static void data_device_handle_selection(void *data,
return;
}
CLOG_INFO(LOG, 2, "selection");
-
/* Get new data offer. */
data_offer = static_cast<GWL_DataOffer *>(wl_data_offer_get_user_data(id));
seat->data_offer_copy_paste = data_offer;
@@ -1572,8 +1571,8 @@ static void data_device_handle_selection(void *data,
data_offer, mime_receive, &seat->data_offer_copy_paste_mutex);
{
- std::lock_guard lock{system_selection_mutex};
- system->selection_set(data);
+ std::lock_guard lock{system_clipboard_mutex};
+ system->clipboard_set(data);
}
};
@@ -1668,7 +1667,7 @@ static void cursor_surface_handle_enter(void *data,
wl_surface);
const GWL_Output *reg_output = ghost_wl_output_user_data(wl_output);
seat_state_pointer->outputs.insert(reg_output);
- update_cursor_scale(seat->cursor, seat->system->shm(), seat_state_pointer, wl_surface);
+ update_cursor_scale(seat->cursor, seat->system->wl_shm(), seat_state_pointer, wl_surface);
}
static void cursor_surface_handle_leave(void *data,
@@ -1686,7 +1685,7 @@ static void cursor_surface_handle_leave(void *data,
wl_surface);
const GWL_Output *reg_output = ghost_wl_output_user_data(wl_output);
seat_state_pointer->outputs.erase(reg_output);
- update_cursor_scale(seat->cursor, seat->system->shm(), seat_state_pointer, wl_surface);
+ update_cursor_scale(seat->cursor, seat->system->wl_shm(), seat_state_pointer, wl_surface);
}
static const struct wl_surface_listener cursor_surface_listener = {
@@ -2258,7 +2257,7 @@ static void tablet_seat_handle_tool_added(void *data,
tablet_tool->seat = seat;
/* Every tool has it's own cursor wl_surface. */
- tablet_tool->wl_surface_cursor = wl_compositor_create_surface(seat->system->compositor());
+ tablet_tool->wl_surface_cursor = wl_compositor_create_surface(seat->system->wl_compositor());
ghost_wl_surface_tag_cursor_tablet(tablet_tool->wl_surface_cursor);
wl_surface_add_listener(tablet_tool->wl_surface_cursor, &cursor_surface_listener, (void *)seat);
@@ -2705,7 +2704,7 @@ static void seat_handle_capabilities(void *data,
if (capabilities & WL_SEAT_CAPABILITY_POINTER) {
seat->wl_pointer = wl_seat_get_pointer(wl_seat);
- seat->cursor.wl_surface = wl_compositor_create_surface(seat->system->compositor());
+ seat->cursor.wl_surface = wl_compositor_create_surface(seat->system->wl_compositor());
seat->cursor.visible = true;
seat->cursor.wl_buffer = nullptr;
if (!get_cursor_settings(seat->cursor.theme_name, seat->cursor.size)) {
@@ -3023,7 +3022,7 @@ static void global_handle_add(void *data,
struct GWL_Display *display = static_cast<struct GWL_Display *>(data);
if (STREQ(interface, wl_compositor_interface.name)) {
- display->compositor = static_cast<wl_compositor *>(
+ display->wl_compositor = static_cast<wl_compositor *>(
wl_registry_bind(wl_registry, name, &wl_compositor_interface, 3));
}
else if (STREQ(interface, xdg_wm_base_interface.name)) {
@@ -3073,7 +3072,7 @@ static void global_handle_add(void *data,
wl_seat_add_listener(seat->wl_seat, &seat_listener, seat);
}
else if (STREQ(interface, wl_shm_interface.name)) {
- display->shm = static_cast<wl_shm *>(
+ display->wl_shm = static_cast<wl_shm *>(
wl_registry_bind(wl_registry, name, &wl_shm_interface, 1));
}
else if (STREQ(interface, wl_data_device_manager_interface.name)) {
@@ -3144,34 +3143,34 @@ static const struct wl_registry_listener registry_listener = {
* WAYLAND specific implementation of the #GHOST_System interface.
* \{ */
-GHOST_SystemWayland::GHOST_SystemWayland() : GHOST_System(), d(new GWL_Display)
+GHOST_SystemWayland::GHOST_SystemWayland() : GHOST_System(), display_(new GWL_Display)
{
wl_log_set_handler_client(ghost_wayland_log_handler);
- d->system = this;
+ display_->system = this;
/* Connect to the Wayland server. */
- d->display = wl_display_connect(nullptr);
- if (!d->display) {
- display_destroy(d);
+ display_->wl_display = wl_display_connect(nullptr);
+ if (!display_->wl_display) {
+ display_destroy(display_);
throw std::runtime_error("Wayland: unable to connect to display!");
}
/* This may be removed later if decorations are required, needed as part of registration. */
- d->xdg_decor = new WGL_XDG_Decor_System;
+ display_->xdg_decor = new WGL_XDG_Decor_System;
/* Register interfaces. */
- struct wl_registry *registry = wl_display_get_registry(d->display);
- wl_registry_add_listener(registry, ®istry_listener, d);
+ struct wl_registry *registry = wl_display_get_registry(display_->wl_display);
+ wl_registry_add_listener(registry, ®istry_listener, display_);
/* Call callback for registry listener. */
- wl_display_roundtrip(d->display);
+ wl_display_roundtrip(display_->wl_display);
/* Call callbacks for registered listeners. */
- wl_display_roundtrip(d->display);
+ wl_display_roundtrip(display_->wl_display);
wl_registry_destroy(registry);
#ifdef WITH_GHOST_WAYLAND_LIBDECOR
- if (d->libdecor_required) {
- wgl_xdg_decor_system_destroy(d->xdg_decor);
- d->xdg_decor = nullptr;
+ if (display_->libdecor_required) {
+ wgl_xdg_decor_system_destroy(display_->xdg_decor);
+ display_->xdg_decor = nullptr;
if (!has_libdecor) {
# ifdef WITH_GHOST_X11
@@ -3180,7 +3179,7 @@ GHOST_SystemWayland::GHOST_SystemWayland() : GHOST_System(), d(new GWL_Display)
"WAYLAND found but libdecor was not, install libdecor for Wayland support, "
"falling back to X11\n");
# endif
- display_destroy(d);
+ display_destroy(display_);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list