Friday, December 21, 2007

Emulating a click event on XWindow

A couple of weeks ago I found this old peace of code to emulate a mouse click button event on XWindows systems.
If somebody has programmed with IDL or executed a distributed program with its virtual machine, you'll have noticed that you must click obligatory in the eternal IDL splash srceen.
Well, this code makes this for you. You can create an script that launch your IDL program and a few second later execute this little program.

/path_to_idl/idl -vm=you_program.sav
sleep 3

I want to point that the next code has HTMLified thanks to C++2HTML:

/* Name: xboton
* Author: Antonio Santiago [asantiagop(at)gmail(dot)com]
* Description: xboton emulates a click with a mouse pointer in the middle
* of screen.
* Compile: gcc -o xboton xboton.c -lX11 -L/usr/X11R6/lib

#include <stdio.h>
#include <string.h>

#include <X11/Xlib.h>
#include <X11/Xos.h>
#include <X11/Xutil.h>

main() {

Display *display;

Window root, win, subwin;
XEvent event;
XWindowAttributes attrib;
unsigned int
width, height;

/* Open a display connection and get root window size. */

display = XOpenDisplay(NULL);
root = RootWindow(display, DefaultScreen(display));

( XGetWindowAttributes(display, root, &attrib) == 0 )

printf("Error: Can't retrieve root window size\n");

width = attrib.width;
height = attrib.height;

/* Move mouse pointer to middle if screen and get the ID of
* the window at this point.

XWarpPointer(display, None, root, 0,0,0,0, width/2, height/2);


event.type = ButtonPress;

event.xbutton.button = Button1;
event.xbutton.same_screen = True;

XQueryPointer(display, root,
event.xbutton.root, &event.xbutton.window,
event.xbutton.x_root, &event.xbutton.y_root,
event.xbutton.x, &event.xbutton.y,

event.xbutton.subwindow = event.xbutton.window;
event.xbutton.state = Button1Mask;

/* Walk down through window hierachy to find youngest child */

(event.xbutton.subwindow) {
event.xbutton.window = event.xbutton.subwindow;

XQueryPointer(display, event.xbutton.window,
event.xbutton.root, &event.xbutton.subwindow,
event.xbutton.x_root, &event.xbutton.y_root,
event.xbutton.x, &event.xbutton.y,

/* Send a ButtonPress and ButtonRelease (of button 1) to the middle screen window */

( XSendEvent(display, event.xbutton.subwindow, True, ButtonPressMask, &event) == 0)

printf("Error: XSendEvent error on ButtonPress event\n");

event.type = ButtonRelease;

event.xbutton.state = Button1Mask;
( XSendEvent(display, event.xbutton.subwindow, True, ButtonPressMask, &event) == 0)

printf("Error: XSendEvent error on ButtonRelease event\n");

Be happy don't worry.

Saturday, December 15, 2007

Working with wizards

Looking for information about how pass data among the panels of a wizards, I found these links posts in the Geertjan's Weblog about how wizards works in NB:

How wizards work: part 1, 2, 3, 4 and 5.

Thursday, December 06, 2007

Not another bubble

I found this video referenced in the Emilian blog, but don't worry we are not living another bubble.

Do I want a Mac?

Sure, I think not ;) I prefer a Linux box, but if you like the Mac LaF take a look here.

Note to configure Grub and Usplash in Ubuntu there exists an easy way called "StartUp-Manager" package.