Ticket #3760: SOLUTION-NUMBER-1-----dont-use-WOP_TOP_SELECT-and-keep-buttonbar-on-top.patch

File SOLUTION-NUMBER-1-----dont-use-WOP_TOP_SELECT-and-keep-buttonbar-on-top.patch, 4.7 KB (added by mooffie, 7 years ago)

(but this patch is blocked by #3763)

  • src/editor/edit-impl.h

    From 031d7565f82ac9fe922a40b64ef975e6d8c01a37 Mon Sep 17 00:00:00 2001
    From: Mooffie <mooffie@gmail.com>
    Date: Wed, 25 Jan 2017 14:05:34 +0200
    Subject: [PATCH] Ticket #3760: keep buttonbar on top so WEdit doesn't steal
     its mouse events.
    
    Signed-off-by: Mooffie <mooffie@gmail.com>
    ---
     src/editor/edit-impl.h  |  1 +
     src/editor/edit.c       |  2 +-
     src/editor/editcmd.c    |  2 +-
     src/editor/editwidget.c | 46 ++++++++++++++++++++++++++++++++++++++++++----
     4 files changed, 45 insertions(+), 6 deletions(-)
    
    diff --git a/src/editor/edit-impl.h b/src/editor/edit-impl.h
    index 73d178b..f557c3b 100644
    a b gboolean edit_drop_hotkey_menu (WDialog * h, int key); 
    144144void edit_menu_cmd (WDialog * h); 
    145145void user_menu (WEdit * edit, const char *menu_file, int selected_entry); 
    146146void edit_init_menu (WMenuBar * menubar); 
     147void edit_bring_to_front (WEdit * edit); 
    147148void edit_save_mode_cmd (void); 
    148149off_t edit_move_forward3 (const WEdit * edit, off_t current, long cols, off_t upto); 
    149150void edit_scroll_screen_over_cursor (WEdit * edit); 
  • src/editor/edit.c

    diff --git a/src/editor/edit.c b/src/editor/edit.c
    index eaab3c4..b079d9a 100644
    a b edit_init (WEdit * edit, int y, int x, int lines, int cols, const vfs_path_t * f 
    21112111 
    21122112        w = WIDGET (edit); 
    21132113        widget_init (w, y, x, lines, cols, NULL, NULL); 
    2114         w->options |= WOP_SELECTABLE | WOP_TOP_SELECT | WOP_WANT_CURSOR; 
     2114        w->options |= WOP_SELECTABLE | WOP_WANT_CURSOR; 
    21152115        edit->fullscreen = TRUE; 
    21162116        edit_save_size (edit); 
    21172117    } 
  • src/editor/editcmd.c

    diff --git a/src/editor/editcmd.c b/src/editor/editcmd.c
    index 4e1101d..8476800 100644
    a b edit_close_cmd (WEdit * edit) 
    22492249        { 
    22502250            edit = find_editor (h); 
    22512251            if (edit != NULL) 
    2252                 widget_select (WIDGET (edit)); 
     2252                edit_bring_to_front (edit); 
    22532253        } 
    22542254    } 
    22552255 
  • src/editor/editwidget.c

    diff --git a/src/editor/editwidget.c b/src/editor/editwidget.c
    index 732db41..67986a1 100644
    a b edit_window_list (const WDialog * h) 
    351351 
    352352    selected = run_listbox_with_data (listbox, h->current->data); 
    353353    if (selected != NULL) 
    354         widget_select (WIDGET (selected)); 
     354        edit_bring_to_front (selected); 
    355355} 
    356356 
    357357/* --------------------------------------------------------------------------------------------- */ 
    edit_quit (WDialog * h) 
    649649 
    650650            if (e->modified) 
    651651            { 
    652                 widget_select (WIDGET (e)); 
     652                edit_bring_to_front (e); 
    653653 
    654654                if (!edit_ok_to_exit (e)) 
    655655                    return; 
    edit_dialog_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event) 
    898898                if (top != h->current) 
    899899                { 
    900900                    /* Window is not active. Activate it */ 
    901                     widget_select (WIDGET (e)); 
     901                    edit_bring_to_front (e); 
    902902                } 
    903903 
    904904                /* Handle buttons */ 
    edit_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event) 
    10741074    switch (msg) 
    10751075    { 
    10761076    case MSG_MOUSE_DOWN: 
    1077         widget_select (w); 
     1077        edit_bring_to_front (edit); 
    10781078        edit_update_curs_row (edit); 
    10791079        edit_update_curs_col (edit); 
    10801080 
    find_editor (const WDialog * h) 
    12631263} 
    12641264 
    12651265/* --------------------------------------------------------------------------------------------- */ 
     1266 
     1267/** 
     1268 * Helper function to float a widget up in the Z order. 
     1269 */ 
     1270static void 
     1271bring_to_front (Widget * w) 
     1272{ 
     1273    widget_options_t original_options; 
     1274 
     1275    original_options = w->options; 
     1276    widget_set_options (w, WOP_TOP_SELECT | WOP_SELECTABLE, TRUE); 
     1277    widget_select (w); 
     1278    w->options = original_options; 
     1279} 
     1280 
     1281/* --------------------------------------------------------------------------------------------- */ 
     1282 
     1283/** 
     1284 * Focuses a WEdit and bring it to the front so it obscures the other WEdit 
     1285 * windows (in our MDI user interface). 
     1286 * 
     1287 * It makes sure to keep the buttonbar at the real front, or else 
     1288 * an overlapping edit will receive its mouse events. 
     1289 */ 
     1290void 
     1291edit_bring_to_front (WEdit * edit) 
     1292{ 
     1293    Widget *bar = WIDGET (find_buttonbar (WIDGET (edit)->owner)); 
     1294 
     1295    /* Bring the edit to the top, then the buttonbar. */ 
     1296    bring_to_front (WIDGET (edit)); 
     1297    bring_to_front (bar); 
     1298 
     1299    /* ...and then move the focus back to the edit. */ 
     1300    widget_select (WIDGET (edit)); 
     1301} 
     1302 
     1303/* --------------------------------------------------------------------------------------------- */ 
    12661304/** 
    12671305 * Check if widget is an WEdit class. 
    12681306 *