mirror of
https://github.com/gryf/tabbedalt.git
synced 2026-08-31 18:17:43 +02:00
Compare commits
6
Commits
57f5423dc4
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ea8e56fae | ||
|
|
5cbd393022 | ||
|
|
1c3555956b | ||
|
|
ea61d2bb5b | ||
|
|
4530aa33aa | ||
|
|
0940d0cf03 |
@@ -170,8 +170,25 @@
|
||||
# 2026-04-21 18:34:16
|
||||
# - Make some more optimization on memory usage - remove data from destroyed
|
||||
# tab and disable its hooks
|
||||
# - update tab property notifications, don't update it too often, clean up X
|
||||
# - update tab property notifications, don't update it too often, clean up X
|
||||
# properties variables after use, update only changed X properties
|
||||
#
|
||||
# 2026-08-10 17:20:53
|
||||
# - remove variables in copy_properties to free memory
|
||||
# - call configure() every time on refresh
|
||||
# - removed throttling to suppress tab property notifications, as they need to
|
||||
# be applied as every call there is different atom to process.
|
||||
#
|
||||
# 2026-08-11 18:42:45
|
||||
# - removed call copy_properties() call from refresh() to avoid unnecessary
|
||||
# Xlib interaction (to spare memory as the consequence) and rely only on
|
||||
# notifications.
|
||||
# - removed call for configure() from places, which will call refresh() as in
|
||||
# refresh() configure will be called anyway.
|
||||
#
|
||||
# 2026-08-12 20:40:54
|
||||
# - narrow down X properties which will be updated during tab_property_notify,
|
||||
# which should slightly improve memory consumption.
|
||||
|
||||
use Scalar::Util;
|
||||
|
||||
@@ -285,10 +302,7 @@ sub refresh {
|
||||
$self->{tabheight} = $self->{_tabheight};
|
||||
}
|
||||
|
||||
if ($old_tabheight != $self->{tabheight}) {
|
||||
$self->configure;
|
||||
$self->copy_properties;
|
||||
}
|
||||
$self->configure;
|
||||
|
||||
my $ncol = $self->ncol;
|
||||
|
||||
@@ -414,8 +428,8 @@ sub copy_properties {
|
||||
my $current = delete $self->{current_properties};
|
||||
|
||||
# pass 1: copy over properties different or nonexisting
|
||||
for my $atom ($tab->XListProperties ($tab->parent)) {
|
||||
my ($type, $format, $items) = $self->XGetWindowProperty ($tab->parent, $atom);
|
||||
for my $atom ($tab->XListProperties($tab->parent)) {
|
||||
my ($type, $format, $items) = $self->XGetWindowProperty($tab->parent, $atom);
|
||||
|
||||
# fix up size hints
|
||||
if ($atom == $wm_normal_hints) {
|
||||
@@ -427,22 +441,29 @@ sub copy_properties {
|
||||
$hints[$_] += $self->{tabheight} for (4, 6, 16);
|
||||
|
||||
$items = pack "l!*", @hints;
|
||||
undef @hints;
|
||||
}
|
||||
|
||||
my $cur = delete $current->{$atom};
|
||||
|
||||
# update if changed, we assume empty items and zero type and format will not happen
|
||||
$self->XChangeProperty ($self->parent, $atom, $type, $format, $items)
|
||||
$self->XChangeProperty($self->parent, $atom, $type, $format, $items)
|
||||
if $cur->[0] != $type or $cur->[1] != $format or $cur->[2] ne $items;
|
||||
|
||||
$self->{current_properties}{$atom} = [$type, $format, $items];
|
||||
|
||||
undef $type;
|
||||
undef $format;
|
||||
undef $items;
|
||||
undef $atom;
|
||||
undef $cur;
|
||||
}
|
||||
|
||||
# pass 2, delete all extraneous properties
|
||||
$self->XDeleteProperty ($self->parent, $_) for keys %$current;
|
||||
|
||||
undef $current;
|
||||
undef $wm_normal_hints;
|
||||
}
|
||||
|
||||
sub make_current {
|
||||
@@ -466,7 +487,6 @@ sub make_current {
|
||||
$self->{cur} = $tab;
|
||||
$tab->enable_activity_hook(0);
|
||||
|
||||
$self->configure;
|
||||
$self->copy_properties;
|
||||
|
||||
$tab->focus_out; # just in case, should be a nop
|
||||
@@ -665,7 +685,6 @@ _on start => sub {
|
||||
_on configure_notify => sub {
|
||||
my ($self, $event) = @_;
|
||||
|
||||
$self->configure;
|
||||
$self->refresh;
|
||||
|
||||
()
|
||||
@@ -807,16 +826,11 @@ sub tab_property_notify {
|
||||
return () unless $event->{window} == $tab->parent;
|
||||
return () unless $tab == $self->{cur};
|
||||
|
||||
# skip if called too often (within 0.1s)
|
||||
my $now = urxvt::NOW;
|
||||
my $last = $self->{last_property_update} // 0;
|
||||
if ($now - $last < 0.1) {
|
||||
return ();
|
||||
}
|
||||
$self->{last_property_update} = $now;
|
||||
|
||||
# update only the changed property instead of all properties
|
||||
# update only the changed selected property instead of all properties
|
||||
my $atom = $event->{atom};
|
||||
my %allowed = map { $_ => 1 } qw(WM_NORMAL_HINTS _NET_WM_NAME WM_NAME);
|
||||
return () unless ($allowed{$self->XGetAtomName($atom)});
|
||||
|
||||
my ($type, $format, $items) = $self->XGetWindowProperty ($tab->parent, $atom);
|
||||
|
||||
my $wm_normal_hints = $self->XInternAtom ("WM_NORMAL_HINTS");
|
||||
@@ -832,6 +846,7 @@ sub tab_property_notify {
|
||||
$self->{current_properties}{$atom} = [$type, $format, $items];
|
||||
|
||||
# free memory from X properties
|
||||
undef $wm_normal_hints;
|
||||
undef $type;
|
||||
undef $format;
|
||||
undef $items;
|
||||
|
||||
Reference in New Issue
Block a user