0
0
mirror of https://github.com/irssi/irssi.git synced 2025-06-30 22:18:06 -04:00

/WINDOW STICK changes - If ref# is given and it's in another split window,

it's moved to the active split window - even if the window was already
sticky in the other one.


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1702 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2001-08-03 23:39:35 +00:00 committed by cras
parent ce0bd80b05
commit 80793ace1c
3 changed files with 66 additions and 56 deletions

View File

@ -103,11 +103,14 @@ static void gui_window_destroyed(WINDOW_REC *window)
signal_emit("gui window destroyed", 1, window); signal_emit("gui window destroyed", 1, window);
parent->sticky_windows =
g_slist_remove(parent->sticky_windows, window);
gui_window_deinit(gui); gui_window_deinit(gui);
window->gui_data = NULL; window->gui_data = NULL;
if (parent->active == window && mainwindows->next != NULL) if (parent->active == window)
mainwindow_destroy(parent); mainwindow_change_active(parent, window);
} }
void gui_window_resize(WINDOW_REC *window, int width, int height) void gui_window_resize(WINDOW_REC *window, int width, int height)

View File

@ -88,6 +88,34 @@ static void mainwindow_resize(MAIN_WINDOW_REC *window, int xdiff, int ydiff)
signal_emit("mainwindow resized", 1, window); signal_emit("mainwindow resized", 1, window);
} }
void mainwindow_change_active(MAIN_WINDOW_REC *mainwin,
WINDOW_REC *skip_window)
{
MAIN_WINDOW_REC *parent;
GSList *tmp;
mainwin->active = NULL;
if (mainwin->sticky_windows != NULL) {
/* sticky window */
window_set_active(mainwin->sticky_windows->data);
return;
}
for (tmp = windows; tmp != NULL; tmp = tmp->next) {
WINDOW_REC *rec = tmp->data;
parent = WINDOW_GUI(rec)->parent;
if (rec != skip_window &&
g_slist_find(parent->sticky_windows, rec) == NULL) {
window_set_active(rec);
return;
}
}
/* no more non-sticky windows, remove main window */
mainwindow_destroy(mainwin);
}
void mainwindows_recreate(void) void mainwindows_recreate(void)
{ {
GSList *tmp; GSList *tmp;
@ -767,80 +795,56 @@ static void cmd_window_right(void)
window_set_active(window); window_set_active(window);
} }
static void mainwindow_change_window(MAIN_WINDOW_REC *mainwin, /* SYNTAX: WINDOW STICK [<ref#>] [ON|OFF] */
WINDOW_REC *window)
{
MAIN_WINDOW_REC *parent;
GSList *tmp;
if (mainwin->sticky_windows != NULL) {
/* sticky window */
window_set_active(mainwin->sticky_windows->data);
return;
}
for (tmp = windows; tmp != NULL; tmp = tmp->next) {
WINDOW_REC *rec = tmp->data;
parent = WINDOW_GUI(rec)->parent;
if (rec != window &&
g_slist_find(parent->sticky_windows, rec) == NULL) {
window_set_active(rec);
return;
}
}
/* no more non-sticky windows, remove main window */
mainwindow_destroy(mainwin);
}
/* SYNTAX: WINDOW STICK [ON|OFF|<ref#>] */
static void cmd_window_stick(const char *data) static void cmd_window_stick(const char *data)
{ {
MAIN_WINDOW_REC *window = active_mainwin; MAIN_WINDOW_REC *mainwin;
WINDOW_REC *win;
mainwin = active_mainwin;
win = active_mainwin->active;
if (is_numeric(data, '\0')) { if (is_numeric(data, '\0')) {
WINDOW_REC *win = window_find_refnum(atoi(data)); /* ref# specified */
win = window_find_refnum(atoi(data));
if (win == NULL) { if (win == NULL) {
printformat_window(active_win, MSGLEVEL_CLIENTERROR, printformat_window(active_win, MSGLEVEL_CLIENTERROR,
TXT_REFNUM_NOT_FOUND, data); TXT_REFNUM_NOT_FOUND, data);
return; return;
} }
window = WINDOW_GUI(win)->parent;
while (*data != ' ' && *data != '\0') data++;
while (*data == ' ') data++;
} }
if (g_strncasecmp(data, "OF", 2) == 0 || toupper(*data) == 'N') { if (g_strncasecmp(data, "OF", 2) == 0 || toupper(*data) == 'N') {
/* unset sticky */ /* unset sticky */
if (g_slist_find(window->sticky_windows, active_win) == NULL) { if (g_slist_find(mainwin->sticky_windows, win) == NULL) {
printformat_window(active_win, MSGLEVEL_CLIENTERROR, printformat_window(win, MSGLEVEL_CLIENTERROR,
TXT_WINDOW_NOT_STICKY); TXT_WINDOW_NOT_STICKY);
} else { } else {
window->sticky_windows = mainwin->sticky_windows =
g_slist_remove(window->sticky_windows, g_slist_remove(mainwin->sticky_windows, win);
active_win); printformat_window(win, MSGLEVEL_CLIENTNOTICE,
printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
TXT_WINDOW_UNSET_STICKY); TXT_WINDOW_UNSET_STICKY);
} }
} else { } else {
/* set sticky */ /* set sticky */
active_mainwin->sticky_windows = MAIN_WINDOW_REC *old_mainwin;
g_slist_remove(active_mainwin->sticky_windows,
active_win);
if (g_slist_find(window->sticky_windows, active_win) == NULL) { old_mainwin = WINDOW_GUI(win)->parent;
window->sticky_windows = old_mainwin->sticky_windows =
g_slist_append(window->sticky_windows, g_slist_remove(old_mainwin->sticky_windows, win);
active_win);
if (g_slist_find(mainwin->sticky_windows, win) == NULL) {
mainwin->sticky_windows =
g_slist_append(mainwin->sticky_windows, win);
} }
if (window != active_mainwin) { if (old_mainwin != mainwin) {
WINDOW_REC *movewin; if (old_mainwin->active == win)
mainwindow_change_active(old_mainwin, win);
movewin = active_win; gui_window_reparent(win, mainwin);
gui_window_reparent(movewin, window); window_set_active(win);
mainwindow_change_window(active_mainwin, movewin);
active_mainwin = window;
window_set_active(movewin);
} }
printformat_window(active_win, MSGLEVEL_CLIENTNOTICE, printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,

View File

@ -33,6 +33,9 @@ void mainwindows_recreate(void);
void mainwindow_set_size(MAIN_WINDOW_REC *window, int size); void mainwindow_set_size(MAIN_WINDOW_REC *window, int size);
void mainwindows_resize(int width, int height); void mainwindows_resize(int width, int height);
void mainwindow_change_active(MAIN_WINDOW_REC *mainwin,
WINDOW_REC *skip_window);
int mainwindows_reserve_lines(int count, int up); int mainwindows_reserve_lines(int count, int up);
GSList *mainwindows_get_sorted(int reverse); GSList *mainwindows_get_sorted(int reverse);