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

Comparing rxvt-unicode/src/perl/urxvt-popup (file contents):
Revision 1.11 by root, Sun Jan 8 01:16:10 2006 UTC vs.
Revision 1.14 by root, Thu Jan 19 17:37:01 2006 UTC

51} 51}
52 52
53sub on_button_release { 53sub on_button_release {
54 my ($self, $event) = @_; 54 my ($self, $event) = @_;
55 55
56 if ($event->{button} == $self->{data}{event}{button}) {
57 $self->ungrab;
58 $self->destroy;
59 }
60
61 $self->{press}[$event->{button}] = 0; 56 $self->{press}[$event->{button}] = 0;
62 57
63 my ($row, $col) = ($event->{row}, $event->{col}); 58 my ($row, $col) = ($event->{row}, $event->{col});
64 if ($col >= 0 && $col < $self->ncol 59 if ($col >= 0 && $col < $self->ncol
65 && $row >= 0 && $row < @{ $self->{data}{item} }) { 60 && $row >= 0 && $row < @{ $self->{data}{item} }) {
66 $self->{data}{item}[$row]{activate}->($event); 61 my $item = $self->{data}{item}[$row];
62 $item->{activate}->($event, $item);
67 } 63 }
68 64
69 $self->refresh; 65 $self->refresh;
66
67 if ($event->{button} == $self->{data}{event}{button}) {
68 $self->ungrab;
69 $self->destroy;
70 }
70 71
71 1 72 1
72} 73}
73 74
74sub on_focus_out { 75sub on_focus_out {
86 my $data = $self->{data} = $urxvt::popup::self; 87 my $data = $self->{data} = $urxvt::popup::self;
87 88
88 $_->{width} = $self->strwidth ($_->{text}) 89 $_->{width} = $self->strwidth ($_->{text})
89 for @{ $data->{item} }; 90 for @{ $data->{item} };
90 91
92 $self->resource (title => "URxvt Popup Menu");
93 $self->resource (name => "URxvt.popup");
94
91 $self->resource ($_ => $data->{term}->resource ($_)) 95 $self->resource ($_ => $data->{term}->resource ($_))
92 for qw(font boldFont italicFont boldItalicFont color+0 color+1); 96 for qw(font boldFont italicFont boldItalicFont color+0 color+1);
93 97
94 my $width = List::Util::max map $_->{width}, @{ $data->{item} }; 98 my $width = List::Util::max map $_->{width}, @{ $data->{item} };
95 my $height = @{ $data->{item} }; 99 my $height = @{ $data->{item} };
97 my $pos = ""; 101 my $pos = "";
98 102
99 if ($data->{event}) { 103 if ($data->{event}) {
100 my $x = int List::Util::max 0, $data->{event}{x_root} - $width * $data->{term}->fwidth * 0.5; 104 my $x = int List::Util::max 0, $data->{event}{x_root} - $width * $data->{term}->fwidth * 0.5;
101 my $y = int List::Util::max 0, $data->{event}{y_root} - $data->{term}->fheight * 0.5; 105 my $y = int List::Util::max 0, $data->{event}{y_root} - $data->{term}->fheight * 0.5;
102
103 $pos = "+$x+$y"; 106 $pos = "+$x+$y";
104 } 107 }
105 108
106 $self->resource (geometry => "${width}x${height}$pos"); 109 $self->resource (geometry => "${width}x${height}$pos");
107 110
130 $self->grab ($self->{data}{event}{time}, 1) 133 $self->grab ($self->{data}{event}{time}, 1)
131 and $self->allow_events_async; 134 and $self->allow_events_async;
132} 135}
133 136
134 137
135
136
137
138

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines