I have implemented a Wayland compositor (via wlroots) in a game engine that is equipped with XWayland/XCB support for X apps. When I launch xev
, it seems to receive ButtonNotify
events just fine (so I can type just fine in windows). It also receives MotionNotify
events every frame, but the problem is that its coordinates are stuck at the origin!
# 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
Note that:
xcb_warp_pointer
calls).WAYLAND_DEBUG=server
flag that the coordinates are successfully being sent over the wayland wire with the proper coordinates every frame in between frame calls.I know that abstracted of all other details it is very hard to debug this problem, but what I am curious about is if there is some well-known thing that needs to get initialized before pointer events can be updated. Because my compositor is so stripped down (the game engine handling most things), is there something that I need to get pointer updates working that I don't realize I need?
To make my question more concrete: What state must be initialized in XCB before pointer motion can be something besides (0,0)?
EDIT: Here is some xev
log data to see what state I might be missing:
$ 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
#...
This can be compared to a properly running rootston
(wlroot's sample compositor) running xev
:
$ 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
The issue was that the XWayland's screen had a width_in_pixels == height_in_pixels == 0
. This was forcing all pointer motion to (0,0)
. Forcing the screen's initialization area to be positive fixed this issue.