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); |
144 | 144 | void edit_menu_cmd (WDialog * h); |
145 | 145 | void user_menu (WEdit * edit, const char *menu_file, int selected_entry); |
146 | 146 | void edit_init_menu (WMenuBar * menubar); |
| 147 | void edit_bring_to_front (WEdit * edit); |
147 | 148 | void edit_save_mode_cmd (void); |
148 | 149 | off_t edit_move_forward3 (const WEdit * edit, off_t current, long cols, off_t upto); |
149 | 150 | void edit_scroll_screen_over_cursor (WEdit * edit); |
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 |
2111 | 2111 | |
2112 | 2112 | w = WIDGET (edit); |
2113 | 2113 | 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; |
2115 | 2115 | edit->fullscreen = TRUE; |
2116 | 2116 | edit_save_size (edit); |
2117 | 2117 | } |
diff --git a/src/editor/editcmd.c b/src/editor/editcmd.c
index 4e1101d..8476800 100644
a
|
b
|
edit_close_cmd (WEdit * edit) |
2249 | 2249 | { |
2250 | 2250 | edit = find_editor (h); |
2251 | 2251 | if (edit != NULL) |
2252 | | widget_select (WIDGET (edit)); |
| 2252 | edit_bring_to_front (edit); |
2253 | 2253 | } |
2254 | 2254 | } |
2255 | 2255 | |
diff --git a/src/editor/editwidget.c b/src/editor/editwidget.c
index 732db41..67986a1 100644
a
|
b
|
edit_window_list (const WDialog * h) |
351 | 351 | |
352 | 352 | selected = run_listbox_with_data (listbox, h->current->data); |
353 | 353 | if (selected != NULL) |
354 | | widget_select (WIDGET (selected)); |
| 354 | edit_bring_to_front (selected); |
355 | 355 | } |
356 | 356 | |
357 | 357 | /* --------------------------------------------------------------------------------------------- */ |
… |
… |
edit_quit (WDialog * h) |
649 | 649 | |
650 | 650 | if (e->modified) |
651 | 651 | { |
652 | | widget_select (WIDGET (e)); |
| 652 | edit_bring_to_front (e); |
653 | 653 | |
654 | 654 | if (!edit_ok_to_exit (e)) |
655 | 655 | return; |
… |
… |
edit_dialog_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event) |
898 | 898 | if (top != h->current) |
899 | 899 | { |
900 | 900 | /* Window is not active. Activate it */ |
901 | | widget_select (WIDGET (e)); |
| 901 | edit_bring_to_front (e); |
902 | 902 | } |
903 | 903 | |
904 | 904 | /* Handle buttons */ |
… |
… |
edit_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event) |
1074 | 1074 | switch (msg) |
1075 | 1075 | { |
1076 | 1076 | case MSG_MOUSE_DOWN: |
1077 | | widget_select (w); |
| 1077 | edit_bring_to_front (edit); |
1078 | 1078 | edit_update_curs_row (edit); |
1079 | 1079 | edit_update_curs_col (edit); |
1080 | 1080 | |
… |
… |
find_editor (const WDialog * h) |
1263 | 1263 | } |
1264 | 1264 | |
1265 | 1265 | /* --------------------------------------------------------------------------------------------- */ |
| 1266 | |
| 1267 | /** |
| 1268 | * Helper function to float a widget up in the Z order. |
| 1269 | */ |
| 1270 | static void |
| 1271 | bring_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 | */ |
| 1290 | void |
| 1291 | edit_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 | /* --------------------------------------------------------------------------------------------- */ |
1266 | 1304 | /** |
1267 | 1305 | * Check if widget is an WEdit class. |
1268 | 1306 | * |