protected EmulatorSkinState currentState;
protected boolean isDisplayDragging;
+ protected Point shellGrabPosition;
protected boolean isShutdownRequested;
public boolean isOnTop;
public boolean isKeyWindow;
this.displayCanvasStyle = displayCanvasStyle;
/* prepare for VM state management */
+ this.shellGrabPosition = new Point(-1, -1);
this.currentState = new EmulatorSkinState();
setColorVM(); /* generate a identity color */
skinComposer.composerFinalize();
}
+ /* window grabbing */
+ public void grabShell(int x, int y) {
+ shellGrabPosition.x = x;
+ shellGrabPosition.y = y;
+ }
+
+ public void ungrabShell() {
+ shellGrabPosition.x = -1;
+ shellGrabPosition.y = -1;
+ }
+
+ public boolean isShellGrabbing() {
+ return shellGrabPosition.x >= 0 && shellGrabPosition.y >= 0;
+ }
+
+ public Point getGrabPosition() {
+ if (isShellGrabbing() == false) {
+ return null;
+ }
+
+ return shellGrabPosition;
+ }
+
private void addMainWindowListeners() {
shellListener = new ShellListener() {
@Override
shellMenuDetectListener = new MenuDetectListener() {
@Override
public void menuDetected(MenuDetectEvent e) {
- if (isDisplayDragging == true) {
- logger.info("menu blocking while display touching");
+ if (isDisplayDragging == true || isShellGrabbing() == true
+ || isShutdownRequested == true) {
+ logger.info("menu is blocked");
e.doit = false;
return;
}
Menu menu = popupMenu.getMenuRoot();
+ keyForceRelease(true);
if (menu != null) {
shell.setMenu(menu);
canvasMenuDetectListener = new MenuDetectListener() {
@Override
public void menuDetected(MenuDetectEvent e) {
+ if (isDisplayDragging == true || isShellGrabbing() == true
+ || isShutdownRequested == true) {
+ logger.info("menu is blocked");
+
+ e.doit = false;
+ return;
+ }
+
Menu menu = popupMenu.getMenuRoot();
keyForceRelease(true);
- if (menu != null && isDisplayDragging == false) {
+ if (menu != null) {
lcdCanvas.setMenu(menu);
menu.setVisible(true);
+
e.doit = false;
} else {
lcdCanvas.setMenu(null);
private MouseListener shellMouseListener;
private GeneralSkinImageRegistry imageRegistry;
- private boolean isGrabbedShell;
- private Point grabPosition;
public GeneralPurposeSkinComposer(
EmulatorConfig config, EmulatorSkin skin) {
this.shell = skin.getShell();
this.currentState = skin.getEmulatorSkinState();
- this.isGrabbedShell= false;
- this.grabPosition = new Point(0, 0);
-
this.imageRegistry =
new GeneralSkinImageRegistry(shell.getDisplay());
shellMouseMoveListener = new MouseMoveListener() {
@Override
public void mouseMove(MouseEvent e) {
- if (isGrabbedShell == true && e.button == 0/* left button */) {
+ if (skin.isShellGrabbing() == true && e.button == 0/* left button */) {
/* move a window */
Point previousLocation = shell.getLocation();
- int x = previousLocation.x + (e.x - grabPosition.x);
- int y = previousLocation.y + (e.y - grabPosition.y);
+ Point grabLocation = skin.getGrabPosition();
+ if (grabLocation != null) {
+ int x = previousLocation.x + (e.x - grabLocation.x);
+ int y = previousLocation.y + (e.y - grabLocation.y);
- shell.setLocation(x, y);
+ shell.setLocation(x, y);
+ }
skin.getKeyWindowKeeper().redock(false, false);
}
if (e.button == 1) { /* left button */
logger.info("mouseUp in Skin");
- isGrabbedShell = false;
- grabPosition.x = grabPosition.y = 0;
+ skin.ungrabShell();
skin.getKeyWindowKeeper().redock(false, true);
}
if (1 == e.button) { /* left button */
logger.info("mouseDown in Skin");
- isGrabbedShell = true;
- grabPosition.x = e.x;
- grabPosition.y = e.y;
+ skin.grabShell(e.x, e.y);
}
}
private MouseListener shellMouseListener;
private ProfileSkinImageRegistry imageRegistry;
- private boolean isGrabbedShell;
- private Point grabPosition;
private HWKey currentPressedHWKey;
private HWKey currentHoveredHWKey;
this.currentState = skin.getEmulatorSkinState();
this.communicator = skin.communicator;
- this.isGrabbedShell= false;
- this.grabPosition = new Point(0, 0);
-
this.imageRegistry = new ProfileSkinImageRegistry(
shell.getDisplay(), config.getDbiContents(), skin.skinInfo.getSkinPath());
}
@Override
public void mouseExit(MouseEvent e) {
/* shell does not receive event only with MouseMoveListener
- * in case that : hover hardkey -> mouse move into LCD area */
+ in case that : hover hardkey -> mouse move into display area */
HWKey hoveredHWKey = currentHoveredHWKey;
if (hoveredHWKey != null) {
shellMouseMoveListener = new MouseMoveListener() {
@Override
public void mouseMove(MouseEvent e) {
- if (isGrabbedShell == true && e.button == 0/* left button */ &&
- currentPressedHWKey == null) {
+ if (skin.isShellGrabbing() == true && e.button == 0/* left button */
+ && currentPressedHWKey == null) {
/* move a window */
Point previousLocation = shell.getLocation();
- int x = previousLocation.x + (e.x - grabPosition.x);
- int y = previousLocation.y + (e.y - grabPosition.y);
+ Point grabLocation = skin.getGrabPosition();
+ if (grabLocation != null) {
+ int x = previousLocation.x + (e.x - grabLocation.x);
+ int y = previousLocation.y + (e.y - grabLocation.y);
- shell.setLocation(x, y);
+ shell.setLocation(x, y);
+ }
skin.getKeyWindowKeeper().redock(false, false);
@Override
public void mouseUp(MouseEvent e) {
if (e.button == 1) { /* left button */
- isGrabbedShell = false;
- grabPosition.x = grabPosition.y = 0;
+ skin.ungrabShell();
skin.getKeyWindowKeeper().redock(false, true);
@Override
public void mouseDown(MouseEvent e) {
if (1 == e.button) { /* left button */
+ skin.grabShell(e.x, e.y);
+
/* HW key handling */
final HWKey hwKey = SkinUtil.getHWKey(e.x, e.y,
currentState.getCurrentRotationId(), currentState.getCurrentScale());
if (hwKey == null) {
logger.info("mouseDown in Skin : " + e.x + ", " + e.y);
- isGrabbedShell = true;
- grabPosition.x = e.x;
- grabPosition.y = e.y;
-
return;
}