1. declare initSkin function to express the inheritance clearly.
2. moved initialization source code to proper class.
3. modified variable name (windowHandleId -> displayHandleId)
Change-Id: Ibafa8763433fc1738365897ab179794d78981da5
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
import java.util.logging.Logger;
import org.eclipse.swt.SWT;
+import org.tizen.emulator.skin.comm.sock.data.StartData;
import org.tizen.emulator.skin.config.EmulatorConfig;
+import org.tizen.emulator.skin.dbi.OptionType;
import org.tizen.emulator.skin.exception.ScreenShotException;
import org.tizen.emulator.skin.image.ImageRegistry.IconName;
import org.tizen.emulator.skin.info.SkinInformation;
super(config, skinInfo, SWT.EMBEDDED, isOnTop);
}
- public long initLayout() {
- super.initLayout();
+ @Override
+ public StartData initSkin() {
+ initLayout();
+
+ /* maru_sdl uses this handle ID */
+ long id = getDisplayHandleId();
+
+ /* generate a start data */
+ int width = getEmulatorSkinState().getCurrentResolutionWidth();
+ int height = getEmulatorSkinState().getCurrentResolutionHeight();
+ int scale = getEmulatorSkinState().getCurrentScale();
+ short rotation = getEmulatorSkinState().getCurrentRotationId();
+
+ boolean isBlankGuide = true;
+ OptionType option = config.getDbiContents().getOption();
+ if (option != null) {
+ isBlankGuide = (option.getBlankGuide() == null) ?
+ true : option.getBlankGuide().isVisible();
+ }
+
+ StartData startData = new StartData(id,
+ width, height, scale, rotation, isBlankGuide);
+ logger.info("" + startData);
- /* sdl uses this handle ID */
- return getWindowHandleId();
+ return startData;
}
- private long getWindowHandleId() {
+ private long getDisplayHandleId() {
long windowHandleId = 0;
/* org.eclipse.swt.widgets.Widget */
import org.tizen.emulator.skin.comm.ICommunicator.SendCommand;
import org.tizen.emulator.skin.comm.sock.data.KeyEventData;
import org.tizen.emulator.skin.comm.sock.data.MouseEventData;
+import org.tizen.emulator.skin.comm.sock.data.StartData;
import org.tizen.emulator.skin.config.EmulatorConfig;
import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
+import org.tizen.emulator.skin.dbi.OptionType;
import org.tizen.emulator.skin.exception.ScreenShotException;
import org.tizen.emulator.skin.image.ImageRegistry.IconName;
import org.tizen.emulator.skin.info.SkinInformation;
this.imageGuide = null;
}
+ @Override
protected void skinFinalize() {
pollThread.stopRequest();
super.skinFinalize();
}
- public long initLayout() {
- super.initLayout();
+ @Override
+ public StartData initSkin() {
+ initLayout();
finger = new EmulatorFingers(maxTouchPoint, currentState, communicator);
if (SwtUtil.isMacPlatform() == true) {
}
multiTouchKeySub = SWT.SHIFT;
+ initDisplay();
+
+ /* generate a start data */
+ int width = getEmulatorSkinState().getCurrentResolutionWidth();
+ int height = getEmulatorSkinState().getCurrentResolutionHeight();
+ int scale = getEmulatorSkinState().getCurrentScale();
+ short rotation = getEmulatorSkinState().getCurrentRotationId();
+
+ boolean isBlankGuide = true;
+ OptionType option = config.getDbiContents().getOption();
+ if (option != null) {
+ isBlankGuide = (option.getBlankGuide() == null) ?
+ true : option.getBlankGuide().isVisible();
+ }
+
+ StartData startData = new StartData(0,
+ width, height, scale, rotation, isBlankGuide);
+ logger.info("" + startData);
+
+ return startData;
+ }
+
+ private void initDisplay() {
+ /* initialize shared memory */
/* base + 1 = sdb port */
/* base + 2 = shared memory key */
int shmkey = config.getArgInt(ArgsConstants.VM_BASE_PORT) + 2;
logger.info("shmkey = " + shmkey);
- /* initialize shared memory */
int result = shmget(shmkey,
currentState.getCurrentResolutionWidth() *
currentState.getCurrentResolutionHeight() * 4);
"Cannot launch this VM.\n" +
"Failed to get identifier of the shared memory segment.",
SWT.ICON_ERROR, config);
+
System.exit(-1);
} else if (result == 2) {
logger.severe("Failed to attach the shared memory segment.");
"Cannot launch this VM.\n" +
"Failed to attach the shared memory segment.",
SWT.ICON_ERROR, config);
+
System.exit(-1);
}
});
pollThread.start();
-
- return 0;
}
@Override
import org.tizen.emulator.skin.comm.sock.data.DisplayStateData;
import org.tizen.emulator.skin.comm.sock.data.KeyEventData;
import org.tizen.emulator.skin.comm.sock.data.MouseEventData;
+import org.tizen.emulator.skin.comm.sock.data.StartData;
import org.tizen.emulator.skin.config.EmulatorConfig;
import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
import org.tizen.emulator.skin.config.EmulatorConfig.SkinPropertiesConstants;
this.pressedKeyEventList = new LinkedList<KeyEventData>();
this.isOnTop = isOnTop;
+ this.isOnKbd = false;
this.isKeyWindow = false;
int style = SWT.NO_TRIM | SWT.DOUBLE_BUFFERED;
}
}
- public long initLayout() {
+ public StartData initSkin() {
+ /* abstract */
+
+ return null;
+ }
+
+ protected long initLayout() {
logger.info("initialize the skin layout");
imageRegistry = ImageRegistry.getInstance();
currentState.setCurrentRotationId(rotationId);
/* create and attach a popup menu */
- isOnKbd = false;
popupMenu = new PopupMenu(config, this);
/* build a skin layout */
lcdCanvas = skinComposer.compose(displayCanvasStyle);
+ /* */
+ //TODO: move
if (config.getArgBoolean(ArgsConstants.INPUT_MOUSE, false) == true) {
prev_x = lcdCanvas.getSize().x / 2;
prev_y = lcdCanvas.getSize().y / 2;
addMainWindowListeners();
addCanvasListeners();
- setFocus();
+ lcdCanvas.setFocus();
return 0;
}
}
}
- public void setFocus() {
- lcdCanvas.setFocus();
- }
-
public void updateSkin() {
skinComposer.updateSkin();
}
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.tizen.emulator.skin.comm.sock.SocketCommunicator;
+import org.tizen.emulator.skin.comm.sock.data.StartData;
import org.tizen.emulator.skin.config.EmulatorConfig;
import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
import org.tizen.emulator.skin.config.EmulatorConfig.ConfigPropertiesConstants;
skin.setCommunicator(communicator);
/* initialize a skin layout */
- long windowHandleId = skin.initLayout();
- communicator.setInitialData(windowHandleId);
+ StartData startData = skin.initSkin();
+ communicator.setInitialData(startData);
Socket commSocket = communicator.getSocket();
import org.tizen.emulator.skin.comm.sock.data.StartData;
import org.tizen.emulator.skin.config.EmulatorConfig;
import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
-import org.tizen.emulator.skin.dbi.OptionType;
import org.tizen.emulator.skin.image.ImageRegistry.ResourceImageName;
import org.tizen.emulator.skin.log.SkinLogger;
import org.tizen.emulator.skin.util.IOUtil;
-import org.tizen.emulator.skin.util.SkinUtil;
/**
private EmulatorConfig config;
private int uId;
- private long initialData;
+ private StartData startData;
private EmulatorSkin skin;
private Socket socket;
this.dataOutputStream = new DataOutputStream(bao);
}
- public void setInitialData(long data) {
- this.initialData = data;
+ public void setInitialData(StartData data) {
+ this.startData = data;
+ }
+
+ private void sendInitialData() {
+ logger.info("send startData");
+ sendToQEMU(SendCommand.SEND_SKIN_OPENED, startData, false);
}
@Override
sendThread.setDaemon(true);
sendThread.start();
- int width = config.getArgInt(ArgsConstants.RESOLUTION_WIDTH);
- int height = config.getArgInt(ArgsConstants.RESOLUTION_HEIGHT);
- int scale = SkinUtil.getValidScale(config);
- short rotation = EmulatorConfig.DEFAULT_WINDOW_ROTATION;
-
- boolean isBlankGuide = true;
- OptionType option = config.getDbiContents().getOption();
- if (option != null) {
- isBlankGuide = (option.getBlankGuide() == null) ?
- true : option.getBlankGuide().isVisible();
- }
-
- StartData startData = new StartData(initialData,
- width, height, scale, rotation, isBlankGuide);
- logger.info("" + startData);
-
- sendToQEMU(SendCommand.SEND_SKIN_OPENED, startData, false);
+ /* notify to Qemu */
+ sendInitialData();
boolean ignoreHeartbeat =
config.getArgBoolean(ArgsConstants.HEART_BEAT_IGNORE);
*
*/
public class StartData extends AbstractSendData {
- private long windowHandleId;
+ private long displayHandleId;
private int displayWidth;
private int displayHeight;
private int scale;
private short rotation;
private boolean isBlankGuide;
- public StartData(long windowHandleId,
+ public StartData(long displayHandleId,
int displayWidth, int displayHeight, int scale, short rotation,
boolean isBlankGuide) {
- this.windowHandleId = windowHandleId;
+ this.displayHandleId = displayHandleId;
this.displayWidth = displayWidth;
this.displayHeight = displayHeight;
this.scale = scale;
@Override
protected void write() throws IOException {
- writeLong(windowHandleId);
+ writeLong(displayHandleId);
writeInt(displayWidth);
writeInt(displayHeight);
writeInt(scale);
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
- builder.append("StartData [windowHandleId=");
- builder.append(windowHandleId);
+ builder.append("StartData [displayHandleId=");
+ builder.append(displayHandleId);
builder.append(", display size " + displayWidth + "x" + displayHeight);
builder.append(", scale=");
builder.append(scale);