Re: A problem about reading the source code
Uli Schlachter <[email protected]> Wed, 3 Jan 2024 08:56:44 +0100
| Newsgroups | gmane.comp.freedesktop.xcb |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--------------AwP0MTEp7PTH3zI6FhwQNHXk
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Hi,
Am 02.01.24 um 07:17 schrieb starcold14:
[...]
> I encountered a problem when I was using the computer, the left mouse button
> would randomly appear to be unresponsive,
That sounds like some program grabbed the mouse. I just do not have any
good ideas on which program or why.
[...]
> 1. The keyboard can be used, so I use crtl+alt+T to open gnome-terminal, enter
> xinput test-xi2, press enter, and then click the left mouse button to confirm
> that gnome-terminal can output the record of mouse click events (thus I think
> the driver and kernel work well);
Nice idea!
I think this still fits an active grab.
> 2. When I input xwininfo in gnome-terminal, the error message "Can't grab the
> mouse." is displayed.
This also fits the "there is an active grab"-theory.
You can find the X11 protocol specification at [0]. Relevant part:
> The request fails with status AlreadyGrabbed if the pointer is
> actively grabbed by some other client. The request fails with status
> Frozen if the pointer is frozen by an active grab of another client.
> The request fails with status NotViewable if grab-window or confine-to
> window is not viewable or if the confine-to window lies completely
> outside the boundaries of the root window. The request fails with
> status InvalidTime if the specified time is earlier than the
> last-pointer-grab time or later than the current server time.
[0]:
https://www.x.org/releases/X11R7.6/doc/xproto/x11protocol.html#requests:GrabPointer
We can rule out InvalidTime since the code uses XCB_TIME_CURRENT_TIME.
We can rule out NotViewable since the grab is established on the root
window. That one is always visible.
That leaves AlreadyGrabbed or Frozen which both basically are "some
other program grabbed mouse input".
[...]
> grab_cookie = xcb_grab_pointer
> (dpy, False, root,
> XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE,
> XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC,
> root, cursor, XCB_TIME_CURRENT_TIME);
> grab_reply = xcb_grab_pointer_reply (dpy, grab_cookie, &err);
> if (grab_reply->status != XCB_GRAB_STATUS_SUCCESS)
> Fatal_Error ("Can't grab the mouse.");
If you want to "compare symptoms" and check whether we can cause this
issue at will, you could try with the attached program. It can be
compiled with "gcc foo.c -lxcb". The possible errors when a grab fails
are (from /usr/include/xcb/xproto.h):
typedef enum xcb_grab_status_t {
XCB_GRAB_STATUS_SUCCESS = 0,
XCB_GRAB_STATUS_ALREADY_GRABBED = 1,
XCB_GRAB_STATUS_INVALID_TIME = 2,
XCB_GRAB_STATUS_NOT_VIEWABLE = 3,
XCB_GRAB_STATUS_FROZEN = 4
} xcb_grab_status_t;
Sadly, I have no good suggestion on what to do about this random grab or
how to figure out which program grabbed the mouse.
Cheers,
Uli
--
Nothing would make me happier than being happy
-- Barney
--------------AwP0MTEp7PTH3zI6FhwQNHXk
Content-Type: text/x-csrc; charset=UTF-8; name="foo.c"
Content-Disposition: attachment; filename="foo.c"
Content-Transfer-Encoding: base64
I2luY2x1ZGUgPHhjYi94Y2IuaD4KI2luY2x1ZGUgPHVuaXN0ZC5oPgojaW5jbHVkZSA8c3Rk
aW8uaD4KCmludCBtYWluKCkgewoJeGNiX2Nvbm5lY3Rpb25fdCAqYyA9IHhjYl9jb25uZWN0
KE5VTEwsIE5VTEwpOwoJaWYgKCFjKSB7CgkJZnByaW50ZihzdGRlcnIsICJGYWlsZWQgdG8g
Y29ubmVjdDogJWRcbiIsIHhjYl9jb25uZWN0aW9uX2hhc19lcnJvcihjKSk7CgkJeGNiX2Rp
c2Nvbm5lY3QoYyk7CgkJcmV0dXJuIDE7Cgl9CgoJeGNiX3dpbmRvd190IHJvb3QgPSB4Y2Jf
c2V0dXBfcm9vdHNfaXRlcmF0b3IoeGNiX2dldF9zZXR1cChjKSkuZGF0YS0+cm9vdDsKCXhj
Yl9ncmFiX3BvaW50ZXJfY29va2llX3QgY29va2llID0geGNiX2dyYWJfcG9pbnRlcihjLCAw
LCByb290LAoJCVhDQl9FVkVOVF9NQVNLX0JVVFRPTl9QUkVTUyB8IFhDQl9FVkVOVF9N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