Compare commits

...

2 Commits

Author SHA1 Message Date
Přemysl Eric Janouch dcb2829e9b
Separate the actions of aborting and quitting
The user should not be afraid of pressing Escape too many times.
2023-03-25 11:39:34 +01:00
Přemysl Eric Janouch 349c907cbf
X11: act on DestroyNotify rather than UnmapNotify
This makes the program survive i3 restarts, which cause a sequence
of: UnmapNotify, ReparentNotify, MapNotify.
2023-03-25 11:10:26 +01:00
3 changed files with 22 additions and 14 deletions

2
NEWS
View File

@ -5,6 +5,8 @@ Unreleased
* Improved song information shown in the window header * Improved song information shown in the window header
* Escape no longer quits the program
* X11: added italic font support * X11: added italic font support
* X11: fixed rendering of overflowing, partially visible list items * X11: fixed rendering of overflowing, partially visible list items

View File

@ -2,6 +2,7 @@ NONE, Do nothing
QUIT, Quit QUIT, Quit
REDRAW, Redraw screen REDRAW, Redraw screen
ABORT, Abort
TAB_HELP, Switch to help tab TAB_HELP, Switch to help tab
TAB_LAST, Switch to last tab TAB_LAST, Switch to last tab
TAB_PREVIOUS, Switch to previous tab TAB_PREVIOUS, Switch to previous tab

View File

@ -2662,6 +2662,14 @@ app_process_action (enum action action)
case ACTION_NONE: case ACTION_NONE:
return true; return true;
case ACTION_QUIT: case ACTION_QUIT:
app_quit ();
return true;
case ACTION_REDRAW:
clear ();
app_invalidate ();
return true;
case ACTION_ABORT:
// It is a pseudomode, avoid surprising the user // It is a pseudomode, avoid surprising the user
if (tab->item_mark > -1) if (tab->item_mark > -1)
{ {
@ -2669,13 +2677,7 @@ app_process_action (enum action action)
app_invalidate (); app_invalidate ();
return true; return true;
} }
return false;
app_quit ();
return true;
case ACTION_REDRAW:
clear ();
app_invalidate ();
return true;
case ACTION_MPD_COMMAND: case ACTION_MPD_COMMAND:
line_editor_start (&g.editor, ':'); line_editor_start (&g.editor, ':');
g.editor.on_end = app_on_mpd_command_editor_end; g.editor.on_end = app_on_mpd_command_editor_end;
@ -2807,7 +2809,7 @@ app_editor_process_action (enum action action)
app_invalidate (); app_invalidate ();
switch (action) switch (action)
{ {
case ACTION_QUIT: case ACTION_ABORT:
line_editor_abort (&g.editor, false); line_editor_abort (&g.editor, false);
g.editor.on_end = NULL; g.editor.on_end = NULL;
return true; return true;
@ -3007,9 +3009,9 @@ static struct binding_default
} }
g_normal_defaults[] = g_normal_defaults[] =
{ {
{ "Escape", ACTION_QUIT },
{ "q", ACTION_QUIT }, { "q", ACTION_QUIT },
{ "C-l", ACTION_REDRAW }, { "C-l", ACTION_REDRAW },
{ "Escape", ACTION_ABORT },
{ "M-Tab", ACTION_TAB_LAST }, { "M-Tab", ACTION_TAB_LAST },
{ "F1", ACTION_TAB_HELP }, { "F1", ACTION_TAB_HELP },
{ "S-Tab", ACTION_TAB_PREVIOUS }, { "S-Tab", ACTION_TAB_PREVIOUS },
@ -3075,6 +3077,10 @@ g_normal_defaults[] =
}, },
g_editor_defaults[] = g_editor_defaults[] =
{ {
{ "C-g", ACTION_ABORT },
{ "Escape", ACTION_ABORT },
{ "Enter", ACTION_EDITOR_CONFIRM },
{ "Left", ACTION_EDITOR_B_CHAR }, { "Left", ACTION_EDITOR_B_CHAR },
{ "Right", ACTION_EDITOR_F_CHAR }, { "Right", ACTION_EDITOR_F_CHAR },
{ "C-b", ACTION_EDITOR_B_CHAR }, { "C-b", ACTION_EDITOR_B_CHAR },
@ -3098,10 +3104,6 @@ g_editor_defaults[] =
{ "C-u", ACTION_EDITOR_B_KILL_LINE }, { "C-u", ACTION_EDITOR_B_KILL_LINE },
{ "C-k", ACTION_EDITOR_F_KILL_LINE }, { "C-k", ACTION_EDITOR_F_KILL_LINE },
{ "C-w", ACTION_EDITOR_B_KILL_WORD }, { "C-w", ACTION_EDITOR_B_KILL_WORD },
{ "C-g", ACTION_QUIT },
{ "Escape", ACTION_QUIT },
{ "Enter", ACTION_EDITOR_CONFIRM },
}; };
static int static int
@ -6748,7 +6750,10 @@ on_x11_event (XEvent *ev)
case SelectionClear: case SelectionClear:
cstr_set (&g.x11_selection, NULL); cstr_set (&g.x11_selection, NULL);
break; break;
case UnmapNotify: // UnmapNotify can be received when restarting the window manager.
// Should this turn out to be unreliable (window not destroyed by WM
// upon closing), opt for the WM_DELETE_WINDOW protocol as well.
case DestroyNotify:
app_quit (); app_quit ();
break; break;
case FocusIn: case FocusIn: