diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2007-06-14 08:03:21 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2007-06-14 08:03:21 +0000 |
commit | 289ddff1ad6882edcb7b36db139e46f13c2c8bda (patch) | |
tree | 71d255aa515660b7ffe916314bf462eb62ad93cc | |
parent | 954099b536c62c15a8472444ef2863e25d0d2285 (diff) | |
download | drakx-kbd-mouse-x11-289ddff1ad6882edcb7b36db139e46f13c2c8bda.tar drakx-kbd-mouse-x11-289ddff1ad6882edcb7b36db139e46f13c2c8bda.tar.gz drakx-kbd-mouse-x11-289ddff1ad6882edcb7b36db139e46f13c2c8bda.tar.bz2 drakx-kbd-mouse-x11-289ddff1ad6882edcb7b36db139e46f13c2c8bda.tar.xz drakx-kbd-mouse-x11-289ddff1ad6882edcb7b36db139e46f13c2c8bda.zip |
create ->is_modified and internalize in the raw_X object the handling of
saying wether it is modified
-rw-r--r-- | lib/Xconfig/main.pm | 11 | ||||
-rw-r--r-- | lib/Xconfig/xfree.pm | 14 |
2 files changed, 12 insertions, 13 deletions
diff --git a/lib/Xconfig/main.pm b/lib/Xconfig/main.pm index 37a02c3..7fb9c8a 100644 --- a/lib/Xconfig/main.pm +++ b/lib/Xconfig/main.pm @@ -17,9 +17,9 @@ use common; sub configure_monitor { my ($in) = @_; - my ($raw_X, $before) = Xconfig::xfree->read_and_prepare_write; + my $raw_X = Xconfig::xfree->read; Xconfig::monitor::configure($in, $raw_X, int($raw_X->get_devices)) or return; - if ($raw_X->prepare_write ne $before) { + if ($raw_X->is_modified) { $raw_X->write; 'need_restart'; } else { @@ -30,7 +30,7 @@ sub configure_monitor { sub configure_resolution { my ($in) = @_; - my ($raw_X, $before) = Xconfig::xfree->read_and_prepare_write; + my $raw_X = Xconfig::xfree->read; my $X = { card => Xconfig::card::from_raw_X($raw_X), monitors => [ $raw_X->get_monitors ], @@ -40,7 +40,7 @@ sub configure_resolution { } $X->{resolutions} = Xconfig::resolution_and_depth::configure($in, $raw_X, $X->{card}, $X->{monitors}) or return; - if ($raw_X->prepare_write ne $before) { + if ($raw_X->is_modified) { &write($raw_X, $X); } else { ''; @@ -161,10 +161,9 @@ sub configure_chooser { monitors => [ $raw_X->get_monitors ], resolutions => [ eval { $raw_X->get_resolutions } ], }; - my $before = $raw_X->prepare_write; my ($ok) = configure_chooser_raw($in, $raw_X, $do_pkgs, $options, $X); - if ($raw_X->prepare_write ne $before) { + if ($raw_X->is_modified) { may_write($in, $raw_X, $X, $ok); } else { ''; diff --git a/lib/Xconfig/xfree.pm b/lib/Xconfig/xfree.pm index 8089f12..519f2ea 100644 --- a/lib/Xconfig/xfree.pm +++ b/lib/Xconfig/xfree.pm @@ -21,11 +21,11 @@ sub _conf_files() { ################################################################################ # I/O ########################################################################## ################################################################################ -sub read_and_prepare_write { +sub read { my ($class) = @_; my $file = find { -f $_ } _conf_files(); my $raw_X = $class->new(Xconfig::parse::read_XF86Config($file)) or return; - my $before = $raw_X->prepare_write; + $raw_X->{before} = $raw_X->prepare_write; if (my ($keyboard) = $raw_X->get_InputDevices('keyboard')) { $keyboard->{Driver}{val} = 'kbd'; @@ -45,11 +45,7 @@ sub read_and_prepare_write { $_->{Driver} && $_->{Driver}{val} eq 'i810' and $_->{Driver}{val} = 'intel'; } - $raw_X, $before; -} -sub read { - my ($class) = @_; - first(read_and_prepare_write($class)); + $raw_X; } sub write { my ($raw_X, $o_file) = @_; @@ -73,6 +69,10 @@ sub prepare_write { set_Revision($raw_X); join('', Xconfig::parse::prepare_write_XF86Config($raw_X->{raw})); } +sub is_modified { + my ($raw_X) = @_; + $raw_X->{before} ne $raw_X->prepare_write; +} sub empty_config { my ($class) = @_; $class->new(Xconfig::parse::read_XF86Config_from_string(our $default_header)); |