multithreading - XCB Custom Message to Event Loop -


i'm trying send message server, sends app's event loop.

on main thread have event loop:

const int my_cust_msg(877); xcb_generic_event_t *event;     while (event = xcb_wait_for_event(connection)) {         switch (event->response_type & ~0x80) {             case my_cust_msg:                     //                 break;             default:                 // unknown event type, ignore                 debug_log("unknown event: ", event->response_type);         }         free(event);     } 

in thread want send trigger event loop on main thread my_cust_msg , send address std::string it. possible? main event loop read address string.

i tried this:

in

t main() {     int rezconnect = xcb_connection_has_error(connection = xcb_connect(null, &default_screen));     if (rezconnect) return rezconnect;      xcb_screen_t *firstscreen;     firstscreen = xcb_setup_roots_iterator(xcb_get_setup(connection)).data;      rootwin = firstscreen->root;       // create inputonly window     xcb_window_t msgw = xcb_generate_id(connection);     const uint32_t values[] = { true };     xcb_create_window(connection, 0, msgw, rootwin, 0, 0, 10, 10, 0, xcb_window_class_input_only, xcb_copy_from_parent, xcb_cw_override_redirect, values);       std::string* payload_ptr = new std::string("rawr rawr rawr");      xcb_client_message_event_t event;      event.response_type = xcb_client_message;     event.format = 32;     event.type = 877; // a__net_wm_desktop;     event.window = msgw;     event.data.data32[0] = payload_ptr;      xcb_send_event(connection, 0, rootwin, xcb_event_mask_substructure_redirect | xcb_event_mask_substructure_notify, (const char *)&event);       xcb_generic_event_t *e;     while (e = xcb_wait_for_event(connection)) {         switch (e->response_type & ~0x80) {             case 877: {                 xcb_client_message_event_t *ce = (xcb_client_message_event_t *)e;                  std::unique_ptr<std::string> payload_ptr(reinterpret_cast<std::string*>(ce.data.data32[0]));                 std::string payload_str = *payload_ptr;                  debug_log("got payload_str:", payload_str);             }             default:                 // unknown e type, ignore                 debug_log("unknown e: ", e->response_type);         }         free(e);     }      xcb_disconnect(connection);      return 0; } 


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -