summaryrefslogtreecommitdiff
path: root/xwayland/selection.c
diff options
context:
space:
mode:
authorPekka Paalanen <pq@iki.fi>2017-10-12 13:18:13 +0200
committerDaniel Stone <daniels@collabora.com>2018-09-17 13:29:48 +0100
commitb3b006559856037ab97200b93641640b88ec7db8 (patch)
tree8c763ea894f84db0978b228c764033b816562a3a /xwayland/selection.c
parent0a3ef9902a210ab1fa0e4ed317ad7782f0399b51 (diff)
downloadweston-b3b006559856037ab97200b93641640b88ec7db8.tar.gz
xwm: move FILE to the callers of dump_property()
This is preparation for using the weston-debug infrastructure for WM_DEBUG. dump_property() may be called from different debugging contexts and often needs to be prefixed with more information. An alternative to this patch would be to pass in the weston_debug_scope as an argument to dump_property(), but then all callers would need to be converted to weston-debug infra in a single commit. Therefore require the callers to provide the FILE* to print to. Signed-off-by: Pekka Paalanen <pq@iki.fi> Signed-off-by: Maniraj Devadoss <Maniraj.Devadoss@in.bosch.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Daniel Stone <daniels@collabora.com>
Diffstat (limited to 'xwayland/selection.c')
-rw-r--r--xwayland/selection.c39
1 files changed, 36 insertions, 3 deletions
diff --git a/xwayland/selection.c b/xwayland/selection.c
index 59702246..e0eb3ffc 100644
--- a/xwayland/selection.c
+++ b/xwayland/selection.c
@@ -34,6 +34,12 @@
#include "xwayland.h"
#include "shared/helpers.h"
+#ifdef WM_DEBUG
+#define wm_log(...) weston_log(__VA_ARGS__)
+#else
+#define wm_log(...) do {} while (0)
+#endif
+
static int
writable_callback(int fd, uint32_t mask, void *data)
{
@@ -102,6 +108,9 @@ weston_wm_get_incr_chunk(struct weston_wm *wm)
{
xcb_get_property_cookie_t cookie;
xcb_get_property_reply_t *reply;
+ FILE *fp;
+ char *logstr;
+ size_t logsize;
cookie = xcb_get_property(wm->conn,
0, /* delete */
@@ -115,7 +124,13 @@ weston_wm_get_incr_chunk(struct weston_wm *wm)
if (reply == NULL)
return;
- dump_property(wm, wm->atom.wl_selection, reply);
+ fp = open_memstream(&logstr, &logsize);
+ if (fp) {
+ dump_property(fp, wm, wm->atom.wl_selection, reply);
+ if (fclose(fp) == 0)
+ wm_log("%s", logstr);
+ free(logstr);
+ }
if (xcb_get_property_value_length(reply) > 0) {
/* reply's ownership is transferred to wm, which is responsible
@@ -178,6 +193,9 @@ weston_wm_get_selection_targets(struct weston_wm *wm)
xcb_atom_t *value;
char **p;
uint32_t i;
+ FILE *fp;
+ char *logstr;
+ size_t logsize;
cookie = xcb_get_property(wm->conn,
1, /* delete */
@@ -191,7 +209,13 @@ weston_wm_get_selection_targets(struct weston_wm *wm)
if (reply == NULL)
return;
- dump_property(wm, wm->atom.wl_selection, reply);
+ fp = open_memstream(&logstr, &logsize);
+ if (fp) {
+ dump_property(fp, wm, wm->atom.wl_selection, reply);
+ if (fclose(fp) == 0)
+ wm_log("%s", logstr);
+ free(logstr);
+ }
if (reply->type != XCB_ATOM_ATOM) {
free(reply);
@@ -232,6 +256,9 @@ weston_wm_get_selection_data(struct weston_wm *wm)
{
xcb_get_property_cookie_t cookie;
xcb_get_property_reply_t *reply;
+ FILE *fp;
+ char *logstr;
+ size_t logsize;
cookie = xcb_get_property(wm->conn,
1, /* delete */
@@ -243,7 +270,13 @@ weston_wm_get_selection_data(struct weston_wm *wm)
reply = xcb_get_property_reply(wm->conn, cookie, NULL);
- dump_property(wm, wm->atom.wl_selection, reply);
+ fp = open_memstream(&logstr, &logsize);
+ if (fp) {
+ dump_property(fp, wm, wm->atom.wl_selection, reply);
+ if (fclose(fp) == 0)
+ wm_log("%s", logstr);
+ free(logstr);
+ }
if (reply == NULL) {
return;