Using a key to generate mouse button press?




My software uses Alt modifier but the Alt key is now
blocked by Gnome. A quick solution is to use key presses
for generating mouse button presses.

How to generate them?

A method found from the mail archives is

  win = gdk_window_at_pointer(&wx, &wy);
  event.type = GDK_BUTTON_PRESS;
  event.button.send_event = True;
  event.button.window = win;
  event.button.x = wx;
  event.button.y = wy;
  event.button.state = 0;
  event.button.button = Button1;
  event.button.source = GDK_SOURCE_MOUSE;
  event.button.x_root = (double)newx;
  event.button.y_root = (double)newy;
  gdk_event_put(&event);


Problem 1: I catch key presses at the top window because I could
not get them working with a drawing area. How to get the pointer
position with respect to the drawing area? How to know if the
pointer is in the drawing area? There is no point in sending the
event if pointer is somewhere else.

Problem 2: Why I should fill the pointer position at all?
I just want generate the mouse button press (with modifier Alt),
and to get GTK/GDK in process of doing the rest, like checking the
pointer position, the active window, and widget.

Problem 3: While sending a mouse button press from the code is
interesting, how my application could catch the Alt modifier?
When my software is in use (focus, enter etc.) the Alt modifier
flow should be guided to my software instead of Gnome.

Juhana



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]