You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

01-str2599-fltk-1.3.x-keyboard-x11.patch 9.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. diff -ur fltk-1.3.0r9619.org/FL/Fl_Widget.H fltk-1.3.0r9619/FL/Fl_Widget.H
  2. --- fltk-1.3.0r9619.org/FL/Fl_Widget.H 2012-04-23 22:12:06.000000000 +0200
  3. +++ fltk-1.3.0r9619/FL/Fl_Widget.H 2012-06-18 13:46:07.302320825 +0200
  4. @@ -171,6 +171,7 @@
  5. GROUP_RELATIVE = 1<<16, ///< position this widget relative to the parent group, not to the window
  6. COPIED_TOOLTIP = 1<<17, ///< the widget tooltip is internally copied, its destruction is handled by the widget
  7. FULLSCREEN = 1<<18, ///< a fullscreen window (Fl_Window)
  8. + SIMPLE_KEYBOARD = 1<<19, ///< the widget wants simple, consistent keypresses and not advanced input (like character composition and CJK input)
  9. // (space for more flags)
  10. USERFLAG3 = 1<<29, ///< reserved for 3rd party extensions
  11. USERFLAG2 = 1<<30, ///< reserved for 3rd party extensions
  12. @@ -776,6 +777,35 @@
  13. */
  14. void clear_changed() {flags_ &= ~CHANGED;}
  15. + /**
  16. + Returns if the widget sees a simplified keyboard model or not.
  17. +
  18. + Normally widgets get a full-featured keyboard model that is geared
  19. + towards text input. This includes support for compose sequences and
  20. + advanced input methods, commonly used for asian writing system. This
  21. + system however has downsides in that extra graphic can be presented
  22. + to the user and that a physical key press doesn't correspond directly
  23. + to a FLTK event.
  24. +
  25. + Widgets that need a direct correspondence between actual key events
  26. + and those seen by the widget can swith to the simplified keyboard
  27. + model.
  28. +
  29. + \retval 0 if the widget uses the normal keyboard model
  30. + \see set_changed(), clear_changed()
  31. + */
  32. + unsigned int simple_keyboard() const {return flags_&SIMPLE_KEYBOARD;}
  33. +
  34. + /** Marks a widget to use the simple keyboard model.
  35. + \see changed(), clear_changed()
  36. + */
  37. + void set_simple_keyboard() {flags_ |= SIMPLE_KEYBOARD;}
  38. +
  39. + /** Marks a widget to use the normal keyboard model.
  40. + \see changed(), set_changed()
  41. + */
  42. + void set_normal_keyboard() {flags_ &= ~SIMPLE_KEYBOARD;}
  43. +
  44. /** Gives the widget the keyboard focus.
  45. Tries to make this widget be the Fl::focus() widget, by first sending
  46. it an FL_FOCUS event, and if it returns non-zero, setting
  47. diff -ur fltk-1.3.0r9619.org/src/Fl.cxx fltk-1.3.0r9619/src/Fl.cxx
  48. --- fltk-1.3.0r9619.org/src/Fl.cxx 2012-03-23 17:47:53.000000000 +0100
  49. +++ fltk-1.3.0r9619/src/Fl.cxx 2012-06-18 13:46:07.303320877 +0200
  50. @@ -70,6 +70,8 @@
  51. extern double fl_mac_flush_and_wait(double time_to_wait, char in_idle);
  52. #endif // WIN32
  53. +extern void fl_update_focus(void);
  54. +
  55. //
  56. // Globals...
  57. //
  58. @@ -876,6 +878,8 @@
  59. fl_oldfocus = p;
  60. }
  61. e_number = old_event;
  62. + // let the platform code do what it needs
  63. + fl_update_focus();
  64. }
  65. }
  66. diff -ur fltk-1.3.0r9619.org/src/Fl_grab.cxx fltk-1.3.0r9619/src/Fl_grab.cxx
  67. --- fltk-1.3.0r9619.org/src/Fl_grab.cxx 2012-03-23 17:47:53.000000000 +0100
  68. +++ fltk-1.3.0r9619/src/Fl_grab.cxx 2012-06-18 13:46:07.303320877 +0200
  69. @@ -29,6 +29,7 @@
  70. // override_redirect, it does similar things on WIN32.
  71. extern void fl_fix_focus(); // in Fl.cxx
  72. +void fl_update_focus(void);
  73. #ifdef WIN32
  74. // We have to keep track of whether we have captured the mouse, since
  75. @@ -80,6 +81,7 @@
  76. #endif
  77. }
  78. grab_ = win;
  79. + fl_update_focus();
  80. } else {
  81. if (grab_) {
  82. #ifdef WIN32
  83. @@ -98,6 +100,7 @@
  84. XFlush(fl_display);
  85. #endif
  86. grab_ = 0;
  87. + fl_update_focus();
  88. fl_fix_focus();
  89. }
  90. }
  91. diff -ur fltk-1.3.0r9619.org/src/Fl_x.cxx fltk-1.3.0r9619/src/Fl_x.cxx
  92. --- fltk-1.3.0r9619.org/src/Fl_x.cxx 2012-06-18 13:46:07.205316173 +0200
  93. +++ fltk-1.3.0r9619/src/Fl_x.cxx 2012-06-18 13:46:18.216844629 +0200
  94. @@ -298,6 +298,7 @@
  95. Colormap fl_colormap;
  96. XIM fl_xim_im = 0;
  97. XIC fl_xim_ic = 0;
  98. +Window fl_xim_win = 0;
  99. char fl_is_over_the_spot = 0;
  100. static XRectangle status_area;
  101. @@ -583,6 +584,65 @@
  102. if(xim_styles) XFree(xim_styles);
  103. }
  104. +void fl_xim_deactivate(void);
  105. +
  106. +void fl_xim_activate(Window xid)
  107. +{
  108. + if (!fl_xim_im)
  109. + return;
  110. +
  111. + // If the focused window has changed, then use the brute force method
  112. + // of completely recreating the input context.
  113. + if (fl_xim_win != xid) {
  114. + fl_xim_deactivate();
  115. +
  116. + fl_new_ic();
  117. + fl_xim_win = xid;
  118. +
  119. + XSetICValues(fl_xim_ic,
  120. + XNFocusWindow, fl_xim_win,
  121. + XNClientWindow, fl_xim_win,
  122. + NULL);
  123. + }
  124. +
  125. + fl_set_spot(spotf, spots, spot.x, spot.y, spot.width, spot.height);
  126. +}
  127. +
  128. +void fl_xim_deactivate(void)
  129. +{
  130. + if (!fl_xim_ic)
  131. + return;
  132. +
  133. + XDestroyIC(fl_xim_ic);
  134. + fl_xim_ic = NULL;
  135. +
  136. + fl_xim_win = 0;
  137. +}
  138. +
  139. +extern Fl_Window *fl_xfocus;
  140. +
  141. +void fl_update_focus(void)
  142. +{
  143. + Fl_Widget *focus;
  144. +
  145. + focus = Fl::grab();
  146. + if (!focus)
  147. + focus = Fl::focus();
  148. + if (!focus)
  149. + return;
  150. +
  151. + if (focus->simple_keyboard()) {
  152. + fl_xim_deactivate();
  153. + } else {
  154. + // fl_xfocus should always be set if something has focus, but let's
  155. + // play it safe
  156. + if (!fl_xfocus || !fl_xid(fl_xfocus))
  157. + return;
  158. +
  159. + fl_xim_activate(fl_xid(fl_xfocus));
  160. + }
  161. +}
  162. +
  163. void fl_open_display() {
  164. if (fl_display) return;
  165. @@ -917,10 +977,9 @@
  166. XEvent xevent = thisevent;
  167. fl_xevent = &thisevent;
  168. Window xid = xevent.xany.window;
  169. - static Window xim_win = 0;
  170. if (fl_xim_ic && xevent.type == DestroyNotify &&
  171. - xid != xim_win && !fl_find(xid))
  172. + xid != fl_xim_win && !fl_find(xid))
  173. {
  174. XIM xim_im;
  175. xim_im = XOpenIM(fl_display, NULL, NULL, NULL);
  176. @@ -935,48 +994,10 @@
  177. return 0;
  178. }
  179. - if (fl_xim_ic && (xevent.type == FocusIn))
  180. - {
  181. -#define POOR_XIM
  182. -#ifdef POOR_XIM
  183. - if (xim_win != xid)
  184. - {
  185. - xim_win = xid;
  186. - XDestroyIC(fl_xim_ic);
  187. - fl_xim_ic = NULL;
  188. - fl_new_ic();
  189. - XSetICValues(fl_xim_ic,
  190. - XNFocusWindow, xevent.xclient.window,
  191. - XNClientWindow, xid,
  192. - NULL);
  193. - }
  194. - fl_set_spot(spotf, spots, spot.x, spot.y, spot.width, spot.height);
  195. -#else
  196. - if (Fl::first_window() && Fl::first_window()->modal()) {
  197. - Window x = fl_xid(Fl::first_window());
  198. - if (x != xim_win) {
  199. - xim_win = x;
  200. - XSetICValues(fl_xim_ic,
  201. - XNFocusWindow, xim_win,
  202. - XNClientWindow, xim_win,
  203. - NULL);
  204. - fl_set_spot(spotf, spots, spot.x, spot.y, spot.width, spot.height);
  205. - }
  206. - } else if (xim_win != xid && xid) {
  207. - xim_win = xid;
  208. - XSetICValues(fl_xim_ic,
  209. - XNFocusWindow, xevent.xclient.window,
  210. - XNClientWindow, xid,
  211. - //XNFocusWindow, xim_win,
  212. - //XNClientWindow, xim_win,
  213. - NULL);
  214. - fl_set_spot(spotf, spots, spot.x, spot.y, spot.width, spot.height);
  215. - }
  216. -#endif
  217. + if (fl_xim_ic) {
  218. + if (XFilterEvent((XEvent *)&xevent, 0))
  219. + return 1;
  220. }
  221. -
  222. - if ( XFilterEvent((XEvent *)&xevent, 0) )
  223. - return(1);
  224. #if USE_XRANDR
  225. if( XRRUpdateConfiguration_f && xevent.type == randrEventBase + RRScreenChangeNotify) {
  226. @@ -1326,15 +1347,15 @@
  227. //static XComposeStatus compose;
  228. len = XLookupString((XKeyEvent*)&(xevent.xkey),
  229. buffer, buffer_len, &keysym, 0/*&compose*/);
  230. - if (keysym && keysym < 0x400) { // a character in latin-1,2,3,4 sets
  231. - // force it to type a character (not sure if this ever is needed):
  232. - // if (!len) {buffer[0] = char(keysym); len = 1;}
  233. - len = fl_utf8encode(XKeysymToUcs(keysym), buffer);
  234. - if (len < 1) len = 1;
  235. - // ignore all effects of shift on the keysyms, which makes it a lot
  236. - // easier to program shortcuts and is Windoze-compatible:
  237. - keysym = XKeycodeToKeysym(fl_display, keycode, 0);
  238. - }
  239. + // XLookupString() is only defined to return Latin-1 (although it
  240. + // often gives you more). To be safe, use our own lookups based on
  241. + // keysym.
  242. + len = fl_utf8encode(XKeysymToUcs(keysym), buffer);
  243. + if (len < 1)
  244. + len = 1;
  245. + // ignore all effects of shift on the keysyms, which makes it a lot
  246. + // easier to program shortcuts and is Windoze-compatable:
  247. + keysym = XKeycodeToKeysym(fl_display, keycode, 0);
  248. }
  249. // MRS: Can't use Fl::event_state(FL_CTRL) since the state is not
  250. // set until set_event_xy() is called later...
  251. diff -ur fltk-1.3.0r9619.org/src/xutf8/imKStoUCS.c fltk-1.3.0r9619/src/xutf8/imKStoUCS.c
  252. --- fltk-1.3.0r9619.org/src/xutf8/imKStoUCS.c 2009-03-13 23:43:43.000000000 +0100
  253. +++ fltk-1.3.0r9619/src/xutf8/imKStoUCS.c 2012-06-18 13:46:07.304320930 +0200
  254. @@ -266,6 +266,12 @@
  255. 0x20a8, 0x20a9, 0x20aa, 0x20ab, 0x20ac /* 0x20a8-0x20af */
  256. };
  257. +static unsigned short const keysym_to_unicode_fe50_fe60[] = {
  258. + 0x0300, 0x0301, 0x0302, 0x0303, 0x0304, 0x0306, 0x0307, 0x0308, /* 0xfe50-0xfe57 */
  259. + 0x030a, 0x030b, 0x030c, 0x0327, 0x0328, 0x1da5, 0x3099, 0x309a, /* 0xfe58-0xfe5f */
  260. + 0x0323 /* 0xfe60-0xfe67 */
  261. +};
  262. +
  263. unsigned int
  264. KeySymToUcs4(KeySym keysym)
  265. {
  266. @@ -315,6 +321,8 @@
  267. return keysym_to_unicode_1e9f_1eff[keysym - 0x1e9f];
  268. else if (keysym > 0x209f && keysym < 0x20ad)
  269. return keysym_to_unicode_20a0_20ac[keysym - 0x20a0];
  270. + else if (keysym > 0xfe4f && keysym < 0xfe61)
  271. + return keysym_to_unicode_fe50_fe60[keysym - 0xfe50];
  272. else
  273. return 0;
  274. }