0

is there a (Xlib, XCB)-way to simulate a mouse click in a minimized window (in this case chromium)? I am trying to automate some stuff and it works fine if the window is somewhere on the screen (see code below). However, as soon as I (sometimes accidently) minimize it, the window doesn't seem to register the XEvents anymore (e. g. buttons on websites aren't pressed, tabs not refreshed...). There are unfortunately no error messages.

Thanks in advance!

.
.
.
XButtonEvent button1EventForSpecificWindow(Display *display, Window rootWindow, Window destWindow, int x,int y, int root_x,int root_y,bool press = true)
{
XButtonEvent click;

// test send event to window
click.display       = display;
click.root          = rootWindow;
click.time          = CurrentTime;
click.same_screen   = True;
click.button        = Button1; // Button 4 mouswheel up!
click.state         = 0;
click.x             = x;
click.y             = y;
click.x_root        = root_x;
click.y_root        = root_y;
click.window        = destWindow;   

if (press)
    click.type = ButtonPress;
else
    click.type = ButtonRelease;

return click;
}
.
.
.
XButtonEvent click1;
XButtonEvent click2;

memset(&click1, 0, sizeof(click1));
memset(&click2, 0, sizeof(click2));

click1 = button1EventForSpecificWindow(display,rootWindow,window_return,dest_x_return,dest_y_return,929,442,true);
click2 = button1EventForSpecificWindow(display,rootWindow,window_return,dest_x_return,dest_y_return,929,442,false);

XSendEvent(click1.display, click1.window, True, ButtonPressMask, (XEvent *)&click1);
XSendEvent(click2.display, click2.window, True, ButtonReleaseMask, (XEvent *)&click2);

XFlush(display); 
.
.
.
limo123
  • 1
  • 1
  • AFAIK, events sent with `XSendEvent` can be differentiated (e.g. by the Chromium browser) from those created by the X11 server. – Basile Starynkevitch Nov 11 '16 at 19:04
  • 2
    The window frame belongs to the display manager, not the application. – stark Nov 11 '16 at 19:04
  • Events are propagated normally to minimized windows (you can run a program that reports events, e.g. xev, and send a few events to it via xdotool while it's minimized). Chromium might just choose to ignore events in its minimized state. You cannot really do anything about it, short of patching its code. – n. m. could be an AI Nov 12 '16 at 18:59

0 Answers0