From a8d2fa0297bd88770e6ecdf88d537a3fdb781532 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sat, 16 Oct 2021 21:58:25 -0700 Subject: [PATCH] doc: Add a large number of `client` examples. Backfill some under-documented APIs with yet more shiny images. --- lib/awful/client.lua | 67 +++++++++- lib/awful/client/urgent.lua | 8 +- lib/awful/permissions/init.lua | 7 +- objects/client.c | 69 +++++++++- tests/examples/awful/client/opacity1.lua | 96 ++++++++++++++ tests/examples/awful/client/shape1.lua | 100 ++++++++++++++ .../examples/awful/client/skip_tasklist1.lua | 97 ++++++++++++++ tests/examples/awful/client/urgent1.lua | 125 ++++++++++++++++++ tests/examples/sequences/client/activate1.lua | 64 +++++++++ .../sequences/client/activate1.output.txt | 1 + tests/examples/sequences/client/floating1.lua | 34 +++++ tests/examples/sequences/client/geometry1.lua | 52 ++++++++ .../sequences/client/geometry1.output.txt | 1 + tests/examples/sequences/client/height1.lua | 29 ++++ tests/examples/sequences/client/jump_to1.lua | 45 +++++++ tests/examples/sequences/client/kill1.lua | 50 +++++++ tests/examples/sequences/client/minimize1.lua | 43 ++++++ .../sequences/client/move_to_screen1.lua | 54 ++++++++ .../sequences/client/move_to_tag1.lua | 33 +++++ .../sequences/client/relative_move1.lua | 61 +++++++++ .../client/relative_move1.output.txt | 2 + tests/examples/sequences/client/tags1.lua | 42 ++++++ .../sequences/client/tags1.output.txt | 2 + .../sequences/client/to_selected_tags1.lua | 40 ++++++ .../examples/sequences/client/toggle_tag1.lua | 33 +++++ tests/examples/sequences/client/width1.lua | 29 ++++ tests/examples/sequences/client/x1.lua | 29 ++++ tests/examples/sequences/client/y1.lua | 29 ++++ tests/examples/sequences/template.lua | 15 ++- 29 files changed, 1239 insertions(+), 18 deletions(-) create mode 100644 tests/examples/awful/client/opacity1.lua create mode 100644 tests/examples/awful/client/shape1.lua create mode 100644 tests/examples/awful/client/skip_tasklist1.lua create mode 100644 tests/examples/awful/client/urgent1.lua create mode 100644 tests/examples/sequences/client/activate1.lua create mode 100644 tests/examples/sequences/client/activate1.output.txt create mode 100644 tests/examples/sequences/client/floating1.lua create mode 100644 tests/examples/sequences/client/geometry1.lua create mode 100644 tests/examples/sequences/client/geometry1.output.txt create mode 100644 tests/examples/sequences/client/height1.lua create mode 100644 tests/examples/sequences/client/jump_to1.lua create mode 100644 tests/examples/sequences/client/kill1.lua create mode 100644 tests/examples/sequences/client/minimize1.lua create mode 100644 tests/examples/sequences/client/move_to_screen1.lua create mode 100644 tests/examples/sequences/client/move_to_tag1.lua create mode 100644 tests/examples/sequences/client/relative_move1.lua create mode 100644 tests/examples/sequences/client/relative_move1.output.txt create mode 100644 tests/examples/sequences/client/tags1.lua create mode 100644 tests/examples/sequences/client/tags1.output.txt create mode 100644 tests/examples/sequences/client/to_selected_tags1.lua create mode 100644 tests/examples/sequences/client/toggle_tag1.lua create mode 100644 tests/examples/sequences/client/width1.lua create mode 100644 tests/examples/sequences/client/x1.lua create mode 100644 tests/examples/sequences/client/y1.lua diff --git a/lib/awful/client.lua b/lib/awful/client.lua index 44b2107a5..6b66d8ed7 100644 --- a/lib/awful/client.lua +++ b/lib/awful/client.lua @@ -168,8 +168,11 @@ function client.jumpto(c, merge) end --- Jump to the given client. +-- -- Takes care of focussing the screen, the right tag, etc. -- +-- @DOC_sequences_client_jump_to1_EXAMPLE@ +-- -- @method jump_to -- @tparam bool|function merge If true then merge tags (select the client's -- first tag additionally) when the client is not visible. @@ -502,6 +505,9 @@ function client.moveresize(x, y, w, h, c) end --- Move/resize a client relative to current coordinates. +-- +-- @DOC_sequences_client_relative_move1_EXAMPLE@ +-- -- @method relative_move -- @see geometry -- @tparam[opt=c.x] number x The relative x coordinate. @@ -510,10 +516,10 @@ end -- @tparam[opt=c.height] number h The relative height. function client.object.relative_move(self, x, y, w, h) local geometry = self:geometry() - geometry['x'] = geometry['x'] + x - geometry['y'] = geometry['y'] + y - geometry['width'] = geometry['width'] + w - geometry['height'] = geometry['height'] + h + geometry['x'] = geometry['x'] + (x or geometry.x) + geometry['y'] = geometry['y'] + (y or geometry.y) + geometry['width'] = geometry['width'] + (w or geometry.width) + geometry['height'] = geometry['height'] + (h or geometry.height) self:geometry(geometry) end @@ -529,6 +535,8 @@ end --- Move a client to a tag. -- +-- @DOC_sequences_client_move_to_tag1_EXAMPLE@ +-- -- @method move_to_tag -- @tparam tag target The tag to move the client to. -- @request client activate client.movetotag granted When a client could be @@ -560,6 +568,8 @@ end --- Toggle a tag on a client. -- +-- @DOC_sequences_client_toggle_tag1_EXAMPLE@ +-- -- @method toggle_tag -- @tparam tag target The tag to move the client to. -- @see tags @@ -597,6 +607,9 @@ function client.movetoscreen(c, s) end --- Move a client to a screen. Default is next screen, cycling. +-- +-- @DOC_sequences_client_move_to_screen1_EXAMPLE@ +-- -- @method move_to_screen -- @tparam[opt=c.screen.index+1] screen s The screen, default to current + 1. -- @see screen @@ -647,6 +660,8 @@ end -- tags at the point of calling this method, it will fall back to the screen's -- full set of tags. -- +-- @DOC_sequences_client_to_selected_tags1_EXAMPLE@ +-- -- @method to_selected_tags -- @see screen.selected_tags function client.object.to_selected_tags(self) @@ -895,6 +910,8 @@ end -- did not set them manually. For example, windows with a type different than -- normal. -- +-- @DOC_sequences_client_floating1_EXAMPLE@ +-- -- @property floating -- @tparam boolean floating The floating state. -- @request client border floating granted When a border update is required @@ -976,6 +993,12 @@ end --- The x coordinates. -- +-- `x` (usually) originate from the top left. `x` does *not* include +-- the outer client border, but rather where the content and/or titlebar +-- starts. +-- +-- @DOC_sequences_client_x1_EXAMPLE@ +-- -- @property x -- @tparam integer x -- @emits property::geometry @@ -983,9 +1006,17 @@ end -- geometry (with `x`, `y`, `width`, `height`). -- @emits property::x -- @emits property::position +-- @see geometry +-- @see relative_move --- The y coordinates. -- +-- `y` (usually) originate from the top left. `y` does *not* include +-- the outer client border, but rather where the content and/or titlebar +-- starts. +-- +-- @DOC_sequences_client_y1_EXAMPLE@ +-- -- @property y -- @tparam integer y -- @emits property::geometry @@ -993,9 +1024,13 @@ end -- geometry (with `x`, `y`, `width`, `height`). -- @emits property::y -- @emits property::position +-- @see geometry +-- @see relative_move --- The width of the client. -- +-- @DOC_sequences_client_width1_EXAMPLE@ +-- -- @property width -- @tparam integer width -- @emits property::geometry @@ -1003,9 +1038,13 @@ end -- geometry (with `x`, `y`, `width`, `height`). -- @emits property::width -- @emits property::size +-- @see geometry +-- @see relative_move --- The height of the client. -- +-- @DOC_sequences_client_height1_EXAMPLE@ +-- -- @property height -- @tparam integer height -- @emits property::geometry @@ -1013,6 +1052,8 @@ end -- geometry (with `x`, `y`, `width`, `height`). -- @emits property::height -- @emits property::size +-- @see geometry +-- @see relative_move -- Add the geometry helpers to match the wibox API for _, v in ipairs {"x", "y", "width", "height"} do @@ -1239,6 +1280,7 @@ end -- @property dockable -- @tparam boolean dockable The dockable state -- @propemits false false +-- @see struts function client.object.get_dockable(c) local value = client.property.get(c, "dockable") @@ -1271,7 +1313,7 @@ end --- If the client requests not to be decorated with a titlebar. -- -- The motif wm hints allow a client to request not to be decorated by the WM in --- various ways. This property uses the motif MWM_DECOR_TITLE hint and +-- various ways. This property uses the motif `MWM_DECOR_TITLE` hint and -- interprets it as the client (not) wanting a titlebar. -- -- @property requests_no_titlebar @@ -1513,6 +1555,8 @@ end, true, true, "keybinding") --- Set the client shape. -- +-- @DOC_awful_client_shape1_EXAMPLE@ +-- -- @property shape -- @tparam gears.shape A gears.shape compatible function. -- @propemits true false @@ -1556,10 +1600,13 @@ end -- isn't already within its geometry, -- * **toggle_minimization**: If the client is already active, minimize it. -- +-- @DOC_sequences_client_activate1_EXAMPLE@ +-- -- @method activate -- @tparam table args -- @tparam[opt=other] string args.context Why was this activate called? --- @tparam[opt=true] boolean args.raise Raise the client to the top of its layer. +-- @tparam[opt=true] boolean args.raise Raise the client to the top of its layer +-- and unminimize it (if needed). -- @tparam[opt=false] boolean args.force Force the activation even for unfocusable -- clients. -- @tparam[opt=false] boolean args.switch_to_tags @@ -1567,6 +1614,7 @@ end -- @tparam[opt=false] boolean args.action Once activated, perform an action. -- @tparam[opt=false] boolean args.toggle_minimization -- @see awful.permissions.add_activate_filter +-- @see awful.permissions.activate -- @see request::activate -- @see active function client.object.activate(c, args) @@ -1735,6 +1783,13 @@ end) -- @classsignal -- @see awful.permissions.update_border +--- Jump to the client that received the urgent hint first. +-- +-- @staticfct awful.client.urgent.jumpto +-- @tparam bool|function merge If true then merge tags (select the client's +-- first tag additionally) when the client is not visible. +-- If it is a function, it will be called with the client as argument. + -- Add clients during startup to focus history. -- This used to happen through permissions.activate, but that only handles visible -- clients now. diff --git a/lib/awful/client/urgent.lua b/lib/awful/client/urgent.lua index 82535f623..16c429dd9 100644 --- a/lib/awful/client/urgent.lua +++ b/lib/awful/client/urgent.lua @@ -28,7 +28,7 @@ local data = setmetatable({}, { __mode = 'k' }) -- Get the first client that got the urgent hint. -- --- @function awful.urgent.get +-- @function awful.client.urgent.get -- @treturn client.object The first urgent client. function urgent.get() if #data > 0 then @@ -46,7 +46,7 @@ end --- Jump to the client that received the urgent hint first. -- --- @function awful.urgent.jumpto +-- @function awful.client.urgent.jumpto -- @tparam bool|function merge If true then merge tags (select the client's -- first tag additionally) when the client is not visible. -- If it is a function, it will be called with the client as argument. @@ -59,7 +59,7 @@ end -- Adds client to urgent stack. -- --- @function awful.urgent.add +-- @function awful.client.urgent.add -- @tparam client c The client object. -- @param prop The property which is updated. -- @request client border active granted When a client becomes active and is no @@ -90,7 +90,7 @@ end -- Remove client from urgent stack. -- --- @function awful.urgent.delete +-- @function awful.client.urgent.delete -- @tparam client c The client object. function urgent.delete(c) for k, cl in ipairs(data) do diff --git a/lib/awful/permissions/init.lua b/lib/awful/permissions/init.lua index d63f603d9..909544293 100644 --- a/lib/awful/permissions/init.lua +++ b/lib/awful/permissions/init.lua @@ -133,7 +133,9 @@ end --- Activate a window. -- --- This sets the focus only if the client is visible. +-- This sets the focus only if the client is visible. If `raise` is set +-- in the hints, it will also unminimize the client and move it to the top +-- of its layer. -- -- It is the default signal handler for `request::activate` on a `client`. -- @@ -141,7 +143,8 @@ end -- @tparam client c A client to use -- @tparam string context The context where this signal was used. -- @tparam[opt] table hints A table with additional hints: --- @tparam[opt=false] boolean hints.raise should the client be raised? +-- @tparam[opt=false] boolean hints.raise should the client be unminimized +-- and raised? -- @tparam[opt=false] boolean hints.switch_to_tag should the client's first tag -- be selected if none of the client's tags are selected? -- @tparam[opt=false] boolean hints.switch_to_tags Select all tags associated diff --git a/objects/client.c b/objects/client.c index 19ad5f3f5..f8b78e5f5 100644 --- a/objects/client.c +++ b/objects/client.c @@ -475,10 +475,14 @@ lua_class_t client_class; * `_NET_WM_STATE_SKIP_TASKBAR` X11 protocol xproperty. Clients can modify this * state through this property. * + * @DOC_awful_client_skip_tasklist1_EXAMPLE@ + * * @property skip_taskbar * @tparam[opt=false] boolean skip_taskbar * @propemits false false * @see sticky + * @see hidden + * @see unmanage */ /** @@ -697,16 +701,28 @@ lua_class_t client_class; * @tparam boolean hidden * @propemits false false * @see minimized + * @see skip_taskbar + * @see unmanage */ /** * Define it the client must be iconify, i.e. only visible in * taskbar. * + * Minimized clients are still part of tags and screens, but + * they are not displayed. You can unminimize using `c.minimized = false`, + * but if you also want to set the focus, it is better to use: + * + * c:activate { context = "unminimized", raise = true } + * + * @DOC_sequences_client_minimize1_EXAMPLE@ + * * @property minimized * @tparam boolean minimized * @propemits false false * @see hidden + * @see isvisible + * @see activate */ /** @@ -819,12 +835,34 @@ lua_class_t client_class; */ /** - * The client urgent state. + * Set to `true` when the client ask for attention. + * + * The urgent state is the visual equivalent of the "bell" noise from + * old computer. It is set by the client when their state changed and + * they need attention. For example, a chat client will set it when + * a new message arrive. Some terminals, like `rxvt-unicode`, will also + * set it when calling the `bell` command. + * + * There is many ways an urgent client can become for visible: + * + * * Highlight in the `awful.widget.taglist` and `awful.widget.tasklist` + * * Highlight in the `awful.titlebar` + * * Highlight of the client border color (or width). + * * Accessible using `Mod4+u` in the default config. + * * Emit the `property::urgent` signal. + * + * @DOC_awful_client_urgent1_EXAMPLE@ * * @property urgent * @tparam boolean urgent * @propemits false false + * @request client border active granted When a client becomes active and is no + * longer urgent. + * @request client border inactive granted When a client stop being active and + * is no longer urgent. + * @request client border urgent granted When a client stop becomes urgent. * @see request::border + * @see awful.client.urgent.jumpto * @usebeautiful beautiful.border_color_urgent The fallback color when the * client is urgent. * @usebeautiful beautiful.border_color_floating_urgent The color when the @@ -841,6 +879,11 @@ lua_class_t client_class; * the client is maximized and urgent. * @usebeautiful beautiful.border_width_fullscreen_urgent The border width when * the client is fullscreen and urgent. + * @usebeautiful beautiful.titlebar_fg_urgent + * @usebeautiful beautiful.titlebar_bg_urgent + * @usebeautiful beautiful.titlebar_bgimage_urgent + * @usebeautiful beautiful.fg_urgent + * @usebeautiful beautiful.bg_urgent */ /** @@ -875,10 +918,17 @@ lua_class_t client_class; /** * The client opacity. * + * The opacity only works when a compositing manager, such as + * [picom](https://github.com/yshui/picom/), is used. Otherwise, + * the clients will remain opaque. + * + * @DOC_awful_client_opacity1_EXAMPLE@ + * * @property opacity * @tparam number opacity Between 0 (transparent) to 1 (opaque). * @propemits false false * @see request::border + * @see awesome.composite_manager_running */ /** @@ -1365,6 +1415,7 @@ lua_class_t client_class; * @method struts * @see geometry * @see screen.workarea + * @see dockable */ /** Get or set mouse buttons bindings for a client. @@ -1373,6 +1424,9 @@ lua_class_t client_class; * @tparam table buttons * @propemits false false * @see awful.button + * @see append_mousebinding + * @see remove_mousebinding + * @see request::default_mousebindings */ /** Get the number of instances. @@ -2922,7 +2976,7 @@ client_kill(client_t *c) /** Get all clients into a table. * - * @tparam[opt] integer screen A screen number to filter clients on. + * @tparam[opt] integer|screen screen A screen number to filter clients on. * @tparam[opt] boolean stacked Return clients in stacking order? (ordered from * top to bottom). * @treturn table A table with clients. @@ -3082,7 +3136,9 @@ out: * * This method can be used to close (kill) a **client** using the * X11 protocol. To use the POSIX way to kill a **process**, use - * `awesome.kill`. + * `awesome.kill` (using the client `pid` property). + * + * @DOC_sequences_client_kill1_EXAMPLE@ * * @method kill * @see awesome.kill @@ -3154,6 +3210,8 @@ luaA_client_swap(lua_State *L) * * Use the `first_tag` field to access the first tag of a client directly. * + * @DOC_sequences_client_tags1_EXAMPLE@ + * * @tparam table tags_table A table with tags to set, or `nil` to get the * current tags. * @treturn table A table with all tags. @@ -3514,6 +3572,8 @@ HANDLE_TITLEBAR(bottom, CLIENT_TITLEBAR_BOTTOM) HANDLE_TITLEBAR(left, CLIENT_TITLEBAR_LEFT) /** Return or set client geometry. + * + * @DOC_sequences_client_geometry1_EXAMPLE@ * * @tparam table|nil geo A table with new coordinates, or nil. * @tparam integer geo.x The horizontal position. @@ -4190,6 +4250,9 @@ luaA_client_set_shape_input(lua_State *L, client_t *c) * @tparam table keys * @propemits false false * @see awful.key + * @see append_keybinding + * @see remove_keybinding + * @see request::default_keybindings */ static int luaA_client_keys(lua_State *L) diff --git a/tests/examples/awful/client/opacity1.lua b/tests/examples/awful/client/opacity1.lua new file mode 100644 index 000000000..3ecdcb72d --- /dev/null +++ b/tests/examples/awful/client/opacity1.lua @@ -0,0 +1,96 @@ +--DOC_NO_USAGE --DOC_GEN_IMAGE --DOC_ASTERISK --DOC_HIDE_START +local awful = require("awful") +local wibox = require("wibox") +local beautiful = require("beautiful") + +screen[1]._resize {width = 480, height = 200} + +local wb = awful.wibar { position = "top" } + +-- Create the same number of tags as the default config +awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, screen[1], awful.layout.layouts[1]) + +-- Only bother with widgets that are visible by default +local mykeyboardlayout = awful.widget.keyboardlayout() +local mytextclock = wibox.widget.textclock() +local mytaglist = awful.widget.taglist(screen[1], awful.widget.taglist.filter.all, {}) +local mytasklist = awful.widget.tasklist(screen[1], awful.widget.tasklist.filter.currenttags, {}) + +client.connect_signal("request::titlebars", function(c) + local top_titlebar = awful.titlebar(c, { + height = 20, + bg_normal = beautiful.bg_normal, + }) + + top_titlebar : setup { + { -- Left + awful.titlebar.widget.iconwidget(c), + layout = wibox.layout.fixed.horizontal + }, + { -- Middle + { -- Title + align = "center", + widget = awful.titlebar.widget.titlewidget(c) + }, + layout = wibox.layout.flex.horizontal + }, + { -- Right + awful.titlebar.widget.floatingbutton (c), + awful.titlebar.widget.maximizedbutton(c), + awful.titlebar.widget.stickybutton (c), + awful.titlebar.widget.ontopbutton (c), + awful.titlebar.widget.closebutton (c), + layout = wibox.layout.fixed.horizontal() + }, + layout = wibox.layout.align.horizontal + } +end) + + +wb:setup { + layout = wibox.layout.align.horizontal, + { + mytaglist, + layout = wibox.layout.fixed.horizontal, + }, + mytasklist, + { + layout = wibox.layout.fixed.horizontal, + mykeyboardlayout, + mytextclock, + }, +} + +require("gears.timer").run_delayed_calls_now() +local counter = 0 + +local function gen_client(label) + local c = client.gen_fake {hide_first=true} + + c:geometry { + x = 45 + counter*1.75, + y = 30 + counter, + height = 60, + width = 230, + } + c._old_geo = {c:geometry()} + c:set_label(label) + c:emit_signal("request::titlebars") + c.border_color = beautiful.bg_highlight + c.border_width = 2 + counter = counter + 40 + + return c +end + + local c1 = gen_client("Opacity: 1") + local c2 = gen_client("Opacity: 0.5") + local c3 = gen_client("Opacity: 0.1") +--DOC_HIDE_END + + c1.opacity = 1 + c2.opacity = 0.5 + c3.opacity = 0.1 + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 + diff --git a/tests/examples/awful/client/shape1.lua b/tests/examples/awful/client/shape1.lua new file mode 100644 index 000000000..c8bf2e37d --- /dev/null +++ b/tests/examples/awful/client/shape1.lua @@ -0,0 +1,100 @@ +--DOC_NO_USAGE --DOC_GEN_IMAGE --DOC_HIDE_START +local awful = require("awful") +local wibox = require("wibox") +local beautiful = require("beautiful") +local gears = { shape = require("gears.shape") } + +screen[1]._resize {width = 480, height = 200} + +awful.client.object.set_shape = nil +awful.client.object.get_shape = nil + +local wb = awful.wibar { position = "top" } + +-- Create the same number of tags as the default config +awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, screen[1], awful.layout.layouts[1]) + +-- Only bother with widgets that are visible by default +local mykeyboardlayout = awful.widget.keyboardlayout() +local mytextclock = wibox.widget.textclock() +local mytaglist = awful.widget.taglist(screen[1], awful.widget.taglist.filter.all, {}) +local mytasklist = awful.widget.tasklist(screen[1], awful.widget.tasklist.filter.currenttags, {}) + +client.connect_signal("request::titlebars", function(c) + local top_titlebar = awful.titlebar(c, { + height = 20, + bg_normal = beautiful.bg_normal, + }) + + top_titlebar : setup { + { -- Left + awful.titlebar.widget.iconwidget(c), + layout = wibox.layout.fixed.horizontal + }, + { -- Middle + { -- Title + align = "center", + widget = awful.titlebar.widget.titlewidget(c) + }, + layout = wibox.layout.flex.horizontal + }, + { -- Right + awful.titlebar.widget.floatingbutton (c), + awful.titlebar.widget.maximizedbutton(c), + awful.titlebar.widget.stickybutton (c), + awful.titlebar.widget.ontopbutton (c), + awful.titlebar.widget.closebutton (c), + layout = wibox.layout.fixed.horizontal() + }, + layout = wibox.layout.align.horizontal + } +end) + + +wb:setup { + layout = wibox.layout.align.horizontal, + { + mytaglist, + layout = wibox.layout.fixed.horizontal, + }, + mytasklist, + { + layout = wibox.layout.fixed.horizontal, + mykeyboardlayout, + mytextclock, + }, +} + +require("gears.timer").run_delayed_calls_now() +local counter = 0 + +local function gen_client(label) + local c = client.gen_fake {hide_first=true} + + c:geometry { + x = 45 + counter*1.75, + y = 30 + counter, + height = 60, + width = 230, + } + c._old_geo = {c:geometry()} + c.border_width = 2 + c:set_label(label) + c:emit_signal("request::titlebars") + c.border_color = beautiful.bg_highlight + counter = counter + 40 + + return c +end + + local c1 = gen_client("Rectangle (default)") + local c2 = gen_client("Rounded rect") + local c3 = gen_client("Octogon") + +--DOC_HIDE_END + c1.shape = gears.shape.rectangle + c2.shape = gears.shape.rounded_rect + c3.shape = gears.shape.octogon + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 + diff --git a/tests/examples/awful/client/skip_tasklist1.lua b/tests/examples/awful/client/skip_tasklist1.lua new file mode 100644 index 000000000..1b0911bd5 --- /dev/null +++ b/tests/examples/awful/client/skip_tasklist1.lua @@ -0,0 +1,97 @@ +--DOC_NO_USAGE --DOC_GEN_IMAGE --DOC_ASTERISK --DOC_HIDE_START +local awful = require("awful") +local wibox = require("wibox") +local beautiful = require("beautiful") + +screen[1]._resize {width = 480, height = 200} + +local wb = awful.wibar { position = "top" } + +-- Create the same number of tags as the default config +awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, screen[1], awful.layout.layouts[1]) + +-- Only bother with widgets that are visible by default +local mykeyboardlayout = awful.widget.keyboardlayout() +local mytextclock = wibox.widget.textclock() +local mytaglist = awful.widget.taglist(screen[1], awful.widget.taglist.filter.all, {}) +local mytasklist = awful.widget.tasklist(screen[1], awful.widget.tasklist.filter.currenttags, {}) + +client.connect_signal("request::titlebars", function(c) + local top_titlebar = awful.titlebar(c, { + height = 20, + bg_normal = beautiful.bg_normal, + }) + + top_titlebar : setup { + { -- Left + awful.titlebar.widget.iconwidget(c), + layout = wibox.layout.fixed.horizontal + }, + { -- Middle + { -- Title + align = "center", + widget = awful.titlebar.widget.titlewidget(c) + }, + layout = wibox.layout.flex.horizontal + }, + { -- Right + awful.titlebar.widget.floatingbutton (c), + awful.titlebar.widget.maximizedbutton(c), + awful.titlebar.widget.stickybutton (c), + awful.titlebar.widget.ontopbutton (c), + awful.titlebar.widget.closebutton (c), + layout = wibox.layout.fixed.horizontal() + }, + layout = wibox.layout.align.horizontal + } +end) + + +wb:setup { + layout = wibox.layout.align.horizontal, + { + mytaglist, + layout = wibox.layout.fixed.horizontal, + }, + mytasklist, + { + layout = wibox.layout.fixed.horizontal, + mykeyboardlayout, + mytextclock, + }, +} + +require("gears.timer").run_delayed_calls_now() +local counter = 0 + +local function gen_client(label) + local c = client.gen_fake {hide_first=true} + + c:geometry { + x = 45 + counter*1.75, + y = 30 + counter, + height = 60, + width = 230, + } + c._old_geo = {c:geometry()} + c:set_label(label) + c:emit_signal("request::titlebars") + c.border_color = beautiful.bg_highlight + c.name = label + counter = counter + 40 + + return c +end + + local c1 = gen_client("Client 1 (in tasktar)") + local c2 = gen_client("Client 2 (NOT in taskbar)") + local c3 = gen_client("Client 3 (in taskbar)") + +--DOC_HIDE_END + + c1.skip_taskbar = false + c2.skip_taskbar = true + c3.skip_taskbar = false + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 + diff --git a/tests/examples/awful/client/urgent1.lua b/tests/examples/awful/client/urgent1.lua new file mode 100644 index 000000000..6527fb1ba --- /dev/null +++ b/tests/examples/awful/client/urgent1.lua @@ -0,0 +1,125 @@ +--DOC_NO_USAGE --DOC_GEN_IMAGE --DOC_ASTERISK --DOC_HIDE_START +local awful = require("awful") +local wibox = require("wibox") +local beautiful = require("beautiful") + +screen[1]._resize {width = 480, height = 200} + +local wb = awful.wibar { position = "top" } + +-- Create the same number of tags as the default config +awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, screen[1], awful.layout.layouts[1]) + +-- Only bother with widgets that are visible by default +local mykeyboardlayout = awful.widget.keyboardlayout() +local mytextclock = wibox.widget.textclock() +local mytaglist = awful.widget.taglist(screen[1], awful.widget.taglist.filter.all, {}) +local mytasklist = awful.widget.tasklist(screen[1], awful.widget.tasklist.filter.currenttags, {}) + +client.connect_signal("request::titlebars", function(c) + local top_titlebar = awful.titlebar(c, { + height = 20, + bg_normal = beautiful.bg_normal, + }) + + top_titlebar : setup { + { -- Left + awful.titlebar.widget.iconwidget(c), + layout = wibox.layout.fixed.horizontal + }, + { -- Middle + { -- Title + align = "center", + widget = awful.titlebar.widget.titlewidget(c) + }, + layout = wibox.layout.flex.horizontal + }, + { -- Right + awful.titlebar.widget.floatingbutton (c), + awful.titlebar.widget.maximizedbutton(c), + awful.titlebar.widget.stickybutton (c), + awful.titlebar.widget.ontopbutton (c), + awful.titlebar.widget.closebutton (c), + layout = wibox.layout.fixed.horizontal() + }, + layout = wibox.layout.align.horizontal + } +end) + + +wb:setup { + layout = wibox.layout.align.horizontal, + { + mytaglist, + layout = wibox.layout.fixed.horizontal, + }, + mytasklist, + { + layout = wibox.layout.fixed.horizontal, + mykeyboardlayout, + mytextclock, + }, +} + +require("gears.timer").run_delayed_calls_now() +local counter = 0 + +local function gen_client(label) + local c = client.gen_fake {hide_first=true} + + c:geometry { + x = 45 + counter*1.75, + y = 30 + counter, + height = 60, + width = 230, + } + c._old_geo = {c:geometry()} + c:set_label(label) + counter = counter + 40 + c.class = label + + return c +end + + local c1 = gen_client("Inactive") + local c2 = gen_client("Urgent") + local c3 = gen_client("Focus") + local c4 = gen_client("Tag") + + c4:tags{screen[1].tags[2]} +--DOC_HIDE_END + + -- Affects mostly the taglist and tasklist.. + beautiful.fg_urgent = "#ffffff" + beautiful.bg_urgent = "#ff0000" + + --DOC_NEWLINE + + -- Set the client border to be orange and large. + beautiful.border_color_urgent = "#ffaa00" + beautiful.border_width_urgent = 6 + + --DOC_NEWLINE + + -- Set the titlebar green. + beautiful.titlebar_bg_urgent = "#00ff00" + beautiful.titlebar_fg_urgent = "#000000" + + --DOC_NEWLINE + + -- This client is in the current tag. + c2.urgent = true + + --DOC_NEWLINE + + -- This client is in a deselected tag. + c4.urgent = true + +--DOC_HIDE_START + c1:emit_signal("request::titlebars") + c2:emit_signal("request::titlebars") + c3:emit_signal("request::titlebars") + +return {honor_titlebar_colors = true} +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 + diff --git a/tests/examples/sequences/client/activate1.lua b/tests/examples/sequences/client/activate1.lua new file mode 100644 index 000000000..0bc879d60 --- /dev/null +++ b/tests/examples/sequences/client/activate1.lua @@ -0,0 +1,64 @@ + --DOC_GEN_IMAGE --DOC_NO_USAGE --DOC_GEN_OUTPUT --DOC_HIDE_START +local module = ... +local awful = {tag = require("awful.tag"), layout = require("awful.layout")} +local beautiful = require("beautiful") +require("awful.ewmh") +screen[1]._resize {x = 0, width = 160, height = 90} +awful.tag({ "one", "two", "three" }, screen[1], awful.layout.suit.tile) + +function awful.spawn(name, properties) + client.gen_fake{class = name, name = name, x = 10, y=10, width = 60, height =50, tags = properties.tags} +end + +local function color_focus() + for _, c in ipairs(client.get()) do + c.color = c.active and "#ff777733" or beautiful.bg_normal + end +end + +module.add_event("Spawn some apps", function() + for tag_idx = 1, 3 do + for i = 1, 3 do + awful.spawn("c"..((tag_idx-1)*3+i), {tags = {screen[1].tags[tag_idx]}}) + end + end + + client.get()[2]:activate{} + + color_focus() +end) + +--DOC_NEWLINE +module.display_tags() + +module.add_event('Activate "c8"', function() + -- Mitigate a bug in the shims. + client.get()[8]:activate { + switch_to_tag = true, + raise = true, + context = "somet_reason", + } + + --DOC_HIDE_END + + client.get()[8]:activate { + switch_to_tag = true, + raise = true, + context = "somet_reason", + } + + --DOC_NEWLINE + + -- Since this isnt denied by any permission, it will be true. + print( + "Confirm:", client.get()[8].active, client.focus == client.get()[8] + ) + + --DOC_HIDE_START + color_focus() +end) + +module.display_tags() + +module.execute { display_screen = false, display_clients = true , + display_label = false, display_client_name = true } diff --git a/tests/examples/sequences/client/activate1.output.txt b/tests/examples/sequences/client/activate1.output.txt new file mode 100644 index 000000000..aa52403d6 --- /dev/null +++ b/tests/examples/sequences/client/activate1.output.txt @@ -0,0 +1 @@ +Confirm: true true diff --git a/tests/examples/sequences/client/floating1.lua b/tests/examples/sequences/client/floating1.lua new file mode 100644 index 000000000..3766e668e --- /dev/null +++ b/tests/examples/sequences/client/floating1.lua @@ -0,0 +1,34 @@ + --DOC_GEN_IMAGE --DOC_NO_USAGE +local module = ... --DOC_HIDE +local awful = {tag = require("awful.tag"), layout = require("awful.layout")} --DOC_HIDE +require("awful.ewmh") --DOC_HIDE +screen[1]._resize {x = 0, width = 800, height = 600} --DOC_HIDE +awful.tag({ "one", "two", "three" }, screen[1], awful.layout.suit.tile) --DOC_HIDE + +function awful.spawn(name) --DOC_HIDE + client.gen_fake{class = name, name = name, x = 10, y=10, width = 60, height =50} --DOC_HIDE +end --DOC_HIDE + +module.add_event("Spawn some tiled apps", function() --DOC_HIDE + for i = 1, 5 do + awful.spawn("Client #"..i) + end + + client.get()[1].color = "#f8dcdb" --DOC_HIDE + +end) --DOC_HIDE + +--DOC_NEWLINE +module.display_tags() --DOC_HIDE + +module.add_event("Raise and un-tile", function() --DOC_HIDE + client.get()[1].floating = true + client.get()[1]:geometry {x= 100, y=150, width = 500, height = 300} --DOC_HIDE + client.get()[1]:raise() +end) --DOC_HIDE + + +module.display_tags() --DOC_HIDE + +module.execute { display_screen = true , display_clients = true , --DOC_HIDE + display_label = false, display_client_name = true } --DOC_HIDE diff --git a/tests/examples/sequences/client/geometry1.lua b/tests/examples/sequences/client/geometry1.lua new file mode 100644 index 000000000..fec629b8f --- /dev/null +++ b/tests/examples/sequences/client/geometry1.lua @@ -0,0 +1,52 @@ + --DOC_GEN_IMAGE --DOC_HIDE_START --DOC_ASTERISK --DOC_NO_USAGE --DOC_GEN_OUTPUT +local module = ... +require("ruled.client") +local awful = {tag = require("awful.tag"), layout = require("awful.layout")} +awful.placement = require("awful.placement") +require("awful.ewmh") +screen[1]:fake_resize(0, 0, 800, 480) +awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, screen[1], awful.layout.suit.tile) + +function awful.spawn(name) + client.gen_fake{class = name, name = name, x = 4, y=10, width = 60, height =50, screen=screen[1]} +end + +--DOC_NEWLINE + +module.add_event("Spawn a floating client.", function() + --DOC_HIDE_END + awful.spawn("") + + --DOC_NEWLINE + + client.get()[1].floating = true + + --DOC_NEWLINE + --DOC_HIDE_START +end) + +module.display_tags() + +module.add_event("Move and resize it.", function() + --DOC_HIDE_END + client.get()[1]:geometry { + x = 200, + y = 200, + width = 300, + height = 240 + } + --DOC_NEWLINE + + -- It can also read the geometry. + local geo = client.get()[1]:geometry() + print("Client geometry:", geo.x, geo.y, geo.width, geo.height) + + --DOC_HIDE_START +end) + +module.display_tags() + +module.execute { display_screen = true , display_clients = true, + display_label = false, display_client_name = true, + display_mouse = false, +} diff --git a/tests/examples/sequences/client/geometry1.output.txt b/tests/examples/sequences/client/geometry1.output.txt new file mode 100644 index 000000000..e952aa244 --- /dev/null +++ b/tests/examples/sequences/client/geometry1.output.txt @@ -0,0 +1 @@ +Client geometry: 200 200 300 240 diff --git a/tests/examples/sequences/client/height1.lua b/tests/examples/sequences/client/height1.lua new file mode 100644 index 000000000..ce04cf63a --- /dev/null +++ b/tests/examples/sequences/client/height1.lua @@ -0,0 +1,29 @@ + --DOC_GEN_IMAGE --DOC_NO_USAGE +local module = ... --DOC_HIDE +local awful = {tag = require("awful.tag"), layout = require("awful.layout")} --DOC_HIDE +require("awful.ewmh") --DOC_HIDE +screen[1]._resize {x = 0, width = 160, height = 90} --DOC_HIDE +awful.tag({ "one", "two", "three" }, screen[1], awful.layout.suit.tile) --DOC_HIDE + +function awful.spawn(name) --DOC_HIDE + client.gen_fake{class = name, name = name, x = 10, y=10, width = 60, height =50, floating = true} --DOC_HIDE +end --DOC_HIDE + +module.add_event("Spawn a client", function() --DOC_HIDE + awful.spawn("") --DOC_HIDE + + client.get()[1].color = "#ff777733" --DOC_HIDE + +end) --DOC_HIDE + +--DOC_NEWLINE +module.display_tags() --DOC_HIDE + +module.add_event("Change the `height` property", function() --DOC_HIDE + client.focus.height = 100 +end) --DOC_HIDE + +module.display_tags() --DOC_HIDE + +module.execute { display_screen = false, display_clients = true , --DOC_HIDE + display_label = false, display_client_name = true } --DOC_HIDE diff --git a/tests/examples/sequences/client/jump_to1.lua b/tests/examples/sequences/client/jump_to1.lua new file mode 100644 index 000000000..d69d4e3b0 --- /dev/null +++ b/tests/examples/sequences/client/jump_to1.lua @@ -0,0 +1,45 @@ + --DOC_GEN_IMAGE --DOC_NO_USAGE +local module = ... --DOC_HIDE +local awful = {tag = require("awful.tag"), layout = require("awful.layout")} --DOC_HIDE +local beautiful = require("beautiful") --DOC_HIDE +require("awful.ewmh") --DOC_HIDE +screen[1]._resize {x = 0, width = 160, height = 90} --DOC_HIDE +awful.tag({ "one", "two", "three" }, screen[1], awful.layout.suit.tile) --DOC_HIDE + +function awful.spawn(name, properties) --DOC_HIDE + client.gen_fake{class = name, name = name, x = 10, y=10, width = 60, height =50, tags = properties.tags} --DOC_HIDE +end --DOC_HIDE + +module.add_event("Spawn some apps", function() --DOC_HIDE + for tag_idx = 1, 3 do + for _ = 1, 3 do + awful.spawn("", {tags = {screen[1].tags[tag_idx]}}) + end + end + + client.get()[1].color = "#ff777733" --DOC_HIDE + +end) --DOC_HIDE + +--DOC_NEWLINE +module.display_tags() --DOC_HIDE + +module.add_event("Call `:jump_to()`, which will select tag #2", function() --DOC_HIDE + client.get()[6]:jump_to() + client.get()[1].color = beautiful.bg_normal --DOC_HIDE + client.get()[6].color = "#ff777733" --DOC_HIDE +end) --DOC_HIDE + +module.display_tags() --DOC_HIDE + +module.add_event("Call `:jump_to(true)`, which will select tag #2 and #3", function() --DOC_HIDE + --DOC_NEWLINE + client.get()[7]:jump_to(true) + client.get()[6].color = beautiful.bg_normal --DOC_HIDE + client.get()[7].color = "#ff777733" --DOC_HIDE +end) --DOC_HIDE + +module.display_tags() --DOC_HIDE + +module.execute { display_screen = false, display_clients = true , --DOC_HIDE + display_label = false, display_client_name = true } --DOC_HIDE diff --git a/tests/examples/sequences/client/kill1.lua b/tests/examples/sequences/client/kill1.lua new file mode 100644 index 000000000..84fd84fb6 --- /dev/null +++ b/tests/examples/sequences/client/kill1.lua @@ -0,0 +1,50 @@ + --DOC_GEN_IMAGE --DOC_HIDE_START --DOC_ASTERISK --DOC_NO_USAGE +local module = ... +require("ruled.client") +local awful = {tag = require("awful.tag"), layout = require("awful.layout")} +awful.placement = require("awful.placement") +require("awful.ewmh") +screen[1]:fake_resize(0, 0, 800, 480) +awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, screen[1], awful.layout.suit.tile) + +function awful.spawn(name) + client.gen_fake{class = name, name = name, x = 2094, y=10, width = 60, height =50, screen=screen[1]} +end + +--DOC_NEWLINE + +module.add_event("Spawn 5 clients in a `awful.layout.suit.tile` layout.", function() + --DOC_HIDE_END + -- Spawn a client on screen #3 + for i=1, 5 do + awful.spawn("Client #"..i) + end + + --DOC_NEWLINE + + client.get()[5]:activate {} + client.get()[5].color = "#ff777733" --DOC_HIDE + + --DOC_NEWLINE + --DOC_HIDE_START +end) + +module.display_tags() + +module.add_event("Kill the the 4th and 5th clients.", function() + --DOC_HIDE_END + local c4, c5 = client.get()[4], client.get()[5] + + --DOC_NEWLINE + -- Kill the clients. + c4:kill() + c5:kill() + --DOC_HIDE_START +end) + +module.display_tags() + +module.execute { display_screen = true , display_clients = true, + display_label = false, display_client_name = true, + display_mouse = false, +} diff --git a/tests/examples/sequences/client/minimize1.lua b/tests/examples/sequences/client/minimize1.lua new file mode 100644 index 000000000..ccaccc3b0 --- /dev/null +++ b/tests/examples/sequences/client/minimize1.lua @@ -0,0 +1,43 @@ + --DOC_GEN_IMAGE --DOC_NO_USAGE --DOC_ASTERISK +local module = ... --DOC_HIDE +local awful = {tag = require("awful.tag"), layout = require("awful.layout")} --DOC_HIDE +require("awful.ewmh") --DOC_HIDE +screen[1]._resize {x = 0, width = 800, height = 600} --DOC_HIDE +awful.tag({ "one", "two", "three" }, screen[1], awful.layout.suit.tile) --DOC_HIDE + +function awful.spawn(name) --DOC_HIDE + client.gen_fake{class = name, name = name, x = 10, y=10, width = 60, height =50} --DOC_HIDE +end --DOC_HIDE + +module.add_event("Spawn some apps", function() --DOC_HIDE + for _ = 1, 3 do + awful.spawn("") + end + + client.get()[1].color = "#ff777733" --DOC_HIDE + +end) --DOC_HIDE + +--DOC_NEWLINE +module.display_tags() --DOC_HIDE + +module.add_event("Minimize the focused client", function() --DOC_HIDE + client.get()[1].minimized = true +end) --DOC_HIDE + +--DOC_NEWLINE +module.display_tags() --DOC_HIDE + +module.add_event("Raise and focus", function() --DOC_HIDE + -- That's the best way to unminimize if you also want to set the focus. + client.get()[1]:activate { + context = "unminimize", + raise = true, + } +end) --DOC_HIDE + + +module.display_tags() --DOC_HIDE + +module.execute { display_screen = true , display_clients = true , --DOC_HIDE + display_label = false, display_client_name = true } --DOC_HIDE diff --git a/tests/examples/sequences/client/move_to_screen1.lua b/tests/examples/sequences/client/move_to_screen1.lua new file mode 100644 index 000000000..61f4055c3 --- /dev/null +++ b/tests/examples/sequences/client/move_to_screen1.lua @@ -0,0 +1,54 @@ + --DOC_GEN_IMAGE --DOC_NO_USAGE +local module = ... --DOC_HIDE +require("ruled.client") --DOC_HIDE +local awful = {tag = require("awful.tag"), layout = require("awful.layout")} --DOC_HIDE +awful.placement = require("awful.placement") --DOC_HIDE +require("awful.ewmh") --DOC_HIDE +screen[1]:fake_resize(0, 0, 800, 480) --DOC_HIDE +screen.fake_add(830, 0, 800, 480).outputs = {["eVGA1"] = {mm_height=50, mm_width=80 }} --DOC_HIDE +screen.fake_add(1660, 0, 800, 480).outputs = {["DVI1" ] = {mm_height=50, mm_width=80 }} --DOC_HIDE +awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, screen[1], awful.layout.suit.corner.nw) --DOC_HIDE +awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, screen[2], awful.layout.suit.corner.nw) --DOC_HIDE +awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, screen[3], awful.layout.suit.corner.nw) --DOC_HIDE + +function awful.spawn(name) --DOC_HIDE + client.gen_fake{class = name, name = name, x = 2094, y=10, width = 60, height =50, screen=screen[1]} --DOC_HIDE +end --DOC_HIDE + + +--DOC_NEWLINE + +module.add_event("Spawn a client on screen #3", function() --DOC_HIDE + -- Move the mouse to screen 3 + mouse.coords {x = 100, y = 100 } + assert(mouse.screen == screen[1]) --DOC_HIDE + + --DOC_NEWLINE + + -- Spawn a client on screen #3 + awful.spawn("firefox") + + assert(client.get()[1].screen == screen[1]) --DOC_HIDE +end) --DOC_HIDE + +--DOC_NEWLINE +module.display_tags() --DOC_HIDE + +module.add_event("Move to screen #2", function() --DOC_HIDE + client.get()[1]:move_to_screen(screen[2]) +end) --DOC_HIDE + +--DOC_NEWLINE +module.display_tags() --DOC_HIDE + +module.add_event("Move to next screen", function() --DOC_HIDE + -- This will default to the next screen (by index). + client.get()[1]:move_to_screen() +end) --DOC_HIDE + +module.display_tags() --DOC_HIDE + +module.execute { display_screen = true , display_clients = true, --DOC_HIDE + display_label = false, display_client_name = true, --DOC_HIDE + display_mouse = true , --DOC_HIDE +} --DOC_HIDE diff --git a/tests/examples/sequences/client/move_to_tag1.lua b/tests/examples/sequences/client/move_to_tag1.lua new file mode 100644 index 000000000..4c59e4cd9 --- /dev/null +++ b/tests/examples/sequences/client/move_to_tag1.lua @@ -0,0 +1,33 @@ + --DOC_GEN_IMAGE --DOC_NO_USAGE +local module = ... --DOC_HIDE +local awful = {tag = require("awful.tag"), layout = require("awful.layout")} --DOC_HIDE +require("awful.ewmh") --DOC_HIDE +screen[1]._resize {x = 0, width = 160, height = 90} --DOC_HIDE +awful.tag({ "one", "two", "three" }, screen[1], awful.layout.suit.tile) --DOC_HIDE + +function awful.spawn(name, properties) --DOC_HIDE + client.gen_fake{class = name, name = name, x = 10, y=10, width = 60, height =50, tags = properties.tags} --DOC_HIDE +end --DOC_HIDE + +module.add_event("Spawn some apps", function() --DOC_HIDE + for tag_idx = 1, 3 do + for _ = 1, 3 do + awful.spawn("", {tags = {screen[1].tags[tag_idx]}}) + end + end + + client.get()[1].color = "#ff777733" --DOC_HIDE + +end) --DOC_HIDE + +--DOC_NEWLINE +module.display_tags() --DOC_HIDE + +module.add_event("Call `:move_to_tag()`", function() --DOC_HIDE + client.get()[1]:move_to_tag(screen[1].tags[2]) +end) --DOC_HIDE + +module.display_tags() --DOC_HIDE + +module.execute { display_screen = false, display_clients = true , --DOC_HIDE + display_label = false, display_client_name = true } --DOC_HIDE diff --git a/tests/examples/sequences/client/relative_move1.lua b/tests/examples/sequences/client/relative_move1.lua new file mode 100644 index 000000000..fd9ecec68 --- /dev/null +++ b/tests/examples/sequences/client/relative_move1.lua @@ -0,0 +1,61 @@ + --DOC_GEN_IMAGE --DOC_HIDE_START --DOC_NO_USAGE --DOC_GEN_OUTPUT +local module = ... +require("ruled.client") +local awful = {tag = require("awful.tag"), layout = require("awful.layout")} +awful.placement = require("awful.placement") +require("awful.ewmh") +screen[1]:fake_resize(0, 0, 800, 480) +awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, screen[1], awful.layout.suit.tile) + +function awful.spawn(name) + client.gen_fake{class = name, name = name, x = 4, y=10, width = 60, height =50, screen=screen[1]} +end + +--DOC_NEWLINE + +module.add_event("Spawn a floating client.", function() + --DOC_HIDE_END + awful.spawn("") + + --DOC_NEWLINE + + client.get()[1].floating = true + + --DOC_NEWLINE + --DOC_HIDE_START +end) + +module.display_tags() + +module.add_event("Move it.", function() + --DOC_HIDE_END + client.get()[1]:relative_move(100, 100) + --DOC_NEWLINE + + local geo = client.get()[1]:geometry() + print("Client geometry:", geo.x, geo.y, geo.width, geo.height) + --DOC_NEWLINE + + --DOC_HIDE_START +end) + +module.display_tags() + +module.add_event("Resize it.", function() + --DOC_HIDE_END + client.get()[1]:relative_move(nil, nil, 100, 100) + --DOC_NEWLINE + + local geo = client.get()[1]:geometry() + print("Client geometry:", geo.x, geo.y, geo.width, geo.height) + + --DOC_HIDE_START +end) + +module.display_tags() + + +module.execute { display_screen = true , display_clients = true, + display_label = false, display_client_name = true, + display_mouse = false, +} diff --git a/tests/examples/sequences/client/relative_move1.output.txt b/tests/examples/sequences/client/relative_move1.output.txt new file mode 100644 index 000000000..3bdf3709f --- /dev/null +++ b/tests/examples/sequences/client/relative_move1.output.txt @@ -0,0 +1,2 @@ +Client geometry: 110 110 120 100 +Client geometry: 220 220 220 200 diff --git a/tests/examples/sequences/client/tags1.lua b/tests/examples/sequences/client/tags1.lua new file mode 100644 index 000000000..e8f89dbef --- /dev/null +++ b/tests/examples/sequences/client/tags1.lua @@ -0,0 +1,42 @@ + --DOC_GEN_IMAGE --DOC_NO_USAGE --DOC_GEN_OUTPUT --DOC_ASTERISK +local module = ... --DOC_HIDE +local awful = {tag = require("awful.tag"), layout = require("awful.layout")} --DOC_HIDE +require("awful.ewmh") --DOC_HIDE +screen[1]._resize {x = 0, width = 160, height = 90} --DOC_HIDE +awful.tag({ "one", "two", "three" }, screen[1], awful.layout.suit.tile) --DOC_HIDE + +function awful.spawn(name, properties) --DOC_HIDE + client.gen_fake{class = name, name = name, x = 10, y=10, width = 60, height =50, tags = properties.tags} --DOC_HIDE +end --DOC_HIDE + +module.add_event("Spawn some apps", function() --DOC_HIDE + for tag_idx = 1, 3 do + for _ = 1, 3 do + awful.spawn("", {tags = {screen[1].tags[tag_idx]}}) + end + end + + client.get()[1].color = "#ff777733" --DOC_HIDE + +end) --DOC_HIDE + +--DOC_NEWLINE +module.display_tags() --DOC_HIDE + +module.add_event("Set the tags", function() --DOC_HIDE + client.get()[1]:tags { + screen[1].tags[2], + screen[1].tags[3] + } + + --DOC_NEWLINE + -- It also works to get the tags. + for _, t in ipairs(client.get()[1]:tags()) do + print("Tag:", t.index, t.name) + end +end) --DOC_HIDE + +module.display_tags() --DOC_HIDE + +module.execute { display_screen = false, display_clients = true , --DOC_HIDE + display_label = false, display_client_name = true } --DOC_HIDE diff --git a/tests/examples/sequences/client/tags1.output.txt b/tests/examples/sequences/client/tags1.output.txt new file mode 100644 index 000000000..70d4b215c --- /dev/null +++ b/tests/examples/sequences/client/tags1.output.txt @@ -0,0 +1,2 @@ +Tag: 2 two +Tag: 3 three diff --git a/tests/examples/sequences/client/to_selected_tags1.lua b/tests/examples/sequences/client/to_selected_tags1.lua new file mode 100644 index 000000000..a32d46e6d --- /dev/null +++ b/tests/examples/sequences/client/to_selected_tags1.lua @@ -0,0 +1,40 @@ + --DOC_GEN_IMAGE --DOC_NO_USAGE +local module = ... --DOC_HIDE +local awful = {tag = require("awful.tag"), layout = require("awful.layout")} --DOC_HIDE +require("awful.ewmh") --DOC_HIDE +screen[1]._resize {x = 0, width = 160, height = 90} --DOC_HIDE +awful.tag({ "one", "two", "three", "four" }, screen[1], awful.layout.suit.tile) --DOC_HIDE + +function awful.spawn(name) --DOC_HIDE + client.gen_fake{class = name, name = name, x = 10, y=10, width = 60, height =50} --DOC_HIDE +end --DOC_HIDE + +module.add_event("Spawn some apps", function() --DOC_HIDE + awful.spawn("Client") + + --DOC_NEWLINE + + client.get()[1].color = "#ff777733" --DOC_HIDE + + + screen[1].tags[1].selected = false + screen[1].tags[2].selected = true + screen[1].tags[3].selected = true +end) --DOC_HIDE + +--DOC_NEWLINE +module.display_tags() --DOC_HIDE + +module.add_event("Call `:to_selected_tags()`", function() --DOC_HIDE + -- Deselect all tags, otherwise it will do nothing. + client.get()[1]:tags{} + + --DOC_NEWLINE + + client.get()[1]:to_selected_tags() +end) --DOC_HIDE + +module.display_tags() --DOC_HIDE + +module.execute { display_screen = false, display_clients = true , --DOC_HIDE + display_label = false, display_client_name = true } --DOC_HIDE diff --git a/tests/examples/sequences/client/toggle_tag1.lua b/tests/examples/sequences/client/toggle_tag1.lua new file mode 100644 index 000000000..c06ce39c9 --- /dev/null +++ b/tests/examples/sequences/client/toggle_tag1.lua @@ -0,0 +1,33 @@ + --DOC_GEN_IMAGE --DOC_NO_USAGE +local module = ... --DOC_HIDE +local awful = {tag = require("awful.tag"), layout = require("awful.layout")} --DOC_HIDE +require("awful.ewmh") --DOC_HIDE +screen[1]._resize {x = 0, width = 160, height = 90} --DOC_HIDE +awful.tag({ "one", "two", "three" }, screen[1], awful.layout.suit.tile) --DOC_HIDE + +function awful.spawn(name, properties) --DOC_HIDE + client.gen_fake{class = name, name = name, x = 10, y=10, width = 60, height =50, tags = properties.tags} --DOC_HIDE +end --DOC_HIDE + +module.add_event("Spawn some apps", function() --DOC_HIDE + for tag_idx = 1, 3 do + for _ = 1, 3 do + awful.spawn("", {tags = {screen[1].tags[tag_idx]}}) + end + end + + client.get()[1].color = "#ff777733" --DOC_HIDE + +end) --DOC_HIDE + +--DOC_NEWLINE +module.display_tags() --DOC_HIDE + +module.add_event("Call `:toggle_tag(screen[1].tags[2])`", function() --DOC_HIDE + client.get()[1]:toggle_tag(screen[1].tags[2]) +end) --DOC_HIDE + +module.display_tags() --DOC_HIDE + +module.execute { display_screen = false, display_clients = true , --DOC_HIDE + display_label = false, display_client_name = true } --DOC_HIDE diff --git a/tests/examples/sequences/client/width1.lua b/tests/examples/sequences/client/width1.lua new file mode 100644 index 000000000..3758c127d --- /dev/null +++ b/tests/examples/sequences/client/width1.lua @@ -0,0 +1,29 @@ + --DOC_GEN_IMAGE --DOC_NO_USAGE +local module = ... --DOC_HIDE +local awful = {tag = require("awful.tag"), layout = require("awful.layout")} --DOC_HIDE +require("awful.ewmh") --DOC_HIDE +screen[1]._resize {x = 0, width = 160, height = 90} --DOC_HIDE +awful.tag({ "one", "two", "three" }, screen[1], awful.layout.suit.tile) --DOC_HIDE + +function awful.spawn(name) --DOC_HIDE + client.gen_fake{class = name, name = name, x = 10, y=10, width = 60, height =50, floating = true} --DOC_HIDE +end --DOC_HIDE + +module.add_event("Spawn a client", function() --DOC_HIDE + awful.spawn("") --DOC_HIDE + + client.get()[1].color = "#ff777733" --DOC_HIDE + +end) --DOC_HIDE + +--DOC_NEWLINE +module.display_tags() --DOC_HIDE + +module.add_event("Change the `width` property", function() --DOC_HIDE + client.focus.width = 100 +end) --DOC_HIDE + +module.display_tags() --DOC_HIDE + +module.execute { display_screen = false, display_clients = true , --DOC_HIDE + display_label = false, display_client_name = true } --DOC_HIDE diff --git a/tests/examples/sequences/client/x1.lua b/tests/examples/sequences/client/x1.lua new file mode 100644 index 000000000..58a2b0810 --- /dev/null +++ b/tests/examples/sequences/client/x1.lua @@ -0,0 +1,29 @@ + --DOC_GEN_IMAGE --DOC_NO_USAGE +local module = ... --DOC_HIDE +local awful = {tag = require("awful.tag"), layout = require("awful.layout")} --DOC_HIDE +require("awful.ewmh") --DOC_HIDE +screen[1]._resize {x = 0, width = 160, height = 90} --DOC_HIDE +awful.tag({ "one", "two", "three" }, screen[1], awful.layout.suit.tile) --DOC_HIDE + +function awful.spawn(name) --DOC_HIDE + client.gen_fake{class = name, name = name, x = 10, y=10, width = 60, height =50, floating = true} --DOC_HIDE +end --DOC_HIDE + +module.add_event("Spawn a client", function() --DOC_HIDE + awful.spawn("") --DOC_HIDE + + client.get()[1].color = "#ff777733" --DOC_HIDE + +end) --DOC_HIDE + +--DOC_NEWLINE +module.display_tags() --DOC_HIDE + +module.add_event("Change the `x` property", function() --DOC_HIDE + client.focus.x = 100 +end) --DOC_HIDE + +module.display_tags() --DOC_HIDE + +module.execute { display_screen = false, display_clients = true , --DOC_HIDE + display_label = false, display_client_name = true } --DOC_HIDE diff --git a/tests/examples/sequences/client/y1.lua b/tests/examples/sequences/client/y1.lua new file mode 100644 index 000000000..46fda5bb6 --- /dev/null +++ b/tests/examples/sequences/client/y1.lua @@ -0,0 +1,29 @@ + --DOC_GEN_IMAGE --DOC_NO_USAGE +local module = ... --DOC_HIDE +local awful = {tag = require("awful.tag"), layout = require("awful.layout")} --DOC_HIDE +require("awful.ewmh") --DOC_HIDE +screen[1]._resize {x = 0, width = 160, height = 90} --DOC_HIDE +awful.tag({ "one", "two", "three" }, screen[1], awful.layout.suit.tile) --DOC_HIDE + +function awful.spawn(name) --DOC_HIDE + client.gen_fake{class = name, name = name, x = 10, y=10, width = 60, height =50, floating = true} --DOC_HIDE +end --DOC_HIDE + +module.add_event("Spawn a client", function() --DOC_HIDE + awful.spawn("") --DOC_HIDE + + client.get()[1].color = "#ff777733" --DOC_HIDE + +end) --DOC_HIDE + +--DOC_NEWLINE +module.display_tags() --DOC_HIDE + +module.add_event("Change the `y` property", function() --DOC_HIDE + client.focus.y = 50 +end) --DOC_HIDE + +module.display_tags() --DOC_HIDE + +module.execute { display_screen = false, display_clients = true , --DOC_HIDE + display_label = false, display_client_name = true } --DOC_HIDE diff --git a/tests/examples/sequences/template.lua b/tests/examples/sequences/template.lua index 73d605049..4dbf16ab6 100644 --- a/tests/examples/sequences/template.lua +++ b/tests/examples/sequences/template.lua @@ -245,10 +245,18 @@ end local function get_all_tag_clients(t) local s = t.screen - local clients = gtable.clone(t:clients(), false) + local all_clients = gtable.clone(t:clients(), false) + + local clients = {} + + for _, c in ipairs(all_clients) do + if not c.minimized then + table.insert(clients, c) + end + end for _, c in ipairs(s.clients) do - if c.sticky then + if c.sticky and not c.minimized then if not gtable.hasitem(clients, c) then table.insert(clients, c) end @@ -304,6 +312,7 @@ local function fake_arrange(tag) for _, geo_src in ipairs {param.geometries, flt } do for c, geo in pairs(geo_src) do geo.c = geo.c or c + geo.color = geo.c.color table.insert(ret, geo) end end @@ -332,7 +341,7 @@ local function gen_fake_clients(tag, args) local y = (geom.y*h)/sgeo.height local width = (geom.width*w)/sgeo.width local height = (geom.height*h)/sgeo.height - cr:set_source(color(geom.c.color or beautiful.bg_normal)) + cr:set_source(color(geom.color or beautiful.bg_normal)) cr:rectangle(x,y,width,height) cr:fill_preserve() cr:set_source(color(geom.c.border_color or beautiful.border_color))