1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-06-02 21:21:10 +00:00

Compare commits

...

3 Commits

Author SHA1 Message Date
John Hernandez
565b9d1487
Merge 0f361e6b52 into 88b26cfdb9 2024-02-19 09:59:00 -07:00
Michael Vetter
88b26cfdb9 Undo gmainloop related changes
Revert "Merge pull request #1943 from H3rnand3zzz/gmainloop

This reverts commit 609fde0998, reversing
changes made to 2ec94064ed.

Revert "Merge pull request #1948 from H3rnand3zzz/fix/rl-less-refreshes"

This reverts commit 11762fd2b0, reversing
changes made to 609fde0998.

We have got several issues, that we don't quite see how to solve, with
the merge of the gmainloop PR.

* Slashguard is broken (#1955) (though #1956 could fix that)
* One person reported problems with copy paste selection via mouse
* Some input buffer seems not to be cleared correctly
  It happened that I was debugging profanity used `/connect` and typed
  the password. I then debugged so long that a time out occurred, so
  profanity disconnected. Then it printed "unknown command: $password".

There was something else that I forgot now.

Bottomline is: so far we didn't get it right so we will undo these
changes until someone proposes a working solution.

We got a slight performance increase (apparently noticable when
alt+mouse scrolling) but got too many issues with this change.
2024-02-19 17:41:06 +01:00
John Hernandez
0f361e6b52
Remove maxtabs limitation for statusbar 2024-01-19 16:25:27 +01:00
10 changed files with 46 additions and 85 deletions

View File

@ -130,7 +130,6 @@ unittest_sources = \
tests/unittests/xmpp/stub_xmpp.c \
tests/unittests/xmpp/stub_message.c \
tests/unittests/ui/stub_ui.c tests/unittests/ui/stub_ui.h \
tests/unittests/ui/stub_inputwin.c tests/unittests/ui/stub_inputwin.h \
tests/unittests/ui/stub_vcardwin.c \
tests/unittests/log/stub_log.c \
tests/unittests/chatlog/stub_chatlog.c \

View File

@ -1298,7 +1298,7 @@ static const struct cmd_t command_defs[] = {
CMD_DESC(
"Manage statusbar display preferences.")
CMD_ARGS(
{ "maxtabs <value>", "Set the maximum number of tabs to display, <value> must be between 0 and 10." },
{ "maxtabs <value>", "Set the maximum number of tabs to display, <value> must be more than or equal to 0." },
{ "tablen <value>", "Set the maximum number of characters to show as the tab name, 0 sets to unlimited." },
{ "tabmode default|dynamic|actlist", "Set the mode tabs are shown. `dynamic` is a mode that displays tabs conveniently around current tab, thus providing proper pagination. `actlist` setting shows only active tabs. `default` setting always shows tabs in 1 to max_tabs range." },
{ "show|hide name", "Show or hide names in tabs." },

View File

@ -6182,11 +6182,6 @@ cmd_statusbar(ProfWin* window, const char* const command, gchar** args)
auto_char char* err_msg = NULL;
gboolean res = strtoi_range(value, &intval, 0, INT_MAX, &err_msg);
if (res) {
if (intval < 0 || intval > 10) {
cons_bad_cmd_usage(command);
return TRUE;
}
prefs_set_statusbartabs(intval);
if (intval == 0) {
cons_show("Status bar tabs disabled.");

View File

@ -43,7 +43,6 @@
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <glib.h>
@ -61,7 +60,6 @@
#include "command/cmd_defs.h"
#include "plugins/plugins.h"
#include "event/client_events.h"
#include "ui/inputwin.h"
#include "ui/ui.h"
#include "ui/window_list.h"
#include "xmpp/resource.h"
@ -88,15 +86,15 @@
static void _init(char* log_level, char* config_file, char* log_file, char* theme_name);
static void _shutdown(void);
static void _connect_default(const char* const account);
static gboolean _main_update(gpointer data);
pthread_mutex_t lock;
static gboolean force_quit = FALSE;
GMainLoop* mainloop = NULL;
void
prof_run(char* log_level, char* account_name, char* config_file, char* log_file, char* theme_name)
{
gboolean cont = TRUE;
_init(log_level, config_file, log_file, theme_name);
plugins_on_start();
_connect_default(account_name);
@ -107,10 +105,33 @@ prof_run(char* log_level, char* account_name, char* config_file, char* log_file,
session_init_activity();
mainloop = g_main_loop_new(NULL, TRUE);
g_timeout_add(1000 / 60, _main_update, NULL);
inp_add_watch();
g_main_loop_run(mainloop);
char* line = NULL;
while (cont && !force_quit) {
log_stderr_handler();
session_check_autoaway();
line = inp_readline();
if (line) {
ProfWin* window = wins_get_current();
cont = cmd_process_input(window, line);
free(line);
line = NULL;
} else {
cont = TRUE;
}
#ifdef HAVE_LIBOTR
otr_poll();
#endif
plugins_run_timed();
notify_remind();
session_process_events();
iq_autoping_check();
ui_update();
#ifdef HAVE_GTK
tray_update();
#endif
}
}
void
@ -119,29 +140,6 @@ prof_set_quit(void)
force_quit = TRUE;
}
static gboolean
_main_update(gpointer data)
{
log_stderr_handler();
session_check_autoaway();
#ifdef HAVE_LIBOTR
otr_poll();
#endif
plugins_run_timed();
notify_remind();
session_process_events();
iq_autoping_check();
ui_update();
chat_state_idle();
#ifdef HAVE_GTK
tray_update();
#endif
// Always repeat
return TRUE;
}
static void
_connect_default(const char* const account)
{

View File

@ -44,6 +44,5 @@ void prof_run(char* log_level, char* account_name, char* config_file, char* log_
void prof_set_quit(void);
extern pthread_mutex_t lock;
extern GMainLoop* mainloop;
#endif

View File

@ -171,41 +171,6 @@ create_input_window(void)
_inp_win_update_virtual();
}
static gboolean
_inp_callback(GIOChannel* source, GIOCondition condition, gpointer data)
{
rl_callback_read_char();
if (rl_line_buffer && rl_line_buffer[0] != '/' && rl_line_buffer[0] != '\0' && rl_line_buffer[0] != '\n') {
chat_state_activity();
}
ui_reset_idle_time();
if (inp_line) {
ProfWin* window = wins_get_current();
if (!cmd_process_input(window, inp_line))
g_main_loop_quit(mainloop);
free(inp_line);
inp_line = NULL;
}
return TRUE;
}
void
inp_add_watch(void)
{
GIOChannel* channel = g_io_channel_unix_new(fileno(rl_instream));
if (g_io_channel_set_encoding(channel, NULL, NULL) != G_IO_STATUS_NORMAL) {
log_error("cannot set NULL encoding");
}
g_io_add_watch(channel, G_IO_IN, _inp_callback, NULL);
}
char*
inp_readline(void)
{

View File

@ -46,6 +46,5 @@ void inp_win_resize(void);
void inp_put_back(void);
char* inp_get_password(void);
char* inp_get_line(void);
void inp_add_watch(void);
#endif

View File

@ -77,8 +77,10 @@ typedef struct _status_bar_t
static GTimeZone* tz;
static StatusBar* statusbar;
static WINDOW* statusbar_win;
static int left_part_size;
void _get_range_bounds(int* start, int* end, gboolean is_static);
static int _get_max_tabs();
static int _status_bar_draw_time(int pos);
static int _status_bar_draw_maintext(int pos);
static int _status_bar_draw_bracket(gboolean current, int pos, const char* ch);
@ -285,11 +287,14 @@ status_bar_draw(void)
werase(statusbar_win);
wbkgd(statusbar_win, theme_attrs(THEME_STATUS_TEXT));
gint max_tabs = prefs_get_statusbartabs();
gint max_tabs = _get_max_tabs();
int pos = 1;
pos = _status_bar_draw_time(pos);
pos = _status_bar_draw_maintext(pos);
left_part_size = pos;
if (max_tabs != 0)
pos = _status_bar_draw_tabs(pos);
@ -367,7 +372,7 @@ _status_bar_draw_tabs(int pos)
static gboolean
_has_new_msgs_beyond_range_on_side(gboolean left_side, int display_tabs_start, int display_tabs_end)
{
gint max_tabs = prefs_get_statusbartabs();
gint max_tabs = _get_max_tabs();
int tabs_count = g_hash_table_size(statusbar->tabs);
if (tabs_count <= max_tabs) {
return FALSE;
@ -389,7 +394,7 @@ _has_new_msgs_beyond_range_on_side(gboolean left_side, int display_tabs_start, i
static int
_status_bar_draw_extended_tabs(int pos, gboolean prefix, int start, int end, gboolean is_static)
{
gint max_tabs = prefs_get_statusbartabs();
gint max_tabs = _get_max_tabs();
if (max_tabs == 0) {
return pos;
}
@ -620,7 +625,7 @@ _tabs_width(int start, int end)
gboolean show_number = prefs_get_boolean(PREF_STATUSBAR_SHOW_NUMBER);
gboolean show_name = prefs_get_boolean(PREF_STATUSBAR_SHOW_NAME);
gboolean show_read = prefs_get_boolean(PREF_STATUSBAR_SHOW_READ);
gint max_tabs = prefs_get_statusbartabs();
gint max_tabs = _get_max_tabs();
guint opened_tabs = g_hash_table_size(statusbar->tabs);
int width = start < 2 ? 1 : 4;
@ -718,7 +723,7 @@ void
_get_range_bounds(int* start, int* end, gboolean is_static)
{
int current_tab = statusbar->current_tab;
gint display_range = prefs_get_statusbartabs();
gint display_range = _get_max_tabs();
int total_tabs = g_hash_table_size(statusbar->tabs);
int side_range = display_range / 2;
@ -766,3 +771,9 @@ _count_digits_in_range(int start, int end)
return total_digits;
}
static int
_get_max_tabs()
{
return MIN(prefs_get_statusbartabs(), (getmaxx(stdscr) - left_part_size) / 3);
}

View File

@ -1,4 +0,0 @@
void
inp_add_watch(void)
{
}

View File

@ -1 +0,0 @@
void inp_add_watch(void);