refactor(src/window/globalmenu): simplify caching logic and remove dynamic menu method selection
This commit is contained in:
2 files changed
+10
-25
No files matched your search
@@ -223,14 +223,9 @@ def executable_gtk_class(executable: str | None) -> str | None:
|
|||||||
cache = _load_cache()
|
cache = _load_cache()
|
||||||
key = f"{path}"
|
key = f"{path}"
|
||||||
|
|
||||||
from services.config import get_config
|
cached = cache.get(key)
|
||||||
|
if cached and cached.get("mtime") == mtime:
|
||||||
use_cache = get_config("global_menu_cache_enabled", True)
|
return cached.get("class")
|
||||||
|
|
||||||
if use_cache:
|
|
||||||
cached = cache.get(key)
|
|
||||||
if cached and cached.get("mtime") == mtime:
|
|
||||||
return cached.get("class")
|
|
||||||
|
|
||||||
needed = _transitive_needed(path)
|
needed = _transitive_needed(path)
|
||||||
if GTK4_SONAME in needed:
|
if GTK4_SONAME in needed:
|
||||||
@@ -240,7 +235,6 @@ def executable_gtk_class(executable: str | None) -> str | None:
|
|||||||
else:
|
else:
|
||||||
klass = None
|
klass = None
|
||||||
|
|
||||||
if use_cache:
|
cache[key] = {"mtime": mtime, "class": klass}
|
||||||
cache[key] = {"mtime": mtime, "class": klass}
|
_save_cache(cache)
|
||||||
_save_cache(cache)
|
|
||||||
return klass
|
return klass
|
||||||
@@ -619,20 +619,11 @@ class GlobalMenuService(Service):
|
|||||||
if target_pid <= 0:
|
if target_pid <= 0:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
from services.config import get_config
|
strategies = [
|
||||||
|
self._find_registry,
|
||||||
method = get_config("global_menu_method", "hyprland")
|
self._find_registrar,
|
||||||
|
self._find_fallback_scan,
|
||||||
strategies = []
|
]
|
||||||
if method in ("hyprland", "auto"):
|
|
||||||
strategies.extend(
|
|
||||||
[
|
|
||||||
self._find_registry,
|
|
||||||
self._find_registrar,
|
|
||||||
]
|
|
||||||
)
|
|
||||||
if method in ("dbus", "auto"):
|
|
||||||
strategies.append(self._find_fallback_scan)
|
|
||||||
|
|
||||||
for strategy in strategies:
|
for strategy in strategies:
|
||||||
result = strategy(wm_class, target_pid)
|
result = strategy(wm_class, target_pid)
|
||||||
|
|||||||
Reference in new issue
Block a user