1 | #! perl |
1 | #! perl |
|
|
2 | |
|
|
3 | #:META:X_RESOURCE:tabbar-fg:tab bar foreground colour |
|
|
4 | #:META:X_RESOURCE:tabbar-bg:tab bar background colour |
|
|
5 | #:META:X_RESOURCE:tab-fg:tab foreground colour |
|
|
6 | #:META:X_RESOURCE:tab-bg:tab background colour |
2 | |
7 | |
3 | sub refresh { |
8 | sub refresh { |
4 | my ($self) = @_; |
9 | my ($self) = @_; |
5 | |
10 | |
6 | my $ncol = $self->ncol; |
11 | my $ncol = $self->ncol; |
… | |
… | |
43 | $self->want_refresh; |
48 | $self->want_refresh; |
44 | } |
49 | } |
45 | |
50 | |
46 | sub new_tab { |
51 | sub new_tab { |
47 | my ($self, @argv) = @_; |
52 | my ($self, @argv) = @_; |
48 | |
|
|
49 | my $offset = $self->fheight; |
|
|
50 | |
53 | |
51 | # save a backlink to us, make sure tabbed is inactive |
54 | # save a backlink to us, make sure tabbed is inactive |
52 | push @urxvt::TERM_INIT, sub { |
55 | push @urxvt::TERM_INIT, sub { |
53 | my ($term) = @_; |
56 | my ($term) = @_; |
54 | $term->{parent} = $self; |
57 | $term->{parent} = $self; |
… | |
… | |
105 | my $current = delete $self->{current_properties}; |
108 | my $current = delete $self->{current_properties}; |
106 | |
109 | |
107 | # pass 1: copy over properties different or nonexisting |
110 | # pass 1: copy over properties different or nonexisting |
108 | for my $atom ($tab->XListProperties ($tab->parent)) { |
111 | for my $atom ($tab->XListProperties ($tab->parent)) { |
109 | my ($type, $format, $items) = $self->XGetWindowProperty ($tab->parent, $atom); |
112 | my ($type, $format, $items) = $self->XGetWindowProperty ($tab->parent, $atom); |
110 | |
113 | |
111 | # fix up size hints |
114 | # fix up size hints |
112 | if ($atom == $wm_normal_hints) { |
115 | if ($atom == $wm_normal_hints) { |
113 | my (@hints) = unpack "l!*", $items; |
116 | my (@hints) = unpack "l!*", $items; |
114 | |
117 | |
115 | $hints[$_] += $self->{tabheight} for (4, 6, 16); |
118 | $hints[$_] += $self->{tabheight} for (4, 6, 16); |
116 | |
119 | |
117 | $items = pack "l!*", @hints; |
120 | $items = pack "l!*", @hints; |
118 | } |
121 | } |
119 | |
122 | |
120 | my $cur = delete $current->{$atom}; |
123 | my $cur = delete $current->{$atom}; |
121 | |
124 | |
… | |
… | |
136 | if (my $cur = $self->{cur}) { |
139 | if (my $cur = $self->{cur}) { |
137 | delete $cur->{activity}; |
140 | delete $cur->{activity}; |
138 | $cur->XUnmapWindow ($cur->parent) if $cur->mapped; |
141 | $cur->XUnmapWindow ($cur->parent) if $cur->mapped; |
139 | $cur->focus_out; |
142 | $cur->focus_out; |
140 | } |
143 | } |
141 | |
144 | |
142 | $self->{cur} = $tab; |
145 | $self->{cur} = $tab; |
143 | |
146 | |
144 | $self->configure; |
147 | $self->configure; |
145 | $self->copy_properties; |
148 | $self->copy_properties; |
146 | |
149 | |
147 | $tab->focus_out; # just in case, should be a nop |
150 | $tab->focus_out; # just in case, should be a nop |
148 | $tab->focus_in if $self->focus; |
151 | $tab->focus_in if $self->focus; |
149 | |
152 | |
150 | $tab->XMapWindow ($tab->parent); |
153 | $tab->XMapWindow ($tab->parent); |
151 | delete $tab->{activity}; |
154 | delete $tab->{activity}; |
152 | $self->refresh; |
155 | $self->refresh; |
153 | |
156 | |
154 | () |
157 | () |
… | |
… | |
166 | my ($self, $event) = @_; |
169 | my ($self, $event) = @_; |
167 | |
170 | |
168 | $self->{cur}->focus_out; |
171 | $self->{cur}->focus_out; |
169 | |
172 | |
170 | () |
173 | () |
|
|
174 | } |
|
|
175 | |
|
|
176 | sub on_tt_write { |
|
|
177 | my ($self, $octets) = @_; |
|
|
178 | |
|
|
179 | $self->{cur}->tt_write ($octets); |
|
|
180 | |
|
|
181 | 1 |
171 | } |
182 | } |
172 | |
183 | |
173 | sub on_key_press { |
184 | sub on_key_press { |
174 | my ($self, $event) = @_; |
185 | my ($self, $event) = @_; |
175 | |
186 | |
… | |
… | |
312 | |
323 | |
313 | --$idx if $keysym == 0xff51; |
324 | --$idx if $keysym == 0xff51; |
314 | ++$idx if $keysym == 0xff53; |
325 | ++$idx if $keysym == 0xff53; |
315 | |
326 | |
316 | $self->make_current ($self->{tabs}[$idx % @{ $self->{tabs}}]); |
327 | $self->make_current ($self->{tabs}[$idx % @{ $self->{tabs}}]); |
317 | |
328 | |
318 | return 1; |
329 | return 1; |
319 | } elsif ($keysym == 0xff54) { |
330 | } elsif ($keysym == 0xff54) { |
320 | $self->new_tab; |
331 | $self->new_tab; |
321 | |
332 | |
322 | return 1; |
333 | return 1; |