2009-02-27 17:22:03 +01:00
|
|
|
---------------------------------------------------------------------------
|
2016-08-14 06:25:50 +02:00
|
|
|
--- Tasklist widget module for awful.
|
2014-05-20 13:02:39 +02:00
|
|
|
--
|
2016-11-15 07:07:25 +01:00
|
|
|
-- <a name="status_icons"></a>
|
|
|
|
-- **Status icons:**
|
|
|
|
--
|
|
|
|
-- By default, the tasklist prepends some symbols in front of the client name.
|
|
|
|
-- This is used to notify that the client has some specific properties that are
|
|
|
|
-- currently enabled. This can be disabled using
|
|
|
|
-- `beautiful.tasklist_plain_task_name`=true in the theme.
|
|
|
|
--
|
|
|
|
-- <table class='widget_list' border=1>
|
|
|
|
-- <tr style='font-weight: bold;'>
|
|
|
|
-- <th align='center'>Icon</th>
|
|
|
|
-- <th align='center'>Client property</th>
|
|
|
|
-- </tr>
|
2021-12-13 19:30:24 +01:00
|
|
|
-- <tr><td>▪</td><td><a href="../core_components/client.html#sticky">sticky</a></td></tr>
|
|
|
|
-- <tr><td>⌃</td><td><a href="../core_components/client.html#ontop">ontop</a></td></tr>
|
|
|
|
-- <tr><td>▴</td><td><a href="../core_components/client.html#above">above</a></td></tr>
|
|
|
|
-- <tr><td>▾</td><td><a href="../core_components/client.html#below">below</a></td></tr>
|
|
|
|
-- <tr><td>✈</td><td><a href="../core_components/client.html#floating">floating</a></td></tr>
|
|
|
|
-- <tr><td>+</td><td><a href="../core_components/client.html#maximized">maximized</a></td></tr>
|
|
|
|
-- <tr><td>⬌</td><td><a href="../core_components/client.html#maximized_horizontal">maximized_horizontal</a></td></tr>
|
|
|
|
-- <tr><td>⬍</td><td><a href="../core_components/client.html#maximized_vertical">maximized_vertical</a></td></tr>
|
2016-11-15 07:07:25 +01:00
|
|
|
-- </table>
|
|
|
|
--
|
2017-08-10 06:32:30 +02:00
|
|
|
-- **Customizing the tasklist:**
|
|
|
|
--
|
2020-12-05 16:17:45 +01:00
|
|
|
-- The `tasklist` created by `rc.lua` uses the default values for almost
|
|
|
|
-- everything. However, it is possible to override each aspect to create a
|
|
|
|
-- very different widget. Here's an example that creates a tasklist similar to
|
2017-08-10 06:32:30 +02:00
|
|
|
-- the default one, but with an explicit layout and some spacing widgets:
|
|
|
|
--
|
|
|
|
--@DOC_wibox_awidget_tasklist_rounded_EXAMPLE@
|
|
|
|
--
|
|
|
|
-- As demonstrated in the example above, there are a few "shortcuts" to avoid
|
|
|
|
-- re-inventing the wheel. By setting the predefined roles as widget `id`s,
|
|
|
|
-- `awful.widget.common` will do most of the work to update the values
|
|
|
|
-- automatically. All of them are optional. The supported roles are:
|
|
|
|
--
|
|
|
|
-- * `icon_role`: A `wibox.widget.imagebox`
|
|
|
|
-- * `text_role`: A `wibox.widget.textbox`
|
|
|
|
-- * `background_role`: A `wibox.container.background`
|
|
|
|
-- * `text_margin_role`: A `wibox.container.margin`
|
|
|
|
-- * `icon_margin_role`: A `wibox.container.margin`
|
|
|
|
--
|
|
|
|
-- `awful.widget.common` also has 2 callbacks to give more control over the widget:
|
|
|
|
--
|
|
|
|
-- * `create_callback`: Called once after the widget instance is created
|
2021-10-05 04:20:03 +02:00
|
|
|
-- * `update_callback`: Called every time the data is refreshed
|
2017-08-10 06:32:30 +02:00
|
|
|
--
|
|
|
|
-- Both callback have the same parameters:
|
|
|
|
--
|
|
|
|
-- * `self`: The widget instance (*widget*).
|
|
|
|
-- * `c`: The client (*client*)
|
|
|
|
-- * `index`: The widget position in the list (*number*)
|
|
|
|
-- * `clients`: The list of client, in order (*table*)
|
|
|
|
--
|
|
|
|
-- It is also possible to omit some roles and create an icon only tasklist.
|
|
|
|
-- Notice that this example use the `awful.widget.clienticon` widget instead
|
2021-10-05 04:20:03 +02:00
|
|
|
-- of an `imagebox`. This allows higher resolution icons to be loaded. This
|
2017-08-10 06:32:30 +02:00
|
|
|
-- example reproduces the Windows 10 tasklist look and feel:
|
|
|
|
--
|
|
|
|
--@DOC_wibox_awidget_tasklist_windows10_EXAMPLE@
|
|
|
|
--
|
|
|
|
-- The tasklist can also be created in an `awful.popup` in case there is no
|
|
|
|
-- permanent `awful.wibar`:
|
|
|
|
--
|
|
|
|
--@DOC_awful_popup_alttab_EXAMPLE@
|
|
|
|
--
|
2009-02-27 17:22:03 +01:00
|
|
|
-- @author Julien Danjou <julien@danjou.info>
|
|
|
|
-- @copyright 2008-2009 Julien Danjou
|
2019-06-06 08:15:53 +02:00
|
|
|
-- @widgetmod awful.widget.tasklist
|
2022-08-22 08:02:26 +02:00
|
|
|
-- @supermodule wibox.widget.base
|
2009-02-27 17:22:03 +01:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
-- Grab environment we need
|
|
|
|
local capi = { screen = screen,
|
|
|
|
client = client }
|
|
|
|
local ipairs = ipairs
|
2009-04-11 14:15:45 +02:00
|
|
|
local setmetatable = setmetatable
|
2009-02-27 17:22:03 +01:00
|
|
|
local table = table
|
|
|
|
local common = require("awful.widget.common")
|
|
|
|
local beautiful = require("beautiful")
|
2009-08-18 16:48:19 +02:00
|
|
|
local tag = require("awful.tag")
|
2010-10-06 14:23:36 +02:00
|
|
|
local flex = require("wibox.layout.flex")
|
2015-07-07 18:07:59 +02:00
|
|
|
local timer = require("gears.timer")
|
2017-03-03 00:02:03 +01:00
|
|
|
local gcolor = require("gears.color")
|
2017-03-12 00:57:32 +01:00
|
|
|
local gstring = require("gears.string")
|
2017-08-08 00:14:35 +02:00
|
|
|
local gdebug = require("gears.debug")
|
2019-03-07 05:16:34 +01:00
|
|
|
local dpi = require("beautiful").xresources.apply_dpi
|
2017-08-08 00:14:35 +02:00
|
|
|
local base = require("wibox.widget.base")
|
2019-03-07 05:16:34 +01:00
|
|
|
local wfixed = require("wibox.layout.fixed")
|
|
|
|
local wmargin = require("wibox.container.margin")
|
|
|
|
local wtextbox = require("wibox.widget.textbox")
|
|
|
|
local clienticon = require("awful.widget.clienticon")
|
|
|
|
local wbackground = require("wibox.container.background")
|
2021-11-03 05:59:56 +01:00
|
|
|
local gtable = require("gears.table")
|
2009-02-27 17:22:03 +01:00
|
|
|
|
2016-02-26 19:19:58 +01:00
|
|
|
local function get_screen(s)
|
|
|
|
return s and screen[s]
|
|
|
|
end
|
|
|
|
|
2012-06-14 01:08:27 +02:00
|
|
|
local tasklist = { mt = {} }
|
2009-02-27 17:22:03 +01:00
|
|
|
|
2015-09-27 14:10:45 +02:00
|
|
|
local instances
|
|
|
|
|
2016-08-14 06:25:50 +02:00
|
|
|
--- The default foreground (text) color.
|
2021-11-13 09:21:21 +01:00
|
|
|
--
|
|
|
|
-- @DOC_wibox_awidget_tasklist_style_fg_normal_EXAMPLE@
|
|
|
|
--
|
2016-08-14 06:25:50 +02:00
|
|
|
-- @beautiful beautiful.tasklist_fg_normal
|
|
|
|
-- @tparam[opt=nil] string|pattern fg_normal
|
|
|
|
-- @see gears.color
|
|
|
|
|
|
|
|
--- The default background color.
|
2021-11-13 09:21:21 +01:00
|
|
|
--
|
|
|
|
-- @DOC_wibox_awidget_tasklist_style_bg_normal_EXAMPLE@
|
|
|
|
--
|
2016-08-14 06:25:50 +02:00
|
|
|
-- @beautiful beautiful.tasklist_bg_normal
|
|
|
|
-- @tparam[opt=nil] string|pattern bg_normal
|
|
|
|
-- @see gears.color
|
|
|
|
|
|
|
|
--- The focused client foreground (text) color.
|
2021-11-13 09:21:21 +01:00
|
|
|
--
|
|
|
|
-- @DOC_wibox_awidget_tasklist_style_fg_focus_EXAMPLE@
|
|
|
|
--
|
2016-08-14 06:25:50 +02:00
|
|
|
-- @beautiful beautiful.tasklist_fg_focus
|
|
|
|
-- @tparam[opt=nil] string|pattern fg_focus
|
|
|
|
-- @see gears.color
|
|
|
|
|
|
|
|
--- The focused client background color.
|
2021-11-13 09:21:21 +01:00
|
|
|
--
|
|
|
|
-- @DOC_wibox_awidget_tasklist_style_bg_focus_EXAMPLE@
|
|
|
|
--
|
2016-08-14 06:25:50 +02:00
|
|
|
-- @beautiful beautiful.tasklist_bg_focus
|
|
|
|
-- @tparam[opt=nil] string|pattern bg_focus
|
|
|
|
-- @see gears.color
|
|
|
|
|
|
|
|
--- The urgent clients foreground (text) color.
|
2021-11-13 09:21:21 +01:00
|
|
|
--
|
|
|
|
-- @DOC_wibox_awidget_tasklist_style_fg_urgent_EXAMPLE@
|
|
|
|
--
|
2016-08-14 06:25:50 +02:00
|
|
|
-- @beautiful beautiful.tasklist_fg_urgent
|
|
|
|
-- @tparam[opt=nil] string|pattern fg_urgent
|
|
|
|
-- @see gears.color
|
|
|
|
|
|
|
|
--- The urgent clients background color.
|
2021-11-13 09:21:21 +01:00
|
|
|
--
|
|
|
|
-- @DOC_wibox_awidget_tasklist_style_bg_urgent_EXAMPLE@
|
|
|
|
--
|
2016-08-14 06:25:50 +02:00
|
|
|
-- @beautiful beautiful.tasklist_bg_urgent
|
|
|
|
-- @tparam[opt=nil] string|pattern bg_urgent
|
|
|
|
-- @see gears.color
|
|
|
|
|
|
|
|
--- The minimized clients foreground (text) color.
|
2021-11-13 09:21:21 +01:00
|
|
|
--
|
|
|
|
-- @DOC_wibox_awidget_tasklist_style_fg_minimize_EXAMPLE@
|
|
|
|
--
|
2016-08-14 06:25:50 +02:00
|
|
|
-- @beautiful beautiful.tasklist_fg_minimize
|
|
|
|
-- @tparam[opt=nil] string|pattern fg_minimize
|
|
|
|
-- @see gears.color
|
|
|
|
|
|
|
|
--- The minimized clients background color.
|
2021-11-13 09:21:21 +01:00
|
|
|
--
|
|
|
|
-- @DOC_wibox_awidget_tasklist_style_bg_minimize_EXAMPLE@
|
|
|
|
--
|
2016-08-14 06:25:50 +02:00
|
|
|
-- @beautiful beautiful.tasklist_bg_minimize
|
|
|
|
-- @tparam[opt=nil] string|pattern bg_minimize
|
|
|
|
-- @see gears.color
|
|
|
|
|
|
|
|
--- The elements default background image.
|
|
|
|
-- @beautiful beautiful.tasklist_bg_image_normal
|
|
|
|
-- @tparam[opt=nil] string bg_image_normal
|
|
|
|
|
|
|
|
--- The focused client background image.
|
|
|
|
-- @beautiful beautiful.tasklist_bg_image_focus
|
|
|
|
-- @tparam[opt=nil] string bg_image_focus
|
|
|
|
|
|
|
|
--- The urgent clients background image.
|
|
|
|
-- @beautiful beautiful.tasklist_bg_image_urgent
|
|
|
|
-- @tparam[opt=nil] string bg_image_urgent
|
|
|
|
|
|
|
|
--- The minimized clients background image.
|
|
|
|
-- @beautiful beautiful.tasklist_bg_image_minimize
|
|
|
|
-- @tparam[opt=nil] string bg_image_minimize
|
|
|
|
|
2016-11-15 07:07:25 +01:00
|
|
|
--- Disable the tasklist client icons.
|
2021-11-13 09:21:21 +01:00
|
|
|
--
|
|
|
|
-- @DOC_wibox_awidget_tasklist_style_disable_icon_EXAMPLE@
|
|
|
|
--
|
2016-12-28 22:25:23 +01:00
|
|
|
-- @beautiful beautiful.tasklist_disable_icon
|
2016-08-14 06:25:50 +02:00
|
|
|
-- @tparam[opt=false] boolean tasklist_disable_icon
|
|
|
|
|
2017-02-26 01:21:36 +01:00
|
|
|
--- Disable the tasklist client titles.
|
2021-11-13 09:21:21 +01:00
|
|
|
--
|
|
|
|
-- @DOC_wibox_awidget_tasklist_style_disable_task_name_EXAMPLE@
|
|
|
|
--
|
2017-02-26 01:21:36 +01:00
|
|
|
-- @beautiful beautiful.tasklist_disable_task_name
|
|
|
|
-- @tparam[opt=false] boolean tasklist_disable_task_name
|
|
|
|
|
2016-11-15 07:07:25 +01:00
|
|
|
--- Disable the extra tasklist client property notification icons.
|
|
|
|
--
|
2020-04-06 14:20:35 +02:00
|
|
|
-- See the <a href="#status_icons">Status icons</a> section for more details.
|
2016-11-15 07:07:25 +01:00
|
|
|
--
|
2021-11-13 09:21:21 +01:00
|
|
|
-- @DOC_wibox_awidget_tasklist_style_plain_task_name_EXAMPLE@
|
|
|
|
--
|
2016-11-15 07:07:25 +01:00
|
|
|
-- @beautiful beautiful.tasklist_plain_task_name
|
|
|
|
-- @tparam[opt=false] boolean tasklist_plain_task_name
|
|
|
|
|
2020-04-06 14:20:35 +02:00
|
|
|
--- Extra tasklist client property notification icon for clients with the sticky property set.
|
|
|
|
-- @beautiful beautiful.tasklist_sticky
|
|
|
|
-- @tparam[opt=nil] string tasklist_sticky
|
|
|
|
|
|
|
|
--- Extra tasklist client property notification icon for clients with the ontop property set.
|
|
|
|
-- @beautiful beautiful.tasklist_ontop
|
|
|
|
-- @tparam[opt=nil] string tasklist_ontop
|
|
|
|
|
|
|
|
--- Extra tasklist client property notification icon for clients with the above property set.
|
|
|
|
-- @beautiful beautiful.tasklist_above
|
|
|
|
-- @tparam[opt=nil] string tasklist_above
|
|
|
|
|
|
|
|
--- Extra tasklist client property notification icon for clients with the below property set.
|
|
|
|
-- @beautiful beautiful.tasklist_below
|
|
|
|
-- @tparam[opt=nil] string tasklist_below
|
|
|
|
|
|
|
|
--- Extra tasklist client property notification icon for clients with the floating property set.
|
|
|
|
-- @beautiful beautiful.tasklist_floating
|
|
|
|
-- @tparam[opt=nil] string tasklist_floating
|
|
|
|
|
|
|
|
--- Extra tasklist client property notification icon for clients with the maximized property set.
|
|
|
|
-- @beautiful beautiful.tasklist_maximized
|
|
|
|
-- @tparam[opt=nil] string tasklist_maximized
|
|
|
|
|
|
|
|
--- Extra tasklist client property notification icon for clients with the maximized_horizontal property set.
|
|
|
|
-- @beautiful beautiful.tasklist_maximized_horizontal
|
|
|
|
-- @tparam[opt=nil] string maximized_horizontal
|
|
|
|
|
|
|
|
--- Extra tasklist client property notification icon for clients with the maximized_vertical property set.
|
|
|
|
-- @beautiful beautiful.tasklist_maximized_vertical
|
|
|
|
-- @tparam[opt=nil] string maximized_vertical
|
|
|
|
|
2021-12-21 20:48:53 +01:00
|
|
|
--- Extra tasklist client property notification icon for clients with the minimized property set.
|
|
|
|
-- @beautiful beautiful.tasklist_minimized
|
|
|
|
-- @tparam[opt=nil] string minimized
|
|
|
|
|
2021-12-21 20:48:53 +01:00
|
|
|
--- The focused client alignment.
|
|
|
|
--
|
|
|
|
-- @DOC_wibox_awidget_tasklist_style_align_EXAMPLE@
|
|
|
|
--
|
|
|
|
-- @beautiful beautiful.tasklist_align
|
2021-12-17 22:46:08 +01:00
|
|
|
-- @tparam[opt="left"] string align *left*, *right* or *center*
|
2021-12-21 20:48:53 +01:00
|
|
|
|
2021-11-13 09:14:29 +01:00
|
|
|
--- The tasklist font.
|
|
|
|
--
|
|
|
|
-- @DOC_wibox_awidget_tasklist_style_font_EXAMPLE@
|
|
|
|
--
|
|
|
|
-- @beautiful beautiful.tasklist_font
|
|
|
|
-- @tparam[opt=nil] string font
|
|
|
|
-- @see wibox.widget.textbox.font
|
2021-12-21 20:48:53 +01:00
|
|
|
|
2016-08-14 06:25:50 +02:00
|
|
|
--- The focused client title alignment.
|
2021-11-13 09:14:29 +01:00
|
|
|
--
|
|
|
|
-- @DOC_wibox_awidget_tasklist_style_font_focus_EXAMPLE@
|
|
|
|
--
|
2016-08-14 06:25:50 +02:00
|
|
|
-- @beautiful beautiful.tasklist_font_focus
|
|
|
|
-- @tparam[opt=nil] string font_focus
|
2021-11-13 09:14:29 +01:00
|
|
|
-- @see wibox.widget.textbox.font
|
2016-08-14 06:25:50 +02:00
|
|
|
|
|
|
|
--- The minimized clients font.
|
2021-11-13 09:14:29 +01:00
|
|
|
--
|
|
|
|
-- @DOC_wibox_awidget_tasklist_style_font_minimized_EXAMPLE@
|
|
|
|
--
|
2016-08-14 06:25:50 +02:00
|
|
|
-- @beautiful beautiful.tasklist_font_minimized
|
|
|
|
-- @tparam[opt=nil] string font_minimized
|
2021-11-13 09:14:29 +01:00
|
|
|
-- @see wibox.widget.textbox.font
|
2016-08-14 06:25:50 +02:00
|
|
|
|
|
|
|
--- The urgent clients font.
|
2021-11-13 09:14:29 +01:00
|
|
|
--
|
|
|
|
-- @DOC_wibox_awidget_tasklist_style_font_urgent_EXAMPLE@
|
|
|
|
--
|
2016-08-14 06:25:50 +02:00
|
|
|
-- @beautiful beautiful.tasklist_font_urgent
|
|
|
|
-- @tparam[opt=nil] string font_urgent
|
2021-11-13 09:14:29 +01:00
|
|
|
-- @see wibox.widget.textbox.font
|
2016-08-14 06:25:50 +02:00
|
|
|
|
|
|
|
--- The space between the tasklist elements.
|
2021-11-13 09:14:29 +01:00
|
|
|
--
|
|
|
|
-- @DOC_wibox_awidget_tasklist_style_spacing_EXAMPLE@
|
|
|
|
--
|
2016-08-14 06:25:50 +02:00
|
|
|
-- @beautiful beautiful.tasklist_spacing
|
2017-01-16 08:11:42 +01:00
|
|
|
-- @tparam[opt=0] number spacing The spacing between tasks.
|
2016-08-14 06:25:50 +02:00
|
|
|
|
|
|
|
--- The default tasklist elements shape.
|
2021-11-13 09:14:29 +01:00
|
|
|
--
|
|
|
|
-- @DOC_wibox_awidget_tasklist_style_shape_EXAMPLE@
|
|
|
|
--
|
2016-08-14 06:25:50 +02:00
|
|
|
-- @beautiful beautiful.tasklist_shape
|
|
|
|
-- @tparam[opt=nil] gears.shape shape
|
|
|
|
|
|
|
|
--- The default tasklist elements border width.
|
2021-11-13 09:14:29 +01:00
|
|
|
--
|
|
|
|
-- @DOC_wibox_awidget_tasklist_style_shape_border_width_EXAMPLE@
|
|
|
|
--
|
2016-08-14 06:25:50 +02:00
|
|
|
-- @beautiful beautiful.tasklist_shape_border_width
|
|
|
|
-- @tparam[opt=0] number shape_border_width
|
|
|
|
|
|
|
|
--- The default tasklist elements border color.
|
2021-11-13 09:14:29 +01:00
|
|
|
--
|
|
|
|
-- @DOC_wibox_awidget_tasklist_style_shape_border_color_EXAMPLE@
|
|
|
|
--
|
2016-08-14 06:25:50 +02:00
|
|
|
-- @beautiful beautiful.tasklist_shape_border_color
|
|
|
|
-- @tparam[opt=nil] string|color shape_border_color
|
|
|
|
-- @see gears.color
|
|
|
|
|
|
|
|
--- The focused client shape.
|
2021-11-13 09:14:29 +01:00
|
|
|
--
|
|
|
|
-- @DOC_wibox_awidget_tasklist_style_shape_focus_EXAMPLE@
|
|
|
|
--
|
2016-08-14 06:25:50 +02:00
|
|
|
-- @beautiful beautiful.tasklist_shape_focus
|
|
|
|
-- @tparam[opt=nil] gears.shape shape_focus
|
|
|
|
|
|
|
|
--- The focused client border width.
|
2021-11-13 09:14:29 +01:00
|
|
|
--
|
|
|
|
-- @DOC_wibox_awidget_tasklist_style_shape_focus_border_width_EXAMPLE@
|
|
|
|
--
|
2016-08-14 06:25:50 +02:00
|
|
|
-- @beautiful beautiful.tasklist_shape_border_width_focus
|
|
|
|
-- @tparam[opt=0] number shape_border_width_focus
|
|
|
|
|
|
|
|
--- The focused client border color.
|
2021-11-13 09:14:29 +01:00
|
|
|
--
|
|
|
|
-- @DOC_wibox_awidget_tasklist_style_shape_focus_border_width_focus_EXAMPLE@
|
|
|
|
--
|
2016-08-14 06:25:50 +02:00
|
|
|
-- @beautiful beautiful.tasklist_shape_border_color_focus
|
|
|
|
-- @tparam[opt=nil] string|color shape_border_color_focus
|
|
|
|
-- @see gears.color
|
|
|
|
|
|
|
|
--- The minimized clients shape.
|
2021-11-13 09:14:29 +01:00
|
|
|
--
|
|
|
|
-- @DOC_wibox_awidget_tasklist_style_shape_minimized_EXAMPLE@
|
|
|
|
--
|
2016-08-14 06:25:50 +02:00
|
|
|
-- @beautiful beautiful.tasklist_shape_minimized
|
|
|
|
-- @tparam[opt=nil] gears.shape shape_minimized
|
|
|
|
|
|
|
|
--- The minimized clients border width.
|
2021-11-13 09:14:29 +01:00
|
|
|
--
|
|
|
|
-- @DOC_wibox_awidget_tasklist_style_shape_border_width_minimized_EXAMPLE@
|
|
|
|
--
|
2016-08-14 06:25:50 +02:00
|
|
|
-- @beautiful beautiful.tasklist_shape_border_width_minimized
|
|
|
|
-- @tparam[opt=0] number shape_border_width_minimized
|
|
|
|
|
|
|
|
--- The minimized clients border color.
|
2021-11-13 09:14:29 +01:00
|
|
|
--
|
|
|
|
-- @DOC_wibox_awidget_tasklist_style_shape_border_color_minimized_EXAMPLE@
|
|
|
|
--
|
2016-08-14 06:25:50 +02:00
|
|
|
-- @beautiful beautiful.tasklist_shape_border_color_minimized
|
|
|
|
-- @tparam[opt=nil] string|color shape_border_color_minimized
|
|
|
|
-- @see gears.color
|
|
|
|
|
|
|
|
--- The urgent clients shape.
|
2021-11-13 09:14:29 +01:00
|
|
|
--
|
|
|
|
-- @DOC_wibox_awidget_tasklist_style_shape_urgent_EXAMPLE@
|
|
|
|
--
|
2016-08-14 06:25:50 +02:00
|
|
|
-- @beautiful beautiful.tasklist_shape_urgent
|
|
|
|
-- @tparam[opt=nil] gears.shape shape_urgent
|
|
|
|
|
|
|
|
--- The urgent clients border width.
|
2021-11-13 09:14:29 +01:00
|
|
|
--
|
|
|
|
-- @DOC_wibox_awidget_tasklist_style_shape_border_width_urgent_EXAMPLE@
|
|
|
|
--
|
2016-08-14 06:25:50 +02:00
|
|
|
-- @beautiful beautiful.tasklist_shape_border_width_urgent
|
|
|
|
-- @tparam[opt=0] number shape_border_width_urgent
|
|
|
|
|
|
|
|
--- The urgent clients border color.
|
2021-11-13 09:14:29 +01:00
|
|
|
--
|
|
|
|
-- @DOC_wibox_awidget_tasklist_style_shape_border_color_urgent_EXAMPLE@
|
|
|
|
--
|
2016-08-14 06:25:50 +02:00
|
|
|
-- @beautiful beautiful.tasklist_shape_border_color_urgent
|
|
|
|
-- @tparam[opt=nil] string|color shape_border_color_urgent
|
|
|
|
-- @see gears.color
|
|
|
|
|
2021-12-21 06:54:15 +01:00
|
|
|
--- The icon size.
|
|
|
|
-- @beautiful beautiful.tasklist_icon_size
|
|
|
|
-- @tparam[opt=nil] integer tasklist_icon_size
|
|
|
|
|
2009-02-27 17:22:03 +01:00
|
|
|
-- Public structures
|
2018-08-18 22:30:15 +02:00
|
|
|
tasklist.filter, tasklist.source = {}, {}
|
2009-02-27 17:22:03 +01:00
|
|
|
|
2019-03-07 05:16:34 +01:00
|
|
|
-- This is the same template as awful.widget.common, but with an clienticon widget
|
2021-11-13 09:14:29 +01:00
|
|
|
local function default_template(self)
|
|
|
|
local has_no_icon = self._private.style.disable_icon
|
|
|
|
or self._private.style.tasklist_disable_icon
|
|
|
|
or beautiful.tasklist_disable_icon
|
|
|
|
|
|
|
|
return {
|
2019-03-07 05:16:34 +01:00
|
|
|
{
|
2021-11-13 09:14:29 +01:00
|
|
|
(not has_no_icon) and {
|
|
|
|
clienticon,
|
|
|
|
id = "icon_margin_role",
|
|
|
|
left = dpi(4),
|
|
|
|
widget = wmargin
|
|
|
|
} or nil,
|
2019-03-07 05:16:34 +01:00
|
|
|
{
|
2021-11-13 09:14:29 +01:00
|
|
|
{
|
|
|
|
id = "text_role",
|
|
|
|
widget = wtextbox,
|
|
|
|
},
|
|
|
|
id = "text_margin_role",
|
|
|
|
left = dpi(4),
|
|
|
|
right = dpi(4),
|
|
|
|
widget = wmargin
|
2019-03-07 05:16:34 +01:00
|
|
|
},
|
2021-11-13 09:14:29 +01:00
|
|
|
fill_space = true,
|
|
|
|
layout = wfixed.horizontal
|
2019-03-07 05:16:34 +01:00
|
|
|
},
|
2021-11-13 09:14:29 +01:00
|
|
|
id = "background_role",
|
|
|
|
widget = wbackground
|
|
|
|
}
|
|
|
|
end
|
2019-03-07 05:16:34 +01:00
|
|
|
|
2015-07-13 23:47:37 +02:00
|
|
|
local function tasklist_label(c, args, tb)
|
2009-02-27 17:22:03 +01:00
|
|
|
if not args then args = {} end
|
|
|
|
local theme = beautiful.get()
|
2016-09-02 18:14:43 +02:00
|
|
|
local align = args.align or theme.tasklist_align or "left"
|
2017-03-03 00:02:03 +01:00
|
|
|
local fg_normal = gcolor.ensure_pango_color(args.fg_normal or theme.tasklist_fg_normal or theme.fg_normal, "white")
|
2013-11-18 15:19:54 +01:00
|
|
|
local bg_normal = args.bg_normal or theme.tasklist_bg_normal or theme.bg_normal or "#000000"
|
2017-03-03 00:02:03 +01:00
|
|
|
local fg_focus = gcolor.ensure_pango_color(args.fg_focus or theme.tasklist_fg_focus or theme.fg_focus, fg_normal)
|
2015-07-11 00:11:45 +02:00
|
|
|
local bg_focus = args.bg_focus or theme.tasklist_bg_focus or theme.bg_focus or bg_normal
|
2017-03-03 00:02:03 +01:00
|
|
|
local fg_urgent = gcolor.ensure_pango_color(args.fg_urgent or theme.tasklist_fg_urgent or theme.fg_urgent,
|
2017-03-03 23:11:06 +01:00
|
|
|
fg_normal)
|
2017-03-03 00:02:03 +01:00
|
|
|
local bg_urgent = args.bg_urgent or theme.tasklist_bg_urgent or theme.bg_urgent or bg_normal
|
|
|
|
local fg_minimize = gcolor.ensure_pango_color(args.fg_minimize or theme.tasklist_fg_minimize or theme.fg_minimize,
|
|
|
|
fg_normal)
|
2015-07-11 00:11:45 +02:00
|
|
|
local bg_minimize = args.bg_minimize or theme.tasklist_bg_minimize or theme.bg_minimize or bg_normal
|
2017-01-16 08:58:26 +01:00
|
|
|
-- FIXME v5, remove the fallback theme.bg_image_* variables, see GH#1403
|
|
|
|
local bg_image_normal = args.bg_image_normal or theme.tasklist_bg_image_normal or theme.bg_image_normal
|
|
|
|
local bg_image_focus = args.bg_image_focus or theme.tasklist_bg_image_focus or theme.bg_image_focus
|
|
|
|
local bg_image_urgent = args.bg_image_urgent or theme.tasklist_bg_image_urgent or theme.bg_image_urgent
|
|
|
|
local bg_image_minimize = args.bg_image_minimize or theme.tasklist_bg_image_minimize or theme.bg_image_minimize
|
2022-08-22 08:02:26 +02:00
|
|
|
local tasklist_disable_icon = args.disable_icon or args.tasklist_disable_icon
|
|
|
|
or theme.tasklist_disable_icon or false
|
2017-02-26 01:21:36 +01:00
|
|
|
local disable_task_name = args.disable_task_name or theme.tasklist_disable_task_name or false
|
2021-11-13 09:12:44 +01:00
|
|
|
local font = args.font or theme.tasklist_font or theme.font
|
|
|
|
local font_focus = args.font_focus or theme.tasklist_font_focus or theme.font_focus or font
|
|
|
|
local font_minimized = args.font_minimized or theme.tasklist_font_minimized or theme.font_minimized or font
|
|
|
|
local font_urgent = args.font_urgent or theme.tasklist_font_urgent or theme.font_urgent or font
|
2015-07-13 23:47:37 +02:00
|
|
|
local text = ""
|
2009-10-03 09:59:27 +02:00
|
|
|
local name = ""
|
2016-02-07 15:12:22 +01:00
|
|
|
local bg
|
|
|
|
local bg_image
|
2016-08-05 07:47:14 +02:00
|
|
|
local shape = args.shape or theme.tasklist_shape
|
|
|
|
local shape_border_width = args.shape_border_width or theme.tasklist_shape_border_width
|
|
|
|
local shape_border_color = args.shape_border_color or theme.tasklist_shape_border_color
|
2019-03-06 20:06:11 +01:00
|
|
|
local icon_size = args.icon_size or theme.tasklist_icon_size
|
2012-01-05 19:31:27 +01:00
|
|
|
|
|
|
|
-- symbol to use to indicate certain client properties
|
2012-01-05 20:24:33 +01:00
|
|
|
local sticky = args.sticky or theme.tasklist_sticky or "▪"
|
2012-01-05 19:31:27 +01:00
|
|
|
local ontop = args.ontop or theme.tasklist_ontop or '⌃'
|
2015-07-17 17:06:43 +02:00
|
|
|
local above = args.above or theme.tasklist_above or '▴'
|
|
|
|
local below = args.below or theme.tasklist_below or '▾'
|
2012-01-05 19:31:27 +01:00
|
|
|
local floating = args.floating or theme.tasklist_floating or '✈'
|
2014-09-02 22:07:53 +02:00
|
|
|
local maximized = args.maximized or theme.tasklist_maximized or '<b>+</b>'
|
2012-01-05 19:31:27 +01:00
|
|
|
local maximized_horizontal = args.maximized_horizontal or theme.tasklist_maximized_horizontal or '⬌'
|
|
|
|
local maximized_vertical = args.maximized_vertical or theme.tasklist_maximized_vertical or '⬍'
|
2021-12-21 20:48:53 +01:00
|
|
|
local minimized = args.minimized or theme.tasklist_minimized or '<b>_</b>'
|
2012-01-05 19:31:27 +01:00
|
|
|
|
2017-08-10 06:32:30 +02:00
|
|
|
if tb then
|
2022-09-04 09:33:09 +02:00
|
|
|
tb:set_halign(align)
|
2017-08-10 06:32:30 +02:00
|
|
|
end
|
2016-09-02 18:14:43 +02:00
|
|
|
|
2013-01-05 16:51:13 +01:00
|
|
|
if not theme.tasklist_plain_task_name then
|
|
|
|
if c.sticky then name = name .. sticky end
|
2015-07-17 17:06:43 +02:00
|
|
|
|
|
|
|
if c.ontop then name = name .. ontop
|
|
|
|
elseif c.above then name = name .. above
|
|
|
|
elseif c.below then name = name .. below end
|
|
|
|
|
2014-09-02 22:07:53 +02:00
|
|
|
if c.maximized then
|
|
|
|
name = name .. maximized
|
|
|
|
else
|
|
|
|
if c.maximized_horizontal then name = name .. maximized_horizontal end
|
|
|
|
if c.maximized_vertical then name = name .. maximized_vertical end
|
2016-03-14 07:21:29 +01:00
|
|
|
if c.floating then name = name .. floating end
|
2014-09-02 22:07:53 +02:00
|
|
|
end
|
2021-12-21 20:48:53 +01:00
|
|
|
if c.minimized then name = name .. minimized end
|
2013-01-05 16:51:13 +01:00
|
|
|
end
|
|
|
|
|
2017-02-26 01:21:36 +01:00
|
|
|
if not disable_task_name then
|
|
|
|
if c.minimized then
|
2017-03-12 00:57:32 +01:00
|
|
|
name = name .. (gstring.xml_escape(c.icon_name) or gstring.xml_escape(c.name) or
|
|
|
|
gstring.xml_escape("<untitled>"))
|
2017-02-26 01:21:36 +01:00
|
|
|
else
|
2017-03-12 00:57:32 +01:00
|
|
|
name = name .. (gstring.xml_escape(c.name) or gstring.xml_escape("<untitled>"))
|
2017-02-26 01:21:36 +01:00
|
|
|
end
|
2009-02-27 17:22:03 +01:00
|
|
|
end
|
2016-03-14 07:21:29 +01:00
|
|
|
|
2019-11-11 00:39:26 +01:00
|
|
|
local focused = c.active
|
2015-03-29 20:20:53 +02:00
|
|
|
-- Handle transient_for: the first parent that does not skip the taskbar
|
|
|
|
-- is considered to be focused, if the real client has skip_taskbar.
|
|
|
|
if not focused and capi.client.focus and capi.client.focus.skip_taskbar
|
2016-04-17 14:30:39 +02:00
|
|
|
and capi.client.focus:get_transient_for_matching(function(cl)
|
|
|
|
return not cl.skip_taskbar
|
|
|
|
end) == c then
|
2015-03-29 20:20:53 +02:00
|
|
|
focused = true
|
|
|
|
end
|
2016-03-14 07:21:29 +01:00
|
|
|
|
2015-03-29 20:20:53 +02:00
|
|
|
if focused then
|
2009-02-27 17:22:03 +01:00
|
|
|
bg = bg_focus
|
2015-07-11 00:11:45 +02:00
|
|
|
text = text .. "<span color='"..fg_focus.."'>"..name.."</span>"
|
2013-01-04 03:00:33 +01:00
|
|
|
bg_image = bg_image_focus
|
2015-07-13 23:47:37 +02:00
|
|
|
font = font_focus
|
2016-08-05 07:47:14 +02:00
|
|
|
|
|
|
|
if args.shape_focus or theme.tasklist_shape_focus then
|
|
|
|
shape = args.shape_focus or theme.tasklist_shape_focus
|
|
|
|
end
|
|
|
|
|
|
|
|
if args.shape_border_width_focus or theme.tasklist_shape_border_width_focus then
|
|
|
|
shape_border_width = args.shape_border_width_focus or theme.tasklist_shape_border_width_focus
|
|
|
|
end
|
|
|
|
|
|
|
|
if args.shape_border_color_focus or theme.tasklist_shape_border_color_focus then
|
|
|
|
shape_border_color = args.shape_border_color_focus or theme.tasklist_shape_border_color_focus
|
|
|
|
end
|
2015-07-11 00:11:45 +02:00
|
|
|
elseif c.urgent then
|
2009-02-27 17:22:03 +01:00
|
|
|
bg = bg_urgent
|
2015-07-11 00:11:45 +02:00
|
|
|
text = text .. "<span color='"..fg_urgent.."'>"..name.."</span>"
|
2013-01-04 03:00:33 +01:00
|
|
|
bg_image = bg_image_urgent
|
2015-07-13 23:47:37 +02:00
|
|
|
font = font_urgent
|
2016-08-05 07:47:14 +02:00
|
|
|
|
|
|
|
if args.shape_urgent or theme.tasklist_shape_urgent then
|
|
|
|
shape = args.shape_urgent or theme.tasklist_shape_urgent
|
|
|
|
end
|
|
|
|
|
|
|
|
if args.shape_border_width_urgent or theme.tasklist_shape_border_width_urgent then
|
|
|
|
shape_border_width = args.shape_border_width_urgent or theme.tasklist_shape_border_width_urgent
|
|
|
|
end
|
|
|
|
|
|
|
|
if args.shape_border_color_urgent or theme.tasklist_shape_border_color_urgent then
|
|
|
|
shape_border_color = args.shape_border_color_urgent or theme.tasklist_shape_border_color_urgent
|
|
|
|
end
|
2015-07-11 00:11:45 +02:00
|
|
|
elseif c.minimized then
|
2009-02-27 17:22:03 +01:00
|
|
|
bg = bg_minimize
|
2015-07-11 00:11:45 +02:00
|
|
|
text = text .. "<span color='"..fg_minimize.."'>"..name.."</span>"
|
2013-01-04 03:00:33 +01:00
|
|
|
bg_image = bg_image_minimize
|
2015-07-13 23:47:37 +02:00
|
|
|
font = font_minimized
|
2016-08-05 07:47:14 +02:00
|
|
|
|
|
|
|
if args.shape_minimized or theme.tasklist_shape_minimized then
|
|
|
|
shape = args.shape_minimized or theme.tasklist_shape_minimized
|
|
|
|
end
|
|
|
|
|
|
|
|
if args.shape_border_width_minimized or theme.tasklist_shape_border_width_minimized then
|
|
|
|
shape_border_width = args.shape_border_width_minimized or theme.tasklist_shape_border_width_minimized
|
|
|
|
end
|
|
|
|
|
|
|
|
if args.shape_border_color_minimized or theme.tasklist_shape_border_color_minimized then
|
|
|
|
shape_border_color = args.shape_border_color_minimized or theme.tasklist_shape_border_color_minimized
|
|
|
|
end
|
2009-02-27 17:22:03 +01:00
|
|
|
else
|
2011-10-11 22:24:44 +02:00
|
|
|
bg = bg_normal
|
2015-07-11 00:11:45 +02:00
|
|
|
text = text .. "<span color='"..fg_normal.."'>"..name.."</span>"
|
2013-01-04 03:00:33 +01:00
|
|
|
bg_image = bg_image_normal
|
2009-02-27 17:22:03 +01:00
|
|
|
end
|
2017-08-10 06:32:30 +02:00
|
|
|
|
|
|
|
if tb then
|
|
|
|
tb:set_font(font)
|
|
|
|
end
|
2016-08-05 07:47:14 +02:00
|
|
|
|
|
|
|
local other_args = {
|
|
|
|
shape = shape,
|
|
|
|
shape_border_width = shape_border_width,
|
|
|
|
shape_border_color = shape_border_color,
|
2019-03-06 20:06:11 +01:00
|
|
|
icon_size = icon_size,
|
2016-08-05 07:47:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return text, bg, bg_image, not tasklist_disable_icon and c.icon or nil, other_args
|
2009-02-27 17:22:03 +01:00
|
|
|
end
|
|
|
|
|
2019-03-07 04:57:34 +01:00
|
|
|
-- Remove some callback boilerplate from the user provided templates.
|
|
|
|
local function create_callback(w, t)
|
|
|
|
common._set_common_property(w, "client", t)
|
|
|
|
end
|
|
|
|
|
2021-11-10 01:57:09 +01:00
|
|
|
local function tasklist_update(s, self, buttons, filter, data, style, update_function, args)
|
2009-10-24 14:53:01 +02:00
|
|
|
local clients = {}
|
2018-08-18 22:30:15 +02:00
|
|
|
|
2021-11-03 05:59:56 +01:00
|
|
|
local source = self.source or tasklist.source.all_clients or nil
|
2018-08-18 22:30:15 +02:00
|
|
|
local list = source and source(s, args) or capi.client.get()
|
|
|
|
|
|
|
|
for _, c in ipairs(list) do
|
2009-10-24 14:53:01 +02:00
|
|
|
if not (c.skip_taskbar or c.hidden
|
|
|
|
or c.type == "splash" or c.type == "dock" or c.type == "desktop")
|
|
|
|
and filter(c, s) then
|
|
|
|
table.insert(clients, c)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-11-10 08:10:43 +01:00
|
|
|
if self._private.last_count ~= #clients then
|
2021-11-13 09:14:29 +01:00
|
|
|
local old = self._private.last_count
|
2021-11-10 08:10:43 +01:00
|
|
|
self._private.last_count = #clients
|
2021-11-13 09:14:29 +01:00
|
|
|
self:emit_signal("property::count", #clients, old)
|
2021-11-10 08:10:43 +01:00
|
|
|
end
|
|
|
|
|
2015-07-13 23:47:37 +02:00
|
|
|
local function label(c, tb) return tasklist_label(c, style, tb) end
|
2009-10-24 14:53:01 +02:00
|
|
|
|
2021-11-10 01:57:09 +01:00
|
|
|
update_function(self._private.base_layout, buttons, label, data, clients, {
|
2021-11-13 09:14:29 +01:00
|
|
|
widget_template = self._private.widget_template or default_template(self),
|
2019-03-07 04:57:34 +01:00
|
|
|
create_callback = create_callback,
|
2019-03-07 04:44:02 +01:00
|
|
|
})
|
2009-10-24 14:53:01 +02:00
|
|
|
end
|
|
|
|
|
2021-11-10 08:10:43 +01:00
|
|
|
--- The current number of clients.
|
|
|
|
--
|
2022-08-22 08:02:26 +02:00
|
|
|
-- Note that the `tasklist` is usually lazy-loaded. Reading this property
|
|
|
|
-- may cause the widgets to be created. Depending on where the property is called
|
|
|
|
-- from, it might, in theory, cause an infinite loop.
|
|
|
|
--
|
2021-11-10 08:10:43 +01:00
|
|
|
-- @property count
|
|
|
|
-- @readonly
|
2022-08-22 08:02:26 +02:00
|
|
|
-- @tparam number count
|
|
|
|
-- @propertydefault The current number of client.
|
|
|
|
-- @negativeallowed false
|
2021-11-10 08:10:43 +01:00
|
|
|
-- @propemits true false
|
|
|
|
|
2021-11-03 05:59:56 +01:00
|
|
|
--- Set the tasklist layout.
|
|
|
|
--
|
2021-11-13 09:21:21 +01:00
|
|
|
-- This can be used to change the layout based on the number of clients:
|
|
|
|
--
|
|
|
|
-- @DOC_sequences_client_tasklist_layout1_EXAMPLE@
|
|
|
|
--
|
2021-11-03 05:59:56 +01:00
|
|
|
-- @property base_layout
|
|
|
|
-- @tparam[opt=wibox.layout.flex.horizontal] wibox.layout base_layout
|
2021-11-10 01:57:09 +01:00
|
|
|
-- @propemits true false
|
2021-11-03 05:59:56 +01:00
|
|
|
-- @see wibox.layout.flex.horizontal
|
|
|
|
|
2021-11-10 01:57:09 +01:00
|
|
|
--- The tasklist screen.
|
|
|
|
--
|
2021-11-13 09:21:21 +01:00
|
|
|
-- @DOC_sequences_client_tasklist_screen1_EXAMPLE@
|
|
|
|
--
|
2021-11-10 01:57:09 +01:00
|
|
|
-- @property screen
|
|
|
|
-- @tparam screen screen
|
2022-08-22 08:02:26 +02:00
|
|
|
-- @propertydefault Obtained from the constructor.
|
2021-11-10 01:57:09 +01:00
|
|
|
-- @propemits true false
|
|
|
|
|
|
|
|
--- A function to narrow down the list of clients.
|
|
|
|
--
|
2021-11-13 09:21:21 +01:00
|
|
|
-- @DOC_sequences_client_tasklist_custom_filter1_EXAMPLE@
|
|
|
|
--
|
2021-11-10 01:57:09 +01:00
|
|
|
-- @property filter
|
2022-08-22 08:02:26 +02:00
|
|
|
-- @tparam[opt=awful.widget.tasklist.filter.alltags] function filter
|
|
|
|
-- @functionparam client c The client to accept or reject.
|
|
|
|
-- @functionparam screen s The value of the tasklist `screen` property.
|
|
|
|
-- @functionreturn boolean `true` if the client is accepter or `false` if it is rejected.
|
2021-11-10 01:57:09 +01:00
|
|
|
-- @propemits true false
|
2021-11-13 09:21:21 +01:00
|
|
|
-- @see awful.widget.tasklist.filter.allscreen
|
|
|
|
-- @see awful.widget.tasklist.filter.alltags
|
|
|
|
-- @see awful.widget.tasklist.filter.currenttags
|
|
|
|
-- @see awful.widget.tasklist.filter.minimizedcurrenttags
|
|
|
|
-- @see awful.widget.tasklist.filter.focused
|
2021-11-10 01:57:09 +01:00
|
|
|
|
|
|
|
--- A function called when the tasklist is refreshed.
|
|
|
|
--
|
|
|
|
-- This is a very low level API, prefer `widget_template` whenever
|
|
|
|
-- you can.
|
|
|
|
--
|
|
|
|
-- @property update_function
|
2022-08-22 08:02:26 +02:00
|
|
|
-- @tparam function|nil update_function
|
|
|
|
-- @propertydefault The default function delegate everything to the `widget_template`.
|
|
|
|
-- @functionparam widget layout The base layout object.
|
|
|
|
-- @functionparam table buttons The buttons for this client entry (see below).
|
|
|
|
-- @functionparam string label The client name.
|
|
|
|
-- @functionparam table data Arbitrary metadate.
|
|
|
|
-- @functionparam table clients The list of clients (ordered).
|
|
|
|
-- @functionparam table metadata Other values.
|
|
|
|
-- @functionnoreturn
|
2021-11-10 01:57:09 +01:00
|
|
|
-- @propemits true false
|
|
|
|
|
|
|
|
--- A template for creating the client widgets.
|
|
|
|
--
|
2021-11-13 09:21:21 +01:00
|
|
|
-- @DOC_sequences_client_tasklist_widget_template1_EXAMPLE@
|
|
|
|
--
|
2021-11-10 01:57:09 +01:00
|
|
|
-- @property widget_template
|
2022-08-22 08:02:26 +02:00
|
|
|
-- @tparam[opt=nil] template|nil widget_template
|
2021-11-10 01:57:09 +01:00
|
|
|
-- @propemits true false
|
|
|
|
|
|
|
|
--- A function to gather the clients to display.
|
|
|
|
--
|
2021-11-13 09:21:21 +01:00
|
|
|
-- @DOC_sequences_client_tasklist_custom_source1_EXAMPLE@
|
|
|
|
--
|
2021-11-10 01:57:09 +01:00
|
|
|
-- @property source
|
2022-08-22 08:02:26 +02:00
|
|
|
-- @tparam[opt=awful.widget.tasklist.source.all_clients] function source
|
|
|
|
-- @functionparam screen s The tasklist screen.
|
|
|
|
-- @functionparam table metadata Various metadata.
|
|
|
|
-- @functionreturn table The list of clients.
|
2021-11-10 01:57:09 +01:00
|
|
|
-- @propemits true false
|
2021-11-13 09:21:21 +01:00
|
|
|
-- @see awful.widget.tasklist.source.all_clients
|
2021-11-10 01:57:09 +01:00
|
|
|
|
2021-11-03 05:59:56 +01:00
|
|
|
function tasklist:set_base_layout(layout)
|
|
|
|
self._private.base_layout = base.make_widget_from_value(
|
|
|
|
layout or flex.horizontal
|
|
|
|
)
|
|
|
|
|
|
|
|
local spacing = self._private.style.spacing or beautiful.tasklist_spacing
|
|
|
|
|
|
|
|
if self._private.base_layout.set_spacing and spacing then
|
|
|
|
self._private.base_layout:set_spacing(spacing)
|
|
|
|
end
|
|
|
|
|
|
|
|
assert(self._private.base_layout.is_widget)
|
|
|
|
|
|
|
|
self._do_tasklist_update()
|
|
|
|
|
|
|
|
self:emit_signal("widget::layout_changed")
|
|
|
|
self:emit_signal("widget::redraw_needed")
|
|
|
|
self:emit_signal("property::base_layout", layout)
|
|
|
|
end
|
|
|
|
|
2021-11-10 08:10:43 +01:00
|
|
|
function tasklist:get_count()
|
|
|
|
if not self._private.last_count then
|
|
|
|
self._do_tasklist_update_now()
|
|
|
|
end
|
|
|
|
|
|
|
|
return self._private.last_count
|
|
|
|
end
|
|
|
|
|
2021-11-03 05:59:56 +01:00
|
|
|
function tasklist:layout(_, width, height)
|
|
|
|
if self._private.base_layout then
|
|
|
|
return { base.place_widget_at(self._private.base_layout, 0, 0, width, height) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function tasklist:fit(context, width, height)
|
|
|
|
if not self._private.base_layout then
|
|
|
|
return 0, 0
|
|
|
|
end
|
|
|
|
|
|
|
|
return base.fit_widget(self, context, self._private.base_layout, width, height)
|
|
|
|
end
|
|
|
|
|
|
|
|
for _, prop in ipairs { "screen", "filter", "update_function", "widget_template", "source"} do
|
|
|
|
tasklist["set_"..prop] = function(self, value)
|
|
|
|
if value == self._private[prop] then return end
|
|
|
|
|
|
|
|
self._private[prop] = value
|
|
|
|
|
|
|
|
self._do_tasklist_update()
|
|
|
|
|
|
|
|
self:emit_signal("widget::layout_changed")
|
|
|
|
self:emit_signal("widget::redraw_needed")
|
|
|
|
self:emit_signal("property::"..prop, value)
|
|
|
|
end
|
|
|
|
|
|
|
|
tasklist["get_"..prop] = function(self)
|
|
|
|
return self._private[prop]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function update_screen(self, screen, old)
|
|
|
|
if not instances then return end
|
|
|
|
|
|
|
|
if old and instances[old] then
|
|
|
|
for k, w in ipairs(instances[old]) do
|
|
|
|
if w == self then
|
|
|
|
table.remove(instances[old], k)
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local list = instances[screen]
|
|
|
|
|
|
|
|
if not list then
|
|
|
|
list = setmetatable({}, { __mode = "v" })
|
|
|
|
instances[screen] = list
|
|
|
|
end
|
|
|
|
|
|
|
|
table.insert(list, self)
|
|
|
|
end
|
|
|
|
|
|
|
|
function tasklist:set_screen(value)
|
|
|
|
value = get_screen(value)
|
|
|
|
|
|
|
|
if value == self._private.screen then return end
|
|
|
|
|
|
|
|
local old = self._private.screen
|
|
|
|
|
|
|
|
self._private.screen = value
|
|
|
|
|
|
|
|
update_screen(self, screen, old)
|
|
|
|
|
|
|
|
self._do_tasklist_update()
|
|
|
|
|
|
|
|
self:emit_signal("widget::layout_changed")
|
|
|
|
self:emit_signal("widget::redraw_needed")
|
|
|
|
self:emit_signal("property::screen", value)
|
|
|
|
end
|
|
|
|
|
|
|
|
function tasklist:set_widget_template(widget_template)
|
|
|
|
self._private.widget_template = widget_template
|
|
|
|
|
|
|
|
-- Remove the existing instances
|
|
|
|
self._private.data = setmetatable({}, { __mode = 'k' })
|
|
|
|
|
|
|
|
self._do_tasklist_update()
|
|
|
|
|
|
|
|
self:emit_signal("widget::layout_changed")
|
|
|
|
self:emit_signal("widget::redraw_needed")
|
|
|
|
self:emit_signal("property::widget_template", widget_template)
|
|
|
|
end
|
|
|
|
|
2017-08-08 00:14:35 +02:00
|
|
|
--- Create a new tasklist widget.
|
|
|
|
-- The last two arguments (update_function
|
|
|
|
-- and layout) serve to customize the layout of the tasklist (eg. to
|
2013-01-05 16:12:51 +01:00
|
|
|
-- make it vertical). For that, you will need to copy the
|
|
|
|
-- awful.widget.common.list_update function, make your changes to it
|
2017-08-08 00:14:35 +02:00
|
|
|
-- and pass it as update_function here. Also change the layout if the
|
2013-01-05 16:12:51 +01:00
|
|
|
-- default is not what you want.
|
2017-08-08 00:14:35 +02:00
|
|
|
--
|
|
|
|
-- @tparam table args
|
|
|
|
-- @tparam screen args.screen The screen to draw tasklist for.
|
|
|
|
-- @tparam function args.filter Filter function to define what clients will be listed.
|
|
|
|
-- @tparam table args.buttons A table with buttons binding to set.
|
|
|
|
-- @tparam[opt] function args.update_function Function to create a tag widget on each
|
2015-02-26 16:06:19 +01:00
|
|
|
-- update. See `awful.widget.common.list_update`.
|
2017-08-08 00:14:35 +02:00
|
|
|
-- @tparam[opt] table args.layout Container widget for tag widgets. Default
|
2015-02-26 16:06:19 +01:00
|
|
|
-- is `wibox.layout.flex.horizontal`.
|
2021-03-22 23:28:53 +01:00
|
|
|
-- @tparam[opt=awful.widget.tasklist.source.all_clients] function args.source The
|
2018-08-18 22:30:15 +02:00
|
|
|
-- function used to generate the list of client.
|
2018-04-22 08:04:01 +02:00
|
|
|
-- @tparam[opt] table args.widget_template A custom widget to be used for each client
|
2017-08-08 00:14:35 +02:00
|
|
|
-- @tparam[opt={}] table args.style The style overrides default theme.
|
2021-12-21 06:54:15 +01:00
|
|
|
-- @tparam[opt=beautiful.tasklist_fg_normal] string|pattern args.style.fg_normal
|
|
|
|
-- @tparam[opt=beautiful.tasklist_bg_normal] string|pattern args.style.bg_normal
|
|
|
|
-- @tparam[opt=beautiful.tasklist_fg_focus or beautiful.fg_focus] string|pattern args.style.fg_focus
|
|
|
|
-- @tparam[opt=beautiful.tasklist_bg_focus or beautiful.bg_focus] string|pattern args.style.bg_focus
|
|
|
|
-- @tparam[opt=beautiful.tasklist_fg_urgent or beautiful.fg_urgent] string|pattern args.style.fg_urgent
|
|
|
|
-- @tparam[opt=beautiful.tasklist_bg_urgent or beautiful.bg_urgent] string|pattern args.style.bg_urgent
|
|
|
|
-- @tparam[opt=beautiful.tasklist_fg_minimize or beautiful.fg_minimize] string|pattern args.style.fg_minimize
|
|
|
|
-- @tparam[opt=beautiful.tasklist_bg_minimize or beautiful.bg_minimize] string|pattern args.style.bg_minimize
|
|
|
|
-- @tparam[opt=beautiful.tasklist_bg_image_normal] string args.style.bg_image_normal
|
|
|
|
-- @tparam[opt=beautiful.tasklist_bg_image_focus] string args.style.bg_image_focus
|
|
|
|
-- @tparam[opt=beautiful.tasklist_bg_image_urgent] string args.style.bg_image_urgent
|
|
|
|
-- @tparam[opt=beautiful.tasklist_bg_image_minimize] string args.style.bg_image_minimize
|
|
|
|
-- @tparam[opt=beautiful.tasklist_disable_icon] boolean args.style.disable_icon
|
|
|
|
-- @tparam[opt=beautiful.tasklist_icon_size] number args.style.icon_size The size of the icon
|
|
|
|
-- @tparam[opt=beautiful.tasklist_sticky or '▪'] string args.style.sticky Extra icon when client is sticky
|
|
|
|
-- @tparam[opt=beautiful.tasklist_ontop or '⌃'] string args.style.ontop Extra icon when client is ontop
|
|
|
|
-- @tparam[opt=beautiful.tasklist_above or '▴'] string args.style.above Extra icon when client is above
|
|
|
|
-- @tparam[opt=beautiful.tasklist_below or '▾'] string args.style.below Extra icon when client is below
|
|
|
|
-- @tparam[opt=beautiful.tasklist_floating or '✈'] string args.style.floating Extra icon when client is floating
|
2022-08-22 08:02:26 +02:00
|
|
|
-- @tparam[opt=beautiful.tasklist_maximized or '<b>+</b>'] string args.style.maximized Extra
|
|
|
|
-- icon when client is maximized
|
|
|
|
-- @tparam[opt=beautiful.tasklist_maximized_horizontal or '⬌'] string args.style.maximized_horizontal Extra
|
|
|
|
-- icon when client is maximized_horizontal
|
|
|
|
-- @tparam[opt=beautiful.tasklist_maximized_vertical or '⬍'] string args.style.maximized_vertical Extra
|
|
|
|
-- icon when client is maximized_vertical
|
2021-12-21 06:54:15 +01:00
|
|
|
-- @tparam[opt=beautiful.tasklist_disable_task_name or false] boolean args.style.disable_task_name
|
|
|
|
-- @tparam[opt=beautiful.tasklist_font] string args.style.font
|
|
|
|
-- @tparam[opt=beautiful.tasklist_align or "left"] string args.style.align *left*, *right* or *center*
|
|
|
|
-- @tparam[opt=beautiful.tasklist_font_focus] string args.style.font_focus
|
|
|
|
-- @tparam[opt=beautiful.tasklist_font_minimized] string args.style.font_minimized
|
|
|
|
-- @tparam[opt=beautiful.tasklist_font_urgent] string args.style.font_urgent
|
|
|
|
-- @tparam[opt=beautiful.tasklist_spacing] number args.style.spacing The spacing between tags.
|
|
|
|
-- @tparam[opt=beautiful.tasklist_shape] gears.shape args.style.shape
|
|
|
|
-- @tparam[opt=beautiful.tasklist_shape_border_width] number args.style.shape_border_width
|
|
|
|
-- @tparam[opt=beautiful.tasklist_shape_border_color] string|color args.style.shape_border_color
|
|
|
|
-- @tparam[opt=beautiful.tasklist_shape_focus] gears.shape args.style.shape_focus
|
|
|
|
-- @tparam[opt=beautiful.tasklist_shape_border_width_focus] number args.style.shape_border_width_focus
|
|
|
|
-- @tparam[opt=beautiful.tasklist_shape_border_color_focus] string|color args.style.shape_border_color_focus
|
|
|
|
-- @tparam[opt=beautiful.tasklist_shape_minimized] gears.shape args.style.shape_minimized
|
|
|
|
-- @tparam[opt=beautiful.tasklist_shape_border_width_minimized] number args.style.shape_border_width_minimized
|
|
|
|
-- @tparam[opt=beautiful.tasklist_shape_border_color_minimized] string|color args.style.shape_border_color_minimized
|
|
|
|
-- @tparam[opt=beautiful.tasklist_shape_urgent] gears.shape args.style.shape_urgent
|
|
|
|
-- @tparam[opt=beautiful.tasklist_shape_border_width_urgent] number args.style.shape_border_width_urgent
|
|
|
|
-- @tparam[opt=beautiful.tasklist_shape_border_color_urgent] string|color args.style.shape_border_color_urgent
|
2022-08-22 08:02:26 +02:00
|
|
|
-- @tparam[opt=beautiful.tasklist_minimized ] string|color args.style.minimized
|
2017-08-08 00:14:35 +02:00
|
|
|
-- @param filter **DEPRECATED** use args.filter
|
|
|
|
-- @param buttons **DEPRECATED** use args.buttons
|
|
|
|
-- @param style **DEPRECATED** use args.style
|
|
|
|
-- @param update_function **DEPRECATED** use args.update_function
|
2021-11-03 05:59:56 +01:00
|
|
|
-- @param base_widget **DEPRECATED** use args.base_layout
|
2019-06-07 20:59:34 +02:00
|
|
|
-- @constructorfct awful.widget.tasklist
|
2021-12-21 06:54:15 +01:00
|
|
|
-- @usebeautiful beautiful.tasklist_plain_task_name
|
2017-08-08 00:14:35 +02:00
|
|
|
function tasklist.new(args, filter, buttons, style, update_function, base_widget)
|
|
|
|
local screen = nil
|
|
|
|
|
|
|
|
local argstype = type(args)
|
|
|
|
|
|
|
|
-- Detect the old function signature
|
|
|
|
if argstype == "number" or argstype == "screen" or
|
|
|
|
(argstype == "table" and args.index and args == capi.screen[args.index]) then
|
2021-10-05 04:20:03 +02:00
|
|
|
gdebug.deprecate("The `screen` parameter is deprecated, use `args.screen`.",
|
2017-08-08 00:14:35 +02:00
|
|
|
{deprecated_in=5})
|
|
|
|
|
|
|
|
screen = get_screen(args)
|
|
|
|
args = {}
|
|
|
|
end
|
|
|
|
|
|
|
|
assert(type(args) == "table")
|
|
|
|
|
|
|
|
for k, v in pairs { filter = filter,
|
|
|
|
buttons = buttons,
|
|
|
|
style = style,
|
|
|
|
update_function = update_function,
|
|
|
|
layout = base_widget
|
|
|
|
} do
|
|
|
|
gdebug.deprecate("The `awful.widget.tasklist()` `"..k
|
2021-10-05 04:20:03 +02:00
|
|
|
.."` parameter is deprecated, use `args."..k.."`.",
|
2017-08-08 00:14:35 +02:00
|
|
|
{deprecated_in=5})
|
|
|
|
args[k] = v
|
|
|
|
end
|
|
|
|
|
|
|
|
screen = screen or get_screen(args.screen)
|
|
|
|
local uf = args.update_function or common.list_update
|
2009-10-24 14:53:01 +02:00
|
|
|
|
2021-11-03 05:59:56 +01:00
|
|
|
local w = base.make_widget(nil, nil, {
|
|
|
|
enable_properties = true,
|
|
|
|
})
|
2015-07-07 18:07:59 +02:00
|
|
|
|
2021-11-03 05:59:56 +01:00
|
|
|
gtable.crush(w._private, {
|
|
|
|
disable_task_name = args.disable_task_name,
|
|
|
|
disable_icon = args.disable_icon,
|
|
|
|
update_function = args.update_function,
|
|
|
|
filter = args.filter,
|
|
|
|
buttons = args.buttons,
|
|
|
|
style = args.style or {},
|
|
|
|
screen = screen,
|
|
|
|
widget_template = args.widget_template,
|
|
|
|
source = args.source,
|
|
|
|
data = setmetatable({}, { __mode = 'k' })
|
|
|
|
})
|
|
|
|
|
|
|
|
gtable.crush(w, tasklist, true)
|
|
|
|
rawset(w, "filter", nil)
|
|
|
|
rawset(w, "source", nil)
|
2016-08-05 07:34:55 +02:00
|
|
|
|
2015-07-07 18:07:59 +02:00
|
|
|
local queued_update = false
|
2017-08-09 06:19:03 +02:00
|
|
|
|
|
|
|
-- For the tests
|
|
|
|
function w._do_tasklist_update_now()
|
|
|
|
queued_update = false
|
2021-11-03 05:59:56 +01:00
|
|
|
if w._private.screen.valid then
|
|
|
|
tasklist_update(
|
|
|
|
w._private.screen, w, w._private.buttons, w._private.filter, w._private.data, args.style, uf, args
|
|
|
|
)
|
2017-08-09 06:19:03 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-27 14:10:45 +02:00
|
|
|
function w._do_tasklist_update()
|
2015-07-07 18:07:59 +02:00
|
|
|
-- Add a delayed callback for the first update.
|
|
|
|
if not queued_update then
|
2017-08-09 06:19:03 +02:00
|
|
|
timer.delayed_call(w._do_tasklist_update_now)
|
2015-07-07 18:07:59 +02:00
|
|
|
queued_update = true
|
|
|
|
end
|
|
|
|
end
|
2016-01-24 16:28:07 +01:00
|
|
|
function w._unmanage(c)
|
2021-11-03 05:59:56 +01:00
|
|
|
w._private.data[c] = nil
|
2016-01-24 16:28:07 +01:00
|
|
|
end
|
2015-09-27 14:10:45 +02:00
|
|
|
if instances == nil then
|
2016-04-17 15:37:00 +02:00
|
|
|
instances = setmetatable({}, { __mode = "k" })
|
2015-09-27 14:10:45 +02:00
|
|
|
local function us(s)
|
2016-02-26 19:19:58 +01:00
|
|
|
local i = instances[get_screen(s)]
|
2015-09-27 14:10:45 +02:00
|
|
|
if i then
|
|
|
|
for _, tlist in pairs(i) do
|
|
|
|
tlist._do_tasklist_update()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
local function u()
|
2015-11-19 20:13:37 +01:00
|
|
|
for s in pairs(instances) do
|
2016-05-01 19:39:28 +02:00
|
|
|
if s.valid then
|
|
|
|
us(s)
|
|
|
|
end
|
2015-09-27 14:10:45 +02:00
|
|
|
end
|
2015-03-17 17:11:40 +01:00
|
|
|
end
|
2015-09-27 14:10:45 +02:00
|
|
|
|
|
|
|
tag.attached_connect_signal(nil, "property::selected", u)
|
|
|
|
tag.attached_connect_signal(nil, "property::activated", u)
|
|
|
|
capi.client.connect_signal("property::urgent", u)
|
|
|
|
capi.client.connect_signal("property::sticky", u)
|
|
|
|
capi.client.connect_signal("property::ontop", u)
|
|
|
|
capi.client.connect_signal("property::above", u)
|
|
|
|
capi.client.connect_signal("property::below", u)
|
|
|
|
capi.client.connect_signal("property::floating", u)
|
|
|
|
capi.client.connect_signal("property::maximized_horizontal", u)
|
|
|
|
capi.client.connect_signal("property::maximized_vertical", u)
|
2017-01-24 10:19:45 +01:00
|
|
|
capi.client.connect_signal("property::maximized", u)
|
2015-09-27 14:10:45 +02:00
|
|
|
capi.client.connect_signal("property::minimized", u)
|
|
|
|
capi.client.connect_signal("property::name", u)
|
|
|
|
capi.client.connect_signal("property::icon_name", u)
|
|
|
|
capi.client.connect_signal("property::icon", u)
|
|
|
|
capi.client.connect_signal("property::skip_taskbar", u)
|
|
|
|
capi.client.connect_signal("property::screen", function(c, old_screen)
|
|
|
|
us(c.screen)
|
|
|
|
us(old_screen)
|
|
|
|
end)
|
|
|
|
capi.client.connect_signal("property::hidden", u)
|
|
|
|
capi.client.connect_signal("tagged", u)
|
|
|
|
capi.client.connect_signal("untagged", u)
|
2019-11-10 07:12:43 +01:00
|
|
|
capi.client.connect_signal("request::unmanage", function(c)
|
2016-01-24 16:28:07 +01:00
|
|
|
u(c)
|
2016-02-12 09:08:21 +01:00
|
|
|
for _, i in pairs(instances) do
|
2016-01-24 16:28:07 +01:00
|
|
|
for _, tlist in pairs(i) do
|
|
|
|
tlist._unmanage(c)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end)
|
2015-09-27 14:10:45 +02:00
|
|
|
capi.client.connect_signal("list", u)
|
2019-11-11 03:04:04 +01:00
|
|
|
capi.client.connect_signal("property::active", u)
|
2016-05-01 19:39:28 +02:00
|
|
|
capi.screen.connect_signal("removed", function(s)
|
|
|
|
instances[get_screen(s)] = nil
|
|
|
|
end)
|
2015-09-27 14:10:45 +02:00
|
|
|
end
|
2021-11-03 05:59:56 +01:00
|
|
|
|
|
|
|
tasklist.set_base_layout(w, args.layout or args.base_layout)
|
|
|
|
|
2015-09-27 14:10:45 +02:00
|
|
|
w._do_tasklist_update()
|
2021-11-03 05:59:56 +01:00
|
|
|
|
|
|
|
update_screen(w, screen)
|
|
|
|
|
2009-10-24 14:53:01 +02:00
|
|
|
return w
|
2009-02-27 17:22:03 +01:00
|
|
|
end
|
|
|
|
|
2009-10-24 14:53:01 +02:00
|
|
|
--- Filtering function to include all clients.
|
2021-11-03 05:59:56 +01:00
|
|
|
--
|
|
|
|
--@DOC_sequences_client_tasklist_filter_allscreen1_EXAMPLE@
|
|
|
|
--
|
2009-10-24 14:53:01 +02:00
|
|
|
-- @return true
|
2021-03-22 23:28:53 +01:00
|
|
|
-- @filterfunction awful.widget.tasklist.filter.allscreen
|
2016-02-07 15:12:22 +01:00
|
|
|
function tasklist.filter.allscreen()
|
2009-10-24 14:53:01 +02:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
--- Filtering function to include the clients from all tags on the screen.
|
2021-11-03 05:59:56 +01:00
|
|
|
--
|
|
|
|
--@DOC_sequences_client_tasklist_filter_alltags1_EXAMPLE@
|
|
|
|
--
|
|
|
|
-- @tparam client c The client.
|
|
|
|
-- @tparam screen screen The screen we are drawing on.
|
2009-10-24 14:53:01 +02:00
|
|
|
-- @return true if c is on screen, false otherwise
|
2021-03-22 23:28:53 +01:00
|
|
|
-- @filterfunction awful.widget.tasklist.filter.alltags
|
2012-06-14 01:08:27 +02:00
|
|
|
function tasklist.filter.alltags(c, screen)
|
2009-02-27 17:22:03 +01:00
|
|
|
-- Only print client on the same screen as this widget
|
2016-02-26 19:19:58 +01:00
|
|
|
return get_screen(c.screen) == get_screen(screen)
|
2009-02-27 17:22:03 +01:00
|
|
|
end
|
|
|
|
|
2009-10-24 14:53:01 +02:00
|
|
|
--- Filtering function to include only the clients from currently selected tags.
|
2021-11-03 05:59:56 +01:00
|
|
|
--
|
|
|
|
-- This is the filter used in the default `rc.lua`.
|
|
|
|
--
|
|
|
|
--@DOC_sequences_client_tasklist_filter_currenttags1_EXAMPLE@
|
|
|
|
--
|
|
|
|
-- @tparam client c The client.
|
|
|
|
-- @tparam screen screen The screen we are drawing on.
|
2009-10-24 14:53:01 +02:00
|
|
|
-- @return true if c is in a selected tag on screen, false otherwise
|
2021-03-22 23:28:53 +01:00
|
|
|
-- @filterfunction awful.widget.tasklist.filter.currenttags
|
2012-06-14 01:08:27 +02:00
|
|
|
function tasklist.filter.currenttags(c, screen)
|
2016-02-26 19:19:58 +01:00
|
|
|
screen = get_screen(screen)
|
2009-02-27 17:22:03 +01:00
|
|
|
-- Only print client on the same screen as this widget
|
2016-02-26 19:19:58 +01:00
|
|
|
if get_screen(c.screen) ~= screen then return false end
|
2009-03-25 14:51:14 +01:00
|
|
|
-- Include sticky client too
|
2009-10-24 14:53:01 +02:00
|
|
|
if c.sticky then return true end
|
2016-04-05 09:02:00 +02:00
|
|
|
local tags = screen.tags
|
2016-02-07 15:12:22 +01:00
|
|
|
for _, t in ipairs(tags) do
|
2009-03-14 13:47:50 +01:00
|
|
|
if t.selected then
|
|
|
|
local ctags = c:tags()
|
|
|
|
for _, v in ipairs(ctags) do
|
|
|
|
if v == t then
|
2009-10-24 14:53:01 +02:00
|
|
|
return true
|
2009-03-14 13:47:50 +01:00
|
|
|
end
|
|
|
|
end
|
2009-02-27 17:22:03 +01:00
|
|
|
end
|
|
|
|
end
|
2009-10-24 14:53:01 +02:00
|
|
|
return false
|
2009-02-27 17:22:03 +01:00
|
|
|
end
|
|
|
|
|
2010-10-17 15:35:50 +02:00
|
|
|
--- Filtering function to include only the minimized clients from currently selected tags.
|
2021-11-13 09:21:21 +01:00
|
|
|
--
|
|
|
|
--@DOC_sequences_client_tasklist_filter_minimizedcurrenttags1_EXAMPLE@
|
|
|
|
--
|
|
|
|
-- @tparam client c The client.
|
|
|
|
-- @tparam screen screen The screen we are drawing on.
|
2010-10-17 15:35:50 +02:00
|
|
|
-- @return true if c is in a selected tag on screen and is minimized, false otherwise
|
2021-03-22 23:28:53 +01:00
|
|
|
-- @filterfunction awful.widget.tasklist.filter.minimizedcurrenttags
|
2012-06-14 01:08:27 +02:00
|
|
|
function tasklist.filter.minimizedcurrenttags(c, screen)
|
2016-02-26 19:19:58 +01:00
|
|
|
screen = get_screen(screen)
|
2010-10-17 15:35:50 +02:00
|
|
|
-- Only print client on the same screen as this widget
|
2016-02-26 19:19:58 +01:00
|
|
|
if get_screen(c.screen) ~= screen then return false end
|
2010-10-17 15:35:50 +02:00
|
|
|
-- Check client is minimized
|
|
|
|
if not c.minimized then return false end
|
2012-12-13 03:30:37 +01:00
|
|
|
-- Include sticky client
|
|
|
|
if c.sticky then return true end
|
2016-04-05 09:02:00 +02:00
|
|
|
local tags = screen.tags
|
2016-02-07 15:12:22 +01:00
|
|
|
for _, t in ipairs(tags) do
|
2010-10-17 15:35:50 +02:00
|
|
|
-- Select only minimized clients
|
|
|
|
if t.selected then
|
|
|
|
local ctags = c:tags()
|
|
|
|
for _, v in ipairs(ctags) do
|
|
|
|
if v == t then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
2009-10-24 14:53:01 +02:00
|
|
|
--- Filtering function to include only the currently focused client.
|
2021-11-13 09:21:21 +01:00
|
|
|
--
|
|
|
|
--@DOC_sequences_client_tasklist_filter_focused1_EXAMPLE@
|
|
|
|
--
|
|
|
|
-- @tparam client c The client.
|
|
|
|
-- @tparam screen screen The screen we are drawing on.
|
2009-10-24 14:53:01 +02:00
|
|
|
-- @return true if c is focused on screen, false otherwise
|
2021-03-22 23:28:53 +01:00
|
|
|
-- @filterfunction awful.widget.tasklist.filter.focused
|
2012-06-14 01:08:27 +02:00
|
|
|
function tasklist.filter.focused(c, screen)
|
2009-08-27 11:21:32 +02:00
|
|
|
-- Only print client on the same screen as this widget
|
2019-11-11 00:39:26 +01:00
|
|
|
return get_screen(c.screen) == get_screen(screen) and c.active
|
2009-08-27 11:21:32 +02:00
|
|
|
end
|
|
|
|
|
2018-08-18 22:30:15 +02:00
|
|
|
--- Get all the clients in an undefined order.
|
|
|
|
--
|
|
|
|
-- This is the default source.
|
|
|
|
--
|
2021-03-22 23:28:53 +01:00
|
|
|
-- @sourcefunction awful.widget.tasklist.source.all_clients
|
2018-08-18 22:30:15 +02:00
|
|
|
function tasklist.source.all_clients()
|
|
|
|
return capi.client.get()
|
|
|
|
end
|
|
|
|
|
2012-06-14 01:08:27 +02:00
|
|
|
function tasklist.mt:__call(...)
|
|
|
|
return tasklist.new(...)
|
|
|
|
end
|
|
|
|
|
2019-12-22 06:53:57 +01:00
|
|
|
--@DOC_object_COMMON@
|
|
|
|
|
2012-06-14 01:08:27 +02:00
|
|
|
return setmetatable(tasklist, tasklist.mt)
|
2009-05-08 11:59:38 +02:00
|
|
|
|
2011-09-11 16:50:01 +02:00
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|