Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion focus-new-window@mdpenguin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ GNOME's handling of window focus to prevent focus-stealing has caused a lot of p
## Options
- Raise window only of listed programs
- When selected, only windows from the programs that you list will be affected by the extension
- When unselected, windows from all programs will be affected by the extension
- When unselected, windows from all programs will be affected by the extension unless included in "Programs to exclude"
- Programs to include
- A comma separated list of programs to include
- The list is not case sensitive and spaces between programs is optional
- Programs to exclude
- A comma separated list of programs that should not have their windows automatically receive focus
- The list is not case sensitive and spaces between programs is optional

## Troubleshooting
- Issue: a listed program is not being focused
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ class SettingsHandler {
this.settings = new Settings.ExtensionSettings(this, uuid);
this.settings.bindProperty(Settings.BindingDirection.IN, "raiseSome", "raiseSome", function () { });
this.settings.bindProperty(Settings.BindingDirection.IN, "programList", "programList", function () { });
this.settings.bindProperty(Settings.BindingDirection.IN, "excludeList", "excludeList", function () { });
}
}

class AttentionHandler {
_parseList(listString) {
return listString.toLowerCase().replace(/\s/g, "").split(",");
}

init() {
if (Main.windowAttentionHandler._windowDemandsAttentionId) {
global.display.disconnect(Main.windowAttentionHandler._windowDemandsAttentionId);
Expand All @@ -40,28 +45,34 @@ class AttentionHandler {
return;
}

let
programList = settings.programList.toLowerCase().replace(/\s/g, "").split(","),
wmclass = window.get_wm_class();
let wmclass = window.get_wm_class();
if (!wmclass) {
return;
}

if (wmclass) {
if (!settings.raiseSome) {
if (settings.raiseSome) {
// Include mode: only activate windows from programs in the list
let programList = this._parseList(settings.programList);
if (programList.includes(wmclass.toLowerCase())) {
window.activate(global.get_current_time());
return;
}
else if (programList.includes(wmclass.toLowerCase()) && window.has_focus() === false) {
}
else {
// Exclude mode: activate all windows except those in the exclude list
let excludeList = this._parseList(settings.excludeList);
if (!excludeList.includes(wmclass.toLowerCase())) {
window.activate(global.get_current_time());
return;
}
else {
let ignored_classes = global.settings.get_strv("demands-attention-passthru-wm-classes");

for (let i = 0; i < ignored_classes.length; i++) {
if (wmclass.toLowerCase().includes(ignored_classes[i].toLowerCase())) {
window.activate(global.get_current_time());
return;
}
}
}

// Fallback: check global ignored classes
let ignored_classes = global.settings.get_strv("demands-attention-passthru-wm-classes");
for (let i = 0; i < ignored_classes.length; i++) {
if (wmclass.toLowerCase().includes(ignored_classes[i].toLowerCase())) {
window.activate(global.get_current_time());
return;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# SOME DESCRIPTIVE TITLE.
# FOCUS NEW WINDOW
# This file is put in the public domain.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
# mdpenguin, 2024
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: focus-new-window@mdpenguin 1.0.0\n"
"Project-Id-Version: focus-new-window@mdpenguin 1.0.3\n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-"
"extensions/issues\n"
"POT-Creation-Date: 2024-03-09 16:48-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"POT-Creation-Date: 2025-12-10 09:24+0100\n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -44,3 +44,13 @@ msgid ""
"Comma separated list of programs that should always have their windows "
"receive focus"
msgstr ""

#. settings-schema.json->excludeList->description
msgid "Programs to exclude"
msgstr ""

#. settings-schema.json->excludeList->tooltip
msgid ""
"Comma separated list of programs that should not have their windows "
"automatically receive focus"
msgstr ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# FOCUS NEW WINDOW
# This file is put in the public domain.
# mdpenguin, 2024
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: focus-new-window@mdpenguin 1.0.3\n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-"
"extensions/issues\n"
"POT-Creation-Date: 2025-12-10 09:24+0100\n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: pl_PL\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.4.2\n"

#. metadata.json->name
msgid "Focus New Window"
msgstr "Fokus nowego okna"

#. metadata.json->description
msgid "A Cinnamon extension that ensures new windows will receive focus"
msgstr ""
"Rozszerzenie Cinnamon, które zapewnia, że nowe okna będą otrzymywać fokus"

#. settings-schema.json->raiseSome->description
msgid "Raise windows only of listed programs"
msgstr "Fokus okien tylko wymienionych programów"

#. settings-schema.json->raiseSome->tooltip
msgid ""
"Disabling this will cause windows from all programs to receive focus if they "
"demand attention"
msgstr ""
"Wyłączenie tej opcji spowoduje, że okna wszystkich programów będą otrzymywać "
"fokus, jeśli będą wymagały uwagi"

#. settings-schema.json->programList->description
msgid "Programs to include"
msgstr "Uwzględniane programy"

#. settings-schema.json->programList->tooltip
msgid ""
"Comma separated list of programs that should always have their windows "
"receive focus"
msgstr ""
"Rozdzielona przecinkami lista programów, których okna powinny otrzymywać "
"fokus"

#. settings-schema.json->excludeList->description
msgid "Programs to exclude"
msgstr "Wykluczone programy"

#. settings-schema.json->excludeList->tooltip
msgid ""
"Comma separated list of programs that should not have their windows "
"automatically receive focus"
msgstr ""
"Rozdzielona przecinkami lista programów, których okna nie powinny otrzymywać "
"fokusu"
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,12 @@
"tooltip": "Comma separated list of programs that should always have their windows receive focus",
"dependency": "raiseSome",
"default": ""
},
"excludeList": {
"type": "entry",
"description": "Programs to exclude",
"tooltip": "Comma separated list of programs that should not have their windows automatically receive focus",
"dependency": "!raiseSome",
"default": ""
}
}