[Bf-blender-cvs] [9978689595f] master: Cleanup: various minor changes to wayland internal conventions
Campbell Barton
noreply at git.blender.org
Wed Jun 15 09:41:19 CEST 2022
Commit: 9978689595f87a6b4d8244ee3d014c8fb239e38d
Author: Campbell Barton
Date: Wed Jun 15 17:09:39 2022 +1000
Branches: master
https://developer.blender.org/rB9978689595f87a6b4d8244ee3d014c8fb239e38d
Cleanup: various minor changes to wayland internal conventions
- Initialize values in the struct declarations
(help avoid accidental uninitialized struct members).
- Use `wl_` prefix for some types to avoid e.g. `output->output`.
- Use `_fn` suffix for locally defined function variables.
- Use `_handle_` as separator for handlers, making function names easier
to follow as this separates the handler name from the interface.
- Add doxy sections for listeners in GHOST_WaylandWindow.cpp.
===================================================================
M intern/ghost/CMakeLists.txt
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/CMakeLists.txt b/intern/ghost/CMakeLists.txt
index 9ef05a99b3c..5b06b5d98e6 100644
--- a/intern/ghost/CMakeLists.txt
+++ b/intern/ghost/CMakeLists.txt
@@ -324,17 +324,17 @@ elseif(WITH_GHOST_X11 OR WITH_GHOST_WAYLAND)
${CMAKE_CURRENT_BINARY_DIR}
)
- # xdg-shell.
+ # `xdg-shell`.
generate_protocol_bindings(
xdg-shell
"${WAYLAND_PROTOCOLS_DIR}/stable/xdg-shell/xdg-shell.xml"
)
- # xdg-decoration.
+ # `xdg-decoration`.
generate_protocol_bindings(
xdg-decoration
"${WAYLAND_PROTOCOLS_DIR}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml"
)
- # xdg-output.
+ # `xdg-output`.
generate_protocol_bindings(
xdg-output
"${WAYLAND_PROTOCOLS_DIR}/unstable/xdg-output/xdg-output-unstable-v1.xml"
diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp
index 9dc6f2fd00b..3d176bdb2f6 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -72,18 +72,18 @@ static GHOST_IWindow *get_window(struct wl_surface *surface);
#define BTN_STYLUS3 0x149
struct buffer_t {
- void *data;
- size_t size;
+ void *data = nullptr;
+ size_t size = 0;
};
struct cursor_t {
- bool visible;
- struct wl_surface *surface = nullptr;
- struct wl_buffer *buffer;
- struct wl_cursor_image image;
+ bool visible = false;
+ struct wl_surface *wl_surface = nullptr;
+ struct wl_buffer *wl_buffer = nullptr;
+ struct wl_cursor_image wl_image = {0};
+ struct wl_cursor_theme *wl_theme = nullptr;
struct buffer_t *file_buffer = nullptr;
- struct wl_cursor_theme *theme = nullptr;
- int size;
+ int size = 0;
std::string theme_name;
/** Outputs on which the cursor is visible. */
std::unordered_set<const output_t *> outputs;
@@ -96,27 +96,27 @@ struct cursor_t {
* Since are no API's to access properties of the tool, store the values here.
*/
struct tablet_tool_input_t {
- struct input_t *input;
- struct wl_surface *cursor_surface;
+ struct input_t *input = nullptr;
+ struct wl_surface *cursor_surface = nullptr;
- GHOST_TabletData data;
+ GHOST_TabletData data = GHOST_TABLET_DATA_NONE;
};
struct data_offer_t {
std::unordered_set<std::string> types;
- uint32_t source_actions;
- uint32_t dnd_action;
- struct wl_data_offer *id;
- std::atomic<bool> in_use;
+ 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. */
- wl_fixed_t xy[2];
+ wl_fixed_t xy[2] = {0, 0};
} dnd;
};
struct data_source_t {
- struct wl_data_source *data_source;
- char *buffer_out;
+ struct wl_data_source *data_source = nullptr;
+ char *buffer_out = nullptr;
};
struct key_repeat_payload_t {
@@ -130,9 +130,9 @@ struct input_t {
GHOST_SystemWayland *system;
std::string name;
- struct wl_seat *seat;
- struct wl_pointer *pointer = nullptr;
- struct wl_keyboard *keyboard = nullptr;
+ struct wl_seat *wl_seat;
+ struct wl_pointer *wl_pointer = nullptr;
+ struct wl_keyboard *wl_keyboard = nullptr;
struct zwp_tablet_seat_v2 *tablet_seat = nullptr;
/** All currently active tablet tools (needed for changing the cursor). */
@@ -157,15 +157,15 @@ struct input_t {
* \endocde
*/
wl_fixed_t xy[2];
- GHOST_Buttons buttons;
+ GHOST_Buttons buttons = GHOST_Buttons();
struct cursor_t cursor;
- struct zwp_relative_pointer_v1 *relative_pointer;
- struct zwp_locked_pointer_v1 *locked_pointer;
- struct zwp_confined_pointer_v1 *confined_pointer;
+ struct zwp_relative_pointer_v1 *relative_pointer = nullptr;
+ struct zwp_locked_pointer_v1 *locked_pointer = nullptr;
+ struct zwp_confined_pointer_v1 *confined_pointer = nullptr;
- struct xkb_context *xkb_context;
- struct xkb_state *xkb_state;
+ struct xkb_context *xkb_context = nullptr;
+ struct xkb_state *xkb_state = nullptr;
struct {
/** Key repetition in character per second. */
int32_t rate;
@@ -182,14 +182,14 @@ struct input_t {
struct wl_data_device *data_device = nullptr;
/** Drag & Drop. */
- struct data_offer_t *data_offer_dnd;
+ struct data_offer_t *data_offer_dnd = nullptr;
std::mutex data_offer_dnd_mutex;
/** Copy & Paste. */
- struct data_offer_t *data_offer_copy_paste;
+ struct data_offer_t *data_offer_copy_paste = nullptr;
std::mutex data_offer_copy_paste_mutex;
- struct data_source_t *data_source;
+ struct data_source_t *data_source = nullptr;
std::mutex data_source_mutex;
/** Last device that was active. */
@@ -197,9 +197,9 @@ struct input_t {
};
struct display_t {
- GHOST_SystemWayland *system;
+ GHOST_SystemWayland *system = nullptr;
- struct wl_display *display;
+ struct wl_display *display = nullptr;
struct wl_compositor *compositor = nullptr;
struct xdg_wm_base *xdg_shell = nullptr;
struct zxdg_decoration_manager_v1 *xdg_decoration_manager = nullptr;
@@ -209,7 +209,7 @@ struct display_t {
std::vector<input_t *> inputs;
struct {
std::string theme;
- int size;
+ int size = 0;
} cursor;
struct wl_data_device_manager *data_device_manager = nullptr;
struct zwp_tablet_manager_v2 *tablet_manager = nullptr;
@@ -259,7 +259,7 @@ static void display_destroy(display_t *d)
}
for (output_t *output : d->outputs) {
- wl_output_destroy(output->output);
+ wl_output_destroy(output->wl_output);
delete output;
}
@@ -278,28 +278,28 @@ static void display_destroy(display_t *d)
if (input->data_device) {
wl_data_device_release(input->data_device);
}
- if (input->pointer) {
+ if (input->wl_pointer) {
if (input->cursor.file_buffer) {
munmap(input->cursor.file_buffer->data, input->cursor.file_buffer->size);
delete input->cursor.file_buffer;
}
- if (input->cursor.surface) {
- wl_surface_destroy(input->cursor.surface);
+ if (input->cursor.wl_surface) {
+ wl_surface_destroy(input->cursor.wl_surface);
}
- if (input->cursor.theme) {
- wl_cursor_theme_destroy(input->cursor.theme);
+ if (input->cursor.wl_theme) {
+ wl_cursor_theme_destroy(input->cursor.wl_theme);
}
- if (input->pointer) {
- wl_pointer_destroy(input->pointer);
+ if (input->wl_pointer) {
+ wl_pointer_destroy(input->wl_pointer);
}
}
- if (input->keyboard) {
+ if (input->wl_keyboard) {
if (input->key_repeat.timer) {
delete static_cast<key_repeat_payload_t *>(input->key_repeat.timer->getUserData());
input->system->removeTimer(input->key_repeat.timer);
input->key_repeat.timer = nullptr;
}
- wl_keyboard_destroy(input->keyboard);
+ wl_keyboard_destroy(input->wl_keyboard);
}
if (input->xkb_state) {
xkb_state_unref(input->xkb_state);
@@ -307,7 +307,7 @@ static void display_destroy(display_t *d)
if (input->xkb_context) {
xkb_context_unref(input->xkb_context);
}
- wl_seat_destroy(input->seat);
+ wl_seat_destroy(input->wl_seat);
delete input;
}
@@ -553,7 +553,7 @@ static const std::vector<std::string> mime_send = {
* an event is received from the compositor.
* \{ */
-static void relative_pointer_relative_motion(
+static void relative_pointer_handle_relative_motion(
void *data,
struct zwp_relative_pointer_v1 * /*zwp_relative_pointer_v1*/,
uint32_t /*utime_hi*/,
@@ -581,7 +581,7 @@ static void relative_pointer_relative_motion(
}
static const zwp_relative_pointer_v1_listener relative_pointer_listener = {
- relative_pointer_relative_motion,
+ relative_pointer_handle_relative_motion,
};
/** \} */
@@ -646,17 +646,17 @@ static std::string read_pipe(data_offer_t *data_offer,
* Sent when a target accepts pointer_focus or motion events. If
* a target does not accept any of the offered types, type is nullptr.
*/
-static void data_source_target(void * /*data*/,
- struct wl_data_source * /*wl_data_source*/,
- const char * /*mime_type*/)
+static void data_source_handle_target(void * /*data*/,
+ struct wl_data_source * /*wl_data_source*/,
+ const char * /*mime_type*/)
{
/* pass */
}
-static void data_source_send(void *data,
- struct wl_data_source * /*wl_data_source*/,
- const char * /*mime_type*/,
- int32_t fd)
+static void data_source_handle_send(void *data,
+ struct wl_data_source * /*wl_data_source*/,
+ const char * /*mime_type*/,
+ int32_t fd)
{
input_t *input = static_cast<input_t *>(data);
std::lock_guard lock{input->data_source_mutex};
@@ -668,7 +668,7 @@ static void data_source_send(void *data,
close(fd);
}
-static void data_source_cancelled(void * /*data*/, struct wl_data_source *wl_data_source)
+static void data_source_handle_cancelled(void * /*data*/, struct wl_data_source *wl_data_source)
{
wl_data_source_destroy(wl_data_source);
}
@@ -680,8 +680,8 @@ static void data_source_cancelled(void * /*data*/, struct wl_data_source *wl_dat
* indicate acceptance, #wl_data_source.cancelled may still be
* emitted afterwards if the drop destination does not accept any mime type.
*/
-static void data_source_dnd_drop_performed(void * /*data*/,
- struct wl_data_source * /*wl_data_source*/)
+static void data_source_handle_dnd_drop_performed(void * /*data*/,
+ struct wl_data_source * /*wl_data_source*/)
{
/* pass */
}
@@ -693,7 +693,8 @@ static void data_source_dnd_drop_performed(void * /*data*/,
* source, so the client is now free to destroy this data source
* and free all associated data.
*/
-static void data_source_dnd_finished(void * /*data*/, struct wl_data_source * /*wl_data_source*/)
+static void data_source_handle_dnd_finished(void * /*data
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list