Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It seems there is no Into<u16> implementation for xproto::EventMask #746

Closed
andreykaere opened this issue Aug 5, 2022 · 23 comments
Closed

Comments

@andreykaere
Copy link

I want to use xproto::grab_pointer, which requires even_mask, which should implement Into. I don't know why, but for some reason I can't just use
grab_pointer(
conn,
true,
screen.root,
EventMask::POINTER_MOTION,
GrabMode::ASYNC,
GrabMode::ASYNC,
x11rb::NONE,
cursor,
Time::CURRENT_TIME,
)?
.reply()?;

And have to use this instead.
grab_pointer(
conn,
true,
screen.root,
<EventMask as Into>::into(EventMask::POINTER_MOTION) as u16,
GrabMode::ASYNC,
GrabMode::ASYNC,
x11rb::NONE,
cursor,
Time::CURRENT_TIME,
)?
.reply()?;

I can't find the implementation Into for EventMask either. I see just From and From. I am new to Rust, so maybe I am just doing something wrong. Thanks in advance for your help!

@psychon
Copy link
Owner

psychon commented Aug 5, 2022

More-or-less a duplicate of #543 (hence, I'll close this issue, but feel free to ask more questions here)

Your "and have to use this instead" is more or less the best that we can do.

The problem IMO comes from the XML description of the X11 protocol. EventMask has values that do not fit into u16 and hence it cannot be transformed into a u16:

<item name="VisibilityChange"> <bit>16</bit></item>
<item name="StructureNotify"> <bit>17</bit></item>
<item name="ResizeRedirect"> <bit>18</bit></item>
<item name="SubstructureNotify"> <bit>19</bit></item>
<item name="SubstructureRedirect"><bit>20</bit></item>
<item name="FocusChange"> <bit>21</bit></item>
<item name="PropertyChange"> <bit>22</bit></item>
<item name="ColorMapChange"> <bit>23</bit></item>
<item name="OwnerGrabButton"> <bit>24</bit></item>

In the X11 protocol documentation, GrabPointer's event-mask argument has type SETofPOINTEREVENT: https://www.x.org/releases/X11R7.6/doc/xproto/x11protocol.html#requests:GrabPointer while other things have SETofEVENT.

Near the end of that document these sets of events are defined. SETofEVENT contains "everything" and afterwards comes.

SETofPOINTEREVENT
     encodings are the same as for SETofEVENT, except with
     #xFFFF8003     unused but must be zero

SETofDEVICEEVENT
     encodings are the same as for SETofEVENT, except with
     #xFFFFC0B0     unused but must be zero

See #542 / #543 for some more details & previous reports.

I doubt libxcb can fix this easily, but I'll give it a try anyway.

@andreykaere
Copy link
Author

Can you please show me where Into implementation is defined, because I can't find it.

And why there should be 16-bit limit for EvenMask in methods like "grab_pointer"? Thank you for your help!

@psychon
Copy link
Owner

psychon commented Aug 5, 2022

Can you please show me where Into implementation is defined, because I can't find it.

Dunno why it does not show up in the docs (I guess because it is for u32), but:

impl From<EventMask> for u32 {
#[inline]
fn from(input: EventMask) -> Self {
input.0
}
}

Also from https://doc.rust-lang.org/std/convert/trait.Into.html

One should avoid implementing Into and implement From instead. Implementing From automatically provides one with an implementation of Into thanks to the blanket implementation in the standard library.

And why there should be 16-bit limit for EvenMask in methods like "grab_pointer"?

That's just X11. Someone a long time ago decided that e.g. FocusChange does not make sense for grab_pointer. Thus, the event mask argument of grab_pointer is only 16 bit large, because that is enough.

@psychon psychon closed this as completed Aug 5, 2022
@andreykaere
Copy link
Author

About From trait, yes, I know, but it's really weird it's not showing up in docs, only From... Anyway, thanks for your help! (And thanks for amazing library and detailed tutorial!). Have a nice day!

@psychon
Copy link
Owner

psychon commented Aug 5, 2022

