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