XMaskEvent not returning

大兔子大兔子 提交于 2019-12-12 01:41:50

问题


I am following this tutorial here: http://www.sbin.org/doc/Xlib/chapt_16.html

Here is the image of the tutorial:

Here is my code: (it is in another thread from which I called XInitThreads - I know using threads and X is bad, I know I should be on the main thread, but just wondering if possible)

            var ev = XEvent();

            var rez_XMaskEvent = XMaskEvent(cachedXOpenDisplay(), ButtonPressMask | ButtonReleaseMask, ev.address());
            console.log('rez_XMaskEvent:', rez_XMaskEvent);

            console.log('ev:', ev);
  • ButtonPressMask is 4
  • ButtonReleaseMask is 8

So XMaskEvent is blocking, but whenever I press my mouse button it is not catching it. Shouldn't it unblock and get to the console.log line?

Do I need to run an event loop somehow in this thread?

Thanks


回答1:


I'm not 100% sure here but I feel this could be your problem:

You probably can't do this from JavaScript without some extra precautions. JavaScript in the browser is single-threaded. That means you're holding a lock and no other JavaScript can run. Your problem is a) you're using threads and b) "If the event you requested is not in the queue, XMaskEvent flushes the output buffer and blocks until one is received." (see the man page)

That means XMaskEvent blocks since the button hasn't been pressed, yet. And your browser can't execute JavaScript anymore. If there is an event in the queue which would trigger some JavaScript, the browser will lock up.



来源:https://stackoverflow.com/questions/33717635/xmaskevent-not-returning

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!