✨ feat(dock): create individual dock buttons for each application instance
This commit is contained in:
1 parent
babdf40262
commit
dcafc9c59e
1 file changed
+27
-26
+27
-26
@@ -472,15 +472,13 @@ class Dock(Window):
|
|||||||
if cmd_to_run:
|
if cmd_to_run:
|
||||||
exec_shell_command_async(f"nohup {cmd_to_run} &")
|
exec_shell_command_async(f"nohup {cmd_to_run} &")
|
||||||
else:
|
else:
|
||||||
focused = self.get_focused()
|
# Since we now have individual buttons for each instance,
|
||||||
idx = next(
|
# directly focus the specific instance instead of cycling
|
||||||
(i for i, inst in enumerate(instances) if inst["address"] == focused),
|
if instances and len(instances) == 1:
|
||||||
-1,
|
instance = instances[0]
|
||||||
)
|
exec_shell_command(
|
||||||
next_inst = instances[(idx + 1) % len(instances)]
|
f"hyprctl dispatch focuswindow address:{instance['address']}"
|
||||||
exec_shell_command(
|
)
|
||||||
f"hyprctl dispatch focuswindow address:{next_inst['address']}"
|
|
||||||
)
|
|
||||||
|
|
||||||
def _on_child_enter(self, widget, event):
|
def _on_child_enter(self, widget, event):
|
||||||
self.is_mouse_over_dock_area = True
|
self.is_mouse_over_dock_area = True
|
||||||
@@ -570,6 +568,7 @@ class Dock(Window):
|
|||||||
|
|
||||||
pinned_buttons = []
|
pinned_buttons = []
|
||||||
used_window_classes = set()
|
used_window_classes = set()
|
||||||
|
used_instances = set()
|
||||||
|
|
||||||
for app_data_item in self.pinned:
|
for app_data_item in self.pinned:
|
||||||
app = self.find_app(app_data_item)
|
app = self.find_app(app_data_item)
|
||||||
@@ -628,23 +627,20 @@ class Dock(Window):
|
|||||||
used_window_classes.add(matched_class)
|
used_window_classes.add(matched_class)
|
||||||
used_window_classes.add(self._normalize_window_class(matched_class))
|
used_window_classes.add(self._normalize_window_class(matched_class))
|
||||||
|
|
||||||
workspace = (
|
# Create separate buttons for each instance of pinned apps
|
||||||
str(instances[0].get("workspace", {}).get("id", ""))
|
if instances:
|
||||||
if instances
|
for instance in instances:
|
||||||
else ""
|
used_instances.add(instance.get("address"))
|
||||||
)
|
workspace = str(instance.get("workspace", {}).get("id", ""))
|
||||||
pinned_buttons.append(
|
pinned_buttons.append(
|
||||||
self.create_button(app_data_item, instances, workspace)
|
self.create_button(app_data_item, [instance], workspace)
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
# No instances running, create button without instances
|
||||||
|
pinned_buttons.append(self.create_button(app_data_item, [], ""))
|
||||||
|
|
||||||
open_buttons = []
|
open_buttons = []
|
||||||
for class_name, instances in running_windows.items():
|
for class_name, instances in running_windows.items():
|
||||||
# print(class_name, instances)
|
|
||||||
workspace = (
|
|
||||||
str(instances[0].get("workspace", {}).get("id", ""))
|
|
||||||
if instances
|
|
||||||
else ""
|
|
||||||
)
|
|
||||||
if class_name not in used_window_classes:
|
if class_name not in used_window_classes:
|
||||||
app = None
|
app = None
|
||||||
app = self.app_identifiers.get(class_name)
|
app = self.app_identifiers.get(class_name)
|
||||||
@@ -670,9 +666,14 @@ class Dock(Window):
|
|||||||
identifier = app_data_obj
|
identifier = app_data_obj
|
||||||
else:
|
else:
|
||||||
identifier = class_name
|
identifier = class_name
|
||||||
open_buttons.append(
|
|
||||||
self.create_button(identifier, instances, workspace)
|
# Create separate buttons for each instance of unpinned apps
|
||||||
)
|
for instance in instances:
|
||||||
|
if instance.get("address") not in used_instances:
|
||||||
|
workspace = str(instance.get("workspace", {}).get("id", ""))
|
||||||
|
open_buttons.append(
|
||||||
|
self.create_button(identifier, [instance], workspace)
|
||||||
|
)
|
||||||
|
|
||||||
children = pinned_buttons
|
children = pinned_buttons
|
||||||
separator_orientation = (
|
separator_orientation = (
|
||||||
|
|||||||
Reference in new issue
Block a user