bread-graphics/breadx

MotionNotify events cannot be parsed

psychon opened this issue · 3 comments

Hi,

due to some conversation on IRC in #xorg-devel I tried to write a program that uses EventMask::POINTER_MOTION and prints the resulting events. I based this on the basic example. Here is the diff:

--- src/main_orig.rs	2022-05-01 10:43:38.087918857 +0200
+++ src/main.rs	2022-05-01 10:43:01.244436254 +0200
@@ -7,12 +7,12 @@ use breadx::{
 use std::process;
 
 fn main() {
-    env_logger::init();
+    //env_logger::init();
 
-    let mut conn = DisplayConnection::create(None).unwrap();
+    let mut conn = DisplayConnection::create(None, None).unwrap();
 
     // create the event mask
-    let event_mask = EventMask::EXPOSURE | EventMask::BUTTON_PRESS | EventMask::STRUCTURE_NOTIFY;
+    let event_mask = EventMask::EXPOSURE | EventMask::BUTTON_PRESS | EventMask::STRUCTURE_NOTIFY | EventMask::POINTER_MOTION;
 
     // window properties
     let mut cwp: WindowParameters = Default::default();
@@ -80,6 +80,7 @@ fn main() {
             }
         };
 
+        println!("Got event {:?}", ev);
         match ev {
             Event::ClientMessage(cme) => {
                 if cme.data.longs()[0] == wm_delete_window.xid {

I ran this in an "empty" project (cargo new --bin foo) where I simply added breadx = "*" to Cargo.toml, hence there was no env_logger.

When I run the above and move the cursor around, the event apparently fails to parse:

Got event NoneOfTheAbove { opcode: 6, bytes: [6, 0, 35, 0, 198, 58, 225, 5, 96, 7, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 177, 3, 42, 2, 29, 1, 215, 0, 0, 0, 1, 0] }
Got event NoneOfTheAbove { opcode: 6, bytes: [6, 0, 35, 0, 206, 58, 225, 5, 96, 7, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 175, 3, 43, 2, 27, 1, 216, 0, 0, 0, 1, 0] }
Got event NoneOfTheAbove { opcode: 6, bytes: [6, 0, 35, 0, 214, 58, 225, 5, 96, 7, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 171, 3, 47, 2, 23, 1, 220, 0, 0, 0, 1, 0] }
Got event NoneOfTheAbove { opcode: 6, bytes: [6, 0, 35, 0, 222, 58, 225, 5, 96, 7, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 167, 3, 50, 2, 19, 1, 223, 0, 0, 0, 1, 0] }

Edit: Searching for motion in src/event/mod.rs does not find anything. This is simply not implemented...?!?

Thanks for the issue! I'm currently working on porting breadx to use the primitives from x11rb-protocol. Would that fix this problem?

I bet so. The same reproducer on x11rb managed to parse the events just fine.

#74 moves breadx to use x11rb-protocol, should close this issue