static void gui_window_created(WINDOW_REC *window, void *automatic) { MAIN_WINDOW_REC *parent; int new_parent; g_return_if_fail(window != NULL); new_parent = window_create_override == 0 || window_create_override == 2 || active_win == NULL || WINDOW_GUI(active_win) == NULL; parent = !new_parent ? WINDOW_MAIN(active_win) : mainwindow_create(); if (parent == NULL) { /* not enough space for new window, but we really can't abort creation of the window anymore, so create hidden window instead. */ parent = WINDOW_MAIN(active_win); } window_create_override = -1; if (parent->active == NULL) parent->active = window; window->gui_data = gui_window_init(window, parent); /* set only non-automatic windows sticky so that the windows irssi creates at startup wont get sticky. */ if (automatic == NULL && (parent->sticky_windows || (new_parent && settings_get_bool("autostick_split_windows")))) gui_window_set_sticky(window); signal_emit("gui window created", 1, window); }
/* SYNTAX: WINDOW STICK [<ref#>] [ON|OFF] */ static void cmd_window_stick(const char *data) { MAIN_WINDOW_REC *mainwin; WINDOW_REC *win; mainwin = active_mainwin; win = active_mainwin->active; if (is_numeric(data, ' ')) { /* ref# specified */ win = window_find_refnum(atoi(data)); if (win == NULL) { printformat_window(active_win, MSGLEVEL_CLIENTERROR, TXT_REFNUM_NOT_FOUND, data); return; } while (*data != ' ' && *data != '\0') data++; while (*data == ' ') data++; } if (g_strncasecmp(data, "OF", 2) == 0 || i_toupper(*data) == 'N') { /* unset sticky */ if (!WINDOW_GUI(win)->sticky) { printformat_window(win, MSGLEVEL_CLIENTERROR, TXT_WINDOW_NOT_STICKY); } else { gui_window_set_unsticky(win); printformat_window(win, MSGLEVEL_CLIENTNOTICE, TXT_WINDOW_UNSET_STICKY); } } else { /* set sticky */ window_reparent(win, mainwin); gui_window_set_sticky(win); printformat_window(active_win, MSGLEVEL_CLIENTNOTICE, TXT_WINDOW_SET_STICKY); } }
void gui_window_reparent(WINDOW_REC *window, MAIN_WINDOW_REC *parent) { MAIN_WINDOW_REC *oldparent; oldparent = WINDOW_MAIN(window); if (oldparent == parent) return; gui_window_set_unsticky(window); textbuffer_view_set_window(WINDOW_GUI(window)->view, NULL); WINDOW_MAIN(window) = parent; if (parent->sticky_windows) gui_window_set_sticky(window); if (MAIN_WINDOW_TEXT_HEIGHT(parent) != MAIN_WINDOW_TEXT_HEIGHT(oldparent) || parent->width != oldparent->width) { gui_window_resize(window, parent->width, MAIN_WINDOW_TEXT_HEIGHT(parent)); } }
/* SYNTAX: WINDOW SHOW <number>|<name> */ static void cmd_window_show(const char *data) { MAIN_WINDOW_REC *parent; WINDOW_REC *window; if (*data == '\0') cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS); if (is_numeric(data, '\0')) { window = window_find_refnum(atoi(data)); if (window == NULL) { printformat_window(active_win, MSGLEVEL_CLIENTERROR, TXT_REFNUM_NOT_FOUND, data); } } else { window = window_find_item(active_win->active_server, data); } if (window == NULL || is_window_visible(window)) return; if (WINDOW_MAIN(window)->sticky_windows) { printformat_window(active_win, MSGLEVEL_CLIENTERROR, TXT_CANT_SHOW_STICKY_WINDOWS); return; } parent = mainwindow_create(); parent->active = window; gui_window_reparent(window, parent); if (settings_get_bool("autostick_split_windows")) gui_window_set_sticky(window); active_mainwin = NULL; window_set_active(window); }