Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / angle / util / win32 / Win32Window.cpp
index ec5a0c0..7802f25 100644 (file)
@@ -6,6 +6,8 @@
 
 #include "win32/Win32Window.h"
 
+#include <sstream>
+
 Key VirtualKeyCodeToKey(WPARAM key, LPARAM flags)
 {
     switch (key)
@@ -377,8 +379,17 @@ bool Win32Window::initialize(const std::string &name, size_t width, size_t heigh
 {
     destroy();
 
-    mParentClassName = name;
-    mChildClassName = name + "Child";
+    // Use a new window class name for ever window to ensure that a new window can be created
+    // even if the last one was not properly destroyed
+    static size_t windowIdx = 0;
+    std::ostringstream nameStream;
+    nameStream << name << "_" << windowIdx++;
+
+    mParentClassName = nameStream.str();
+    mChildClassName = mParentClassName + "_Child";
+
+    // Work around compile error from not defining "UNICODE" while Chromium does
+    const LPSTR idcArrow = MAKEINTRESOURCEA(32512);
 
     WNDCLASSEXA parentWindowClass = { 0 };
     parentWindowClass.cbSize = sizeof(WNDCLASSEXA);
@@ -388,7 +399,7 @@ bool Win32Window::initialize(const std::string &name, size_t width, size_t heigh
     parentWindowClass.cbWndExtra = 0;
     parentWindowClass.hInstance = GetModuleHandle(NULL);
     parentWindowClass.hIcon = NULL;
-    parentWindowClass.hCursor = LoadCursorA(NULL, IDC_ARROW);
+    parentWindowClass.hCursor = LoadCursorA(NULL, idcArrow);
     parentWindowClass.hbrBackground = 0;
     parentWindowClass.lpszMenuName = NULL;
     parentWindowClass.lpszClassName = mParentClassName.c_str();
@@ -405,7 +416,7 @@ bool Win32Window::initialize(const std::string &name, size_t width, size_t heigh
     childWindowClass.cbWndExtra = 0;
     childWindowClass.hInstance = GetModuleHandle(NULL);
     childWindowClass.hIcon = NULL;
-    childWindowClass.hCursor = LoadCursorA(NULL, IDC_ARROW);
+    childWindowClass.hCursor = LoadCursorA(NULL, idcArrow);
     childWindowClass.hbrBackground = 0;
     childWindowClass.lpszMenuName = NULL;
     childWindowClass.lpszClassName = mChildClassName.c_str();
@@ -414,7 +425,7 @@ bool Win32Window::initialize(const std::string &name, size_t width, size_t heigh
         return false;
     }
 
-    DWORD parentStyle = WS_VISIBLE | WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU;
+    DWORD parentStyle = WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU;
     DWORD parentExtendedStyle = WS_EX_APPWINDOW;
 
     RECT sizeRect = { 0, 0, width, height };
@@ -424,7 +435,7 @@ bool Win32Window::initialize(const std::string &name, size_t width, size_t heigh
                                     sizeRect.right - sizeRect.left, sizeRect.bottom - sizeRect.top, NULL, NULL,
                                     GetModuleHandle(NULL), this);
 
-    mNativeWindow = CreateWindowExA(0, mChildClassName.c_str(), name.c_str(), WS_VISIBLE | WS_CHILD, 0, 0, width, height,
+    mNativeWindow = CreateWindowExA(0, mChildClassName.c_str(), name.c_str(), WS_CHILD, 0, 0, width, height,
                                     mParentWindow, NULL, GetModuleHandle(NULL), this);
 
     mNativeDisplay = GetDC(mNativeWindow);
@@ -533,12 +544,12 @@ bool Win32Window::resize(int width, int height)
     return true;
 }
 
-bool Win32Window::setVisible(bool isVisible)
+void Win32Window::setVisible(bool isVisible)
 {
     int flag = (isVisible ? SW_SHOW : SW_HIDE);
 
-    return (ShowWindow(mNativeWindow, flag) == TRUE) &&
-           (ShowWindow(mParentWindow, flag) == TRUE);
+    ShowWindow(mParentWindow, flag);
+    ShowWindow(mNativeWindow, flag);
 }
 
 void Win32Window::pushEvent(Event event)