Corona Admin
Loading...
Forum List Message List Search
Hamsphere 2.0.19 and Ubuntu 10.04 problems
2010-09-28 20:15
Registered: 13 years ago
Posts: 2
Hi,

I am running Hamsphere 2.0.19 on Ubuntu 10.04. It works fine, but Hamsphere window it keeping window focus for itself and prevents other windows from being able get focus. So for example when I have terminal window and Hamsphere opened at the same time, I can not type in terminal because the focus is kept by Hampshere. Is this know issue and is there a way to fix it?

Vy 73
SP4SKR
Re: Hamsphere 2.0.19 and Ubuntu 10.04 problems
2010-09-29 12:25
Registered: 14 years ago
Posts: 33
I've also experienced this behavior.

It has to do something with the "radio shape" of the hasphere window. Hamsphere takes a picture of the desktop and draws this image into it's window, then it draws all the other parts, so the hasphere window looks transparent.

This might be FB, but there is a bug in hamsphere / java / linux java implemetation, that brings the window to focus whenever this update happens.

I also consumes too much CPU.

Kelly, I suggest you to use the appropriate API for transculent and shaped windows: http://java.sun.com/developer/technicalArticles/GUI/translucent_shaped_windows/

It is not without problems, but once I managed to set up an application that works without problems on Linux.
Re: Hamsphere 2.0.19 and Ubuntu 10.04 problems
2010-09-29 12:53
Admin
Registered: 14 years ago
Posts: 1,061
Have in mind that this issue only affects Linux users. In Windows and Mac the Translucent code works quite OK.

At the time of writing the translucent code I was actually looking at that API, but I couldn't make it work.

The skin is based on a JFrame that is using the class below for the Transparency.
I will have to look into this for the next release.

73
Kelly

public class TransparentBackground extends JComponent {
private JFrame frame;
private Image background;
static final long serialVersionUID = 0;

public TransparentBackground(JFrame frame) {
this.frame = frame;
updateBackground( );
}

public void updateBackground( ) {
try {
Robot rbt = new Robot( );
Toolkit tk = Toolkit.getDefaultToolkit( );
Dimension dim = tk.getScreenSize( );
background = rbt.createScreenCapture(
new Rectangle(0,0,(int)dim.getWidth( ),
(int)dim.getHeight( )));


} catch (Exception ex) {
System.out.println(ex.toString( ));
ex.printStackTrace( );
}
}
public void paintComponent(Graphics g) {
Point pos = this.getLocationOnScreen( );
Point offset = new Point(-pos.x,-pos.y);
g.drawImage(background,offset.x,offset.y,null);

}

public void setXYpos(int xpos, int ypos) {
this.frame.setLocation(xpos, ypos);

}

public int getXpos() {
Point pos = this.getLocationOnScreen( );
return pos.x;
}

public int getYpos() {
Point pos = this.getLocationOnScreen( );
return pos.y;
}

}
Re: Hamsphere 2.0.19 and Ubuntu 10.04 problems
2010-09-30 13:39
Registered: 14 years ago
Posts: 33
Here is an example of an ellipse shaped window:

This is the frame class. It extends JFrame, implements ComponentListener, and listens to it's own resize event. Upon resize, it sets it's shape. You can implement any shape using a polygon:

ShapedFrame.java:
-------------8<---------------8<----------------
import java.awt.Shape;
import java.awt.Window;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.geom.Ellipse2D;
import java.lang.reflect.Method;
import javax.swing.JButton;
import javax.swing.JFrame;

public class ShapedFrame extends JFrame implements ComponentListener {

    private Method mSetWindowShape = null;

    public ShapedFrame() {

        try {
            mSetWindowShape = Class.forName("com.sun.awt.AWTUtilities").getMethod("setWindowShape", Window.class, Shape.class);
        } catch (ClassNotFoundException ex) {
            System.out.println("No AWTUtilities class was found");
        } catch (NoSuchMethodException ex) {
            System.out.println("No AWTUtilities.setWindowShape method was found");
        }

        addComponentListener(this);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setMinimumSize(new java.awt.Dimension(321, 250));
        setUndecorated(true);
        setLocationRelativeTo(null);
        add(new JButton("Push Me!"));
    }

    public void componentResized(ComponentEvent ce) {
        if (mSetWindowShape == null) {
            return;
        }
        try {
            Shape shape = new Ellipse2D.Float(0, 0, this.getWidth(), this.getHeight());
            mSetWindowShape.invoke(null, this, shape);
        } catch (Exception ex) {
            System.out.println("Error invoking setWindowShape method: " + ex.getLocalizedMessage());
        }
    }

    public void componentMoved(ComponentEvent ce) {
    }

    public void componentShown(ComponentEvent ce) {
    }

    public void componentHidden(ComponentEvent ce) {
    }

}

-------------8<---------------8<----------------


Here is the main class, you can try the frame with this one:
-------------8<---------------8<----------------
public class Main {
    public static void main(String args[]) {

        ShapedFrame frame = new ShapedFrame();
        frame.setVisible(true);

    }
}
-------------8<---------------8<----------------
Re: Hamsphere 2.0.19 and Ubuntu 10.04 problems
2010-09-30 13:41
Registered: 14 years ago
Posts: 33
Hm. some closing parentheses were replaced to smilyes. ;) hope you can still decipher the code :D
Sorry, only registered users may post in this forum.

Click here to login

© HamSphere AB, All Right Reserved.