Commit: 36fc98cb0ba193084888c18b13f8645ee50bd25f
Author: Severin
Date:   Tue Dec 2 01:24:16 2014 +0100
Branches: input_method_editor
https://developer.blender.org/rB36fc98cb0ba193084888c18b13f8645ee50bd25f

IME: Various fixes + usual cleanup

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

M       intern/ghost/intern/GHOST_WindowWin32.cpp
M       source/blender/editors/include/ED_space_api.h
M       source/blender/editors/interface/interface_handlers.c
M       source/blender/editors/interface/interface_intern.h
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/editors/space_text/text_draw.c
M       source/blender/editors/util/ed_util.c
M       source/blender/makesdna/DNA_windowmanager_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

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

diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp 
b/intern/ghost/intern/GHOST_WindowWin32.cpp
index 5ae5ec0..4e38488 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.cpp
+++ b/intern/ghost/intern/GHOST_WindowWin32.cpp
@@ -1054,7 +1054,6 @@ GHOST_TSuccess GHOST_WindowWin32::endProgressBar()
 #ifdef WITH_INPUT_IME
 void GHOST_WindowWin32::beginIME(GHOST_TInt32 x, GHOST_TInt32 y, GHOST_TInt32 
w, GHOST_TInt32 h, int completed)
 {
-       h = 20; /* text height */
        this->getImeInput()->BeginIME(this->getHWND(),  GHOST_Rect(x, y - h , 
x, y), (bool)completed);
 }
 
diff --git a/source/blender/editors/include/ED_space_api.h 
b/source/blender/editors/include/ED_space_api.h
index d268c57..204c0e1 100644
--- a/source/blender/editors/include/ED_space_api.h
+++ b/source/blender/editors/include/ED_space_api.h
@@ -78,5 +78,6 @@ void *ED_region_draw_cb_customdata(void *handle);
 /* generic callbacks */
 /* ed_util.c */
 void ED_region_draw_mouse_line_cb(const struct bContext *C, struct ARegion 
*ar, void *arg_info);
+void ED_text_draw_underline(int x, int y, int len, int height);
 
 #endif /* __ED_SPACE_API_H__ */
diff --git a/source/blender/editors/interface/interface_handlers.c 
b/source/blender/editors/interface/interface_handlers.c
index ec212c7..fef9e20 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -2635,7 +2635,7 @@ 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;
+       bool is_ime_composing = ime_data && ime_data->is_ime_composite;
 
        switch (event->type) {
                case MOUSEMOVE:
@@ -2831,10 +2831,10 @@ static void ui_do_but_textedit(bContext *C, uiBlock 
*block, uiBut *but, uiHandle
                }
 
                if ((event->ascii || event->utf8_buf[0]) &&
-                       (retval == WM_UI_HANDLER_CONTINUE) &&
-                       !is_ime_composing
+                       (retval == WM_UI_HANDLER_CONTINUE)
 #ifdef WITH_INPUT_IME
-                       && !WM_event_is_ime_switch(event)
+                        && !is_ime_composing &&
+                        !WM_event_is_ime_switch(event)
 #endif
                        )
                {
@@ -2874,7 +2874,6 @@ static void ui_do_but_textedit(bContext *C, uiBlock 
*block, uiBut *but, uiHandle
 
 #ifdef WITH_INPUT_IME
        if (event->type == WM_IME_COMPOSITE_START || event->type == 
WM_IME_COMPOSITE_EVENT) {
-               but->editime = ime_data;
                changed = true;
                
                if (event->type == WM_IME_COMPOSITE_START && but->selend > 
but->selsta)
@@ -2886,7 +2885,6 @@ static void ui_do_but_textedit(bContext *C, uiBlock 
*block, uiBut *but, uiHandle
        }
        else if (event->type == WM_IME_COMPOSITE_END) {
                changed = true;
-               but->editime = NULL;
        }
 #endif
 
diff --git a/source/blender/editors/interface/interface_intern.h 
b/source/blender/editors/interface/interface_intern.h
index 3a8f8b7..3a42ca5 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -302,7 +302,6 @@ struct uiBut {
        float *editvec;
        void *editcoba;
        void *editcumap;
-       void *editime;
        
        /* pointer back */
        uiBlock *block;
diff --git a/source/blender/editors/screen/screen_edit.c 
b/source/blender/editors/screen/screen_edit.c
index 816479f..d1af93b 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -1436,9 +1436,7 @@ void ED_screen_set_subwinactive(bContext *C, wmEvent 
*event)
                        /* notifier invokes freeing the buttons... causing a 
bit too much redraws */
                        if (oldswin != scr->subwinactive) {
 #ifdef WITH_INPUT_IME
-                               /* when cursor leave a region, disable IME,
-                                * used for disable IME when cursor leave text 
or console region
-                                */
+                               /* when cursor leaves a region, disable IME */
                                wm_window_IME_end(win);
 #endif
 
diff --git a/source/blender/editors/space_console/space_console.c 
b/source/blender/editors/space_console/space_console.c
index 80e2623..6e02a4c 100644
--- a/source/blender/editors/space_console/space_console.c
+++ b/source/blender/editors/space_console/space_console.c
@@ -170,6 +170,7 @@ static void console_cursor(wmWindow *win, ScrArea *sa, 
ARegion *ar)
                wmcursor = CURSOR_STD;
        }
 #ifdef WITH_INPUT_IME
+       /* XXX find a better place */
        else {
                wm_window_IME_begin(win, ar->winrct.xmin, ar->winrct.ymin, 0, 
0, true);
        }
@@ -255,22 +256,24 @@ static void console_main_area_draw(const bContext *C, 
ARegion *ar)
        console_history_verify(C); /* make sure we have some command line */
 
 #ifdef WITH_INPUT_IME
-       /* get cursor position from console_textview_main and repositon ime 
window */
        if (is_ime_active) {
+               /* get cursor position from console_textview_main and repositon 
ime window */
                ConsoleLine *line = (ConsoleLine *)sc->history.last;
                ime_data->cursor_pos_text = line->cursor + strlen(sc->prompt);
        }
        else {
+               /* delete ImeData if it didn't exist previously */
                ime_data = NULL;
        }
 
        console_textview_main(sc, ar, ime_data);
 
-       if (is_ime_active) {
+       if (ime_data && is_ime_active) {
                int x = ime_data->cursor_xy[0];
                int y = ime_data->cursor_xy[1];
 
                ui_region_to_window(ar, &x, &y);
+
                wm_window_IME_begin(win, x + 5, y, 0, 0, false);
 
                ime_data->cursor_xy[0] = ime_data->cursor_xy[1] = 0;
diff --git a/source/blender/editors/space_text/space_text.c 
b/source/blender/editors/space_text/space_text.c
index 362b286..2e6ce2c 100644
--- a/source/blender/editors/space_text/space_text.c
+++ b/source/blender/editors/space_text/space_text.c
@@ -449,13 +449,17 @@ static void text_main_area_draw(const bContext *C, 
ARegion *ar)
        
        /* get cursor position from draw_text_main and repositon ime window */
 #ifdef WITH_INPUT_IME
+       if (!is_ime_active) {
+               ime_data = NULL;
+       }
        draw_text_main(win, st, ar);
 
-       if (is_ime_active) {
+       if (ime_data && is_ime_active) {
                int x = ime_data->cursor_xy[0];
                int y = ime_data->cursor_xy[1];
 
                ui_region_to_window(ar, &x, &y);
+
                wm_window_IME_begin(win, x + 5, y, 0, 0, false);
 
                ime_data->cursor_xy[0] = ime_data->cursor_xy[1] = 0;
diff --git a/source/blender/editors/space_text/text_draw.c 
b/source/blender/editors/space_text/text_draw.c
index 7166fd0..216937b 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -48,6 +48,8 @@
 
 #include "BIF_gl.h"
 
+#include "ED_space_api.h"
+
 #include "UI_interface.h"
 #include "UI_resources.h"
 #include "UI_view2d.h"
@@ -374,10 +376,6 @@ static const char *txt_utf8_forward_columns(const char 
*str, int columns, int *p
        return p;
 }
 
-static void text_draw_ime_underline(SpaceText *st, int x, int y, int len, int 
height) {
-       glRecti(x, y - 4, x + len, y - 4 + height);
-}
-
 static int text_draw_wrapped(SpaceText *st, const char *str, int x, int y, int 
w, const char *format, int skip)
 {
        const bool use_syntax = (st->showsyntax && format);
@@ -427,10 +425,10 @@ static int text_draw_wrapped(SpaceText *st, const char 
*str, int x, int y, int w
                                len = text_font_draw_character_utf8(st, x, y, 
str + ma);
                                /* draw underline */
                                if (format && format[a] == FMT_TYPE_ULINE)
-                                       text_draw_ime_underline(st, x, y, len, 
1);
+                                       ED_text_draw_underline(x, y, len, 1);
                                else
                                if (format && format[a] == FMT_TYPE_TULINE)
-                                       text_draw_ime_underline(st, x, y, len, 
2);
+                                       ED_text_draw_underline(x, y, len, 2);
                                x += len;
                                fpos++;
                        }
@@ -460,10 +458,10 @@ static int text_draw_wrapped(SpaceText *st, const char 
*str, int x, int y, int w
 
                /* draw underline */
                if (format && format[a] == FMT_TYPE_ULINE)
-                       text_draw_ime_underline(st, x, y, len, 1);
+                       ED_text_draw_underline(x, y, len, 1);
                else
                if (format && format[a] == FMT_TYPE_TULINE)
-                       text_draw_ime_underline(st, x, y, len, 2);
+                       ED_text_draw_underline(x, y, len, 2);
                x += len;
        }
 
@@ -516,10 +514,10 @@ static void text_draw(SpaceText *st, wmImeData *ime_data, 
char *str, int cshift,
                        len = text_font_draw_character_utf8(st, x, y, in + 
str_shift);
                        /* draw underline */
                        if (fmt_prev == FMT_TYPE_ULINE)
-                               text_draw_ime_underline(st, x, y, len, 1);
+                               ED_text_draw_underline(x, y, len, 1);
                        else
                        if (fmt_prev == FMT_TYPE_TULINE)
-                               text_draw_ime_underline(st, x, y, len, 2);
+                               ED_text_draw_underline(x, y, len, 2);
                        x += len;
                        str_shift += BLI_str_utf8_size_safe(in + str_shift);
                }
@@ -1358,8 +1356,7 @@ void draw_text_main(wmWindow *win, SpaceText *st, ARegion 
*ar)
 {
        Text *text = st->text;
        TextFormatType *tft;
-       TextLine *tmp, bak = {0};
-       wmImeData *ime_data = win->ime_data;
+       TextLine *tmp;
        rcti scroll, back;
        char linenr[12];
        int i, x, y, winx, linecount = 0, lineno = 0;
@@ -1367,6 +1364,14 @@ void draw_text_main(wmWindow *win, SpaceText *st, 
ARegion *ar)
        int margin_column_x;
        /* don't draw lines below this */
        const int clip_min_y = -(int)(st->lheight_dpi - 1);
+#ifdef WITH_INPUT_IME
+       TextLine bak = {0};
+       wmImeData *ime_data = win->ime_data;
+       bool is_ime_active = ime_data &&
+                            ime_data->cursor_xy &&
+                            ime_data->composite_len &&
+                            BLI_rcti_isect_pt_v(&ar->winrct, 
&win->eventstate->x);
+#endif
 
        /* if no text, nothing to do */
        if (!text)
@@ -1378,11 +1383,7 @@ void draw_text_main(wmWindow *win, SpaceText *st, 
ARegion *ar)
 
 #ifdef WITH_INPUT_IME
        /* if is composing, backup and insert composition string */
-       if (ime_data &&
-               ime_data->cursor_xy &&
-               ime_data->composite_len &&
-               text->curl)
-       {
+       if (is_ime_active && text->curl) {
                int clen = ime_data->composite_len;
                int tlen = text->curl->len;
                int clen_utf8 = BLI_strnlen_utf8(ime_data->composite, clen);
@@ -1547,16 +1548,16 @@ void draw_text_main(wmWindow *win, SpaceText *st, 
ARegion *ar)
        
        text_font_end(st);
 
+#ifdef WITH_INPUT_IME
        if (bak.line) {
                MEM_freeN(text->curl->line);
                MEM_freeN(text->curl->format);
                *text->curl = bak;
-#ifdef WITH_INPUT_IME
                /* recover the cursor */
                text->curc -= ime_data->cursor_position;
                text->selc -= ime_data->cursor_position;
-#endif
        }
+#endif
 }
 
 /************************** update ***************************/
diff --git a/source/blender/editors/util/ed_util.c 
b/source/blender/editors/util/ed_util.c
index 86b9696..ad9a873 100644
--- a/source/blender/editors/util/ed_util.c

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to