ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/command.C
(Generate patch)

Comparing rxvt-unicode/src/command.C (file contents):
Revision 1.585 by root, Sun Jul 7 08:06:44 2019 UTC vs.
Revision 1.586 by sf-exg, Fri May 7 19:03:11 2021 UTC

1277#endif 1277#endif
1278 1278
1279void 1279void
1280rxvt_term::mouse_report (XButtonEvent &ev) 1280rxvt_term::mouse_report (XButtonEvent &ev)
1281{ 1281{
1282 int button_number, key_state = 0; 1282 int button_number, state = 0;
1283 int x, y; 1283 int x, y;
1284 int code = 32; 1284 bool release = ev.type == ButtonRelease;
1285 1285
1286 x = Pixel2Col (ev.x) + 1; 1286 x = Pixel2Col (ev.x) + 1;
1287 y = Pixel2Row (ev.y) + 1; 1287 y = Pixel2Row (ev.y) + 1;
1288 1288
1289 if (ev.type == MotionNotify) 1289 if (ev.type == MotionNotify)
1291 if (x == mouse_row && y == mouse_col) 1291 if (x == mouse_row && y == mouse_col)
1292 return; 1292 return;
1293 1293
1294 mouse_row = x; 1294 mouse_row = x;
1295 mouse_col = y; 1295 mouse_col = y;
1296 code += 32; 1296 state += 32;
1297 }
1298
1299 if (MEvent.button == AnyButton)
1300 button_number = 3;
1301 else
1302 { 1297 }
1298
1303 button_number = MEvent.button - Button1; 1299 button_number = MEvent.button - Button1;
1304 /* add 0x3D for wheel events, like xterm does */ 1300 /* add 0x3D for wheel events, like xterm does */
1305 if (button_number >= 3) 1301 if (button_number >= 3)
1306 button_number += 64 - 3; 1302 button_number += 64 - 3;
1307 }
1308 1303
1309 if (priv_modes & PrivMode_MouseX10) 1304 if (priv_modes & PrivMode_MouseX10)
1310 { 1305 {
1311 /* 1306 /*
1312 * do not report ButtonRelease 1307 * do not report ButtonRelease
1313 * no state info allowed 1308 * no state info allowed
1314 */ 1309 */
1315 key_state = 0; 1310 if (release)
1316 if (button_number == 3)
1317 return; 1311 return;
1318 } 1312 }
1319 else 1313 else
1320 { 1314 {
1321 /* XTerm mouse reporting needs these values: 1315 /* XTerm mouse reporting needs these values:
1323 * 8 = Meta 1317 * 8 = Meta
1324 * 16 = Control 1318 * 16 = Control
1325 * plus will add in our own Double-Click reporting 1319 * plus will add in our own Double-Click reporting
1326 * 32 = Double Click 1320 * 32 = Double Click
1327 */ 1321 */
1328 key_state = ((MEvent.state & ShiftMask) ? 4 : 0) 1322 state += ((MEvent.state & ShiftMask) ? 4 : 0)
1329 + ((MEvent.state & ModMetaMask) ? 8 : 0) 1323 + ((MEvent.state & ModMetaMask) ? 8 : 0)
1330 + ((MEvent.state & ControlMask) ? 16 : 0); 1324 + ((MEvent.state & ControlMask) ? 16 : 0);
1331#ifdef MOUSE_REPORT_DOUBLECLICK 1325#ifdef MOUSE_REPORT_DOUBLECLICK
1332 key_state += ((MEvent.clicks > 1) ? 32 : 0); 1326 state += ((MEvent.clicks > 1) ? 32 : 0);
1333#endif 1327#endif
1334 } 1328 }
1329
1330 int code = 32 + (release ? 3 : button_number) + state;
1335 1331
1336#if DEBUG_MOUSEREPORT 1332#if DEBUG_MOUSEREPORT
1337 fprintf (stderr, "Mouse ["); 1333 fprintf (stderr, "Mouse [");
1338 if (key_state & 16) 1334 if (state & 16)
1339 fputc ('C', stderr); 1335 fputc ('C', stderr);
1340 if (key_state & 4) 1336 if (state & 4)
1341 fputc ('S', stderr); 1337 fputc ('S', stderr);
1342 if (key_state & 8) 1338 if (state & 8)
1343 fputc ('A', stderr); 1339 fputc ('A', stderr);
1344 if (key_state & 32) 1340 if (state & 32)
1345 fputc ('2', stderr); 1341 fputc ('2', stderr);
1346 fprintf (stderr, "]: <%d>, %d/%d\n", 1342 fprintf (stderr, "]: <%d>, %d/%d\n",
1347 button_number, 1343 button_number,
1348 x, 1344 x,
1349 y); 1345 y);
1350#endif 1346#endif
1351 1347
1352#if ENABLE_FRILLS 1348#if ENABLE_FRILLS
1349 if (priv_modes & PrivMode_ExtMouseSGR)
1350 tt_printf ("\033[<%d;%d;%d%c",
1351 button_number + state,
1352 x,
1353 y,
1354 release ? 'm' : 'M');
1353 if (priv_modes & PrivMode_ExtMouseRight) 1355 else if (priv_modes & PrivMode_ExtMouseRight)
1354 tt_printf ("\033[%d;%d;%dM", 1356 tt_printf ("\033[%d;%d;%dM",
1355 code + button_number + key_state, 1357 code,
1356 x, 1358 x,
1357 y); 1359 y);
1358 else if (priv_modes & PrivMode_ExtModeMouse) 1360 else if (priv_modes & PrivMode_ExtModeMouse)
1359 tt_printf ("\033[M%c%lc%lc", 1361 tt_printf ("\033[M%c%lc%lc",
1360 code + button_number + key_state, 1362 code,
1361 wint_t (32 + x), 1363 wint_t (32 + x),
1362 wint_t (32 + y)); 1364 wint_t (32 + y));
1363 else 1365 else
1364#endif 1366#endif
1365 tt_printf ("\033[M%c%c%c", 1367 tt_printf ("\033[M%c%c%c",
1366 code + button_number + key_state, 1368 code,
1367 32 + x, 1369 32 + x,
1368 32 + y); 1370 32 + y);
1369} 1371}
1370 1372
1371/*{{{ process an X event */ 1373/*{{{ process an X event */
2149 && (ev.button != MEvent.button 2151 && (ev.button != MEvent.button
2150 || (ev.time - MEvent.time 2152 || (ev.time - MEvent.time
2151 > multiClickTime / 2))) 2153 > multiClickTime / 2)))
2152 { 2154 {
2153 MEvent.clicks = 0; 2155 MEvent.clicks = 0;
2154 MEvent.button = AnyButton; 2156 MEvent.button = ev.button;
2155 mouse_report (ev); 2157 mouse_report (ev);
2156 } 2158 }
2157#else /* MOUSE_REPORT_DOUBLECLICK */ 2159#else /* MOUSE_REPORT_DOUBLECLICK */
2158 MEvent.button = AnyButton; 2160 MEvent.button = ev.button;
2159 mouse_report (ev); 2161 mouse_report (ev);
2160#endif /* MOUSE_REPORT_DOUBLECLICK */ 2162#endif /* MOUSE_REPORT_DOUBLECLICK */
2161 return; 2163 return;
2162 } 2164 }
2163 2165
2874 { 2876 {
2875 /* DECSTR: soft terminal reset, used by our terminfo since 9.06 */ 2877 /* DECSTR: soft terminal reset, used by our terminfo since 9.06 */
2876 scr_soft_reset (); 2878 scr_soft_reset ();
2877 2879
2878 static const int pm_h[] = { 7, 25 }; 2880 static const int pm_h[] = { 7, 25 };
2879 static const int pm_l[] = { 1, 3, 4, 5, 6, 9, 66, 1000, 1001, 1005, 1015, 1049 }; 2881 static const int pm_l[] = { 1, 3, 4, 5, 6, 9, 66, 1000, 1001, 1005, 1006, 1015, 1049 };
2880 2882
2881 process_terminal_mode ('h', 0, ecb_array_length (pm_h), pm_h); 2883 process_terminal_mode ('h', 0, ecb_array_length (pm_h), pm_h);
2882 process_terminal_mode ('l', 0, ecb_array_length (pm_l), pm_l); 2884 process_terminal_mode ('l', 0, ecb_array_length (pm_l), pm_l);
2883 } 2885 }
2884 break; 2886 break;
3701 { 1002, PrivMode_MouseBtnEvent }, 3703 { 1002, PrivMode_MouseBtnEvent },
3702 { 1003, PrivMode_MouseAnyEvent }, 3704 { 1003, PrivMode_MouseAnyEvent },
3703#if ENABLE_FRILLS 3705#if ENABLE_FRILLS
3704 { 1004, PrivMode_FocusEvent }, 3706 { 1004, PrivMode_FocusEvent },
3705 { 1005, PrivMode_ExtModeMouse }, 3707 { 1005, PrivMode_ExtModeMouse },
3708 { 1006, PrivMode_ExtMouseSGR },
3706#endif 3709#endif
3707 { 1010, PrivMode_TtyOutputInh }, // rxvt extension 3710 { 1010, PrivMode_TtyOutputInh }, // rxvt extension
3708 { 1011, PrivMode_Keypress }, // rxvt extension 3711 { 1011, PrivMode_Keypress }, // rxvt extension
3709#if ENABLE_FRILLS 3712#if ENABLE_FRILLS
3710 { 1015, PrivMode_ExtMouseRight }, // urxvt extension of 1005 3713 { 1015, PrivMode_ExtMouseRight }, // urxvt extension of 1005
3979 case 38: // set fg color, ISO 8613-6 3982 case 38: // set fg color, ISO 8613-6
3980 case 48: // set bg color, ISO 8613-6 3983 case 48: // set bg color, ISO 8613-6
3981 { 3984 {
3982 unsigned int fgbg = arg[i] == 38 ? Color_fg : Color_bg; 3985 unsigned int fgbg = arg[i] == 38 ? Color_fg : Color_bg;
3983 unsigned int idx; 3986 unsigned int idx;
3984 3987
3985 if (nargs > i + 2 && arg[i + 1] == 5) 3988 if (nargs > i + 2 && arg[i + 1] == 5)
3986 { 3989 {
3987 idx = minCOLOR + arg[i + 2]; 3990 idx = minCOLOR + arg[i + 2];
3988 i += 2; 3991 i += 2;
3989 3992

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines