skin: block the popup menu while shell grabbing 92/11192/1
authorGiWoong Kim <giwoong.kim@samsung.com>
Tue, 22 Oct 2013 10:21:07 +0000 (19:21 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Tue, 22 Oct 2013 10:21:07 +0000 (19:21 +0900)
Change-Id: If92b632362127f1e42e29f57f0f9c50a9094bbc8
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java
tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java
tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java

index 0af8d5deb35e960341af6ebb1c6ad84412d2947c..bf8178a7a4a24ef2437dcea46a84122154b8a3e5 100755 (executable)
@@ -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);
index f524d31489709d2de5c09605a9e049e1a5c484f3..eb97bc3d32ad8e97247de6fa61033d87058746dd 100644 (file)
@@ -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);
                                }
                        }
 
index 78ea4ea5837570c894f0e6e3c7a0f86215caf3cf..a47fef01da2ff22b89d48fcfcc7b11b47d965d2d 100644 (file)
@@ -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;
                                        }