summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2007-08-09 08:57:05 +0000
committerPascal Rigaux <pixel@mandriva.com>2007-08-09 08:57:05 +0000
commited37ddb1f4ef2ea7f23c092267e70bd39b8b62c7 (patch)
tree3772cd25555a2b153c05b7aad436cb9a0d503e11 /lib
parent4d6058730c978aafc8e726001bfa9ad9319b5453 (diff)
downloaddrakx-kbd-mouse-x11-ed37ddb1f4ef2ea7f23c092267e70bd39b8b62c7.tar
drakx-kbd-mouse-x11-ed37ddb1f4ef2ea7f23c092267e70bd39b8b62c7.tar.gz
drakx-kbd-mouse-x11-ed37ddb1f4ef2ea7f23c092267e70bd39b8b62c7.tar.bz2
drakx-kbd-mouse-x11-ed37ddb1f4ef2ea7f23c092267e70bd39b8b62c7.tar.xz
drakx-kbd-mouse-x11-ed37ddb1f4ef2ea7f23c092267e70bd39b8b62c7.zip
- when removing/replacing an InputDevice section, ensure we remove the
corresponding entry in ServerLayout. ie do not rely on InputDevice sections to use XFdrake-compatible Identifiers (as suggested by fcrozat)
Diffstat (limited to 'lib')
-rw-r--r--lib/Xconfig/xfree.pm31
1 files changed, 17 insertions, 14 deletions
diff --git a/lib/Xconfig/xfree.pm b/lib/Xconfig/xfree.pm
index 0b84ba4..5c3f5bc 100644
--- a/lib/Xconfig/xfree.pm
+++ b/lib/Xconfig/xfree.pm
@@ -159,10 +159,7 @@ sub _is_mouse {
}
sub _new_mouse_sections {
my ($raw_X, @Drivers) = @_;
- $raw_X->remove_Section('InputDevice', \&_is_mouse);
-
- my $layout = get_ServerLayout($raw_X)->{InputDevice} ||= [];
- @$layout = grep { $_->{val} !~ /^"Mouse/ } @$layout;
+ $raw_X->remove_InputDevices_when(\&_is_mouse);
@Drivers or return;
@@ -170,7 +167,8 @@ sub _new_mouse_sections {
my $h = { Identifier => { val => 'Mouse' . ($::i + 1) }, Driver => { val => $_ } };
$raw_X->add_Section('InputDevice', $h);
} @Drivers;
-
+
+ my $layout = get_ServerLayout($raw_X)->{InputDevice} ||= [];
push @$layout, { val => qq("Mouse1" "CorePointer") };
push @$layout, { val => qq("Mouse$_" "SendCoreEvents") } foreach 2 .. @Drivers;
@@ -274,13 +272,11 @@ sub set_wacoms {
my ($raw_X, @wacoms) = @_;
$raw_X->remove_InputDevices('wacom');
- my $layout = get_ServerLayout($raw_X)->{InputDevice} ||= [];
- @$layout = grep { $_->{val} !~ /^"(Stylus|Eraser|Cursor|Pad)/ } @$layout;
-
@wacoms or return;
my @Modes = ('Stylus', 'Eraser', 'Cursor', 'Pad');
+ my $layout = get_ServerLayout($raw_X)->{InputDevice} ||= [];
each_index {
my $wacom = $_;
foreach (@Modes) {
@@ -305,11 +301,9 @@ sub set_synaptics {
my ($raw_X, @synaptics) = @_;
$raw_X->remove_InputDevices('synaptics');
- my $layout = get_ServerLayout($raw_X)->{InputDevice} ||= [];
- @$layout = grep { $_->{val} !~ /^"SynapticsMouse/ } @$layout;
-
@synaptics or return;
+ my $layout = get_ServerLayout($raw_X)->{InputDevice} ||= [];
each_index {
my $synaptics_mouse = $_;
my $identifier = "SynapticsMouse" . ($::i + 1);
@@ -553,7 +547,15 @@ sub get_InputDevices {
}
sub remove_InputDevices {
my ($raw_X, $Driver) = @_;
- $raw_X->remove_Section('InputDevice', sub { val($_[0]{Driver}) eq $Driver });
+ $raw_X->remove_InputDevices_when(sub { val($_[0]{Driver}) eq $Driver });
+}
+sub remove_InputDevices_when {
+ my ($raw_X, $when) = @_;
+ my @removed = $raw_X->remove_Section('InputDevice', $when);
+
+ my $Identifier_regexp = join('|', map { val($_->{l}{Identifier}) } @removed);
+ my $layout = get_ServerLayout($raw_X)->{InputDevice} ||= [];
+ @$layout = grep { $_->{val} !~ /^"$Identifier_regexp"/ } @$layout;
}
sub get_ServerLayout {
@@ -607,8 +609,9 @@ sub add_Section {
sub remove_Section {
my ($raw_X, $Section, $o_when) = @_;
my $raw = $raw_X->{raw};
- @$raw = grep { $_->{name} ne $Section || $o_when && !$o_when->($_->{l}) } @$raw;
- $raw_X;
+ my ($keep, $remove) = partition { $_->{name} ne $Section || $o_when && !$o_when->($_->{l}) } @$raw;
+ @$raw = @$keep;
+ @$remove;
}
sub get_Sections {
my ($raw_X, $Section, $o_when) = @_;