Ticket #3571: 3571-FIX-FOR-WEdit-get-rid-of-mouse-event-pump.patch

File 3571-FIX-FOR-WEdit-get-rid-of-mouse-event-pump.patch, 3.7 KB (added by mooffie, 9 years ago)
  • src/editor/editwidget.c

    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 
    212212edit_restore_size (WEdit * edit) 
    213213{ 
    214214    edit->drag_state = MCEDIT_DRAG_NORMAL; 
     215    WIDGET (edit)->mouse.forced_capture = FALSE; 
    215216    widget_set_size (WIDGET (edit), edit->y_prev, edit->x_prev, edit->lines_prev, edit->cols_prev); 
    216217    dlg_redraw (WIDGET (edit)->owner); 
    217218} 
    edit_mouse_handle_move_resize (Widget * w, mouse_msg_t msg, mouse_event_t * even 
    10101011 
    10111012    if (msg == MSG_MOUSE_UP) 
    10121013    { 
    1013         /* Exit drag mode. */ 
     1014        /* Exit move/resize mode. */ 
    10141015        edit_execute_cmd (edit, CK_Enter, -1); 
    10151016        return; 
    10161017    } 
    10171018 
     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 
    10181029    /* Convert point to global coordinates for easier calculations. */ 
    10191030    global_x = event->x + w->x; 
    10201031    global_y = event->y + w->y; 
    edit_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event) 
    10861097                else 
    10871098                { 
    10881099                    /* start window move */ 
    1089                     edit->drag_state_start = event->x; 
    10901100                    edit_execute_cmd (edit, CK_WindowMove, -1); 
     1101                    edit->drag_state_start = event->x; 
    10911102                } 
    10921103                break; 
    10931104            } 
    edit_add_window (WDialog * h, int y, int x, int lines, int cols, const vfs_path_ 
    13551366 * 
    13561367 * @param edit    editor object 
    13571368 * @param command action id 
    1358  * @return TRUE if mouse actions was handled, FALSE otherwise 
     1369 * @return TRUE if the action was handled, FALSE otherwise 
    13591370 */ 
    13601371 
    13611372gboolean 
    13621373edit_handle_move_resize (WEdit * edit, long command) 
    13631374{ 
     1375    Widget *w = WIDGET (edit); 
    13641376    gboolean ret = FALSE; 
    13651377 
    13661378    if (edit->fullscreen) 
    13671379    { 
    13681380        edit->drag_state = MCEDIT_DRAG_NORMAL; 
     1381        w->mouse.forced_capture = FALSE; 
    13691382        return ret; 
    13701383    } 
    13711384 
    edit_handle_move_resize (WEdit * edit, long command) 
    13791392            edit->drag_state = MCEDIT_DRAG_MOVE; 
    13801393            edit_save_size (edit); 
    13811394            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; 
    13821401            ret = TRUE; 
    13831402            break; 
    13841403        case CK_WindowResize: 
    edit_handle_move_resize (WEdit * edit, long command) 
    14441463        break; 
    14451464    } 
    14461465 
     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 
    14471477    return ret; 
    14481478} 
    14491479