Compare commits

...
6 Commits
Author SHA1 Message Date
gryf 6ea8e56fae Update only selected properties, not all.
That should slightly decrease memory consumption.
2026-08-12 20:47:09 +02:00
gryf 5cbd393022 Removed unnecesary calls for configure and copy_properties 2026-08-12 20:40:35 +02:00
gryf 1c3555956b Added note on changes 2026-08-11 06:53:35 +02:00
gryf ea61d2bb5b Skip throttling for event handling for tab_property_notify.
After some experiments, it turns out, that notifications for X
properties for the embedded window (i.e. tab) are not very often, but
they usually send with "packs", so for example, there could be several
different atoms send in short period of time, i.e.:

_XEMBED_INFO
WM_NORMAL_HINTS
WM_NORMAL_HINTS
WM_NAME
_NET_WM_NAME
WM_ICON_NAME
_NET_WM_ICON_NAME

Some of the atoms represents title change, size of window, size of the
font and so on. Allow those changes to be applied.
2026-08-10 18:10:09 +02:00
gryf 4530aa33aa Remove referencees for variables to free memory in copy_properties function 2026-08-10 17:26:30 +02:00
gryf 0940d0cf03 Make window configure on every refresh 2026-08-10 17:24:19 +02:00
+32 -17
View File
@@ -172,6 +172,23 @@
# tab and disable its hooks
# - 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;
}
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;