Lines Matching defs:w

99 winlink_find_by_window(struct winlinks *wwl, struct window *w)
104 if (wl->window == w)
184 winlink_set_window(struct winlink *wl, struct window *w)
190 TAILQ_INSERT_TAIL(&w->winlinks, wl, wentry);
191 wl->window = w;
192 window_add_ref(w, __func__);
198 struct window *w = wl->window;
200 if (w != NULL) {
201 TAILQ_REMOVE(&w->winlinks, wl, wentry);
202 window_remove_ref(w, __func__);
281 struct window w;
283 w.id = id;
284 return (RB_FIND(windows, &windows, &w));
288 window_update_activity(struct window *w)
290 gettimeofday(&w->activity_time, NULL);
291 alerts_queue(w, WINDOW_ACTIVITY);
297 struct window *w;
304 w = xcalloc(1, sizeof *w);
305 w->name = xstrdup("");
306 w->flags = 0;
308 TAILQ_INIT(&w->panes);
309 TAILQ_INIT(&w->last_panes);
310 w->active = NULL;
312 w->lastlayout = -1;
313 w->layout_root = NULL;
315 w->sx = sx;
316 w->sy = sy;
317 w->manual_sx = sx;
318 w->manual_sy = sy;
319 w->xpixel = xpixel;
320 w->ypixel = ypixel;
322 w->options = options_create(global_w_options);
324 w->references = 0;
325 TAILQ_INIT(&w->winlinks);
327 w->id = next_window_id++;
328 RB_INSERT(windows, &windows, w);
330 window_set_fill_character(w);
331 window_update_activity(w);
333 log_debug("%s: @%u create %ux%u (%ux%u)", __func__, w->id, sx, sy,
334 w->xpixel, w->ypixel);
335 return (w);
339 window_destroy(struct window *w)
341 log_debug("window @%u destroyed (%d references)", w->id, w->references);
343 window_unzoom(w, 0);
344 RB_REMOVE(windows, &windows, w);
346 if (w->layout_root != NULL)
347 layout_free_cell(w->layout_root);
348 if (w->saved_layout_root != NULL)
349 layout_free_cell(w->saved_layout_root);
350 free(w->old_layout);
352 window_destroy_panes(w);
354 if (event_initialized(&w->name_event))
355 evtimer_del(&w->name_event);
357 if (event_initialized(&w->alerts_timer))
358 evtimer_del(&w->alerts_timer);
359 if (event_initialized(&w->offset_timer))
360 event_del(&w->offset_timer);
362 options_free(w->options);
363 free(w->fill_character);
365 free(w->name);
366 free(w);
387 window_add_ref(struct window *w, const char *from)
389 w->references++;
390 log_debug("%s: @%u %s, now %d", __func__, w->id, from, w->references);
394 window_remove_ref(struct window *w, const char *from)
396 w->references--;
397 log_debug("%s: @%u %s, now %d", __func__, w->id, from, w->references);
399 if (w->references == 0)
400 window_destroy(w);
404 window_set_name(struct window *w, const char *new_name)
406 free(w->name);
407 utf8_stravis(&w->name, new_name, VIS_OCTAL|VIS_CSTYLE|VIS_TAB|VIS_NL);
408 notify_window("window-renamed", w);
412 window_resize(struct window *w, u_int sx, u_int sy, int xpixel, int ypixel)
419 log_debug("%s: @%u resize %ux%u (%ux%u)", __func__, w->id, sx, sy,
420 xpixel == -1 ? w->xpixel : (u_int)xpixel,
421 ypixel == -1 ? w->ypixel : (u_int)ypixel);
422 w->sx = sx;
423 w->sy = sy;
425 w->xpixel = xpixel;
427 w->ypixel = ypixel;
433 struct window *w = wp->window;
444 ws.ws_xpixel = w->xpixel * ws.ws_col;
445 ws.ws_ypixel = w->ypixel * ws.ws_row;
451 window_has_pane(struct window *w, struct window_pane *wp)
455 TAILQ_FOREACH(wp1, &w->panes, entry) {
463 window_update_focus(struct window *w)
465 if (w != NULL) {
466 log_debug("%s: @%u", __func__, w->id);
467 window_pane_update_focus(w->active);
510 window_set_active_pane(struct window *w, struct window_pane *wp, int notify)
516 if (wp == w->active)
518 lastwp = w->active;
520 window_pane_stack_remove(&w->last_panes, wp);
521 window_pane_stack_push(&w->last_panes, lastwp);
523 w->active = wp;
524 w->active->active_point = next_active_point++;
525 w->active->flags |= PANE_CHANGED;
529 window_pane_update_focus(w->active);
532 tty_update_window_offset(w);
535 notify_window("window-pane-changed", w);
548 window_redraw_active_switch(struct window *w, struct window_pane *wp)
553 if (wp == w->active)
577 if (wp == w->active)
579 wp = w->active;
584 window_get_active_at(struct window *w, u_int x, u_int y)
590 pane_scrollbars = options_get_number(w->options, "pane-scrollbars");
591 sb_pos = options_get_number(w->options, "pane-scrollbars-position");
593 TAILQ_FOREACH(wp, &w->panes, entry) {
622 window_find_string(struct window *w, const char *s)
624 u_int x, y, top = 0, bottom = w->sy - 1;
627 x = w->sx / 2;
628 y = w->sy / 2;
630 status = options_get_number(w->options, "pane-border-status");
643 x = w->sx - 1;
648 x = w->sx - 1;
654 x = w->sx - 1;
659 return (window_get_active_at(w, x, y));
665 struct window *w = wp->window;
668 if (w->flags & WINDOW_ZOOMED)
671 if (window_count_panes(w) == 1)
674 if (w->active != wp)
675 window_set_active_pane(w, wp, 1);
677 TAILQ_FOREACH(wp1, &w->panes, entry) {
682 w->saved_layout_root = w->layout_root;
683 layout_init(w, wp);
684 w->flags |= WINDOW_ZOOMED;
685 notify_window("window-layout-changed", w);
691 window_unzoom(struct window *w, int notify)
695 if (!(w->flags & WINDOW_ZOOMED))
698 w->flags &= ~WINDOW_ZOOMED;
699 layout_free(w);
700 w->layout_root = w->saved_layout_root;
701 w->saved_layout_root = NULL;
703 TAILQ_FOREACH(wp, &w->panes, entry) {
707 layout_fix_panes(w, NULL);
710 notify_window("window-layout-changed", w);
716 window_push_zoom(struct window *w, int always, int flag)
718 log_debug("%s: @%u %d", __func__, w->id,
719 flag && (w->flags & WINDOW_ZOOMED));
720 if (flag && (always || (w->flags & WINDOW_ZOOMED)))
721 w->flags |= WINDOW_WASZOOMED;
723 w->flags &= ~WINDOW_WASZOOMED;
724 return (window_unzoom(w, 1) == 0);
728 window_pop_zoom(struct window *w)
730 log_debug("%s: @%u %d", __func__, w->id,
731 !!(w->flags & WINDOW_WASZOOMED));
732 if (w->flags & WINDOW_WASZOOMED)
733 return (window_zoom(w->active) == 0);
738 window_add_pane(struct window *w, struct window_pane *other, u_int hlimit,
744 other = w->active;
746 wp = window_pane_create(w, w->sx, w->sy, hlimit);
747 if (TAILQ_EMPTY(&w->panes)) {
748 log_debug("%s: @%u at start", __func__, w->id);
749 TAILQ_INSERT_HEAD(&w->panes, wp, entry);
751 log_debug("%s: @%u before %%%u", __func__, w->id, wp->id);
753 TAILQ_INSERT_HEAD(&w->panes, wp, entry);
757 log_debug("%s: @%u after %%%u", __func__, w->id, wp->id);
759 TAILQ_INSERT_TAIL(&w->panes, wp, entry);
761 TAILQ_INSERT_AFTER(&w->panes, other, wp, entry);
767 window_lost_pane(struct window *w, struct window_pane *wp)
769 log_debug("%s: @%u pane %%%u", __func__, w->id, wp->id);
774 window_pane_stack_remove(&w->last_panes, wp);
775 if (wp == w->active) {
776 w->active = TAILQ_FIRST(&w->last_panes);
777 if (w->active == NULL) {
778 w->active = TAILQ_PREV(wp, window_panes, entry);
779 if (w->active == NULL)
780 w->active = TAILQ_NEXT(wp, entry);
782 if (w->active != NULL) {
783 window_pane_stack_remove(&w->last_panes, w->active);
784 w->active->flags |= PANE_CHANGED;
785 notify_window("window-pane-changed", w);
786 window_update_focus(w);
792 window_remove_pane(struct window *w, struct window_pane *wp)
794 window_lost_pane(w, wp);
796 TAILQ_REMOVE(&w->panes, wp, entry);
801 window_pane_at_index(struct window *w, u_int idx)
806 n = options_get_number(w->options, "pane-base-index");
807 TAILQ_FOREACH(wp, &w->panes, entry) {
816 window_pane_next_by_number(struct window *w, struct window_pane *wp, u_int n)
820 wp = TAILQ_FIRST(&w->panes);
827 window_pane_previous_by_number(struct window *w, struct window_pane *wp,
832 wp = TAILQ_LAST(&w->panes, window_panes);
842 struct window *w = wp->window;
844 *i = options_get_number(w->options, "pane-base-index");
845 TAILQ_FOREACH(wq, &w->panes, entry) {
856 window_count_panes(struct window *w)
862 TAILQ_FOREACH(wp, &w->panes, entry)
868 window_destroy_panes(struct window *w)
872 while (!TAILQ_EMPTY(&w->last_panes)) {
873 wp = TAILQ_FIRST(&w->last_panes);
874 window_pane_stack_remove(&w->last_panes, wp);
877 while (!TAILQ_EMPTY(&w->panes)) {
878 wp = TAILQ_FIRST(&w->panes);
879 TAILQ_REMOVE(&w->panes, wp, entry);
938 window_pane_create(struct window *w, u_int sx, u_int sy, u_int hlimit)
944 wp->window = w;
945 wp->options = options_create(w->options);
1113 struct window *w = wp->window;
1137 layout_fix_panes(w, NULL);
1150 struct window *w = wp->window;
1173 layout_fix_panes(w, NULL);
1359 struct window *w;
1366 w = wp->window;
1367 status = options_get_number(w->options, "pane-border-status");
1375 edge = w->sy + 1;
1378 edge = w->sy;
1381 edge = w->sy + 1;
1387 TAILQ_FOREACH(next, &w->panes, entry) {
1416 struct window *w;
1423 w = wp->window;
1424 status = options_get_number(w->options, "pane-border-status");
1431 if (edge >= w->sy)
1434 if (edge >= w->sy - 1)
1437 if (edge >= w->sy)
1444 TAILQ_FOREACH(next, &w->panes, entry) {
1473 struct window *w;
1480 w = wp->window;
1487 edge = w->sx + 1;
1492 TAILQ_FOREACH(next, &w->panes, entry) {
1521 struct window *w;
1528 w = wp->window;
1534 if (edge >= w->sx)
1540 TAILQ_FOREACH(next, &w->panes, entry) {
1703 window_set_fill_character(struct window *w)
1708 free(w->fill_character);
1709 w->fill_character = NULL;
1711 value = options_get_string(w->options, "fill-character");
1715 w->fill_character = ud;