[Bf-blender-cvs] [d399927] input_method_editor: IME: Deduplicate wmImeData + minor cleanup

Severin noreply at git.blender.org
Mon Dec 1 15:20:20 CET 2014


Commit: d399927749c4d222bf3f0ac623880ec4e8626bc8
Author: Severin
Date:   Mon Dec 1 15:12:24 2014 +0100
Branches: input_method_editor
https://developer.blender.org/rBd399927749c4d222bf3f0ac623880ec4e8626bc8

IME: Deduplicate wmImeData + minor cleanup

* deduplicate use of wmImeData
* add missing "ifdef WITH_INPUT_IME"s
* usual minor cleanup

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

M	source/blender/editors/interface/interface_handlers.c
M	source/blender/editors/interface/interface_widgets.c
M	source/blender/editors/space_console/console_draw.c
M	source/blender/editors/space_console/console_intern.h
M	source/blender/editors/space_console/console_ops.c
M	source/blender/editors/space_console/space_console.c
M	source/blender/editors/space_info/info_draw.c
M	source/blender/editors/space_info/info_intern.h
M	source/blender/editors/space_info/info_report.c
M	source/blender/editors/space_info/space_info.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_intern.h
M	source/blender/editors/space_text/text_ops.c
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/windowmanager/intern/wm_event_system.c

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

diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 0161211..ec212c7 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -2636,8 +2636,6 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
 	wmWindow *win = CTX_wm_window(C);
 	wmImeData *ime_data = win->ime_data;
 	bool is_ime_composing = win->is_ime_composite;
-	/* most os using ctrl/oskey + space to switch ime, avoid added space */
-	bool is_ime_switch = WM_event_is_ime_switch(event);
 
 	switch (event->type) {
 		case MOUSEMOVE:
@@ -2832,9 +2830,13 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
 				break;
 		}
 
-		if ((event->ascii || event->utf8_buf[0]) && 
+		if ((event->ascii || event->utf8_buf[0]) &&
 			(retval == WM_UI_HANDLER_CONTINUE) &&
-			!is_ime_composing && !is_ime_switch)
+			!is_ime_composing
+#ifdef WITH_INPUT_IME
+			&& !WM_event_is_ime_switch(event)
+#endif
+			)
 		{
 			char ascii = event->ascii;
 			const char *utf8_buf = event->utf8_buf;
@@ -2870,6 +2872,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
 			update = true;
 	}
 
+#ifdef WITH_INPUT_IME
 	if (event->type == WM_IME_COMPOSITE_START || event->type == WM_IME_COMPOSITE_EVENT) {
 		but->editime = ime_data;
 		changed = true;
@@ -2885,6 +2888,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
 		changed = true;
 		but->editime = NULL;
 	}
+#endif
 
 	if (changed) {
 		/* only update when typing for TAB key */
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index ab1a859..c027406 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;
+	wmImeData *ime_data;
 
 	UI_fontstyle_set(fstyle);
 	
@@ -1274,12 +1274,12 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
 			drawstr_left_len = INT_MAX;
 
 #ifdef WITH_INPUT_IME
-			ime = ui_but_get_ime_data(but);
+			ime_data = ui_but_get_ime_data(but);
 
-			if (ime && ime->composite_len) {
+			if (ime_data && ime_data->composite_len) {
 				/* insert composite string into cursor pos */
 				BLI_snprintf(drawstr, UI_MAX_DRAW_STR, "%s%s%s", /* XXX drawstr is limited to 400 chars - check if that's enough */
-				             but->editstr, ime->composite,
+				             but->editstr, ime_data->composite,
 				             but->editstr + but->pos);
 			}
 			else {
@@ -1324,8 +1324,8 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
 		vpos = but->pos;
 #ifdef WITH_INPUT_IME
 		/* if is ime compositing, move the cursor */
-		if (ime && ime->composite_len && ime->cursor_position != -1) {
-			vpos += ime->cursor_position;
+		if (ime_data && ime_data->composite_len && ime_data->cursor_position != -1) {
+			vpos += ime_data->cursor_position;
 		}
 #else
 		(void)ime;
@@ -1352,8 +1352,8 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
 		}
 
 		/* composite underline */
-		if (ime && ime->composite_len) {
-			int draw_start, draw_end, target_start = ime->target_start, target_end = ime->target_end;
+		if (ime_data && ime_data->composite_len) {
+			int draw_start, draw_end, target_start = ime_data->target_start, target_end = ime_data->target_end;
 
 			if (drawstr[0] != 0) {
 
@@ -1365,7 +1365,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
 				}
 
 				draw_end = BLF_width(fstyle->uifont_id, drawstr + but->ofs, 
-								     ime->composite_len + but->pos - but->ofs);
+				                     ime_data->composite_len + but->pos - but->ofs);
 
 				glColor4ubv((unsigned char *)wcol->text);
 				glRecti(rect->xmin + draw_start,
@@ -1385,7 +1385,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
 					}
 
 					draw_end = BLF_width(fstyle->uifont_id, drawstr + but->ofs,
-										 target_end + target_start - but->ofs);
+					                     target_end + target_start - but->ofs);
 
 					glRecti(rect->xmin + draw_start,
 						rect->ymin + 3,
diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c
index de3815c..a8ee10d 100644
--- a/source/blender/editors/space_console/console_draw.c
+++ b/source/blender/editors/space_console/console_draw.c
@@ -162,7 +162,7 @@ static void console_cursor_wrap_offset(const char *str, int width, int *row, int
 	return;
 }
 
-static int console_textview_line_color(struct TextViewContext *tvc, unsigned char fg[3], unsigned char UNUSED(bg[3]))
+static int console_textview_line_color(struct TextViewContext *tvc, wmImeData *ime_data, unsigned char fg[3], unsigned char UNUSED(bg[3]))
 {
 	ConsoleLine *cl_iter = (ConsoleLine *)tvc->iter;
 
@@ -182,12 +182,12 @@ static int console_textview_line_color(struct TextViewContext *tvc, unsigned cha
 		pen[1] = -2 - tvc->lheight * offl;
 
 		/* consider the effect of composition string */
-		if (tvc->ime && tvc->ime->composite_len) {
+		if (ime_data && ime_data->composite_len) {
 			char *end = NULL;
-			if (tvc->ime->cursor_position != -1)
-				end = tvc->ime->composite + tvc->ime->cursor_position;
+			if (ime_data->cursor_position != -1)
+				end = ime_data->composite + ime_data->cursor_position;
 
-			console_cursor_wrap_offset(tvc->ime->composite, tvc->console_width, &offl, &offc, end);
+			console_cursor_wrap_offset(ime_data->composite, tvc->console_width, &offl, &offc, end);
 
 			/* cursor inside the composition string */
 			pen[0] = tvc->cwidth * offc;
@@ -213,9 +213,9 @@ static int console_textview_line_color(struct TextViewContext *tvc, unsigned cha
 
 #ifdef WITH_INPUT_IME
 		/* cursor following */
-		if (tvc->ime && tvc->ime->composite_len) {
-			tvc->ime->cursor_xy[0] = (xy[0] + pen[0]) + 1;
-			tvc->ime->cursor_xy[1] = (xy[1] + pen[1]) - 1;
+		if (ime_data && ime_data->composite_len) {
+			ime_data->cursor_xy[0] = (xy[0] + pen[0]) + 1;
+			ime_data->cursor_xy[1] = (xy[1] + pen[1]) - 1;
 		}
 #endif
 
@@ -231,8 +231,8 @@ static void console_textview_const_colors(TextViewContext *UNUSED(tvc), unsigned
 	UI_GetThemeColor4ubv(TH_CONSOLE_SELECT, bg_sel);
 }
 
-static int console_textview_main__internal(struct SpaceConsole *sc, ARegion *ar, int draw,
-                                           int mval[2], void **mouse_pick, int *pos_pick)
+static int console_textview_main__internal(struct SpaceConsole *sc, ARegion *ar, wmImeData *ime_data,
+                                           int draw, int mval[2], void **mouse_pick, int *pos_pick)
 {
 	ConsoleLine cl_dummy = {NULL};
 	int ret = 0;
@@ -260,32 +260,33 @@ static int console_textview_main__internal(struct SpaceConsole *sc, ARegion *ar,
 	tvc.ymax = v2d->cur.ymax;
 	tvc.winx = ar->winx - V2D_SCROLL_WIDTH;
 
-	if (draw)
-		tvc.ime = sc->ime;
-	else
-		tvc.ime = NULL;
+#ifdef WITH_INPUT_IME
+	if (!draw) {
+		ime_data = NULL;
+	}
+#endif
 
 	console_scrollback_prompt_begin(sc, &cl_dummy);
-	ret = textview_draw(&tvc, draw, mval, mouse_pick, pos_pick);
+	ret = textview_draw(&tvc, ime_data, draw, mval, mouse_pick, pos_pick);
 	console_scrollback_prompt_end(sc, &cl_dummy);
 
 	return ret;
 }
 
 
-void console_textview_main(struct SpaceConsole *sc, ARegion *ar)
+void console_textview_main(struct SpaceConsole *sc, ARegion *ar, wmImeData *ime_data)
 {
 	int mval[2] = {INT_MAX, INT_MAX};
-	console_textview_main__internal(sc, ar, 1,  mval, NULL, NULL);
+	console_textview_main__internal(sc, ar, ime_data, 1, mval, NULL, NULL);
 }
 
 int console_textview_height(struct SpaceConsole *sc, ARegion *ar)
 {
 	int mval[2] = {INT_MAX, INT_MAX};
-	return console_textview_main__internal(sc, ar, 0,  mval, NULL, NULL);
+	return console_textview_main__internal(sc, ar, NULL, 0,  mval, NULL, NULL);
 }
 
-int console_char_pick(struct SpaceConsole *sc, ARegion *ar, const int mval[2])
+int console_char_pick(struct SpaceConsole *sc, ARegion *ar, wmImeData *ime_data, const int mval[2])
 {
 	int pos_pick = 0;
 	void *mouse_pick = NULL;
@@ -294,6 +295,6 @@ int console_char_pick(struct SpaceConsole *sc, ARegion *ar, const int mval[2])
 	mval_clamp[0] = CLAMPIS(mval[0], CONSOLE_DRAW_MARGIN, ar->winx - CONSOLE_DRAW_MARGIN);
 	mval_clamp[1] = CLAMPIS(mval[1], CONSOLE_DRAW_MARGIN, ar->winy - CONSOLE_DRAW_MARGIN);
 
-	console_textview_main__internal(sc, ar, 0, mval_clamp, &mouse_pick, &pos_pick);
+	console_textview_main__internal(sc, ar, ime_data, 0, mval_clamp, &mouse_pick, &pos_pick);
 	return pos_pick;
 }
diff --git a/source/blender/editors/space_console/console_intern.h b/source/blender/editors/space_console/console_intern.h
index 00f1f8c2..dde6c58 100644
--- a/source/blender/editors/space_console/console_intern.h
+++ b/source/blender/editors/space_console/console_intern.h
@@ -35,9 +35,9 @@ struct ReportList;
 struct bContext;
 
 /* console_draw.c */
-void console_textview_main(struct SpaceConsole *sc, struct ARegion *ar);
+void console_textview_main(struct SpaceConsole *sc, struct ARegion *ar, struct wmImeData *ime_data);
 int console_textview_height(struct SpaceConsole *sc, struct ARegion *ar); /* needed to calculate the scrollbar */
-int console_char_pick(struct SpaceConsole *sc, struct ARegion *ar, const int mval[2]);
+int console_char_pick(struct SpaceConsole *sc, struct ARegion *ar, struct wmImeData *ime_data, const int mval[2]);
 
 void console_scrollback_prompt_begin(struct SpaceConsole *sc, ConsoleLine *cl_dummy);
 void console_scrollback_prompt_end(struct SpaceConsole *sc, ConsoleLine *cl_dummy);
diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c
index c0901d9..4f1e5e3 100644
--- a/source/blender/editors/space_console/console_ops.c
+++ b/source/blender/editors/space_console/console_ops.c
@@ -1058,10 +1058,10 @@ typedef struct SetConsoleCu

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list