From 61c6d5817204bb1e053a8d3676849e6031be8651 Mon Sep 17 00:00:00 2001 From: Ismael Asensio Date: Fri, 22 May 2020 22:05:55 +0200 Subject: [PATCH] [kwinrules] Add kconf_update script to fix placement rule Since the port to KConfigXT, the placement setting in `kwinrulesrc` now stores the enum value instead of a string equivalent. The strings and enum values are taken from `placement.h/.cpp` This was suggested by @zzag in https://phabricator.kde.org/D29790 --- kconf_update/CMakeLists.txt | 5 +++++ kconf_update/kwinrules-5.19-placement.pl | 22 ++++++++++++++++++++++ kconf_update/kwinrules.upd | 7 +++++++ 3 files changed, 34 insertions(+) create mode 100644 kconf_update/kwinrules-5.19-placement.pl create mode 100644 kconf_update/kwinrules.upd diff --git a/kconf_update/CMakeLists.txt b/kconf_update/CMakeLists.txt index 8d1756ec2..1ce575c7c 100644 --- a/kconf_update/CMakeLists.txt +++ b/kconf_update/CMakeLists.txt @@ -4,3 +4,8 @@ install(PROGRAMS kwin-5.16-auto-bordersize.sh DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR}) install(PROGRAMS kwin-5.18-move-animspeed.py DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR}) + +install(FILES kwinrules.upd + DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR}) +install(PROGRAMS kwinrules-5.19-placement.pl + DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR}) diff --git a/kconf_update/kwinrules-5.19-placement.pl b/kconf_update/kwinrules-5.19-placement.pl new file mode 100644 index 000000000..85ffd3385 --- /dev/null +++ b/kconf_update/kwinrules-5.19-placement.pl @@ -0,0 +1,22 @@ +#! /usr/bin/perl + +# Convert strings as in `Placement::policyToString()` from `placement.cpp` +# to correponding values of enum `Placement::Policy` defined in `placement.h` + +use strict; + +while (<>) +{ + chomp; + s/placement=NoPlacement/placement=0/; + s/placement=Default/placement=1/; + s/placement=Random/placement=3/; + s/placement=Smart/placement=4/; + s/placement=Cascade/placement=5/; + s/placement=Centered/placement=6/; + s/placement=ZeroCornered/placement=7/; + s/placement=UnderMouse/placement=8/; + s/placement=OnMainWindow/placement=9/; + s/placement=Maximizing/placement=10/; + print "$_\n"; +} diff --git a/kconf_update/kwinrules.upd b/kconf_update/kwinrules.upd new file mode 100644 index 000000000..0b30010c9 --- /dev/null +++ b/kconf_update/kwinrules.upd @@ -0,0 +1,7 @@ +Version=5 + +# Replace `placement` string policy to its enum value equivalent +Id=replace-placement-string-to-enum +File=kwinrulesrc +Script=kwinrules-5.19-placement.pl,perl +