I now opened https://gitlab.freedesktop.org/xorg/proto/xcbproto/-/merge_requests/35 with xcb-proto. Let's see if that is accepted and whether this actually helps much in this confusion...

@andreykaere
Copy link
Author

I want to know if I got right what you're proposing: you created new enums which specify what kind of events we want to grub and therefore we can avoid such cumbersome conversion and just use appropriate type of mask instead. Is that right?

@psychon
Copy link
Owner

psychon commented Aug 5, 2022

Yup, new enums which only contain the valid values for the two cases. And since the contained values all fit into u16, our code generator will automatically implement impl From<DeviceEventMask> for u16, too.

@andreykaere
Copy link
Author

Thank you! Hope it will be resolved! By the way, would it be a good idea to use TryInto here? Because, for example, in xcb or even in earlier versions of x11rb EvenMask::foo was just a number and we could use as u16 straight away. But now it's a bit of confusion ... What I mean is that, if they won't accept PR, maybe you could handle it inside x11rb? Because for me it's more like of an issue with Rust strict type system ... What are your thoughts on using TryInto?

@psychon
Copy link
Owner

psychon commented Aug 5, 2022

I am not quite sure what you are asking...? You can just use TryInto yourself:

grab_pointer(
conn,
true,
screen.root,
u32::from(EventMask::POINTER_MOTION).try_into().expect("PointerMotion should fit into an u16 just fine"),
GrabMode::ASYNC,
GrabMode::ASYNC,
x11rb::NONE,
cursor,
Time::CURRENT_TIME,
)?
.reply()?;

So I guess you mean something else...?

@andreykaere
Copy link
Author

andreykaere commented Aug 5, 2022

I meant to put TryInto (instead of Into) for mask argument in trait bounds in definition of grab_pointer

@psychon
Copy link
Owner

psychon commented Aug 5, 2022

Uhm. Having a TryInto<u16> bound there... uhm... Doesn't that end up with a generic error type in TryInto<u16>::Error? If grab_pointer should be able to return that, that means that its error type would also need to be generic.

I haven't fully thought this through nor tried it out, but from a quick first impression: That feels like it would end up in "generic hell" and causing lots of problems down the road.

@andreykaere
Copy link
Author

andreykaere commented Aug 5, 2022

Can't we just panic on error? I.e. in body of grab_pointer use something like foo.try_into().unwrap(). Seems reasonable here. Rust will panic anyway in such situations, if u32 is bigger than u16.

@psychon
Copy link
Owner

psychon commented Aug 6, 2022

Well, yes, of course that's possible. But that does not really feel Rust-y to me. I'd try to avoid more panics in x11rb.

@andreykaere
Copy link
Author

Oh, okay! I just thought it might avoid some confusion. I don't know why it's not Rusty to you, because it will panic only when you do something bad, and Rust will panic in this case anyway ... Maybe not in TryInto, but in as.

And I hope that xorg will accept your PR and I think it's the best idiomatically-wise solution.

But I think it would be a good idea to add some notes into documentation!

@psychon
Copy link
Owner

psychon commented Aug 6, 2022

I just opened #747. This gets rid of the Into generic argument and instead uses the right type directly. Hopefully that is the best solution and means that things are "auto-documented" into what kind of bitmask is expected.

@andreykaere
Copy link
Author

But what will happen if someone uses u32 EvenMask parameter?

@psychon
Copy link
Owner

psychon commented Aug 7, 2022

Something between "won't compile" and "they will have to add a call to .into() to call the From<u32> impl.

@andreykaere
Copy link
Author

But why it won't compile? If there is no restriction for the EventMask type ...

@psychon
Copy link
Owner

psychon commented Aug 7, 2022

Well, I don't mind giving people the tools to shoot themselves into the foot. I am just trying to make it harder.

Previously, anything implementing Into<u16> could be used and there was no indication of what the correct enumeration for that argument is. One was free to just use the wrong one. Now, one at least gets a suggestions on what "they way to go" is.

@andreykaere
Copy link
Author

