Noitidart
Noitidart

Reputation: 37238

XCB event loop not getting any events

I am making an addon in Firefox, so I have a ChromeWorker - which is a privileged WebWorker. This is just a thread other then the mainthread.

In here I have no code but this (modified to make it look like not js-ctypes [which is the language for addons])

On startup I run this code, conn is a global variable:

conn = xcb_connect(null, null);

Then I run this in a 200ms interval:

evt = xcb_poll_for_event(conn);
console.log('evt:', evt);

if (!evt.isNull()) {
    console.log('good got an event!!');
    ostypes.API('free')(evt);
}

However evt is always null, I am never getting any events. My goal is to get all events on the system.

Anyone know what can cause something so simple to not work?

I have tried

xcb_change_window_attributes (conn, screens.data->root, XCB_CW_EVENT_MASK, values);

But this didn't fix it :(

The only way I can get it to work is by doing xcb_create_window xcb_map_window but then I get ONLY the events that happen in this created window.

Upvotes: 1

Views: 897

Answers (1)

Ingo Bürk
Ingo Bürk

Reputation: 20043

You don't just magically get all events by opening a connection. There's only very few messages any client will receive, such as client messages, most others will only be sent to a client if it explicitly registered itself to receive them.

And yes, that means you have to register them on each and every window, which involves both crawling the tree and listening for windows being created, mapped, unmapped and destroyed and registering on them as well.

However, I would reconsider whether

My goal is to get all events on the system.

isn't an A-B problem. Why do you "need" all events? What do you actually want to do?

Upvotes: 1

Related Questions