diff --git a/src/client.cc b/src/client.cc index 7dd22f88..d9fbf946 100644 --- a/src/client.cc +++ b/src/client.cc @@ -77,6 +77,8 @@ void Client::handle_available_input(EventMode mode) { if (*key == ctrl('c')) killpg(getpgrp(), SIGINT); + if (*key == ctrl('l')) + redraw_ifn(true); else if (*key == Key::FocusIn) context().hooks().run_hook("FocusIn", context().name(), context()); else if (*key == Key::FocusOut) @@ -171,18 +173,18 @@ static bool is_inline(InfoStyle style) style == InfoStyle::InlineBelow; } -void Client::redraw_ifn() +void Client::redraw_ifn(bool force) { Window& window = context().window(); const bool needs_redraw = window.needs_redraw(context()); - if (needs_redraw) + if (needs_redraw or force) { auto window_pos = window.position(); m_ui->draw(window.update_display_buffer(context()), get_face("Default")); // window moved, reanchor eventual menu and info - if (window_pos != window.position()) + if (force or window_pos != window.position()) { if (not m_menu.items.empty() and m_menu.style == MenuStyle::Inline) { @@ -199,7 +201,7 @@ void Client::redraw_ifn() } DisplayLine mode_line = generate_mode_line(); - if (needs_redraw or + if (force or needs_redraw or m_status_line.atoms() != m_pending_status_line.atoms() or mode_line.atoms() != m_mode_line.atoms()) { @@ -210,10 +212,10 @@ void Client::redraw_ifn() m_ui_dirty = true; } - if (m_ui_dirty) + if (m_ui_dirty or force) { m_ui_dirty = false; - m_ui->refresh(); + m_ui->refresh(force); } } diff --git a/src/client.hh b/src/client.hh index b5d13b7d..4674dce7 100644 --- a/src/client.hh +++ b/src/client.hh @@ -46,7 +46,7 @@ public: CharCoord dimensions() const { return m_ui->dimensions(); } void force_redraw(); - void redraw_ifn(); + void redraw_ifn(bool force = false); void check_if_buffer_needs_reloading(); diff --git a/src/json_ui.cc b/src/json_ui.cc index 913113de..eb576094 100644 --- a/src/json_ui.cc +++ b/src/json_ui.cc @@ -197,9 +197,9 @@ void JsonUI::info_hide() rpc_call("info_hide"); } -void JsonUI::refresh() +void JsonUI::refresh(bool force) { - rpc_call("refresh"); + rpc_call("refresh", force); } void JsonUI::set_input_callback(InputCallback callback) diff --git a/src/json_ui.hh b/src/json_ui.hh index ec48bf41..563ff997 100644 --- a/src/json_ui.hh +++ b/src/json_ui.hh @@ -39,7 +39,7 @@ public: InfoStyle style) override; void info_hide() override; - void refresh() override; + void refresh(bool force) override; void set_input_callback(InputCallback callback) override; diff --git a/src/main.cc b/src/main.cc index 3f1cd10b..f8716d1d 100644 --- a/src/main.cc +++ b/src/main.cc @@ -296,7 +296,7 @@ std::unique_ptr create_local_ui(bool dummy_ui) CharCoord dimensions() override { return {24,80}; } bool is_key_available() override { return false; } Key get_key() override { return Key::Invalid; } - void refresh() override {} + void refresh(bool) override {} void set_input_callback(InputCallback) override {} void set_ui_options(const Options&) override {} }; diff --git a/src/ncurses_ui.cc b/src/ncurses_ui.cc index 5309ecb8..72c349c0 100644 --- a/src/ncurses_ui.cc +++ b/src/ncurses_ui.cc @@ -301,9 +301,12 @@ void NCursesUI::redraw() doupdate(); } -void NCursesUI::refresh() +void NCursesUI::refresh(bool force) { - if (m_dirty) + if (force) + redrawwin(m_window); + + if (m_dirty or force) redraw(); m_dirty = false; } @@ -491,11 +494,6 @@ Key NCursesUI::get_key() if (c > 0 and c < 27) { - if (c == control('l')) - { - redrawwin(m_window); - redraw(); - } if (c == control('z')) { raise(SIGTSTP); diff --git a/src/ncurses_ui.hh b/src/ncurses_ui.hh index fdf1b6a7..870a3fc7 100644 --- a/src/ncurses_ui.hh +++ b/src/ncurses_ui.hh @@ -43,7 +43,7 @@ public: InfoStyle style) override; void info_hide() override; - void refresh() override; + void refresh(bool force) override; void set_input_callback(InputCallback callback) override; diff --git a/src/remote.cc b/src/remote.cc index e2756ef1..718d7f7d 100644 --- a/src/remote.cc +++ b/src/remote.cc @@ -255,7 +255,7 @@ public: const DisplayLine& mode_line, const Face& default_face) override; - void refresh() override; + void refresh(bool force) override; bool is_key_available() override; Key get_key() override; @@ -353,10 +353,11 @@ void RemoteUI::draw_status(const DisplayLine& status_line, msg.write(default_face); } -void RemoteUI::refresh() +void RemoteUI::refresh(bool force) { Message msg(m_socket_watcher.fd()); msg.write(RemoteUIMsg::Refresh); + msg.write(force); } void RemoteUI::set_ui_options(const Options& options) @@ -516,7 +517,7 @@ void RemoteClient::process_next_message() break; } case RemoteUIMsg::Refresh: - m_ui->refresh(); + m_ui->refresh(read(socket)); break; case RemoteUIMsg::SetOptions: m_ui->set_ui_options(read_idmap(socket)); diff --git a/src/user_interface.hh b/src/user_interface.hh index 67553922..e8a30a4b 100644 --- a/src/user_interface.hh +++ b/src/user_interface.hh @@ -63,7 +63,7 @@ public: virtual bool is_key_available() = 0; virtual Key get_key() = 0; - virtual void refresh() = 0; + virtual void refresh(bool force) = 0; virtual void set_input_callback(InputCallback callback) = 0;