XMaskEvent 不返回 [英] XMaskEvent not returning

查看:24
本文介绍了XMaskEvent 不返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里学习本教程:)

这意味着 XMaskEvent 阻塞,因为按钮还没有被按下.并且您的浏览器无法再执行 JavaScript.如果队列中存在会触发某些 JavaScript 的事件,则浏览器将锁定.

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

解决方案

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.

这篇关于XMaskEvent 不返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