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
xboton


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>

int
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));

if
( 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);

bzero(&event,sizeof(XEvent));

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.state);

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



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

while
(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,
&
event.xbutton.state);
}


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

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

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

event.type = ButtonRelease;

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

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




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.

Thursday, November 29, 2007

Beyond the JPA and the possible cache problems

Yesterday I detect an strange behavior in a little JEE5 application: queried JPA data doesn't reflect the real state of the data when I was made changes on database through an external database client program.
Looking at google I found this very interesting post:
Understanding the cache of TopLink Essentials(GlassFish JPA)

Summarizing, the persistence provider, in this case TopLink maintains data in a session cache, maintaining it synchronized only if is modified through an EntityManager and it doesn't if you modify through an external tool. To avoid use the cache, with all its implication, you need to specify it explicitly.

Monday, November 26, 2007

The 10 programmers

Via TechRepublic I found 10 types of programmers you’ll encounter in the field.
What are your roll? ;)

Monday, October 29, 2007

New wave to share music

I have faith in this new (or not so new) way to share music. To lead by exmaple here is a Jamendo album from JT Bruce, until now an absolutely unknown artists that I must put in the new preferred artist:

Saturday, October 27, 2007

Updating to Gutsy

Really, I think Ubuntu is (for the moment) the best Linux desktop distribution. I am an Ubuntu believer from the beginning of the times :)
Recently I have upgraded my laptop from Feisty to Gutsy Ubuntu distro. Really there is not much say, simply put Ubuntu CD or upgrade from update manager.
I only want to note two point here:

Sunday, October 21, 2007

Read me at...

Lately I'm very busy working on the Balloon Project. Thus, better you can read my post at The Balloon Project blog.

Thursday, September 27, 2007

Preparing Liferay EXT environment

  • Install JDK and ANT.
  • Set JAVA_HOME and ANT_HOME to your Ant and Java directories. Add JAVA_HOME\bin and ANT_HOME\bin to System Path.
  • Create a Liferay directory:
$HOME/liferay-devel (refered as {LIFERAY}).
  • Create a directory called:
{LIFERAY}/portal
and unzip de Liferay sources into it.

  • Create a file called:
release.{user name}.properties, where {user name} is the user name used to develop.
  • and put the next lines with the appropiate values:
lp.ext.dir={LIFERAY}/ext
  • If you expect to be using eclipse add also a property called lp.eclipse.project.name with the desired name of the project:
lp.eclipse.project.name=liferay-ext

  • Create a file called:
app.server.{user name}.properties
  • and put the next lines with the appropiate values:
app.server.type=tomcat
app.server.tomcat.dir={LIFERAY}/tomcat
sourceforge.mirror=http://belnet.dl.sourceforge.net/sourceforge/lportal

  • Create a file called:
build.{user name}.properties
  • and put the next lines with the appropiate values:
javac.compiler=modern, for use Sun's compiler.
javac.fork=true

  • Go into {LIFERAY}/portal directory an execute:
> ant clean
> ant start
> ant build-ext

This must create a directory {LIFERAY}/ext (or what you called in lp.ext.dir) and create your EXT environment.
  • Copy files release.{user name}.properties, app.server.{user name}.properties and build.{user name}.properties to the {LIFERAY}/ext directory.
  • Go to the {LIFERAY}/ext/servers and execute:
> ant install-tomcat
It must download and install a tomcat liferay bundle into {LIFERAY}/tomcat.

  • The idea is to have:
{LIFERAY}
{LIFERAY}/ext -> Your EXT environment to develop.
{LIFERAY}/portal -> The portal sources used to create the EXT.
{LIFERAY}/tomcat -> The server (lifery bundle) used to develop.

  • Now execute:
> chmod a+x {LIFERAY}/tomcat/bin/*.sh
  • and try to start liferay bundle:
> {LIFERAY}/tomcat/bin/catalina.sh start

  • Connect to http://localhost:8080 (user test@liferay.com, password test).