From efc85868376ee4e592b9a5bb7361861150593caf Mon Sep 17 00:00:00 2001 From: GiWoong Kim Date: Mon, 9 Mar 2015 19:36:13 +0900 Subject: [PATCH] skin: Command+Q handling on MacOS Change-Id: If229ed37e5336602ec84e060fa9ad14d42264382 Signed-off-by: GiWoong Kim --- .../src/org/tizen/emulator/skin/EmulatorShmSkin.java | 16 +++++++++------- .../client/src/org/tizen/emulator/skin/EmulatorSkin.java | 15 +++++++++++++++ .../org/tizen/emulator/skin/menu/GeneralKeyWindow.java | 4 +++- .../org/tizen/emulator/skin/menu/SpecialKeyWindow.java | 4 +++- 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java index 774333c..408ff78 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java @@ -195,13 +195,15 @@ public class EmulatorShmSkin extends EmulatorSkin { dataFramebuffer.setPixels(0, 0, sizeFramebuffer, arrayFramebuffer, 0); - display.asyncExec(new Runnable() { - @Override - public void run() { - imageFramebuffer.dispose(); - imageFramebuffer = new Image(display, dataFramebuffer); - } - }); + if (display.isDisposed() == false) { + display.asyncExec(new Runnable() { + @Override + public void run() { + imageFramebuffer.dispose(); + imageFramebuffer = new Image(display, dataFramebuffer); + } + }); + } } public void stopRequest() { 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 ce19d61..a339ae0 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java @@ -221,6 +221,21 @@ public class EmulatorSkin { setColorVM(); /* generate a identity color */ this.keyWindowKeeper = new KeyWindowKeeper(this); + + if (SwtUtil.isMacPlatform() == true) { + shell.getDisplay().addListener(SWT.Close, new Listener() { + @Override + public void handleEvent(Event e) { + if (pressedKeyEventList.size() == 1) { + KeyEventData data = pressedKeyEventList.get(0); + if (data.keycode == SWT.COMMAND && data.stateMask == 0) { + logger.info("COMMAND terminated!"); + EmulatorSkinMain.terminateImmediately(-1); + } + } + } + }); + } } public void setCommunicator(SocketCommunicator communicator) { diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/GeneralKeyWindow.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/GeneralKeyWindow.java index 8857421..85266e6 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/GeneralKeyWindow.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/GeneralKeyWindow.java @@ -380,7 +380,9 @@ public class GeneralKeyWindow extends SkinWindow { logger.info("activate"); if (SwtUtil.isMacPlatform() == true) { - parent.moveAbove(shell); + if (parent.isDisposed() == false) { + parent.moveAbove(shell); + } } else { shell.getDisplay().asyncExec(new Runnable() { @Override diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/SpecialKeyWindow.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/SpecialKeyWindow.java index ad68a27..c8f7367 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/SpecialKeyWindow.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/SpecialKeyWindow.java @@ -231,7 +231,9 @@ public class SpecialKeyWindow extends SkinWindow { logger.info("activate"); if (SwtUtil.isMacPlatform() == true) { - parent.moveAbove(shell); + if (parent.isDisposed() == false) { + parent.moveAbove(shell); + } } else { shell.getDisplay().asyncExec(new Runnable() { @Override -- 2.7.4