ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/perl/tabbed
(Generate patch)

Comparing rxvt-unicode/src/perl/tabbed (file contents):
Revision 1.9 by root, Fri Jan 20 16:13:33 2006 UTC vs.
Revision 1.14 by root, Fri Feb 3 05:49:42 2006 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines