ime-placement.patch 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. diff -aur old/src/text-context.cpp new/src/text-context.cpp
  2. --- old/src/text-context.cpp 2011-07-08 08:25:09.468790000 -1000
  3. +++ new/src/text-context.cpp 2014-04-21 14:48:22.668759004 -1000
  4. @@ -684,6 +684,17 @@
  5. // articifically here, for the text object does not exist yet:
  6. double cursor_height = sp_desktop_get_font_size_tool(desktop);
  7. sp_ctrlline_set_coords(SP_CTRLLINE(tc->cursor), dtp, dtp + Geom::Point(0, cursor_height));
  8. + if (tc->imc) {
  9. + GdkRectangle im_cursor;
  10. + Geom::Point const top_left = SP_EVENT_CONTEXT(tc)->desktop->get_display_area().corner(3);
  11. + Geom::Point const cursor_size(0, cursor_height);
  12. + Geom::Point const im_position = SP_EVENT_CONTEXT(tc)->desktop->d2w(dtp + cursor_size - top_left);
  13. + im_cursor.x = (int) floor(im_position[Geom::X]);
  14. + im_cursor.y = (int) floor(im_position[Geom::Y]);
  15. + im_cursor.width = 0;
  16. + im_cursor.height = (int) -floor(SP_EVENT_CONTEXT(tc)->desktop->d2w(cursor_size)[Geom::Y]);
  17. + gtk_im_context_set_cursor_location(tc->imc, &im_cursor);
  18. + }
  19. event_context->_message_context->set(Inkscape::NORMAL_MESSAGE, _("Type text; <b>Enter</b> to start new line.")); // FIXME:: this is a copy of a string from _update_cursor below, do not desync
  20. event_context->within_tolerance = false;
  21. @@ -1560,8 +1571,6 @@
  22. static void
  23. sp_text_context_update_cursor(SPTextContext *tc, bool scroll_to_see)
  24. {
  25. - GdkRectangle im_cursor = { 0, 0, 1, 1 };
  26. -
  27. // due to interruptible display, tc may already be destroyed during a display update before
  28. // the cursor update (can't do both atomically, alas)
  29. if (!tc->desktop) return;
  30. @@ -1586,10 +1595,17 @@
  31. sp_ctrlline_set_coords(SP_CTRLLINE(tc->cursor), d0, d1);
  32. /* fixme: ... need another transformation to get canvas widget coordinate space? */
  33. - im_cursor.x = (int) floor(d0[Geom::X]);
  34. - im_cursor.y = (int) floor(d0[Geom::Y]);
  35. - im_cursor.width = (int) floor(d1[Geom::X]) - im_cursor.x;
  36. - im_cursor.height = (int) floor(d1[Geom::Y]) - im_cursor.y;
  37. + if (tc->imc) {
  38. + GdkRectangle im_cursor = { 0, 0, 1, 1 };
  39. + Geom::Point const top_left = SP_EVENT_CONTEXT(tc)->desktop->get_display_area().corner(3);
  40. + Geom::Point const im_d0 = SP_EVENT_CONTEXT(tc)->desktop->d2w(d0 - top_left);
  41. + Geom::Point const im_d1 = SP_EVENT_CONTEXT(tc)->desktop->d2w(d1 - top_left);
  42. + im_cursor.x = (int) floor(im_d0[Geom::X]);
  43. + im_cursor.y = (int) floor(im_d1[Geom::Y]);
  44. + im_cursor.width = (int) floor(im_d1[Geom::X]) - im_cursor.x;
  45. + im_cursor.height = (int) floor(im_d0[Geom::Y]) - im_cursor.y;
  46. + gtk_im_context_set_cursor_location(tc->imc, &im_cursor);
  47. + }
  48. tc->show = TRUE;
  49. tc->phase = 1;
  50. @@ -1631,9 +1647,6 @@
  51. }
  52. }
  53. - if (tc->imc) {
  54. - gtk_im_context_set_cursor_location(tc->imc, &im_cursor);
  55. - }
  56. SP_EVENT_CONTEXT(tc)->desktop->emitToolSubselectionChanged((gpointer)tc);
  57. }