… | |
… | |
76 | $tab->XMoveResizeWindow ( |
76 | $tab->XMoveResizeWindow ( |
77 | $tab->parent, |
77 | $tab->parent, |
78 | 0, $self->{tabheight}, |
78 | 0, $self->{tabheight}, |
79 | $self->width, $self->height - $self->{tabheight} |
79 | $self->width, $self->height - $self->{tabheight} |
80 | ); |
80 | ); |
|
|
81 | } |
|
|
82 | |
|
|
83 | sub copy_properties { |
|
|
84 | my ($self) = @_; |
|
|
85 | my $tab = $self->{cur}; |
81 | |
86 | |
82 | my $wm_normal_hints = $self->XInternAtom ("WM_NORMAL_HINTS"); |
87 | my $wm_normal_hints = $self->XInternAtom ("WM_NORMAL_HINTS"); |
|
|
88 | |
|
|
89 | my %our_props = map +($_ => undef), $self->XListProperties ($self->parent); |
83 | |
90 | |
84 | for my $atom ($tab->XListProperties ($tab->parent)) { |
91 | for my $atom ($tab->XListProperties ($tab->parent)) { |
85 | my ($type, $format, $items) = $self->XGetWindowProperty ($tab->parent, $atom); |
92 | my ($type, $format, $items) = $self->XGetWindowProperty ($tab->parent, $atom); |
|
|
93 | |
|
|
94 | delete $our_props{$atom}; |
86 | |
95 | |
87 | if ($atom == $wm_normal_hints) { |
96 | if ($atom == $wm_normal_hints) { |
88 | my (@hints) = unpack "l!*", $items; |
97 | my (@hints) = unpack "l!*", $items; |
89 | |
98 | |
90 | $hints[$_] += $self->{tabheight} for (4, 6, 16); |
99 | $hints[$_] += $self->{tabheight} for (4, 6, 16); |
… | |
… | |
92 | $items = pack "l!*", @hints; |
101 | $items = pack "l!*", @hints; |
93 | } |
102 | } |
94 | $self->XChangeWindowProperty ($self->parent, $atom, $type, $format, $items); |
103 | $self->XChangeWindowProperty ($self->parent, $atom, $type, $format, $items); |
95 | } |
104 | } |
96 | |
105 | |
97 | $self->refresh; |
106 | $self->XDeleteProperty ($self->parent, $_) for keys %our_props; |
98 | } |
107 | } |
99 | |
108 | |
100 | sub make_current { |
109 | sub make_current { |
101 | my ($self, $tab) = @_; |
110 | my ($self, $tab) = @_; |
102 | |
111 | |
… | |
… | |
107 | } |
116 | } |
108 | |
117 | |
109 | $self->{cur} = $tab; |
118 | $self->{cur} = $tab; |
110 | |
119 | |
111 | $self->configure; |
120 | $self->configure; |
|
|
121 | $self->copy_properties; |
112 | $tab->focus_in; |
122 | $tab->focus_in; |
113 | $tab->XMapWindow ($tab->parent); |
123 | $tab->XMapWindow ($tab->parent); |
|
|
124 | delete $tab->{activity}; |
114 | $self->refresh; |
125 | $self->refresh; |
115 | delete $tab->{activity}; |
|
|
116 | |
126 | |
117 | () |
127 | () |
118 | } |
128 | } |
119 | |
129 | |
120 | sub on_button_press { |
130 | sub on_button_press { |
… | |
… | |
170 | |
180 | |
171 | sub on_configure_notify { |
181 | sub on_configure_notify { |
172 | my ($self, $event) = @_; |
182 | my ($self, $event) = @_; |
173 | |
183 | |
174 | $self->configure; |
184 | $self->configure; |
|
|
185 | $self->refresh; |
175 | |
186 | |
176 | () |
187 | () |
177 | } |
188 | } |
178 | |
189 | |
179 | sub on_wm_delete_window { |
190 | sub on_wm_delete_window { |
… | |
… | |
184 | 1 |
195 | 1 |
185 | } |
196 | } |
186 | |
197 | |
187 | sub tab_start { |
198 | sub tab_start { |
188 | my ($self, $tab) = @_; |
199 | my ($self, $tab) = @_; |
|
|
200 | |
|
|
201 | $tab->XChangeInput ($tab->parent, urxvt::PropertyChangeMask); |
189 | |
202 | |
190 | push @{ $self->{tabs} }, $tab; |
203 | push @{ $self->{tabs} }, $tab; |
191 | |
204 | |
192 | # $tab->{name} ||= scalar @{ $self->{tabs} }; |
205 | # $tab->{name} ||= scalar @{ $self->{tabs} }; |
193 | $self->make_current ($tab); |
206 | $self->make_current ($tab); |
… | |
… | |
216 | } |
229 | } |
217 | |
230 | |
218 | sub tab_key_press { |
231 | sub tab_key_press { |
219 | my ($self, $tab, $event, $keysym, $str) = @_; |
232 | my ($self, $tab, $event, $keysym, $str) = @_; |
220 | |
233 | |
221 | if ($event->{state} & urxvt::ShiftMask |
234 | if ($event->{state} & urxvt::ShiftMask) { |
222 | && ($keysym == 0xff51 || $keysym == 0xff53)) { |
235 | if ($keysym == 0xff51 || $keysym == 0xff53) { |
223 | my ($idx) = grep $self->{tabs}[$_] == $tab, 0 .. $#{ $self->{tabs} }; |
236 | my ($idx) = grep $self->{tabs}[$_] == $tab, 0 .. $#{ $self->{tabs} }; |
224 | |
237 | |
225 | --$idx if $keysym == 0xff51; |
238 | --$idx if $keysym == 0xff51; |
226 | ++$idx if $keysym == 0xff53; |
239 | ++$idx if $keysym == 0xff53; |
227 | |
240 | |
228 | $self->make_current ($self->{tabs}[$idx % @{ $self->{tabs}}]); |
241 | $self->make_current ($self->{tabs}[$idx % @{ $self->{tabs}}]); |
229 | $self->refresh; |
242 | |
|
|
243 | return 1; |
|
|
244 | } elsif ($keysym == 0xff54) { |
|
|
245 | $self->new_tab; |
|
|
246 | |
|
|
247 | return 1; |
230 | |
248 | } |
231 | return 1; |
|
|
232 | } |
249 | } |
|
|
250 | |
|
|
251 | () |
|
|
252 | } |
|
|
253 | |
|
|
254 | sub tab_property_notify { |
|
|
255 | my ($self, $tab, $event) = @_; |
|
|
256 | |
|
|
257 | $self->copy_properties |
|
|
258 | if $event->{window} == $tab->parent; |
233 | |
259 | |
234 | () |
260 | () |
235 | } |
261 | } |
236 | |
262 | |
237 | sub tab_activity { |
263 | sub tab_activity { |
… | |
… | |
244 | |
270 | |
245 | # helper extension implementing the subwindows of a tabbed terminal. |
271 | # helper extension implementing the subwindows of a tabbed terminal. |
246 | # simply proxies all interesting calls back to the tabbed class. |
272 | # simply proxies all interesting calls back to the tabbed class. |
247 | |
273 | |
248 | { |
274 | { |
249 | for my $hook qw(start destroy key_press) { |
275 | for my $hook qw(start destroy key_press property_notify) { |
250 | eval qq{ |
276 | eval qq{ |
251 | sub on_$hook { |
277 | sub on_$hook { |
252 | my \$parent = \$_[0]{term}{parent} |
278 | my \$parent = \$_[0]{term}{parent} |
253 | or return; |
279 | or return; |
254 | \$parent->tab_$hook (\@_) |
280 | \$parent->tab_$hook (\@_) |