我已经在配有X应用程序XWayland / XCB支持的游戏引擎中实现了Wayland合成器(通过wlroots)。当我启动xev
时,似乎接收到ButtonNotify
事件就很好了(所以我可以在Windows中输入就好了)。它也每帧接收MotionNotify
个事件,但是问题是它的坐标停留在原点!
# This repeats every frame when I mouse over windows:
MotionNotify event, serial 32, synthetic NO, window 0x400001,
root 0x29c, subw 0x0, time 1275037533, (-2,-2), root:(0,0),
state 0x0, is_hint 0, same_screen YES
请注意:
xcb_warp_pointer
调用)。WAYLAND_DEBUG=server
标志验证了坐标已成功通过Wayland导线以正确的坐标在两次框架调用之间的每一帧发送。我知道抽象所有其他细节很难调试这个问题,但是我很好奇的是,是否有一些知名的东西需要先进行初始化才能更新指针事件。因为我的合成器被精简了(游戏引擎处理了大多数事情),我是否需要某些东西来使指针更新正常工作,而我却没有意识到自己需要这样做?
让我的问题更具体:在指针移动可以是(0,0)之外的其他东西之前,必须在XCB中初始化什么状态?
编辑:以下是一些xev
日志数据,以查看我可能缺少的状态:
$ DISPLAY=:2 xev & # `DISPLAY=:2` is where XWayland is located
[1] 26726
Outer window is 0x400001, inner window is 0x400002
PropertyNotify event, serial 8, synthetic NO, window 0x400001,
atom 0x27 (WM_NAME), time 1549489650, state PropertyNewValue
PropertyNotify event, serial 9, synthetic NO, window 0x400001,
atom 0x22 (WM_COMMAND), time 1549489650, state PropertyNewValue
PropertyNotify event, serial 10, synthetic NO, window 0x400001,
atom 0x28 (WM_NORMAL_HINTS), time 1549489650, state PropertyNewValue
CreateNotify event, serial 11, synthetic NO, window 0x400001,
parent 0x400001, window 0x400002, (10,10), width 50, height 50
border_width 4, override NO
PropertyNotify event, serial 14, synthetic NO, window 0x400001,
atom 0xf7 (WM_PROTOCOLS), time 1549489650, state PropertyNewValue
MapNotify event, serial 15, synthetic NO, window 0x400001,
event 0x400001, window 0x400002, override NO
ClientMessage event, serial 28, synthetic YES, window 0x400001,
message_type 0xf7 (WM_PROTOCOLS), format 32, message 0x10a (_NET_WM_PING)
PropertyNotify event, serial 29, synthetic NO, window 0x400001,
atom 0x10b (WM_STATE), time 1549489661, state PropertyNewValue
PropertyNotify event, serial 29, synthetic NO, window 0x400001,
atom 0x100 (_NET_WM_STATE), time 1549489661, state PropertyNewValue
MapNotify event, serial 29, synthetic NO, window 0x400001,
event 0x400001, window 0x400001, override NO
VisibilityNotify event, serial 29, synthetic NO, window 0x400001,
state VisibilityUnobscured
Expose event, serial 29, synthetic NO, window 0x400001,
(0,0), width 178, height 10, count 3
Expose event, serial 29, synthetic NO, window 0x400001,
(0,10), width 10, height 58, count 2
Expose event, serial 29, synthetic NO, window 0x400001,
(68,10), width 110, height 58, count 1
Expose event, serial 29, synthetic NO, window 0x400001,
(0,68), width 178, height 110, count 0
EnterNotify event, serial 29, synthetic NO, window 0x400001,
root 0x29c, subw 0x0, time 1549489662, (-2,-2), root:(0,0),
mode NotifyNormal, detail NotifyAncestor, same_screen YES,
focus YES, state 0
KeymapNotify event, serial 29, synthetic NO, window 0x0,
keys: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
MotionNotify event, serial 31, synthetic NO, window 0x400001,
root 0x29c, subw 0x0, time 1549495244, (-2,-2), root:(0,0),
state 0x0, is_hint 0, same_screen YES
MotionNotify event, serial 31, synthetic NO, window 0x400001,
root 0x29c, subw 0x0, time 1549495260, (-2,-2), root:(0,0),
state 0x0, is_hint 0, same_screen YES
MotionNotify event, serial 31, synthetic NO, window 0x400001,
root 0x29c, subw 0x0, time 1549495260, (-2,-2), root:(0,0),
state 0x0, is_hint 0, same_screen YES
MotionNotify event, serial 31, synthetic NO, window 0x400001,
root 0x29c, subw 0x0, time 1549495277, (-2,-2), root:(0,0),
state 0x0, is_hint 0, same_screen YES
#...
这可以与运行rootston
的运行正常的xev
(wlroot的示例合成器)进行比较:
$ Outer window is 0x400001, inner window is 0x400002
MappingNotify event, serial 0, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 248
MappingNotify event, serial 0, synthetic NO, window 0x0,
request MappingModifier, first_keycode 0, count 0
PropertyNotify event, serial 8, synthetic NO, window 0x400001,
atom 0x27 (WM_NAME), time 1549619590, state PropertyNewValue
PropertyNotify event, serial 9, synthetic NO, window 0x400001,
atom 0x22 (WM_COMMAND), time 1549619590, state PropertyNewValue
PropertyNotify event, serial 10, synthetic NO, window 0x400001,
atom 0x28 (WM_NORMAL_HINTS), time 1549619590, state PropertyNewValue
CreateNotify event, serial 11, synthetic NO, window 0x400001,
parent 0x400001, window 0x400002, (10,10), width 50, height 50
border_width 4, override NO
PropertyNotify event, serial 14, synthetic NO, window 0x400001,
atom 0xf7 (WM_PROTOCOLS), time 1549619590, state PropertyNewValue
MapNotify event, serial 15, synthetic NO, window 0x400001,
event 0x400001, window 0x400002, override NO
PropertyNotify event, serial 29, synthetic NO, window 0x400001,
atom 0x10b (WM_STATE), time 1549619590, state PropertyNewValue
PropertyNotify event, serial 29, synthetic NO, window 0x400001,
atom 0x100 (_NET_WM_STATE), time 1549619590, state PropertyNewValue
MapNotify event, serial 29, synthetic NO, window 0x400001,
event 0x400001, window 0x400001, override NO
VisibilityNotify event, serial 29, synthetic NO, window 0x400001,
state VisibilityUnobscured
Expose event, serial 29, synthetic NO, window 0x400001,
(0,0), width 178, height 10, count 3
Expose event, serial 29, synthetic NO, window 0x400001,
(0,10), width 10, height 58, count 2
Expose event, serial 29, synthetic NO, window 0x400001,
(68,10), width 110, height 58, count 1
Expose event, serial 29, synthetic NO, window 0x400001,
(0,68), width 178, height 110, count 0
EnterNotify event, serial 34, synthetic NO, window 0x400001,
root 0x29c, subw 0x0, time 1549638410, (153,0), root:(155,2),
mode NotifyNormal, detail NotifyAncestor, same_screen YES,
focus YES, state 0
KeymapNotify event, serial 34, synthetic NO, window 0x0,
keys: 68 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
MotionNotify event, serial 34, synthetic NO, window 0x400001,
root 0x29c, subw 0x0, time 1549638410, (153,0), root:(155,2),
state 0x0, is_hint 0, same_screen YES
MotionNotify event, serial 34, synthetic NO, window 0x400001,
root 0x29c, subw 0x0, time 1549638417, (154,4), root:(156,6),
state 0x0, is_hint 0, same_screen YES
MotionNotify event, serial 34, synthetic NO, window 0x400001,
root 0x29c, subw 0x0, time 1549638426, (155,9), root:(157,11),
state 0x0, is_hint 0, same_screen YES
MotionNotify event, serial 34, synthetic NO, window 0x400001,
root 0x29c, subw 0x0, time 1549638434, (157,13), root:(159,15),
state 0x0, is_hint 0, same_screen YES
MotionNotify event, serial 34, synthetic NO, window 0x400001,
root 0x29c, subw 0x0, time 1549638442, (161,18), root:(163,20),
state 0x0, is_hint 0, same_screen YES
MotionNotify event, serial 34, synthetic NO, window 0x400001,
root 0x29c, subw 0x0, time 1549638450, (165,25), root:(167,27),
state 0x0, is_hint 0, same_screen YES
MotionNotify event, serial 34, synthetic NO, window 0x400001,
root 0x29c, subw 0x0, time 1549638458, (172,30), root:(174,32),
state 0x0, is_hint 0, same_screen YES
答案 0 :(得分:1)
问题是XWayland的屏幕上有一个width_in_pixels == height_in_pixels == 0
。这迫使所有指针移动到(0,0)
。强制屏幕的初始化区域为正数可以解决此问题。
答案 1 :(得分:0)
我不能说我知道我的解决方法(我不认为这是一个xcb问题),但是您调用wlroots中的哪些函数来移动光标? 例如,我快速浏览了wlroots多指针示例,发现了这一点:
static void handle_cursor_motion(struct wl_listener *listener, void *data) {
struct sample_cursor *cursor =
wl_container_of(listener, cursor, cursor_motion);
struct wlr_event_pointer_motion *event = data;
wlr_cursor_move(cursor->cursor, event->device, event->delta_x,
event->delta_y);
}
static void handle_cursor_motion_absolute(struct wl_listener *listener,
void *data) {
struct sample_cursor *cursor =
wl_container_of(listener, cursor, cursor_motion_absolute);
struct wlr_event_pointer_motion_absolute *event = data;
wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, event->y);
}
因此,我想说的是您的代码为wlroots提供了光标位置。