From fbb4a23f68cda77cd71b694f0059010c0c0d0dc2 Mon Sep 17 00:00:00 2001 From: GiWoong Kim Date: Tue, 22 Oct 2013 19:21:07 +0900 Subject: [PATCH] skin: block the popup menu while shell grabbing Change-Id: If92b632362127f1e42e29f57f0f9c50a9094bbc8 Signed-off-by: GiWoong Kim --- .../org/tizen/emulator/skin/EmulatorSkin.java | 42 +++++++++++++++++-- .../layout/GeneralPurposeSkinComposer.java | 23 ++++------ .../layout/ProfileSpecificSkinComposer.java | 29 ++++++------- 3 files changed, 60 insertions(+), 34 deletions(-) diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java index 0af8d5deb3..bf8178a7a4 100755 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java @@ -147,6 +147,7 @@ public class EmulatorSkin { protected EmulatorSkinState currentState; protected boolean isDisplayDragging; + protected Point shellGrabPosition; protected boolean isShutdownRequested; public boolean isOnTop; public boolean isKeyWindow; @@ -202,6 +203,7 @@ public class EmulatorSkin { this.displayCanvasStyle = displayCanvasStyle; /* prepare for VM state management */ + this.shellGrabPosition = new Point(-1, -1); this.currentState = new EmulatorSkinState(); setColorVM(); /* generate a identity color */ @@ -357,6 +359,29 @@ public class EmulatorSkin { 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 @@ -528,14 +553,16 @@ public class EmulatorSkin { 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); @@ -790,12 +817,21 @@ public class EmulatorSkin { 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); diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java index f524d31489..eb97bc3d32 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java @@ -85,8 +85,6 @@ public class GeneralPurposeSkinComposer implements ISkinComposer { private MouseListener shellMouseListener; private GeneralSkinImageRegistry imageRegistry; - private boolean isGrabbedShell; - private Point grabPosition; public GeneralPurposeSkinComposer( EmulatorConfig config, EmulatorSkin skin) { @@ -95,9 +93,6 @@ public class GeneralPurposeSkinComposer implements ISkinComposer { this.shell = skin.getShell(); this.currentState = skin.getEmulatorSkinState(); - this.isGrabbedShell= false; - this.grabPosition = new Point(0, 0); - this.imageRegistry = new GeneralSkinImageRegistry(shell.getDisplay()); @@ -407,13 +402,16 @@ public class GeneralPurposeSkinComposer implements ISkinComposer { 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); } @@ -428,8 +426,7 @@ public class GeneralPurposeSkinComposer implements ISkinComposer { 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); } @@ -440,9 +437,7 @@ public class GeneralPurposeSkinComposer implements ISkinComposer { 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); } } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java index 78ea4ea583..a47fef01da 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java @@ -87,8 +87,6 @@ public class ProfileSpecificSkinComposer implements ISkinComposer { private MouseListener shellMouseListener; private ProfileSkinImageRegistry imageRegistry; - private boolean isGrabbedShell; - private Point grabPosition; private HWKey currentPressedHWKey; private HWKey currentHoveredHWKey; @@ -100,9 +98,6 @@ public class ProfileSpecificSkinComposer implements ISkinComposer { 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()); } @@ -334,7 +329,7 @@ public class ProfileSpecificSkinComposer implements ISkinComposer { @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) { @@ -354,14 +349,17 @@ public class ProfileSpecificSkinComposer implements ISkinComposer { 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); @@ -432,8 +430,7 @@ public class ProfileSpecificSkinComposer implements ISkinComposer { @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); @@ -471,16 +468,14 @@ public class ProfileSpecificSkinComposer implements ISkinComposer { @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; } -- 2.34.1