Skip to content

Commit ed93b0a

Browse files
authored
Merge pull request #15 from tam1m/main
adds the possibility to allow or deny certain windows from being affected by the positioning scripts [closes #14]
2 parents 17d8387 + a3aa8fd commit ed93b0a

File tree

12 files changed

+349
-21
lines changed

12 files changed

+349
-21
lines changed

always-open-on-active-screen/contents/code/main.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,20 @@ GNU General Public License v3.0
55
*/
66

77
// initialization
8-
const debugMode = readConfig("debugMode", true);
9-
function debug(...args) {if (debugMode)
10-
console.debug("alwaysopenonactivescreen:", ...args);}
11-
debug("initializing");
8+
const config = {
9+
classlist: readConfig("classlist", "")
10+
.toLowerCase()
11+
.split("\n")
12+
.map((s) => s.trim()),
13+
allowmode: readConfig("allowmode", false),
14+
denymode: readConfig("denymode", true),
15+
debugmode: readConfig("debugMode", false),
16+
};
17+
18+
function debug(...args) {
19+
if (config.debugmode) console.debug("alwaysopenonactivescreen:", ...args);
20+
}
21+
debug("initializing");
1222

1323
// when a client is added
1424
workspace.clientAdded.connect(client => {
@@ -19,9 +29,12 @@ workspace.clientAdded.connect(client => {
1929

2030
// abort if client is null, not regeometrizable, or already on right screen
2131
if (!client
22-
|| !(client.resizeable && client.moveable && client.moveableAcrossScreens)
23-
|| client.screen == activeScreen)
24-
return;
32+
|| (config.denymode && config.classlist.includes(String(client.resourceClass))) // using denymode and window class is in list
33+
|| (config.allowmode && !config.classlist.includes(String(client.resourceClass))) // using allowmode and window class is not in list
34+
|| !(client.resizeable && client.moveable && client.moveableAcrossScreens)
35+
|| !(client.resizeable && client.moveable && client.moveableAcrossScreens)
36+
|| client.screen == activeScreen)
37+
return;
2538

2639
// move client to active screen
2740
debug("sending client", client.caption, "to active screen", activeScreen);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
5+
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
6+
<kcfgfile name=""/>
7+
<group name="">
8+
<entry name="classlist" type="String">
9+
<label>Effected window class names</label>
10+
<default></default>
11+
</entry>
12+
<entry name="allowmode" type="Bool">
13+
<default>false</default>
14+
</entry>
15+
<entry name="denymode" type="Bool">
16+
<default>true</default>
17+
</entry>
18+
<entry name="debugMode" type="Bool">
19+
<label>Whether to log debug information</label>
20+
<default>false</default>
21+
</entry>
22+
</group>
23+
</kcfg>
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>AlwaysOpenOnActiveScreenConfigForm</class>
4+
<widget class="QWidget" name="AlwaysOpenOnActiveScreenConfigForm">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>400</width>
10+
<height>451</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>Form</string>
15+
</property>
16+
<layout class="QVBoxLayout" name="verticalLayout">
17+
<item>
18+
<widget class="QLabel" name="label">
19+
<property name="whatsThis">
20+
<string notr="true">Effected window class names. One per line</string>
21+
</property>
22+
<property name="text">
23+
<string notr="true">Effected window class names. One per line</string>
24+
</property>
25+
</widget>
26+
</item>
27+
<item>
28+
<widget class="QPlainTextEdit" name="kcfg_classlist"/>
29+
</item>
30+
<item>
31+
<widget class="QSplitter" name="splitter">
32+
<property name="sizePolicy">
33+
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
34+
<horstretch>0</horstretch>
35+
<verstretch>0</verstretch>
36+
</sizepolicy>
37+
</property>
38+
<property name="orientation">
39+
<enum>Qt::Horizontal</enum>
40+
</property>
41+
<widget class="QRadioButton" name="kcfg_allowmode">
42+
<property name="text">
43+
<string notr="true">Allow matching windows</string>
44+
</property>
45+
<attribute name="buttonGroup">
46+
<string notr="true">matchTypeGroup</string>
47+
</attribute>
48+
</widget>
49+
<widget class="QRadioButton" name="kcfg_denymode">
50+
<property name="text">
51+
<string notr="true">Deny matching windows</string>
52+
</property>
53+
<attribute name="buttonGroup">
54+
<string notr="true">matchTypeGroup</string>
55+
</attribute>
56+
</widget>
57+
</widget>
58+
</item>
59+
<item>
60+
<widget class="QCheckBox" name="kcfg_debugMode">
61+
<property name="text">
62+
<string notr="true">DebugMode</string>
63+
</property>
64+
</widget>
65+
</item>
66+
</layout>
67+
</widget>
68+
<resources/>
69+
<connections/>
70+
<buttongroups>
71+
<buttongroup name="matchTypeGroup"/>
72+
</buttongroups>
73+
</ui>

always-open-on-active-screen/metadata.desktop

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Type=Service
2222
X-Plasma-API=javascript
2323
X-Plasma-MainScript=code/main.js
2424
X-KDE-ServiceTypes=KWin/Script,KCModule
25+
X-KDE-ConfigModule=kwin/effects/configs/kcm_kwin4_genericscripted
2526
X-KDE-PluginKeyword=alwaysopenonactivescreen
2627
X-KDE-ParentComponents=alwaysopenonactivescreen
2728
X-KDE-PluginInfo-EnabledByDefault=true

always-open-on-focused-screen/contents/code/main.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,20 @@ GNU General Public License v3.0
55
*/
66

77
// initialization
8-
const debugMode = readConfig("debugMode", true);
9-
function debug(...args) {if (debugMode)
10-
console.debug("alwaysopenonfocusedscreen:", ...args);}
11-
debug("initializing");
8+
const config = {
9+
classlist: readConfig("classlist", "")
10+
.toLowerCase()
11+
.split("\n")
12+
.map((s) => s.trim()),
13+
allowmode: readConfig("allowmode", false),
14+
denymode: readConfig("denymode", true),
15+
debugmode: readConfig("debugMode", false),
16+
};
17+
18+
function debug(...args) {
19+
if (config.debugmode) console.debug("alwaysopenonfocusedscreen:", ...args);
20+
}
21+
debug("initializing");
1222

1323
// when a client is activated, update focused screen to screen client is on
1424
focusedScreen = workspace.activeScreen;
@@ -24,9 +34,11 @@ workspace.clientAdded.connect(client => {
2434

2535
// abort if client is null, not regeometrizable, or already on right screen
2636
if (!client
27-
|| !(client.resizeable && client.moveable && client.moveableAcrossScreens)
28-
|| client.screen == focusedScreen)
29-
return;
37+
|| (config.denymode && config.classlist.includes(String(client.resourceClass))) // using denymode and window class is in list
38+
|| (config.allowmode && !config.classlist.includes(String(client.resourceClass))) // using allowmode and window class is not in list
39+
|| !(client.resizeable && client.moveable && client.moveableAcrossScreens)
40+
|| client.screen == focusedScreen)
41+
return;
3042

3143
// move client to focused screen
3244
debug("sending client", client.caption, "to focused screen", focusedScreen);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
5+
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
6+
<kcfgfile name=""/>
7+
<group name="">
8+
<entry name="classlist" type="String">
9+
<label>Effected window class names</label>
10+
<default></default>
11+
</entry>
12+
<entry name="allowmode" type="Bool">
13+
<default>false</default>
14+
</entry>
15+
<entry name="denymode" type="Bool">
16+
<default>true</default>
17+
</entry>
18+
<entry name="debugMode" type="Bool">
19+
<label>Whether to log debug information</label>
20+
<default>false</default>
21+
</entry>
22+
</group>
23+
</kcfg>
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>AlwaysOpenOnFocusedScreenConfigForm</class>
4+
<widget class="QWidget" name="AlwaysOpenOnFocusedScreenConfigForm">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>400</width>
10+
<height>451</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>Form</string>
15+
</property>
16+
<layout class="QVBoxLayout" name="verticalLayout">
17+
<item>
18+
<widget class="QLabel" name="label">
19+
<property name="whatsThis">
20+
<string notr="true">Effected window class names. One per line</string>
21+
</property>
22+
<property name="text">
23+
<string notr="true">Effected window class names. One per line</string>
24+
</property>
25+
</widget>
26+
</item>
27+
<item>
28+
<widget class="QPlainTextEdit" name="kcfg_classlist"/>
29+
</item>
30+
<item>
31+
<widget class="QSplitter" name="splitter">
32+
<property name="sizePolicy">
33+
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
34+
<horstretch>0</horstretch>
35+
<verstretch>0</verstretch>
36+
</sizepolicy>
37+
</property>
38+
<property name="orientation">
39+
<enum>Qt::Horizontal</enum>
40+
</property>
41+
<widget class="QRadioButton" name="kcfg_allowmode">
42+
<property name="text">
43+
<string notr="true">Allow matching windows</string>
44+
</property>
45+
<attribute name="buttonGroup">
46+
<string notr="true">matchTypeGroup</string>
47+
</attribute>
48+
</widget>
49+
<widget class="QRadioButton" name="kcfg_denymode">
50+
<property name="text">
51+
<string notr="true">Deny matching windows</string>
52+
</property>
53+
<attribute name="buttonGroup">
54+
<string notr="true">matchTypeGroup</string>
55+
</attribute>
56+
</widget>
57+
</widget>
58+
</item>
59+
<item>
60+
<widget class="QCheckBox" name="kcfg_debugMode">
61+
<property name="text">
62+
<string notr="true">DebugMode</string>
63+
</property>
64+
</widget>
65+
</item>
66+
</layout>
67+
</widget>
68+
<resources/>
69+
<connections/>
70+
<buttongroups>
71+
<buttongroup name="matchTypeGroup"/>
72+
</buttongroups>
73+
</ui>

always-open-on-focused-screen/metadata.desktop

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Type=Service
2222
X-Plasma-API=javascript
2323
X-Plasma-MainScript=code/main.js
2424
X-KDE-ServiceTypes=KWin/Script,KCModule
25+
X-KDE-ConfigModule=kwin/effects/configs/kcm_kwin4_genericscripted
2526
X-KDE-PluginKeyword=alwaysopenonfocusedscreen
2627
X-KDE-ParentComponents=alwaysopenonfocusedscreen
2728
X-KDE-PluginInfo-EnabledByDefault=true

always-open-on-primary-screen/contents/code/main.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,20 @@ GNU General Public License v3.0
55
*/
66

77
// initialization
8-
const debugMode = readConfig("debugMode", true);
9-
function debug(...args) {if (debugMode)
10-
console.debug("alwaysopenonprimaryscreen:", ...args);}
11-
debug("initializing");
8+
const config = {
9+
classlist: readConfig("classlist", "")
10+
.toLowerCase()
11+
.split("\n")
12+
.map((s) => s.trim()),
13+
allowmode: readConfig("allowmode", false),
14+
denymode: readConfig("denymode", true),
15+
debugmode: readConfig("debugMode", false),
16+
};
17+
18+
function debug(...args) {
19+
if (config.debugmode) console.debug("alwaysopenonprimaryscreen:", ...args);
20+
}
21+
debug("initializing");
1222

1323
// primary screen is 0'th
1424
primaryScreen = 0;
@@ -19,9 +29,11 @@ workspace.clientAdded.connect(client => {
1929

2030
// abort if client is null, not regeometrizable, or already on right screen
2131
if (!client
22-
|| !(client.resizeable && client.moveable && client.moveableAcrossScreens)
23-
|| client.screen == primaryScreen)
24-
return;
32+
|| (config.denymode && config.classlist.includes(String(client.resourceClass))) // using denymode and window class is in list
33+
|| (config.allowmode && !config.classlist.includes(String(client.resourceClass))) // using allowmode and window class is not in list
34+
|| !(client.resizeable && client.moveable && client.moveableAcrossScreens)
35+
|| client.screen == primaryScreen)
36+
return;
2537

2638
// move client to primary screen
2739
debug("sending client", client.caption, "to primary screen", primaryScreen);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
5+
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
6+
<kcfgfile name=""/>
7+
<group name="">
8+
<entry name="classlist" type="String">
9+
<label>Effected window class names</label>
10+
<default></default>
11+
</entry>
12+
<entry name="allowmode" type="Bool">
13+
<default>false</default>
14+
</entry>
15+
<entry name="denymode" type="Bool">
16+
<default>true</default>
17+
</entry>
18+
<entry name="debugMode" type="Bool">
19+
<label>Whether to log debug information</label>
20+
<default>false</default>
21+
</entry>
22+
</group>
23+
</kcfg>

0 commit comments

Comments
 (0)