[Bf-blender-cvs] [754dae6c766] master: GHOST/Wayland: add logging for listener handlers
Campbell Barton
noreply at git.blender.org
Fri Jul 8 11:42:07 CEST 2022
Commit: 754dae6c7667fd861b6e663c6d33affcd687a251
Author: Campbell Barton
Date: Fri Jul 8 19:36:34 2022 +1000
Branches: master
https://developer.blender.org/rB754dae6c7667fd861b6e663c6d33affcd687a251
GHOST/Wayland: add logging for listener handlers
Add logging to all Wayland listener callbacks as it can be difficult
to detect the cause of problems.
Using break-points often isn't practical for debugging interactive
windowing / compositor issues
Logging needs to be enabled on the command line, e.g:
blender --log "ghost.wl.*" --log-level 2 --log-show-basename
===================================================================
M intern/ghost/CMakeLists.txt
M intern/ghost/intern/GHOST_SystemWayland.cpp
M intern/ghost/intern/GHOST_WindowWayland.cpp
===================================================================
diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt
index edf13b6eff0..c681dc368bb 100644
--- a/intern/ghost/CMakeLists.txt
+++ b/intern/ghost/CMakeLists.txt
@@ -3,6 +3,7 @@
set(INC
.
+ ../clog
../glew-mx
../../source/blender/imbuf
../../source/blender/makesdna
diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp
index f6406d098ca..08aa640c5cd 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -57,6 +57,9 @@
#include <cstring>
#include <mutex>
+/* Logging, use `ghost.wl.*` prefix. */
+#include "CLG_log.h"
+
static void keyboard_handle_key_repeat_cancel(struct input_t *input);
static void output_handle_done(void *data, struct wl_output *wl_output);
@@ -356,6 +359,8 @@ struct display_t {
struct zwp_pointer_constraints_v1 *pointer_constraints = nullptr;
};
+#undef LOG
+
/** \} */
/* -------------------------------------------------------------------- */
@@ -742,6 +747,8 @@ static const std::vector<std::string> mime_send = {
"text/plain",
};
+#undef LOG
+
/** \} */
/* -------------------------------------------------------------------- */
@@ -751,6 +758,9 @@ static const std::vector<std::string> mime_send = {
* an event is received from the compositor.
* \{ */
+static CLG_LogRef LOG_WL_RELATIVE_POINTER = {"ghost.wl.handle.relative_pointer"};
+#define LOG (&LOG_WL_RELATIVE_POINTER)
+
/**
* The caller is responsible for setting the value of `input->xy`.
*/
@@ -798,6 +808,7 @@ static void relative_pointer_handle_relative_motion(
{
input_t *input = static_cast<input_t *>(data);
if (wl_surface *focus_surface = input->pointer.wl_surface) {
+ CLOG_INFO(LOG, 2, "relative_motion");
GHOST_WindowWayland *win = ghost_wl_surface_user_data(focus_surface);
const wl_fixed_t scale = win->scale();
const wl_fixed_t xy_next[2] = {
@@ -806,18 +817,26 @@ static void relative_pointer_handle_relative_motion(
};
relative_pointer_handle_relative_motion_impl(input, win, xy_next);
}
+ else {
+ CLOG_INFO(LOG, 2, "relative_motion (skipped)");
+ }
}
static const zwp_relative_pointer_v1_listener relative_pointer_listener = {
relative_pointer_handle_relative_motion,
};
+#undef LOG
+
/** \} */
/* -------------------------------------------------------------------- */
/** \name Listener (Data Source), #wl_data_source_listener
* \{ */
+static CLG_LogRef LOG_WL_DATA_SOURCE = {"ghost.wl.handle.data_source"};
+#define LOG (&LOG_WL_DATA_SOURCE)
+
static void dnd_events(const input_t *const input, const GHOST_TEventType event)
{
/* NOTE: `input->data_offer_dnd_mutex` must already be locked. */
@@ -876,7 +895,7 @@ static void data_source_handle_target(void * /*data*/,
struct wl_data_source * /*wl_data_source*/,
const char * /*mime_type*/)
{
- /* pass */
+ CLOG_INFO(LOG, 2, "target");
}
static void data_source_handle_send(void *data,
@@ -887,6 +906,8 @@ static void data_source_handle_send(void *data,
input_t *input = static_cast<input_t *>(data);
std::lock_guard lock{input->data_source_mutex};
+ CLOG_INFO(LOG, 2, "send");
+
const char *const buffer = input->data_source->buffer_out;
if (write(fd, buffer, strlen(buffer)) < 0) {
GHOST_PRINT("error writing to clipboard: " << std::strerror(errno) << std::endl);
@@ -896,6 +917,7 @@ static void data_source_handle_send(void *data,
static void data_source_handle_cancelled(void * /*data*/, struct wl_data_source *wl_data_source)
{
+ CLOG_INFO(LOG, 2, "cancelled");
wl_data_source_destroy(wl_data_source);
}
@@ -909,7 +931,7 @@ static void data_source_handle_cancelled(void * /*data*/, struct wl_data_source
static void data_source_handle_dnd_drop_performed(void * /*data*/,
struct wl_data_source * /*wl_data_source*/)
{
- /* pass */
+ CLOG_INFO(LOG, 2, "dnd_drop_performed");
}
/**
@@ -922,7 +944,7 @@ static void data_source_handle_dnd_drop_performed(void * /*data*/,
static void data_source_handle_dnd_finished(void * /*data*/,
struct wl_data_source * /*wl_data_source*/)
{
- /* pass */
+ CLOG_INFO(LOG, 2, "dnd_finished");
}
/**
@@ -934,9 +956,9 @@ static void data_source_handle_dnd_finished(void * /*data*/,
*/
static void data_source_handle_action(void * /*data*/,
struct wl_data_source * /*wl_data_source*/,
- const uint32_t /*dnd_action*/)
+ const uint32_t dnd_action)
{
- /* pass */
+ CLOG_INFO(LOG, 2, "handle_action (dnd_action=%u)", dnd_action);
}
static const struct wl_data_source_listener data_source_listener = {
@@ -948,16 +970,22 @@ static const struct wl_data_source_listener data_source_listener = {
data_source_handle_action,
};
+#undef LOG
+
/** \} */
/* -------------------------------------------------------------------- */
/** \name Listener (Data Offer), #wl_data_offer_listener
* \{ */
+static CLG_LogRef LOG_WL_DATA_OFFER = {"ghost.wl.handle.data_offer"};
+#define LOG (&LOG_WL_DATA_OFFER)
+
static void data_offer_handle_offer(void *data,
struct wl_data_offer * /*wl_data_offer*/,
const char *mime_type)
{
+ CLOG_INFO(LOG, 2, "offer (mime_type=%s)", mime_type);
static_cast<data_offer_t *>(data)->types.insert(mime_type);
}
@@ -965,6 +993,7 @@ static void data_offer_handle_source_actions(void *data,
struct wl_data_offer * /*wl_data_offer*/,
const uint32_t source_actions)
{
+ CLOG_INFO(LOG, 2, "source_actions (%u)", source_actions);
static_cast<data_offer_t *>(data)->source_actions = source_actions;
}
@@ -972,6 +1001,7 @@ static void data_offer_handle_action(void *data,
struct wl_data_offer * /*wl_data_offer*/,
const uint32_t dnd_action)
{
+ CLOG_INFO(LOG, 2, "actions (%u)", dnd_action);
static_cast<data_offer_t *>(data)->dnd_action = dnd_action;
}
@@ -981,16 +1011,23 @@ static const struct wl_data_offer_listener data_offer_listener = {
data_offer_handle_action,
};
+#undef LOG
+
/** \} */
/* -------------------------------------------------------------------- */
/** \name Listener (Data Device), #wl_data_device_listener
* \{ */
+static CLG_LogRef LOG_WL_DATA_DEVICE = {"ghost.wl.handle.data_device"};
+#define LOG (&LOG_WL_DATA_DEVICE)
+
static void data_device_handle_data_offer(void * /*data*/,
struct wl_data_device * /*wl_data_device*/,
struct wl_data_offer *id)
{
+ CLOG_INFO(LOG, 2, "data_offer");
+
data_offer_t *data_offer = new data_offer_t;
data_offer->id = id;
wl_data_offer_add_listener(id, &data_offer_listener, data_offer);
@@ -1005,8 +1042,10 @@ static void data_device_handle_enter(void *data,
struct wl_data_offer *id)
{
if (!ghost_wl_surface_own(surface)) {
+ CLOG_INFO(LOG, 2, "enter (skipped)");
return;
}
+ CLOG_INFO(LOG, 2, "enter");
input_t *input = static_cast<input_t *>(data);
std::lock_guard lock{input->data_offer_dnd_mutex};
@@ -1036,6 +1075,8 @@ static void data_device_handle_leave(void *data, struct wl_data_device * /*wl_da
input_t *input = static_cast<input_t *>(data);
std::lock_guard lock{input->data_offer_dnd_mutex};
+ CLOG_INFO(LOG, 2, "leave");
+
dnd_events(input, GHOST_kEventDraggingExited);
input->focus_dnd = nullptr;
@@ -1055,6 +1096,8 @@ static void data_device_handle_motion(void *data,
input_t *input = static_cast<input_t *>(data);
std::lock_guard lock{input->data_offer_dnd_mutex};
+ CLOG_INFO(LOG, 2, "motion");
+
input->data_offer_dnd->dnd.xy[0] = x;
input->data_offer_dnd->dnd.xy[1] = y;
@@ -1066,6 +1109,8 @@ static void data_device_handle_drop(void *data, struct wl_data_device * /*wl_dat
input_t *input = static_cast<input_t *>(data);
std::lock_guard lock{input->data_offer_dnd_mutex};
+ CLOG_INFO(LOG, 2, "drop");
+
data_offer_t *data_offer = input->data_offer_dnd;
const std::string mime_receive = *std::find_first_of(mime_preference_order.begin(),
@@ -1158,8 +1203,10 @@ static void data_device_handle_selection(void *data,
}
if (id == nullptr) {
+ CLOG_INFO(LOG, 2, "selection: (skipped)");
return;
}
+ CLOG_INFO(LOG, 2, "selection");
/* Get new data offer. */
data_offer = static_cast<data_offer_t *>(wl_data_offer_get_user_data(id));
@@ -1199,16 +1246,22 @@ static const struct wl_data_device_listener data_device_listener = {
data_device_handle_selection,
};
+#undef LOG
+
/** \} */
/* -------------------------------------------------------------------- */
/** \name Listener (Buffer), #wl_buffer_listener
* \{ */
+static CLG_LogRef LOG_WL_CURSOR_BUFFER = {"ghost.wl.handle.cursor_buffer"};
+#define LOG (&LOG_WL_CURSOR_BUFFER)
+
static void cursor_buffer_handle_release(void *data, struct wl_buffer *wl_buffer)
{
- cursor_t *cursor = static_cast<cursor_t *>(data);
+ CLOG_INFO(LOG, 2, "release");
+ cursor_t *cursor = static_cast<cursor_t *>(data);
wl_buffer_destroy(wl_buffer);
if (wl_buffer == cursor->wl_buffer) {
@@ -1221,12 +1274,17 @@ static const struct wl_buffer_listener cursor_buffer_listener = {
cursor_buffer_handle_release,
};
+#undef LOG
+
/** \} */
/* -------------------------------------------------------------------- */
/** \name Listener (Surface), #wl_surface_listener
* \{ */
+static CLG_LogRef LOG_WL_CURSOR_SURFACE = {"ghost.wl.handle.cursor_surface"};
+#define LOG (&LOG_WL_CURSOR_SURFACE)
+
static bool update_cursor_scale(cursor_t &cursor, wl_shm *shm)
{
int scale = 0;
@@ -1253,8 +1311,10 @@ static void cursor_surface_handle_enter(void *data,
struct wl_output *output)
{
if (!ghost_wl_output_own(output))
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list