[Bf-blender-cvs] [e42f974] input_method_editor: Finish support for CMake flag WITH_INPUT_IME

Severin noreply at git.blender.org
Tue Nov 18 20:07:43 CET 2014


Commit: e42f974ae6056f4aaebca819222a12f1b9040396
Author: Severin
Date:   Tue Nov 18 20:05:05 2014 +0100
Branches: input_method_editor
https://developer.blender.org/rBe42f974ae6056f4aaebca819222a12f1b9040396

Finish support for CMake flag WITH_INPUT_IME

Note: implementation not finished, needs a bit cleanup

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

M	intern/ghost/CMakeLists.txt
M	intern/ghost/GHOST_IWindow.h
M	intern/ghost/intern/GHOST_C-api.cpp
M	intern/ghost/intern/GHOST_ImeWin32.cpp
M	intern/ghost/intern/GHOST_ImeWin32.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/CMakeLists.txt
M	source/blender/editors/interface/interface_handlers.c
M	source/blender/editors/interface/interface_widgets.c
M	source/blender/editors/screen/screen_edit.c
M	source/blender/editors/space_console/space_console.c
M	source/blender/editors/space_text/space_text.c
M	source/blender/windowmanager/CMakeLists.txt
M	source/blender/windowmanager/intern/wm_window.c
M	source/blender/windowmanager/wm_window.h

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

diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt
index acd8c1d..8f30564 100644
--- a/intern/ghost/CMakeLists.txt
+++ b/intern/ghost/CMakeLists.txt
@@ -282,9 +282,10 @@ elseif(WIN32)
 
 	if(WITH_INPUT_IME)
 		add_definitions(-DWITH_INPUT_IME)
+
 		list(APPEND SRC
 			intern/GHOST_ImeWin32.cpp
-			
+				
 			intern/GHOST_ImeWin32.h
 		)
 	endif()
diff --git a/intern/ghost/GHOST_IWindow.h b/intern/ghost/GHOST_IWindow.h
index e76068c..58d8172 100644
--- a/intern/ghost/GHOST_IWindow.h
+++ b/intern/ghost/GHOST_IWindow.h
@@ -331,6 +331,7 @@ public:
 
 	virtual float getNativePixelSize(void) = 0;
 
+#ifdef WITH_INPUT_IME
 	/**
 	 * Enable IME attached to the given window, i.e. allows user-input
 	 * events to be dispatched to the IME.
@@ -342,7 +343,7 @@ public:
 	 *     true:  Start a new composition
 	 *     false: Move the IME windows to the given position without finishing it.
 	 */
-	virtual void enableIME(GHOST_TInt32 x,
+	virtual void beginIME(GHOST_TInt32 x,
                            GHOST_TInt32 y,
                            GHOST_TInt32 w,
                            GHOST_TInt32 h,
@@ -352,7 +353,8 @@ public:
 	 * 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;
+	virtual void endIME() = 0;
+#endif /* WITH_INPUT_IME */
 	
 #ifdef WITH_CXX_GUARDEDALLOC
 	MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_IWindow")
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index 0158329..71725c1 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -925,13 +925,13 @@ void GHOST_BeginIME(GHOST_WindowHandle windowhandle,
                      int complete)
 {
 	GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
-	window->enableIME(x, y, w, h, complete);
+	window->beginIME(x, y, w, h, complete);
 }
 
 void GHOST_EndIME(GHOST_WindowHandle windowhandle)
 {
 	GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
-	window->disableIME();
+	window->endIME();
 }
 
 #endif /* WITH_INPUT_IME */
diff --git a/intern/ghost/intern/GHOST_ImeWin32.cpp b/intern/ghost/intern/GHOST_ImeWin32.cpp
index 7430c12..21e842a 100644
--- a/intern/ghost/intern/GHOST_ImeWin32.cpp
+++ b/intern/ghost/intern/GHOST_ImeWin32.cpp
@@ -209,7 +209,7 @@ void GHOST_ImeWin32::CleanupComposition(HWND window_handle)
 void GHOST_ImeWin32::CheckFirst(HWND window_handle)
 {
 	if (is_first) {
-		this->DisableIME(window_handle);
+		this->EndIME(window_handle);
 		is_first = false;
 	}
 }
@@ -411,7 +411,7 @@ bool GHOST_ImeWin32::GetComposition(HWND window_handle, LPARAM lparam, ImeCompos
 }
 
 
-void GHOST_ImeWin32::DisableIME(HWND window_handle)
+void GHOST_ImeWin32::EndIME(HWND window_handle)
 {
 	/**
 	 * A renderer process have moved its input focus to a password input
@@ -428,7 +428,7 @@ void GHOST_ImeWin32::DisableIME(HWND window_handle)
 }
 
 
-void GHOST_ImeWin32::EnableIME(HWND window_handle, const GHOST_Rect &caret_rect, bool complete)
+void GHOST_ImeWin32::BeginIME(HWND window_handle, const GHOST_Rect &caret_rect, bool complete)
 {
 	if (is_enable && complete) return;
 	is_enable = true;
diff --git a/intern/ghost/intern/GHOST_ImeWin32.h b/intern/ghost/intern/GHOST_ImeWin32.h
index 648588a..3c73263 100644
--- a/intern/ghost/intern/GHOST_ImeWin32.h
+++ b/intern/ghost/intern/GHOST_ImeWin32.h
@@ -298,7 +298,7 @@ public:
 	 *       Just move the IME windows of the ongoing composition to the given
 	 *       position without finishing it.
 	 */
-	void EnableIME(HWND window_handle,
+	void BeginIME(HWND window_handle,
 	               const GHOST_Rect& caret_rect,
 	               bool complete);
 
@@ -311,7 +311,7 @@ public:
 	 *   * window_handle [in] (HWND)
 	 *     Represents the window handle of the caller.
 	 */
-	void DisableIME(HWND window_handle);
+	void EndIME(HWND window_handle);
 
 	/* Updatg resultInfo and compInfo */
 	void UpdateInfo(HWND window_handle);
diff --git a/intern/ghost/intern/GHOST_Window.h b/intern/ghost/intern/GHOST_Window.h
index 1a79285..9be8651 100644
--- a/intern/ghost/intern/GHOST_Window.h
+++ b/intern/ghost/intern/GHOST_Window.h
@@ -296,7 +296,7 @@ public:
 	}
 
 #ifdef WITH_INPUT_IME
-	virtual void enableIME(GHOST_TInt32 x,
+	virtual void beginIME(GHOST_TInt32 x,
 	                       GHOST_TInt32 y,
 	                       GHOST_TInt32 w,
 	                       GHOST_TInt32 h,
@@ -305,7 +305,7 @@ public:
 		/* do nothing temporarily if not in windows */
 	}
 
-	virtual void disableIME() 
+	virtual void endIME()
 	{
 		/* do nothing temporarily if not in windows */
 	}
diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp
index f8c49af..a09e431 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.cpp
+++ b/intern/ghost/intern/GHOST_WindowWin32.cpp
@@ -1052,15 +1052,15 @@ GHOST_TSuccess GHOST_WindowWin32::endProgressBar()
 
 
 #ifdef WITH_INPUT_IME
-void GHOST_WindowWin32::enableIME(GHOST_TInt32 x, GHOST_TInt32 y, GHOST_TInt32 w, GHOST_TInt32 h, int completed)
+void GHOST_WindowWin32::beginIME(GHOST_TInt32 x, GHOST_TInt32 y, GHOST_TInt32 w, GHOST_TInt32 h, int completed)
 {
 	h = 20; /* text height */
-	this->getImeInput()->EnableIME(this->getHWND(),	GHOST_Rect(x, y-h, x, y), (bool)completed);
+	this->getImeInput()->BeginIME(this->getHWND(),	GHOST_Rect(x, y-h, x, y), (bool)completed);
 }
 
 
-void GHOST_WindowWin32::disableIME()
+void GHOST_WindowWin32::endIME()
 {
-	this->getImeInput()->DisableIME(this->getHWND());
+	this->getImeInput()->EndIME(this->getHWND());
 }
 #endif /* WITH_INPUT_IME */
diff --git a/intern/ghost/intern/GHOST_WindowWin32.h b/intern/ghost/intern/GHOST_WindowWin32.h
index e05752b..9696a7c 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.h
+++ b/intern/ghost/intern/GHOST_WindowWin32.h
@@ -259,13 +259,13 @@ public:
 #ifdef WITH_INPUT_IME
 	GHOST_ImeWin32 *getImeInput() {return &m_imeImput;}
 
-	virtual void enableIME(GHOST_TInt32 x,
+	virtual void beginIME(GHOST_TInt32 x,
 	                       GHOST_TInt32 y,
 	                       GHOST_TInt32 w,
 	                       GHOST_TInt32 h,
 	                       int completed);
 
-	virtual void disableIME();
+	virtual void endIME();
 #endif /* WITH_INPUT_IME */
 
 private:
diff --git a/source/blender/editors/interface/CMakeLists.txt b/source/blender/editors/interface/CMakeLists.txt
index b921d17..972eca7 100644
--- a/source/blender/editors/interface/CMakeLists.txt
+++ b/source/blender/editors/interface/CMakeLists.txt
@@ -71,6 +71,12 @@ if(WITH_PYTHON)
 	add_definitions(-DWITH_PYTHON)
 endif()
 
+if(WIN32)
+	if(WITH_INPUT_IME)
+		add_definitions(-DWITH_INPUT_IME)
+	endif()
+endif()
+
 add_definitions(${GL_DEFINITIONS})
 
 blender_add_lib(bf_editor_interface "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index c84c722..fd69ebc 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -2426,27 +2426,28 @@ static bool ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, const in
 	return changed;
 }
 
+#ifdef WITH_INPUT_IME
 /* enable ime, and set up uibut ime data */
-static void ui_textedit_ime_enable(wmWindow *win, uiBut *UNUSED(but)) 
+static void ui_textedit_ime_begin(wmWindow *win, uiBut *UNUSED(but))
 {
 	int x, y;
 	/* enable IME and position to cursor, it's a trick */
 	x = win->eventstate->x;
 	/* flip y and move down a bit, prevent the IME panel cover the edit button */
 	y = win->eventstate->y - 12;
-	wm_window_IME_enable(win, x, y, 0, 0, true);
+	wm_window_IME_begin(win, x, y, 0, 0, true);
 }
 
 /* disable ime, and clear uibut ime data */
-static void ui_textedit_ime_disable(wmWindow *win, uiBut *UNUSED(but)) 
+static void ui_textedit_ime_end(wmWindow *win, uiBut *UNUSED(but))
 {
-	wm_window_IME_disable(win);
+	wm_window_IME_end(win);
 }
 
 void ui_but_ime_reposition(uiBut *but, int x, int y, int complete) 
 {
 	ui_region_to_window(but->active->region, &x, &y);
-	wm_window_IME_enable(but->active->window, x, y-4, 0, 0, complete);
+	wm_window_IME_begin(but->active->window, x, y-4, 0, 0, complete);
 }
 
 wmImeData *ui_but_get_ime_data(uiBut *but) 
@@ -2456,9 +2457,11 @@ wmImeData *ui_but_get_ime_data(uiBut *but)
 	else
 		return NULL;
 }
+#endif /* WITH_INPUT_IME */
 
 static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
 {
+	wmWindow *win = CTX_wm_window(C);
 	int len;
 
 	if (data->str) {
@@ -2515,7 +2518,13 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
 
 	ui_but_update(but);
 	
-	WM_cursor_modal_set(CTX_wm_window(C), BC_TEXTEDITCURSOR);
+#ifdef WITH_INPUT_IME
+	WM_cursor_modal_set(win, BC_TEXTEDITCURSOR);
+
+	ui_textedit_ime_begin(win, but);
+#else
+	(void)win;
+#endif
 }
 
 static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data)
@@ -2552,10 +2561,14 @@ static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data)
 		but->pos = -1;
 	}
 
+#ifdef WITH_INPUT_IME
 	win = CTX_wm_window(C);
 	WM_cursor_modal_restore(win);
 
-	ui_textedit_ime_disable(win, but);
+	ui_textedit_ime_end(win, but);
+#else
+	(void)win;
+#endif
 }
 
 static void ui_textedit_next_but(uiBlock *block, uiBut *actbut, uiHandleButtonData *data)
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 5ea3bb1..457907b 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -1243,7 +1243,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
 	const char *drawstr_right = NULL;
 	char *drawstr_edit = NULL;
 	bool use_right_only = false;
-	wmImeData *ime = ui_but_get_ime_data(but);
+	wmImeData *ime;
 
 	UI_fontstyle_set(fstyle);
 	
@@ -1273,6 +1273,9 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
 			 * we rely on string being NULL terminated. */
 			drawstr_left_len = INT_MAX;
 
+#ifdef WITH_INPUT_IME
+			ime = ui_but_get_ime_data(but);
+
 			if (ime && ime->composite_len) 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list