在windows下,GUI线程通常调用GetMessage来等待消息,当另一个线程使用PoseMessage将消息放入队列时,GUI线程将返回GetMessage(退出阻塞).
有没有人能告诉我,当我在XWindows下使用XNextEvent等待事件时,如何在另一个线程中"唤醒"GUI线程.有没有像我可以使用的PoseMessage这样的API?
我在Xlib中实现了一个水平分割器小部件.当用户点击并拖动分割条时,我试图抓住鼠标(这样用户就可以动态移动分割,从而调整分割条两侧的窗口大小).
我XGrabPointer()在接到左键单击后使用,希望所有未来的鼠标移动(拖动)都将转移到拆分器窗口,直到释放左键.
不幸的是,它似乎并没有像那样工作.如果用户拖得太快并且鼠标指针进入分割两侧的一个窗口,则MotionEvent消息将转移到该(子)窗口而不是分割器窗口.
我做错了什么?我的XGrabPointer()电话如下:
::XGrabPointer(mDisplay, window, True,
ButtonPressMask |
ButtonReleaseMask |
PointerMotionMask |
FocusChangeMask |
EnterWindowMask |
LeaveWindowMask,
GrabModeAsync,
GrabModeAsync,
RootWindow(mDisplay, DefaultScreen(mDisplay)),
None,
CurrentTime);
Run Code Online (Sandbox Code Playgroud) 我有一台运行Linux/X11的嵌入式设备连接到通过USB连接提供触摸事件的设备.此设备无法识别为任何形式的标准指针/鼠标输入.我正在尝试做的是找到一种方法,在外部设备报告事件时将鼠标事件"注入"X11.
这样做将不再需要我的应用程序(使用Gtk +用C语言编写)来伪造用Gtk +调用的鼠标.
如果可以这样做,我的Gtk +应用程序将不需要知道或关心生成触摸事件的设备.它只会在应用程序中显示为标准鼠标事件.
谁知道如何将合成鼠标事件插入X11?
现在我正在做以下工作,但不是最佳的.
GtkWidget *btnSpin; /* sample button */
gboolean buttonPress_cb( void *btn );
gboolean buttonDePress_cb( void *btn );
/* make this call after the device library calls the TouchEvent_cb() callback
and the application has determined which, if any, button was touched
In this example we are assuming btnSpin was touched.
This function will, in 5ms, begin the process of causing the button to do it's
normal animation ( button in, button out effects ) …Run Code Online (Sandbox Code Playgroud) 在XLib中创建窗口时
SetWindowAttributes.event_mask会员提供的口罩是什么?XCreateWindow()XNextEvent(lDisplay, &xEvent);?我找了一个类似的帖子.如果那里已经有一个,请指出我正确的方向.
更新
对于那些想要轻松回答第1-3部分的人:
1.
xAttributes.event_mask = ExposureMask | KeyPressMask | ButtonPress |
StructureNotifyMask | ButtonReleaseMask |
KeyReleaseMask | EnterWindowMask | LeaveWindowMask |
PointerMotionMask | Button1MotionMask | VisibilityChangeMask |
ColormapChangeMask;
Run Code Online (Sandbox Code Playgroud)
2.
unsigned long valuemask = CWEventMask | CWBackPixel | CWBorderPixel | CWCursor;
switch (xEvent.type)
{
case MapNotify:
break;
case Expose:
// If this is not the last expose event break
if (xEvent.xexpose.count != 0)
break;
else
break;
case ConfigureNotify: …Run Code Online (Sandbox Code Playgroud)