You didn't get me. I meant, earlier you could put something beyond 32u size, but now you can. Isn't it bad?

@psychon
Copy link
Owner

psychon commented Aug 7, 2022

What do you mean with "beyond 32u size"? Larger than u32? Uhm, how? The only integer types implementing Into<u16> are u8 and u16. Sorry, apparently I am not understanding your question.

Or are you asking for a way to turn e.g. u8 into EventMask? If so: There already is: https://docs.rs/x11rb/latest/x11rb/protocol/xproto/struct.EventMask.html#impl-From%3Cu8%3E

@andreykaere
Copy link
Author

No, I mean, that, when you removed trait bound Into<u16> and just put EventMask type instead, you've allowed putting values, potentially, bigger, than u16. And isn't it wrong? (Or you're not actually allowing that? If so, how?)

@psychon
Copy link
Owner

psychon commented Aug 7, 2022

Ah, that part. Yeah.

Let's forget about e.g. GrabButton. For other cases, this now does the right thing: Anything that implements Into<u16> was previously allowed and now only the specific enum is expected. That provides some hints/help in finding the right enumerations.

For GrabButton, the change will only help once https://gitlab.freedesktop.org/xorg/proto/xcbproto/-/merge_requests/35 is accepted upstream and we updated our copy of xcb-proto. At that point, the EventMask argument will be replaced with the right mask.

Here's the diff if I manually update the xcb-proto version right now:
diff --git a/x11rb-protocol/src/protocol/xproto.rs b/x11rb-protocol/src/protocol/xproto.rs
index bdb7e8b..d006629 100644
--- a/x11rb-protocol/src/protocol/xproto.rs
+++ b/x11rb-protocol/src/protocol/xproto.rs
@@ -558,6 +558,166 @@ impl core::fmt::Debug for EventMask  {
 }
 bitmask_binop!(EventMask, u32);
 
+/// subset of event mask for pointer events in grabs.
+///
+/// # See
+///
+/// * `GrabPointer`: request
+/// * `GrabButton`: request
+/// * `ChangeActivePointerGrab`: request
+#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
+#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
+pub struct PointerEventMask(u16);
+impl PointerEventMask {
+    pub const NO_EVENT: Self = Self(0);
+    pub const BUTTON_PRESS: Self = Self(1 << 2);
+    pub const BUTTON_RELEASE: Self = Self(1 << 3);
+    pub const ENTER_WINDOW: Self = Self(1 << 4);
+    pub const LEAVE_WINDOW: Self = Self(1 << 5);
+    pub const POINTER_MOTION: Self = Self(1 << 6);
+    pub const POINTER_MOTION_HINT: Self = Self(1 << 7);
+    pub const BUTTON1_MOTION: Self = Self(1 << 8);
+    pub const BUTTON2_MOTION: Self = Self(1 << 9);
+    pub const BUTTON3_MOTION: Self = Self(1 << 10);
+    pub const BUTTON4_MOTION: Self = Self(1 << 11);
+    pub const BUTTON5_MOTION: Self = Self(1 << 12);
+    pub const BUTTON_MOTION: Self = Self(1 << 13);
+    pub const KEYMAP_STATE: Self = Self(1 << 14);
+}
+impl From<PointerEventMask> for u16 {
+    #[inline]
+    fn from(input: PointerEventMask) -> Self {
+        input.0
+    }
+}
+impl From<PointerEventMask> for Option<u16> {
+    #[inline]
+    fn from(input: PointerEventMask) -> Self {
+        Some(input.0)
+    }
+}
+impl From<PointerEventMask> for u32 {
+    #[inline]
+    fn from(input: PointerEventMask) -> Self {
+        u32::from(input.0)
+    }
+}
+impl From<PointerEventMask> for Option<u32> {
+    #[inline]
+    fn from(input: PointerEventMask) -> Self {
+        Some(u32::from(input.0))
+    }
+}
+impl From<u8> for PointerEventMask {
+    #[inline]
+    fn from(value: u8) -> Self {
+        Self(value.into())
+    }
+}
+impl From<u16> for PointerEventMask {
+    #[inline]
+    fn from(value: u16) -> Self {
+        Self(value)
+    }
+}
+impl core::fmt::Debug for PointerEventMask  {
+    fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
+        let variants = [
+            (Self::NO_EVENT.0.into(), "NO_EVENT", "NoEvent"),
+            (Self::BUTTON_PRESS.0.into(), "BUTTON_PRESS", "ButtonPress"),
+            (Self::BUTTON_RELEASE.0.into(), "BUTTON_RELEASE", "ButtonRelease"),
+            (Self::ENTER_WINDOW.0.into(), "ENTER_WINDOW", "EnterWindow"),
+            (Self::LEAVE_WINDOW.0.into(), "LEAVE_WINDOW", "LeaveWindow"),
+            (Self::POINTER_MOTION.0.into(), "POINTER_MOTION", "PointerMotion"),
+            (Self::POINTER_MOTION_HINT.0.into(), "POINTER_MOTION_HINT", "PointerMotionHint"),
+            (Self::BUTTON1_MOTION.0.into(), "BUTTON1_MOTION", "Button1Motion"),
+            (Self::BUTTON2_MOTION.0.into(), "BUTTON2_MOTION", "Button2Motion"),
+            (Self::BUTTON3_MOTION.0.into(), "BUTTON3_MOTION", "Button3Motion"),
+            (Self::BUTTON4_MOTION.0.into(), "BUTTON4_MOTION", "Button4Motion"),
+            (Self::BUTTON5_MOTION.0.into(), "BUTTON5_MOTION", "Button5Motion"),
+            (Self::BUTTON_MOTION.0.into(), "BUTTON_MOTION", "ButtonMotion"),
+            (Self::KEYMAP_STATE.0.into(), "KEYMAP_STATE", "KeymapState"),
+        ];
+        pretty_print_bitmask(fmt, self.0.into(), &variants)
+    }
+}
+bitmask_binop!(PointerEventMask, u16);
+
+/// subset of event mask for device events that is used in do_not_propagate_mask.
+///
+/// # See
+///
+/// * `CreateWindow`: request
+/// * `ChangeWindowAttributes`: request
+/// * `GetWindowAttributes`: request
+#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
+#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
+pub struct DeviceEventMask(u32);
+impl DeviceEventMask {
+    pub const NO_EVENT: Self = Self(0);
+    pub const KEY_PRESS: Self = Self(1 << 0);
+    pub const KEY_RELEASE: Self = Self(1 << 1);
+    pub const BUTTON_PRESS: Self = Self(1 << 2);
+    pub const BUTTON_RELEASE: Self = Self(1 << 3);
+    pub const POINTER_MOTION: Self = Self(1 << 6);
+    pub const BUTTON1_MOTION: Self = Self(1 << 8);
+    pub const BUTTON2_MOTION: Self = Self(1 << 9);
+    pub const BUTTON3_MOTION: Self = Self(1 << 10);
+    pub const BUTTON4_MOTION: Self = Self(1 << 11);
+    pub const BUTTON5_MOTION: Self = Self(1 << 12);
+    pub const BUTTON_MOTION: Self = Self(1 << 13);
+}
+impl From<DeviceEventMask> for u32 {
+    #[inline]
+    fn from(input: DeviceEventMask) -> Self {
+        input.0
+    }
+}
+impl From<DeviceEventMask> for Option<u32> {
+    #[inline]
+    fn from(input: DeviceEventMask) -> Self {
+        Some(input.0)
+    }
+}
+impl From<u8> for DeviceEventMask {
+    #[inline]
+    fn from(value: u8) -> Self {
+        Self(value.into())
+    }
+}
+impl From<u16> for DeviceEventMask {
+    #[inline]
+    fn from(value: u16) -> Self {
+        Self(value.into())
+    }
+}
+impl From<u32> for DeviceEventMask {
+    #[inline]
+    fn from(value: u32) -> Self {
+        Self(value)
+    }
+}
+impl core::fmt::Debug for DeviceEventMask  {
+    fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
+        let variants = [
+            (Self::NO_EVENT.0, "NO_EVENT", "NoEvent"),
+            (Self::KEY_PRESS.0, "KEY_PRESS", "KeyPress"),
+            (Self::KEY_RELEASE.0, "KEY_RELEASE", "KeyRelease"),
+            (Self::BUTTON_PRESS.0, "BUTTON_PRESS", "ButtonPress"),
+            (Self::BUTTON_RELEASE.0, "BUTTON_RELEASE", "ButtonRelease"),
+            (Self::POINTER_MOTION.0, "POINTER_MOTION", "PointerMotion"),
+            (Self::BUTTON1_MOTION.0, "BUTTON1_MOTION", "Button1Motion"),
+            (Self::BUTTON2_MOTION.0, "BUTTON2_MOTION", "Button2Motion"),
+            (Self::BUTTON3_MOTION.0, "BUTTON3_MOTION", "Button3Motion"),
+            (Self::BUTTON4_MOTION.0, "BUTTON4_MOTION", "Button4Motion"),
+            (Self::BUTTON5_MOTION.0, "BUTTON5_MOTION", "Button5Motion"),
+            (Self::BUTTON_MOTION.0, "BUTTON_MOTION", "ButtonMotion"),
+        ];
+        pretty_print_bitmask(fmt, self.0, &variants)
+    }
+}
+bitmask_binop!(DeviceEventMask, u32);
+
 #[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
 #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
 pub struct BackingStore(u32);
