Re: Simulating a mouse click
Thanks for the help. I was able to fix this now by setting the time member correctly. I had it set to CurrentTime before, but that didn't fix it. Cheers, Markus On 03.11.2011 00:34, Peter Hutterer wrote: On Wed, Nov 02, 2011 at 03:27:42PM +0100, Markus Kramer wrote: Hi, I'm attempting to use xlib to simulate a series of mouse clicks in an application (gedit). I found some posts that describe how to do this and it essentially works. I can do left clicks on buttons and so on. But if I generate a click on the menu bar, a menu opens and something breaks and no further ButtonPress/ButtonRelease events that I send will be processed by the application. When debugging it with xtrace I noticed that my events look slightly different than real left click events. Real: ButtonPress(4) [1]button=left button(0x01) [4]time=0x03752355 [8]root=0x0102 [12]event=0x01a3 [16]child=None(0x) [20]root-x=428 [22]root-y=33 [24]event-x=295 [26]event-y=10 state=0 [30]same-screen=true(0x01) My simulated event: SendEvent [1]propagate=true(0x01) [4]destination=PointerWindow(0x) event-mask=ButtonPress ButtonPress(4) [1]button=left button(0x01) [4]time=0x [8]root=0x0102 [12]event=0x012000a3 [16]child=None(0x) [20]root-x=407 [22]root-y=40 [24]event-x=274 [26]event-y=19 state=0 [30]same-screen=true(0x01) The field event of the real event says 0x01a3 mine is 0x012000a3. What is this event field about? It is not part of the ButtonPress struct. event is the window the event happens on. once you send a button down on a menu, the client usually grabs the device that sent the event and the event window from then on is the grab window, not necessarily the window underneath the cursor. If you're tyring to emulate click events, I recommend to use the XTest extension instead, it's much simpler to handle. Cheers, Peter This is the code that I use to simulate a left click: --- XEvent event; memset(event, 0, sizeof(XEvent)); XWindowAttributes attr; XGetWindowAttributes(dpy, windowId,attr); event.type = ButtonPress; event.xbutton.same_screen = TRUE; event.xbutton.root = root; event.xbutton.window = windowId; event.xbutton.subwindow = None; event.xbutton.x = x; event.xbutton.y = y; event.xbutton.x_root = attr.x + x; event.xbutton.y_root = attr.y + y; event.xbutton.state = 0; event.xbutton.button = Button1; XSendEvent(dpy, PointerWindow, True, ButtonPressMask,event); XFlush(dpy); // the same for ButtonRelease, with modified state and mask -- Thanks in advance. Markus ___ xorg@lists.freedesktop.org: X.Org support Archives: http://lists.freedesktop.org/archives/xorg Info: http://lists.freedesktop.org/mailman/listinfo/xorg Your subscription address: peter.hutte...@who-t.net ___ xorg@lists.freedesktop.org: X.Org support Archives: http://lists.freedesktop.org/archives/xorg Info: http://lists.freedesktop.org/mailman/listinfo/xorg Your subscription address: arch...@mail-archive.com
Simulating a mouse click
Hi, I'm attempting to use xlib to simulate a series of mouse clicks in an application (gedit). I found some posts that describe how to do this and it essentially works. I can do left clicks on buttons and so on. But if I generate a click on the menu bar, a menu opens and something breaks and no further ButtonPress/ButtonRelease events that I send will be processed by the application. When debugging it with xtrace I noticed that my events look slightly different than real left click events. Real: ButtonPress(4) [1]button=left button(0x01) [4]time=0x03752355 [8]root=0x0102 [12]event=0x01a3 [16]child=None(0x) [20]root-x=428 [22]root-y=33 [24]event-x=295 [26]event-y=10 state=0 [30]same-screen=true(0x01) My simulated event: SendEvent [1]propagate=true(0x01) [4]destination=PointerWindow(0x) event-mask=ButtonPress ButtonPress(4) [1]button=left button(0x01) [4]time=0x [8]root=0x0102 [12]event=0x012000a3 [16]child=None(0x) [20]root-x=407 [22]root-y=40 [24]event-x=274 [26]event-y=19 state=0 [30]same-screen=true(0x01) The field event of the real event says 0x01a3 mine is 0x012000a3. What is this event field about? It is not part of the ButtonPress struct. This is the code that I use to simulate a left click: --- XEvent event; memset(event, 0, sizeof(XEvent)); XWindowAttributes attr; XGetWindowAttributes(dpy, windowId, attr); event.type = ButtonPress; event.xbutton.same_screen = TRUE; event.xbutton.root = root; event.xbutton.window = windowId; event.xbutton.subwindow = None; event.xbutton.x = x; event.xbutton.y = y; event.xbutton.x_root = attr.x + x; event.xbutton.y_root = attr.y + y; event.xbutton.state = 0; event.xbutton.button = Button1; XSendEvent(dpy, PointerWindow, True, ButtonPressMask, event); XFlush(dpy); // the same for ButtonRelease, with modified state and mask -- Thanks in advance. Markus ___ xorg@lists.freedesktop.org: X.Org support Archives: http://lists.freedesktop.org/archives/xorg Info: http://lists.freedesktop.org/mailman/listinfo/xorg Your subscription address: arch...@mail-archive.com
Re: Identify parent window of menus and tooltips
Thanks, that's exactly what I've been looking for. Unfortunately, for GTK, it only seems to be set for menus and not for tooltips. Weird, considering that GTK has been around for such a long time. On 29.09.2011 18:40, Marty Jack wrote: On 09/29/2011 12:07 PM, Markus Kramer wrote: Is there a way to identify the parent window of a menu or tooltip? I know that menus and tooltips are top level windows. So their parent would be the root window. I'm wondering if there is some other property which tells me to what window they belong to? cheers, Markus ___ xorg@lists.freedesktop.org: X.Org support Archives: http://lists.freedesktop.org/archives/xorg Info: http://lists.freedesktop.org/mailman/listinfo/xorg Your subscription address: marty...@comcast.net The WM_TRANSIENT_FOR property does this, but of course it is only as good as the toolkits who must be relied on to set it properly. See the ICCCM. ___ xorg@lists.freedesktop.org: X.Org support Archives: http://lists.freedesktop.org/archives/xorg Info: http://lists.freedesktop.org/mailman/listinfo/xorg Your subscription address: arch...@mail-archive.com
Re: Identify parent window of menus and tooltips
Thanks, that's exactly what I've been looking for. Unfortunately, for GTK, it only seems to be set for menus and not for tooltips. Weird, considering that GTK has been around for such a long time. 2011/9/29 Marty Jack marty...@comcast.net: On 09/29/2011 12:07 PM, Markus Kramer wrote: Is there a way to identify the parent window of a menu or tooltip? I know that menus and tooltips are top level windows. So their parent would be the root window. I'm wondering if there is some other property which tells me to what window they belong to? cheers, Markus ___ xorg@lists.freedesktop.org: X.Org support Archives: http://lists.freedesktop.org/archives/xorg Info: http://lists.freedesktop.org/mailman/listinfo/xorg Your subscription address: marty...@comcast.net The WM_TRANSIENT_FOR property does this, but of course it is only as good as the toolkits who must be relied on to set it properly. See the ICCCM. ___ xorg@lists.freedesktop.org: X.Org support Archives: http://lists.freedesktop.org/archives/xorg Info: http://lists.freedesktop.org/mailman/listinfo/xorg Your subscription address: arch...@mail-archive.com
Identify parent window of menus and tooltips
Is there a way to identify the parent window of a menu or tooltip? I know that menus and tooltips are top level windows. So their parent would be the root window. I'm wondering if there is some other property which tells me to what window they belong to? cheers, Markus ___ xorg@lists.freedesktop.org: X.Org support Archives: http://lists.freedesktop.org/archives/xorg Info: http://lists.freedesktop.org/mailman/listinfo/xorg Your subscription address: arch...@mail-archive.com