| @@ -1,32 +1,189 @@ | | | @@ -1,32 +1,189 @@ |
1 | $NetBSD: patch-xwindow_fb_x__display.c,v 1.1 2013/06/23 06:02:39 tsutsui Exp $ | | 1 | $NetBSD: patch-xwindow_fb_x__display.c,v 1.2 2013/06/26 11:29:47 tsutsui Exp $ |
2 | | | 2 | |
3 | Pull fix from http://mlterm.sf.net/mlterm-3.2.0-fixes.patch | | 3 | Pull fix from http://mlterm.sf.net/mlterm-3.2.0-fixes.patch |
4 | > Fix the bug which caused segmentation fault in closing input method | | 4 | > Fix the bug which caused segmentation fault in closing input method |
5 | > status window. | | 5 | > status window. |
6 | | | 6 | |
| | | 7 | Pull update for ibus on mlterm-fb from rev c881417 |
| | | 8 | https://bitbucket.org/arakiken/mlterm/commits/c8814173cb051b32ce1d1b440b4033bd0bba567d#chg-xwindow/fb/x_display.c |
| | | 9 | > fb/x_display.c: get_ps2_kcode() is added to convert usb keycode |
| | | 10 | > to ps2 keycode for iBus on NetBSD/OpenBSD framebuffer. |
| | | 11 | |
7 | --- xwindow/fb/x_display.c.orig 2013-05-26 02:13:13.000000000 +0000 | | 12 | --- xwindow/fb/x_display.c.orig 2013-05-26 02:13:13.000000000 +0000 |
8 | +++ xwindow/fb/x_display.c | | 13 | +++ xwindow/fb/x_display.c |
9 | @@ -849,19 +849,17 @@ receive_event_for_multi_roots( | | 14 | @@ -169,6 +169,7 @@ static x_display_t * opened_disps[] = { |
| | | 15 | #if defined(__FreeBSD__) |
| | | 16 | static keymap_t keymap ; |
| | | 17 | #elif defined(__NetBSD__) |
| | | 18 | +static u_int kbd_type ; |
| | | 19 | static struct wskbd_map_data keymap ; |
| | | 20 | static int console_id = -1 ; |
| | | 21 | static int orig_console_mode = WSDISPLAYIO_MODE_EMUL ; /* 0 */ |
| | | 22 | @@ -1589,6 +1590,149 @@ receive_key_event(void) |
| | | 23 | |
| | | 24 | #elif defined(__NetBSD__) |
10 | | | 25 | |
11 | x_window_receive_event( _disp.roots[0] , xev) ; | | 26 | +/* For iBus */ |
| | | 27 | +static u_int |
| | | 28 | +get_ps2_kcode( |
| | | 29 | + u_int kcode |
| | | 30 | + ) |
| | | 31 | +{ |
| | | 32 | + if( kbd_type == WSKBD_TYPE_USB) |
| | | 33 | + { |
| | | 34 | + static u_char map_table1[] = |
| | | 35 | + { |
| | | 36 | + 30 , /* A (4) */ |
| | | 37 | + 48 , /* B */ |
| | | 38 | + 46 , /* C */ |
| | | 39 | + 32 , /* D */ |
| | | 40 | + 18 , /* E */ |
| | | 41 | + 33 , /* F */ |
| | | 42 | + 34 , /* G (10) */ |
| | | 43 | + 35 , /* H */ |
| | | 44 | + 23 , /* I */ |
| | | 45 | + 36 , /* J */ |
| | | 46 | + 37 , /* K */ |
| | | 47 | + 38 , /* L */ |
| | | 48 | + 50 , /* M */ |
| | | 49 | + 49 , /* N */ |
| | | 50 | + 24 , /* O */ |
| | | 51 | + 25 , /* P */ |
| | | 52 | + 16 , /* Q (20) */ |
| | | 53 | + 19 , /* R */ |
| | | 54 | + 31 , /* S */ |
| | | 55 | + 20 , /* T */ |
| | | 56 | + 22 , /* U */ |
| | | 57 | + 47 , /* V */ |
| | | 58 | + 17 , /* W */ |
| | | 59 | + 45 , /* X */ |
| | | 60 | + 21 , /* Y */ |
| | | 61 | + 44 , /* Z */ |
| | | 62 | + 2 , /* 1 (30) */ |
| | | 63 | + 3 , /* 2 */ |
| | | 64 | + 4 , /* 3 */ |
| | | 65 | + 5 , /* 4 */ |
| | | 66 | + 6 , /* 5 */ |
| | | 67 | + 7 , /* 6 */ |
| | | 68 | + 8 , /* 7 */ |
| | | 69 | + 9 , /* 8 */ |
| | | 70 | + 10 , /* 9 */ |
| | | 71 | + 11 , /* 0 */ |
| | | 72 | + 28 , /* Enter (40) */ |
| | | 73 | + 1 , /* ESC */ |
| | | 74 | + 14 , /* BackSpace */ |
| | | 75 | + 15 , /* Tab */ |
| | | 76 | + 57 , /* Space */ |
| | | 77 | + 12 , /* _ - */ |
| | | 78 | + 13 , /* + = */ |
| | | 79 | + 26 , /* { [ */ |
| | | 80 | + 27 , /* } ] */ |
| | | 81 | + 43 , /* \ | */ |
| | | 82 | + 0 , /* (50) */ |
| | | 83 | + 39 , /* : ; */ |
| | | 84 | + 40 , /* " ' */ |
| | | 85 | + 41 , /* ~ ` */ |
| | | 86 | + 51 , /* < , */ |
| | | 87 | + 52 , /* > . */ |
| | | 88 | + 53 , /* ? / */ |
| | | 89 | + 58 , /* CapsLock */ |
| | | 90 | + 59 , /* F1 */ |
| | | 91 | + 60 , /* F2 */ |
| | | 92 | + 61 , /* F3 (60) */ |
| | | 93 | + 62 , /* F4 */ |
| | | 94 | + 63 , /* F5 */ |
| | | 95 | + 64 , /* F6 */ |
| | | 96 | + 65 , /* F7 */ |
| | | 97 | + 66 , /* F8 */ |
| | | 98 | + 67 , /* F9 */ |
| | | 99 | + 68 , /* F10 */ |
| | | 100 | + 87 , /* F11 */ |
| | | 101 | + 88 , /* F12 */ |
| | | 102 | + 0 , /* Print Screen (70) */ |
| | | 103 | + 70 , /* ScreenLock */ |
| | | 104 | + 0 , /* Pause */ |
| | | 105 | + 110 , /* Insert */ |
| | | 106 | + 102 , /* Home */ |
| | | 107 | + 104 , /* Page Up */ |
| | | 108 | + 111 , /* Delete */ |
| | | 109 | + 107 , /* End */ |
| | | 110 | + 109 , /* Page Down */ |
| | | 111 | + 106 , /* Right */ |
| | | 112 | + 105 , /* Left (80) */ |
| | | 113 | + 108 , /* Down */ |
| | | 114 | + 103 , /* Up */ |
| | | 115 | + 69 , /* NumLock */ |
| | | 116 | + 0 , /* Num / */ |
| | | 117 | + 55 , /* Num * */ |
| | | 118 | + 74 , /* Num - */ |
| | | 119 | + 78 , /* Num + */ |
| | | 120 | + 0 , /* Num Enter */ |
| | | 121 | + 79 , /* Num 1 */ |
| | | 122 | + 80 , /* Num 2 (90) */ |
| | | 123 | + 81 , /* Num 3 */ |
| | | 124 | + 75 , /* Num 4 */ |
| | | 125 | + 76 , /* Num 5 */ |
| | | 126 | + 77 , /* Num 6 */ |
| | | 127 | + 71 , /* Num 7 */ |
| | | 128 | + 72 , /* Num 8 */ |
| | | 129 | + 73 , /* Num 9 */ |
| | | 130 | + 82 , /* Num 0 */ |
| | | 131 | + 83 , /* Num . */ |
| | | 132 | + } ; |
| | | 133 | + |
| | | 134 | + static u_char map_table2[] = |
| | | 135 | + { |
| | | 136 | + 29 , /* Control L (224) */ |
| | | 137 | + 42 , /* Shift L */ |
| | | 138 | + 56 , /* Alt L */ |
| | | 139 | + 0 , /* Windows L */ |
| | | 140 | + 97 , /* Control R */ |
| | | 141 | + 54 , /* Shift R */ |
| | | 142 | + 100 , /* Alt R (230) */ |
| | | 143 | + 0 , /* Windows R */ |
| | | 144 | + } ; |
| | | 145 | + |
| | | 146 | + if( 4 <= kcode) |
| | | 147 | + { |
| | | 148 | + if( kcode <= 99) |
| | | 149 | + { |
| | | 150 | + return map_table1[kcode - 4] ; |
| | | 151 | + } |
| | | 152 | + else if( 224 <= kcode) |
| | | 153 | + { |
| | | 154 | + if( kcode <= 231) |
| | | 155 | + { |
| | | 156 | + return map_table2[kcode - 224] ; |
| | | 157 | + } |
| | | 158 | + } |
| | | 159 | + } |
| | | 160 | + |
| | | 161 | + return 0 ; |
| | | 162 | + } |
| | | 163 | + else |
| | | 164 | + { |
| | | 165 | + return kcode ; |
| | | 166 | + } |
| | | 167 | +} |
| | | 168 | + |
| | | 169 | static void |
| | | 170 | process_wskbd_event( |
| | | 171 | struct wscons_event * ev |
| | | 172 | @@ -1656,7 +1800,7 @@ process_wskbd_event( |
| | | 173 | xev.ksym = ksym ; |
| | | 174 | xev.state = _mouse.button_state | |
| | | 175 | _display.key_state ; |
| | | 176 | - xev.keycode = ev->value ; |
| | | 177 | + xev.keycode = get_ps2_kcode( ev->value) ; |
12 | | | 178 | |
13 | - if( redraw_im_win) | | 179 | receive_event_for_multi_roots( &xev) ; |
14 | + if( redraw_im_win && _disp.num_of_roots == 2) | | | |
15 | { | | | |
16 | /* Restart drawing input method window */ | | | |
17 | _disp.roots[1]->is_mapped = 1 ; | | | |
18 | } | | | |
19 | | | 180 | |
20 | - if( ! check_visibility_of_im_window()) | | 181 | @@ -1884,6 +2028,8 @@ open_display(void) |
21 | + if( check_visibility_of_im_window()) | | 182 | ioctl( _display.fd , WSKBDIO_SETVERSION , &mode) ; |
22 | { | | 183 | #endif |
23 | - return ; | | | |
24 | + expose_window( _disp.roots[1] , _disp.roots[1]->x , _disp.roots[1]->y , | | | |
25 | + ACTUAL_WIDTH(_disp.roots[1]) , ACTUAL_HEIGHT(_disp.roots[1])) ; | | | |
26 | } | | | |
27 | - | | | |
28 | - expose_window( _disp.roots[1] , _disp.roots[1]->x , _disp.roots[1]->y , | | | |
29 | - ACTUAL_WIDTH(_disp.roots[1]) , ACTUAL_HEIGHT(_disp.roots[1])) ; | | | |
30 | } | | | |
31 | | | 184 | |
32 | #ifndef __FreeBSD__ | | 185 | + ioctl( _display.fd , WSKBDIO_GTYPE , &kbd_type) ; |
| | | 186 | + |
| | | 187 | keymap.maplen = KS_NUMKEYCODES ; |
| | | 188 | keymap.map = map ; |
| | | 189 | ioctl( _display.fd , WSKBDIO_GETMAP , &keymap) ; |