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.23 by root, Sun Jun 15 13:54:16 2008 UTC vs.
Revision 1.31 by root, Wed Jun 6 15:06:41 2012 UTC

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
3sub refresh { 8sub 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
46sub new_tab { 51sub 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;
55 58
56 $term->resource ($_->[0] => $_->[1]) 59 for (0 .. urxvt::NUM_RESOURCES - 1) {
57 for @{ $self->{resource} || [] }; 60 my $value = $self->{resource}[$_];
61
62 $term->resource ("+$_" => $value)
63 if defined $value;
64 }
58 65
59 $term->resource (perl_ext_2 => $term->resource ("perl_ext_2") . ",-tabbed"); 66 $term->resource (perl_ext_2 => $term->resource ("perl_ext_2") . ",-tabbed");
60 }; 67 };
61 68
62 push @urxvt::TERM_EXT, urxvt::ext::tabbed::tab::; 69 push @urxvt::TERM_EXT, urxvt::ext::tabbed::tab::;
96 my ($self) = @_; 103 my ($self) = @_;
97 my $tab = $self->{cur}; 104 my $tab = $self->{cur};
98 105
99 my $wm_normal_hints = $self->XInternAtom ("WM_NORMAL_HINTS"); 106 my $wm_normal_hints = $self->XInternAtom ("WM_NORMAL_HINTS");
100 107
101 my %our_props = map +($_ => undef), $self->XListProperties ($self->parent); 108 my $current = delete $self->{current_properties};
102 109
103 delete $our_props{$self->XInternAtom ($_)} 110 # pass 1: copy over properties different or nonexisting
104 for qw(WM_STATE WM_ICON_SIZE
105 _NET_WM_VISIBLE_NAME _NET_WM_VISIBLE_ICON_NAME _NET_WM_ICON_GEOMETRY _NET_FRAME_EXTENTS);
106
107 for my $atom ($tab->XListProperties ($tab->parent)) { 111 for my $atom ($tab->XListProperties ($tab->parent)) {
108 my ($type, $format, $items) = $self->XGetWindowProperty ($tab->parent, $atom); 112 my ($type, $format, $items) = $self->XGetWindowProperty ($tab->parent, $atom);
109
110 delete $our_props{$atom};
111 113
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 ($dtype, $dformat, $ditems) = $self->XGetWindowProperty ($self->parent, $atom); 123 my $cur = delete $current->{$atom};
121 124
122 if ($dtype != $type or $dformat != $format or $ditems ne $items) { 125 # update if changed, we assume empty items and zero type and format will not happen
123 $self->XChangeWindowProperty ($self->parent, $atom, $type, $format, $items); 126 $self->XChangeProperty ($self->parent, $atom, $type, $format, $items)
124 } 127 if $cur->[0] != $type or $cur->[1] != $format or $cur->[2] ne $items;
125 }
126 128
129 $self->{current_properties}{$atom} = [$type, $format, $items];
130 }
131
132 # pass 2, delete all extraneous properties
127 $self->XDeleteProperty ($self->parent, $_) for keys %our_props; 133 $self->XDeleteProperty ($self->parent, $_) for keys %$current;
128} 134}
129 135
130sub make_current { 136sub make_current {
131 my ($self, $tab) = @_; 137 my ($self, $tab) = @_;
132 138
133 if (my $cur = $self->{cur}) { 139 if (my $cur = $self->{cur}) {
134 delete $cur->{activity}; 140 delete $cur->{activity};
135 $cur->XUnmapWindow ($cur->parent) if $cur->mapped; 141 $cur->XUnmapWindow ($cur->parent) if $cur->mapped;
136 $cur->focus_out; 142 $cur->focus_out;
137 } 143 }
138 144
139 $self->{cur} = $tab; 145 $self->{cur} = $tab;
140 146
141 $self->configure; 147 $self->configure;
142 $self->copy_properties; 148 $self->copy_properties;
143 149
144 $tab->focus_out; # just in case, should be a nop 150 $tab->focus_out; # just in case, should be a nop
145 $tab->focus_in if $self->focus; 151 $tab->focus_in if $self->focus;
146 152
147 $tab->XMapWindow ($tab->parent); 153 $tab->XMapWindow ($tab->parent);
148 delete $tab->{activity}; 154 delete $tab->{activity};
149 $self->refresh; 155 $self->refresh;
150 156
151 () 157 ()
163 my ($self, $event) = @_; 169 my ($self, $event) = @_;
164 170
165 $self->{cur}->focus_out; 171 $self->{cur}->focus_out;
166 172
167 () 173 ()
174}
175
176sub on_tt_write {
177 my ($self, $octets) = @_;
178
179 $self->{cur}->tt_write ($octets);
180
181 1
168} 182}
169 183
170sub on_key_press { 184sub on_key_press {
171 my ($self, $event) = @_; 185 my ($self, $event) = @_;
172 186
206} 220}
207 221
208sub on_init { 222sub on_init {
209 my ($self) = @_; 223 my ($self) = @_;
210 224
211 for (qw(name chdir perl_ext_1 perl_ext_2)) { 225 $self->{resource} = [map $self->resource ("+$_"), 0 .. urxvt::NUM_RESOURCES - 1];
212 my $val = $self->resource ($_);
213
214 push @{ $self->{resource} }, [$_ => $val]
215 if defined $val;
216 }
217 226
218 $self->resource (int_bwidth => 0); 227 $self->resource (int_bwidth => 0);
219 $self->resource (name => "URxvt.tabbed"); 228 $self->resource (name => "URxvt.tabbed");
220 $self->resource (pty_fd => -1); 229 $self->resource (pty_fd => -1);
221 230
314 323
315 --$idx if $keysym == 0xff51; 324 --$idx if $keysym == 0xff51;
316 ++$idx if $keysym == 0xff53; 325 ++$idx if $keysym == 0xff53;
317 326
318 $self->make_current ($self->{tabs}[$idx % @{ $self->{tabs}}]); 327 $self->make_current ($self->{tabs}[$idx % @{ $self->{tabs}}]);
319 328
320 return 1; 329 return 1;
321 } elsif ($keysym == 0xff54) { 330 } elsif ($keysym == 0xff54) {
322 $self->new_tab; 331 $self->new_tab;
323 332
324 return 1; 333 return 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines