--- rxvt-unicode/src/perl/urxvt-popup 2006/01/08 01:16:10 1.11 +++ rxvt-unicode/src/perl/urxvt-popup 2012/06/10 17:31:53 1.16 @@ -1,7 +1,7 @@ #! perl # this extension implements popup-menu functionality for urxvt. it works -# together with the urxvt::popup class. +# together with the urxvt::popup class - "no user servicable parts inside". sub refresh { my ($self) = @_; @@ -53,21 +53,22 @@ sub on_button_release { my ($self, $event) = @_; - if ($event->{button} == $self->{data}{event}{button}) { - $self->ungrab; - $self->destroy; - } - $self->{press}[$event->{button}] = 0; my ($row, $col) = ($event->{row}, $event->{col}); if ($col >= 0 && $col < $self->ncol && $row >= 0 && $row < @{ $self->{data}{item} }) { - $self->{data}{item}[$row]{activate}->($event); + my $item = $self->{data}{item}[$row]; + $item->{activate}->($event, $item); } $self->refresh; + if ($event->{button} == $self->{data}{event}{button}) { + $self->ungrab; + $self->destroy; + } + 1 } @@ -88,6 +89,9 @@ $_->{width} = $self->strwidth ($_->{text}) for @{ $data->{item} }; + $self->resource (title => "URxvt Popup Menu"); + $self->resource (name => "URxvt.popup"); + $self->resource ($_ => $data->{term}->resource ($_)) for qw(font boldFont italicFont boldItalicFont color+0 color+1); @@ -99,12 +103,13 @@ if ($data->{event}) { my $x = int List::Util::max 0, $data->{event}{x_root} - $width * $data->{term}->fwidth * 0.5; my $y = int List::Util::max 0, $data->{event}{y_root} - $data->{term}->fheight * 0.5; - $pos = "+$x+$y"; } $self->resource (geometry => "${width}x${height}$pos"); + $self->{term}{urxvt_popup_init_done} = 1; + () } @@ -132,7 +137,3 @@ } - - - -