@@ -6779,7 +6939,7 @@ pub struct CreateWindowAux {
     pub override_redirect: Option<Bool32>,
     pub save_under: Option<Bool32>,
     pub event_mask: Option<EventMask>,
-    pub do_not_propogate_mask: Option<EventMask>,
+    pub do_not_propogate_mask: Option<DeviceEventMask>,
     pub colormap: Option<Colormap>,
     pub cursor: Option<Cursor>,
 }
@@ -7102,7 +7262,7 @@ impl CreateWindowAux {
     }
     /// Set the `do_not_propogate_mask` field of this structure.
     #[must_use]
-    pub fn do_not_propogate_mask<I>(mut self, value: I) -> Self where I: Into<Option<EventMask>> {
+    pub fn do_not_propogate_mask<I>(mut self, value: I) -> Self where I: Into<Option<DeviceEventMask>> {
         self.do_not_propogate_mask = value.into();
         self
     }
@@ -7332,7 +7492,7 @@ pub struct ChangeWindowAttributesAux {
     pub override_redirect: Option<Bool32>,
     pub save_under: Option<Bool32>,
     pub event_mask: Option<EventMask>,
-    pub do_not_propogate_mask: Option<EventMask>,
+    pub do_not_propogate_mask: Option<DeviceEventMask>,
     pub colormap: Option<Colormap>,
     pub cursor: Option<Cursor>,
 }
@@ -7655,7 +7815,7 @@ impl ChangeWindowAttributesAux {
     }
     /// Set the `do_not_propogate_mask` field of this structure.
     #[must_use]
-    pub fn do_not_propogate_mask<I>(mut self, value: I) -> Self where I: Into<Option<EventMask>> {
+    pub fn do_not_propogate_mask<I>(mut self, value: I) -> Self where I: Into<Option<DeviceEventMask>> {
         self.do_not_propogate_mask = value.into();
         self
     }
@@ -7935,7 +8095,7 @@ pub struct GetWindowAttributesReply {
     pub colormap: Colormap,
     pub all_event_masks: EventMask,
     pub your_event_mask: EventMask,
-    pub do_not_propagate_mask: EventMask,
+    pub do_not_propagate_mask: DeviceEventMask,
 }
 impl TryParse for GetWindowAttributesReply {
     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
@@ -11667,7 +11827,7 @@ pub const GRAB_POINTER_REQUEST: u8 = 26;
 pub struct GrabPointerRequest {
     pub owner_events: bool,
     pub grab_window: Window,
-    pub event_mask: EventMask,
+    pub event_mask: PointerEventMask,
     pub pointer_mode: GrabMode,
     pub keyboard_mode: GrabMode,
     pub confine_to: Window,
@@ -11680,7 +11840,7 @@ impl GrabPointerRequest {
         let length_so_far = 0;
         let owner_events_bytes = self.owner_events.serialize();
         let grab_window_bytes = self.grab_window.serialize();
-        let event_mask_bytes = (u32::from(self.event_mask) as u16).serialize();
+        let event_mask_bytes = u16::from(self.event_mask).serialize();
         let pointer_mode_bytes = u8::from(self.pointer_mode).serialize();
         let keyboard_mode_bytes = u8::from(self.keyboard_mode).serialize();
         let confine_to_bytes = self.confine_to.serialize();
@@ -12044,7 +12204,7 @@ pub const GRAB_BUTTON_REQUEST: u8 = 28;
 pub struct GrabButtonRequest {
     pub owner_events: bool,
     pub grab_window: Window,
-    pub event_mask: EventMask,
+    pub event_mask: PointerEventMask,
     pub pointer_mode: GrabMode,
     pub keyboard_mode: GrabMode,
     pub confine_to: Window,
@@ -12058,7 +12218,7 @@ impl GrabButtonRequest {
         let length_so_far = 0;
         let owner_events_bytes = self.owner_events.serialize();
         let grab_window_bytes = self.grab_window.serialize();
-        let event_mask_bytes = (u32::from(self.event_mask) as u16).serialize();
+        let event_mask_bytes = u16::from(self.event_mask).serialize();
         let pointer_mode_bytes = u8::from(self.pointer_mode).serialize();
         let keyboard_mode_bytes = u8::from(self.keyboard_mode).serialize();
         let confine_to_bytes = self.confine_to.serialize();
@@ -12223,7 +12383,7 @@ pub const CHANGE_ACTIVE_POINTER_GRAB_REQUEST: u8 = 30;
 pub struct ChangeActivePointerGrabRequest {
     pub cursor: Cursor,
     pub time: Timestamp,
-    pub event_mask: EventMask,
+    pub event_mask: PointerEventMask,
 }
 impl ChangeActivePointerGrabRequest {
     /// Serialize this request into bytes for the provided connection
@@ -12231,7 +12391,7 @@ impl ChangeActivePointerGrabRequest {
         let length_so_far = 0;
         let cursor_bytes = self.cursor.serialize();
         let time_bytes = self.time.serialize();
-        let event_mask_bytes = (u32::from(self.event_mask) as u16).serialize();
+        let event_mask_bytes = u16::from(self.event_mask).serialize();
         let mut request0 = vec![
             CHANGE_ACTIVE_POINTER_GRAB_REQUEST,
             0,
diff --git a/x11rb/src/protocol/xproto.rs b/x11rb/src/protocol/xproto.rs
index 5cfc4bc..e46997b 100644
--- a/x11rb/src/protocol/xproto.rs
+++ b/x11rb/src/protocol/xproto.rs
@@ -1103,7 +1103,7 @@ where
 ///     }
 /// }
 /// ```
-pub fn grab_pointer<Conn, A, B, C>(conn: &Conn, owner_events: bool, grab_window: Window, event_mask: EventMask, pointer_mode: GrabMode, keyboard_mode: GrabMode, confine_to: A, cursor: B, time: C) -> Result<Cookie<'_, Conn, GrabPointerReply>, ConnectionError>
+pub fn grab_pointer<Conn, A, B, C>(conn: &Conn, owner_events: bool, grab_window: Window, event_mask: PointerEventMask, pointer_mode: GrabMode, keyboard_mode: GrabMode, confine_to: A, cursor: B, time: C) -> Result<Cookie<'_, Conn, GrabPointerReply>, ConnectionError>
 where
     Conn: RequestConnection + ?Sized,
     A: Into<Window>,
@@ -1232,7 +1232,7 @@ where
 /// * `Value` - TODO: reasons?
 /// * `Cursor` - The specified `cursor` does not exist.
 /// * `Window` - The specified `window` does not exist.
-pub fn grab_button<Conn, A, B>(conn: &Conn, owner_events: bool, grab_window: Window, event_mask: EventMask, pointer_mode: GrabMode, keyboard_mode: GrabMode, confine_to: A, cursor: B, button: ButtonIndex, modifiers: ModMask) -> Result<VoidCookie<'_, Conn>, ConnectionError>
+pub fn grab_button<Conn, A, B>(conn: &Conn, owner_events: bool, grab_window: Window, event_mask: PointerEventMask, pointer_mode: GrabMode, keyboard_mode: GrabMode, confine_to: A, cursor: B, button: ButtonIndex, modifiers: ModMask) -> Result<VoidCookie<'_, Conn>, ConnectionError>
 where
     Conn: RequestConnection + ?Sized,
     A: Into<Window>,
@@ -1270,7 +1270,7 @@ where
     conn.send_request_without_reply(&slices, fds)
 }
 
-pub fn change_active_pointer_grab<Conn, A, B>(conn: &Conn, cursor: A, time: B, event_mask: EventMask) -> Result<VoidCookie<'_, Conn>, ConnectionError>
+pub fn change_active_pointer_grab<Conn, A, B>(conn: &Conn, cursor: A, time: B, event_mask: PointerEventMask) -> Result<VoidCookie<'_, Conn>, ConnectionError>
 where
     Conn: RequestConnection + ?Sized,
     A: Into<Cursor>,
@@ -4115,7 +4115,7 @@ pub trait ConnectionExt: RequestConnection {
     ///     }
     /// }
     /// ```
-    fn grab_pointer<A, B, C>(&self, owner_events: bool, grab_window: Window, event_mask: EventMask, pointer_mode: GrabMode, keyboard_mode: GrabMode, confine_to: A, cursor: B, time: C) -> Result<Cookie<'_, Self, GrabPointerReply>, ConnectionError>
+    fn grab_pointer<A, B, C>(&self, owner_events: bool, grab_window: Window, event_mask: PointerEventMask, pointer_mode: GrabMode, keyboard_mode: GrabMode, confine_to: A, cursor: B, time: C) -> Result<Cookie<'_, Self, GrabPointerReply>, ConnectionError>
     where
         A: Into<Window>,
         B: Into<Cursor>,
@@ -4219,7 +4219,7 @@ pub trait ConnectionExt: RequestConnection {
     /// * `Value` - TODO: reasons?
     /// * `Cursor` - The specified `cursor` does not exist.
     /// * `Window` - The specified `window` does not exist.
-    fn grab_button<A, B>(&self, owner_events: bool, grab_window: Window, event_mask: EventMask, pointer_mode: GrabMode, keyboard_mode: GrabMode, confine_to: A, cursor: B, button: ButtonIndex, modifiers: ModMask) -> Result<VoidCookie<'_, Self>, ConnectionError>
+    fn grab_button<A, B>(&self, owner_events: bool, grab_window: Window, event_mask: PointerEventMask, pointer_mode: GrabMode, keyboard_mode: GrabMode, confine_to: A, cursor: B, button: ButtonIndex, modifiers: ModMask) -> Result<VoidCookie<'_, Self>, ConnectionError>
     where
         A: Into<Window>,
         B: Into<Cursor>,
@@ -4230,7 +4230,7 @@ pub trait ConnectionExt: RequestConnection {
     {
         ungrab_button(self, button, grab_window, modifiers)
     }
-    fn change_active_pointer_grab<A, B>(&self, cursor: A, time: B, event_mask: EventMask) -> Result<VoidCookie<'_, Self>, ConnectionError>
+    fn change_active_pointer_grab<A, B>(&self, cursor: A, time: B, event_mask: PointerEventMask) -> Result<VoidCookie<'_, Self>, ConnectionError>
     where
         A: Into<Cursor>,
         B: Into<Timestamp>,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants