[Bf-blender-cvs] [7816dfc] testbuild: D765: Blender input method editor support for windows (diff #7).

Tamito Kajiyama noreply at git.blender.org
Wed Sep 10 02:26:31 CEST 2014


Commit: 7816dfc782e3b46280001e837049b235903e6823
Author: Tamito Kajiyama
Date:   Wed Sep 10 09:24:59 2014 +0900
Branches: testbuild
https://developer.blender.org/rB7816dfc782e3b46280001e837049b235903e6823

D765: Blender input method editor support for windows (diff #7).

===================================================================

M	intern/ghost/CMakeLists.txt
M	intern/ghost/GHOST_C-api.h
M	intern/ghost/GHOST_IWindow.h
M	intern/ghost/GHOST_Types.h
M	intern/ghost/SConscript
M	intern/ghost/intern/GHOST_C-api.cpp
A	intern/ghost/intern/GHOST_ImeWin32.cpp
A	intern/ghost/intern/GHOST_ImeWin32.h
M	intern/ghost/intern/GHOST_SystemWin32.cpp
M	intern/ghost/intern/GHOST_SystemWin32.h
M	intern/ghost/intern/GHOST_Window.h
M	intern/ghost/intern/GHOST_WindowWin32.cpp
M	intern/ghost/intern/GHOST_WindowWin32.h
M	source/blender/editors/interface/interface.c
M	source/blender/editors/interface/interface_handlers.c
M	source/blender/editors/interface/interface_intern.h
M	source/blender/editors/interface/interface_widgets.c
M	source/blender/editors/screen/screen_edit.c
M	source/blender/editors/space_console/console_draw.c
M	source/blender/editors/space_console/console_ops.c
M	source/blender/editors/space_console/space_console.c
M	source/blender/editors/space_info/textview.c
M	source/blender/editors/space_info/textview.h
M	source/blender/editors/space_text/space_text.c
M	source/blender/editors/space_text/text_draw.c
M	source/blender/editors/space_text/text_format.h
M	source/blender/editors/space_text/text_ops.c
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/windowmanager/WM_types.h
M	source/blender/windowmanager/intern/wm_event_system.c
M	source/blender/windowmanager/intern/wm_window.c
M	source/blender/windowmanager/wm_event_types.h
M	source/blender/windowmanager/wm_window.h

===================================================================

diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt
index cfa2f54..2b0d664 100644
--- a/intern/ghost/CMakeLists.txt
+++ b/intern/ghost/CMakeLists.txt
@@ -28,6 +28,7 @@ set(INC
 	../string
 	../../source/blender/imbuf
 	../../source/blender/makesdna
+	../../source/blender/blenlib
 )
 
 set(INC_SYS
@@ -277,6 +278,7 @@ elseif(WIN32)
 		intern/GHOST_SystemPathsWin32.cpp
 		intern/GHOST_WindowWin32.cpp
 		intern/GHOST_DropTargetWin32.cpp
+		intern/GHOST_ImeWin32.cpp
 
 		intern/GHOST_DisplayManagerWin32.h
 		intern/GHOST_DropTargetWin32.h
@@ -284,6 +286,7 @@ elseif(WIN32)
 		intern/GHOST_SystemPathsWin32.h
 		intern/GHOST_WindowWin32.h
 		intern/GHOST_TaskbarWin32.h
+		intern/GHOST_ImeWin32.h
 	)
 
 	if(WITH_INPUT_NDOF)
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index c877a3b..f78a853 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -889,6 +889,38 @@ extern int GHOST_UseNativePixels(void);
  */
 extern float GHOST_GetNativePixelSize(GHOST_WindowHandle windowhandle);
 
+/**
+ * Enable the IME attached to the given window, i.e. allows user-input
+ * events to be dispatched to the IME.
+ * \param window_handle
+ *     Represents the window handle of the caller.
+ * \param x requested x-coordinate of the rectangle
+ * \param y requested y-coordinate of the rectangle
+ * \param w requested width of the rectangle
+ * \param h requested height of the rectangle
+ * \param complete
+ *     Represents whether or not to complete the ongoing composition.
+ *     + true
+ *       After finishing the ongoing composition and close its IME windows,
+ *       start another composition and display its IME windows to the given
+ *       position.
+ *     + false
+ *       Just move the IME windows of the ongoing composition to the given
+ *       position without finishing it.
+ */
+extern void GHOST_enableIME(GHOST_WindowHandle windowhandle,
+							GHOST_TInt32 x,
+							GHOST_TInt32 y,
+							GHOST_TInt32 w,
+							GHOST_TInt32 h,
+							int complete);
+/**
+ * Disable the IME attached to the given window, i.e. prohibits any user-input
+ * events from being dispatched to the IME.
+ * \param window_handle
+ *     Represents the window handle of the caller.
+ */
+extern void GHOST_disableIME(GHOST_WindowHandle windowhandle);
 
 #ifdef __cplusplus
 }
diff --git a/intern/ghost/GHOST_IWindow.h b/intern/ghost/GHOST_IWindow.h
index c6befff..51265e5 100644
--- a/intern/ghost/GHOST_IWindow.h
+++ b/intern/ghost/GHOST_IWindow.h
@@ -323,6 +323,34 @@ public:
 
 	virtual float getNativePixelSize(void) = 0;
 
+	/**
+	* Enable the IME attached to the given window, i.e. allows user-input
+	* events to be dispatched to the IME.
+	* \param x requested x-coordinate of the rectangle
+	* \param y requested y-coordinate of the rectangle
+	* \param w requested width of the rectangle
+	* \param h requested height of the rectangle
+	* \param complete
+	*     Represents whether or not to complete the ongoing composition.
+	*     + true
+	*       After finishing the ongoing composition and close its IME windows,
+	*       start another composition and display its IME windows to the given
+	*       position.
+	*     + false
+	*       Just move the IME windows of the ongoing composition to the given
+	*       position without finishing it.
+	*/
+	virtual void enableIME(GHOST_TInt32 x,
+						   GHOST_TInt32 y,
+						   GHOST_TInt32 w,
+						   GHOST_TInt32 h,
+						   int completed) = 0;
+
+	/**
+	* Disable the IME attached to the given window, i.e. prohibits any user-input
+	* events from being dispatched to the IME.
+	*/
+	virtual void disableIME() = 0;
 	
 #ifdef WITH_CXX_GUARDEDALLOC
 	MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_IWindow")
diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h
index 7333ba0..6a7d6f0 100644
--- a/intern/ghost/GHOST_Types.h
+++ b/intern/ghost/GHOST_Types.h
@@ -190,6 +190,10 @@ typedef enum {
 
 	GHOST_kEventTimer,
 
+	GHOST_kEventImeCompositionStart,
+	GHOST_kEventImeComposition,
+	GHOST_kEventImeCompositionEnd,
+
 	GHOST_kNumEventTypes
 } GHOST_TEventType;
 
@@ -436,6 +440,13 @@ typedef struct {
 	GHOST_TEventDataPtr data;
 } GHOST_TEventDragnDropData;
 
+/** same with wmImeData */
+typedef struct {
+	GHOST_TUserDataPtr result_len, composite_len; /** size_t */
+	GHOST_TUserDataPtr result, composite; /** char * utf8 encoding */
+	GHOST_TUserDataPtr tmp; /* custom temporal data */
+} GHOST_TEventImeData;
+
 typedef struct {
 	int count;
 	GHOST_TUns8 **strings;
diff --git a/intern/ghost/SConscript b/intern/ghost/SConscript
index 8075647..9c0d2dd 100644
--- a/intern/ghost/SConscript
+++ b/intern/ghost/SConscript
@@ -47,6 +47,7 @@ incs = [
     '#source/blender/imbuf',
     '#source/blender/makesdna',
     '../string',
+    '../../source/blender/blenlib',
     ]
 incs = ' '.join(incs)
 
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index eaa59f0..eba9fdc 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -914,3 +914,19 @@ float GHOST_GetNativePixelSize(GHOST_WindowHandle windowhandle)
 	return 1.0f;
 }
 
+void GHOST_enableIME(GHOST_WindowHandle windowhandle,
+					 GHOST_TInt32 x,
+					 GHOST_TInt32 y,
+					 GHOST_TInt32 w,
+					 GHOST_TInt32 h,
+					 int complete)
+{
+	GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
+	window->enableIME(x, y, w, h, complete);
+}
+
+void GHOST_disableIME(GHOST_WindowHandle windowhandle)
+{
+	GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
+	window->disableIME();
+}
\ No newline at end of file
diff --git a/intern/ghost/intern/GHOST_ImeWin32.cpp b/intern/ghost/intern/GHOST_ImeWin32.cpp
new file mode 100644
index 0000000..d4a0876
--- /dev/null
+++ b/intern/ghost/intern/GHOST_ImeWin32.cpp
@@ -0,0 +1,444 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+//
+// ***** BEGIN BSD LICENSE BLOCK *****
+//
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//    * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//    * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//    * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// ***** END BSD LICENSE BLOCK *****
+//
+
+/** \file ghost/intern/GHOST_ImeWin32.cpp
+*  \ingroup GHOST
+*  \date	Aug 27, 2014
+*/
+
+#include "GHOST_C-api.h"
+#include "GHOST_ImeWin32.h"
+#include "GHOST_WindowWin32.h"
+#include "BLI_string_utf8.h"
+
+IME_Rect::IME_Rect(int _x, int _y, int _width, int _height)
+	: x(_x), y(_y), width(_width), height(_height) {
+}
+
+// "imm32.lib" is required by IMM32 APIs used in this file.
+// NOTE(hbono): To comply with a comment from Darin, I have added
+// this #pragma directive instead of adding "imm32.lib" to a project file.
+#pragma comment(lib, "imm32.lib")
+
+///////////////////////////////////////////////////////////////////////////////
+// GHOST_ImeWin32
+
+GHOST_ImeWin32::GHOST_ImeWin32()
+    : ime_status_(false),
+      input_language_id_(LANG_USER_DEFAULT),
+      is_composing_(false),
+      system_caret_(false),
+      caret_rect_(-1, -1, 0, 0),
+	  is_first(true),
+	  is_enable(true)
+{
+}
+
+GHOST_ImeWin32::~GHOST_ImeWin32() {
+}
+
+bool GHOST_ImeWin32::SetInputLanguage() {
+  // Retrieve the current keyboard layout from Windows and determine whether
+  // or not the current input context has IMEs.
+  // Also save its input language for language-specific operations required
+  // while composing a text.
+  HKL keyboard_layout = ::GetKeyboardLayout(0);
+  input_language_id_ = reinterpret_cast<LANGID>(keyboard_layout);
+  ime_status_ = (::ImmIsIME(keyboard_layout) == TRUE) ? true : false;
+  return ime_status_;
+}
+
+
+void GHOST_ImeWin32::CreateImeWindow(HWND window_handle) {
+  // When a user disables TSF (Text Service Framework) and CUAS (Cicero
+  // Unaware Application Support), Chinese IMEs somehow ignore function calls
+  // to ::ImmSetCandidateWindow(), i.e. they do not move their candidate
+  // window to the position given as its parameters, and use the position
+  // of the current system caret instead, i.e. it uses ::GetCaretPos() to
+  // retrieve the position of their IME candidate window.
+  // Therefore, we create a temporary system caret for Chinese IMEs and use
+  // it during this input context.
+  // Since some third-party Japanese IME also uses ::GetCaretPos() to determine
+  // their window position, we also create a caret for Japanese IMEs.
+  if (PRIMARYLANGID(input_language_id_) == LANG_CHINESE ||
+      PRIMARYLANGID(input_language_id_) == LANG_JAPANESE) {
+    if (!system_caret_) {
+      if (::CreateCaret(window_handle, NULL, 1, 1)) {
+        system_caret_ = true;
+      }
+    }
+  }
+  // Restore the positions of the IME windows.
+  UpdateImeWindow(window_handle);
+}
+
+void G

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list