Skip to content

Commit 4265779

Browse files
committed
demo/xcb_cairo/nuklear_xcb.h: do not discard xcb_client_message_event_t
Currently nk_xcb_handle_event discard everything that was sent from other clients through xcb_send_event. To enable a minimal IPC over such channel, this patch adds a new option NK_XCB_CLIENT_MESSAGE to the nk_xcb_event_type enum and stores the message recieved in xcb_ctx->last_client_message. This can be useful in particular when a background process or thread completes a data retrieval or processing and want to wake up the GUI.
1 parent fcd64f8 commit 4265779

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

demo/xcb_cairo/nuklear_xcb.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ struct nk_cairo_context;
4444
enum nk_xcb_event_type {
4545
NK_XCB_EVENT_PAINT = 0x02,
4646
NK_XCB_EVENT_RESIZED = 0x04,
47-
NK_XCB_EVENT_STOP = 0x08
47+
NK_XCB_EVENT_STOP = 0x08,
48+
NK_XCB_CLIENT_MESSAGE = 0x10
4849
};
4950

5051
/* Xcb part: work on windows */
@@ -155,6 +156,7 @@ struct nk_xcb_context {
155156
int events;
156157
xcb_intern_atom_reply_t* del_atom;
157158
int width, height;
159+
xcb_client_message_event_t last_client_message;
158160
};
159161

160162
NK_API struct nk_xcb_context *nk_xcb_init(const char *title, int pos_x, int pos_y, int width, int height)
@@ -236,6 +238,8 @@ NK_API void nk_xcb_free(struct nk_xcb_context *xcb_ctx)
236238
free(xcb_ctx);
237239
}
238240

241+
static const xcb_client_message_event_t EMPTY_CLIENT_MESSAGE;
242+
239243
NK_API int nk_xcb_handle_event(struct nk_xcb_context *xcb_ctx, struct nk_context *nk_ctx)
240244
{
241245
int events = 0;
@@ -251,6 +255,7 @@ NK_API int nk_xcb_handle_event(struct nk_xcb_context *xcb_ctx, struct nk_context
251255

252256
event = xcb_wait_for_event(xcb_ctx->conn);
253257

258+
xcb_ctx->last_client_message = EMPTY_CLIENT_MESSAGE;
254259
nk_input_begin(nk_ctx);
255260
do {
256261
switch (XCB_EVENT_RESPONSE_TYPE(event)) {
@@ -424,6 +429,11 @@ NK_API int nk_xcb_handle_event(struct nk_xcb_context *xcb_ctx, struct nk_context
424429
{
425430
events = NK_XCB_EVENT_STOP;
426431
}
432+
else
433+
{
434+
xcb_ctx->last_client_message = *cm;
435+
events = NK_XCB_CLIENT_MESSAGE;
436+
}
427437
}
428438
break;
429439
default:

0 commit comments

Comments
 (0)