Skip to content

Commit

Permalink
TaskList: add markup_focused_floating option
Browse files Browse the repository at this point in the history
  • Loading branch information
Akmadan23 authored and elParaguayo committed Jan 28, 2024
1 parent a54cad9 commit 00dcf12
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
15 changes: 13 additions & 2 deletions libqtile/widget/tasklist.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ class TaskList(base._Widget, base.PaddingMixin, base.MarginMixin):
"Text markup of the focused window state. Supports pangomarkup with markup=True."
'e.g., "{}" or "<span underline="low">{}</span>"',
),
(
"markup_focused_floating",
None,
"Text markup of the focused and floating window state. Supports pangomarkup with markup=True."
'e.g., "{}" or "<span underline="low">{}</span>"',
),
(
"icon_size",
None,
Expand Down Expand Up @@ -216,6 +222,7 @@ def get_taskname(self, window):
or self.markup_maximized
or self.markup_floating
or self.markup_focused
or self.markup_focused_floating
):
enforce_markup = True
else:
Expand All @@ -229,11 +236,15 @@ def get_taskname(self, window):
elif window.maximized:
state = self.txt_maximized
markup_str = self.markup_maximized
elif window is window.group.current_window:
if window.floating:
state = self.txt_floating
markup_str = self.markup_focused_floating or self.markup_floating
else:
markup_str = self.markup_focused
elif window.floating:
state = self.txt_floating
markup_str = self.markup_floating
elif window is window.group.current_window:
markup_str = self.markup_focused

window_location = (
f"[{window.group.windows.index(window) + self.window_name_location_offset}] "
Expand Down
16 changes: 16 additions & 0 deletions test/widgets/test_tasklist.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,22 @@ def test_tasklist_custom_markup(tasklist_manager):
assert widget.info()["text"] == "One|Two"


@configure_tasklist(markup_focused="({})", markup_focused_floating="[{}]")
def test_tasklist_focused_and_floating(tasklist_manager):
widget = tasklist_manager.c.widget["tasklist"]

tasklist_manager.test_window("One")
tasklist_manager.test_window("Two")
assert widget.info()["text"] == "One|(Two)"

# Test floating
tasklist_manager.c.window.toggle_floating()
assert widget.info()["text"] == "One|[Two]"

tasklist_manager.c.window.toggle_floating()
assert widget.info()["text"] == "One|(Two)"


@configure_tasklist(margin=0)
def test_tasklist_click_task(tasklist_manager):
tasklist_manager.test_window("One")
Expand Down

0 comments on commit 00dcf12

Please sign in to comment.