From b3e5581900b86a713f83ade4d34bc6bdd8dc5ff6 Mon Sep 17 00:00:00 2001
From: Mooffie <mooffie@gmail.com>
Date: Fri, 1 Apr 2016 12:40:06 +0300
Subject: [PATCH] FIX FOR: WEdit: get rid of mouse event pump.
---
src/editor/editwidget.c | 36 +++++++++++++++++++++++++++++++++---
1 file changed, 33 insertions(+), 3 deletions(-)
diff --git a/src/editor/editwidget.c b/src/editor/editwidget.c
index b2f1ee0..2e8388c 100644
a
|
b
|
static void |
212 | 212 | edit_restore_size (WEdit * edit) |
213 | 213 | { |
214 | 214 | edit->drag_state = MCEDIT_DRAG_NORMAL; |
| 215 | WIDGET (edit)->mouse.forced_capture = FALSE; |
215 | 216 | widget_set_size (WIDGET (edit), edit->y_prev, edit->x_prev, edit->lines_prev, edit->cols_prev); |
216 | 217 | dlg_redraw (WIDGET (edit)->owner); |
217 | 218 | } |
… |
… |
edit_mouse_handle_move_resize (Widget * w, mouse_msg_t msg, mouse_event_t * even |
1010 | 1011 | |
1011 | 1012 | if (msg == MSG_MOUSE_UP) |
1012 | 1013 | { |
1013 | | /* Exit drag mode. */ |
| 1014 | /* Exit move/resize mode. */ |
1014 | 1015 | edit_execute_cmd (edit, CK_Enter, -1); |
1015 | 1016 | return; |
1016 | 1017 | } |
1017 | 1018 | |
| 1019 | if (msg != MSG_MOUSE_DRAG) |
| 1020 | /** |
| 1021 | * We ignore any other events. Specifically, MSG_MOUSE_DOWN. |
| 1022 | * |
| 1023 | * When the move/resize is initiated by the menu, we let the user |
| 1024 | * stop it by clicking with the mouse. Which is why we don't want |
| 1025 | * a mouse down to affect the window. |
| 1026 | */ |
| 1027 | return; |
| 1028 | |
1018 | 1029 | /* Convert point to global coordinates for easier calculations. */ |
1019 | 1030 | global_x = event->x + w->x; |
1020 | 1031 | global_y = event->y + w->y; |
… |
… |
edit_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event) |
1086 | 1097 | else |
1087 | 1098 | { |
1088 | 1099 | /* start window move */ |
1089 | | edit->drag_state_start = event->x; |
1090 | 1100 | edit_execute_cmd (edit, CK_WindowMove, -1); |
| 1101 | edit->drag_state_start = event->x; |
1091 | 1102 | } |
1092 | 1103 | break; |
1093 | 1104 | } |
… |
… |
edit_add_window (WDialog * h, int y, int x, int lines, int cols, const vfs_path_ |
1355 | 1366 | * |
1356 | 1367 | * @param edit editor object |
1357 | 1368 | * @param command action id |
1358 | | * @return TRUE if mouse actions was handled, FALSE otherwise |
| 1369 | * @return TRUE if the action was handled, FALSE otherwise |
1359 | 1370 | */ |
1360 | 1371 | |
1361 | 1372 | gboolean |
1362 | 1373 | edit_handle_move_resize (WEdit * edit, long command) |
1363 | 1374 | { |
| 1375 | Widget *w = WIDGET (edit); |
1364 | 1376 | gboolean ret = FALSE; |
1365 | 1377 | |
1366 | 1378 | if (edit->fullscreen) |
1367 | 1379 | { |
1368 | 1380 | edit->drag_state = MCEDIT_DRAG_NORMAL; |
| 1381 | w->mouse.forced_capture = FALSE; |
1369 | 1382 | return ret; |
1370 | 1383 | } |
1371 | 1384 | |
… |
… |
edit_handle_move_resize (WEdit * edit, long command) |
1379 | 1392 | edit->drag_state = MCEDIT_DRAG_MOVE; |
1380 | 1393 | edit_save_size (edit); |
1381 | 1394 | edit_status (edit, TRUE); /* redraw frame and status */ |
| 1395 | /** |
| 1396 | * If a user initiates a move by the menu, not by the mouse, we |
| 1397 | * make a subsequent mouse drag pull the frame from its middle. |
| 1398 | * (We can instead choose '0' to pull it from the corner.) |
| 1399 | */ |
| 1400 | edit->drag_state_start = w->cols / 2; |
1382 | 1401 | ret = TRUE; |
1383 | 1402 | break; |
1384 | 1403 | case CK_WindowResize: |
… |
… |
edit_handle_move_resize (WEdit * edit, long command) |
1444 | 1463 | break; |
1445 | 1464 | } |
1446 | 1465 | |
| 1466 | /** |
| 1467 | * - We let the user stop a resize/move operation by clicking with the |
| 1468 | * mouse anywhere. ("clicking" = pressing and releasing a button.) |
| 1469 | * - We let the user perform a resize/move operation by a mouse drag |
| 1470 | * initiated anywhere. |
| 1471 | * |
| 1472 | * "Anywhere" means: inside or outside the window. We make this happen |
| 1473 | * with the 'forced_capture' flag. |
| 1474 | */ |
| 1475 | w->mouse.forced_capture = (edit->drag_state != MCEDIT_DRAG_NORMAL); |
| 1476 | |
1447 | 1477 | return ret; |
1448 | 1478 | } |
1449 | 1479 | |