Compare commits

...
4 Commits
Author SHA1 Message Date
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
+19 -13
View File
@@ -170,8 +170,14 @@
# 2026-04-21 18:34:16 # 2026-04-21 18:34:16
# - Make some more optimization on memory usage - remove data from destroyed # - Make some more optimization on memory usage - remove data from destroyed
# tab and disable its hooks # 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 # 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.
use Scalar::Util; use Scalar::Util;
@@ -285,8 +291,9 @@ sub refresh {
$self->{tabheight} = $self->{_tabheight}; $self->{tabheight} = $self->{_tabheight};
} }
$self->configure;
if ($old_tabheight != $self->{tabheight}) { if ($old_tabheight != $self->{tabheight}) {
$self->configure;
$self->copy_properties; $self->copy_properties;
} }
@@ -414,8 +421,8 @@ sub copy_properties {
my $current = delete $self->{current_properties}; my $current = delete $self->{current_properties};
# pass 1: copy over properties different or nonexisting # pass 1: copy over properties different or nonexisting
for my $atom ($tab->XListProperties ($tab->parent)) { for my $atom ($tab->XListProperties($tab->parent)) {
my ($type, $format, $items) = $self->XGetWindowProperty ($tab->parent, $atom); my ($type, $format, $items) = $self->XGetWindowProperty($tab->parent, $atom);
# fix up size hints # fix up size hints
if ($atom == $wm_normal_hints) { if ($atom == $wm_normal_hints) {
@@ -427,22 +434,29 @@ sub copy_properties {
$hints[$_] += $self->{tabheight} for (4, 6, 16); $hints[$_] += $self->{tabheight} for (4, 6, 16);
$items = pack "l!*", @hints; $items = pack "l!*", @hints;
undef @hints;
} }
my $cur = delete $current->{$atom}; my $cur = delete $current->{$atom};
# update if changed, we assume empty items and zero type and format will not happen # 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; if $cur->[0] != $type or $cur->[1] != $format or $cur->[2] ne $items;
$self->{current_properties}{$atom} = [$type, $format, $items]; $self->{current_properties}{$atom} = [$type, $format, $items];
undef $type; undef $type;
undef $format; undef $format;
undef $items; undef $items;
undef $atom;
undef $cur;
} }
# pass 2, delete all extraneous properties # pass 2, delete all extraneous properties
$self->XDeleteProperty ($self->parent, $_) for keys %$current; $self->XDeleteProperty ($self->parent, $_) for keys %$current;
undef $current;
undef $wm_normal_hints;
} }
sub make_current { sub make_current {
@@ -807,14 +821,6 @@ sub tab_property_notify {
return () unless $event->{window} == $tab->parent; return () unless $event->{window} == $tab->parent;
return () unless $tab == $self->{cur}; 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 property instead of all properties
my $atom = $event->{atom}; my $atom = $event->{atom};
my ($type, $format, $items) = $self->XGetWindowProperty ($tab->parent, $atom); my ($type, $format, $items) = $self->XGetWindowProperty ($tab->parent, $atom);