From fa2433192a02b53da41f0d5766b46a7286501536 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sun, 29 Sep 2019 23:16:34 -0400 Subject: [PATCH] doc: Add some screen example sequences. --- objects/screen.c | 14 ++++++++++- .../examples/sequences/screen/fake_remove.lua | 23 +++++++++++++++++++ .../examples/sequences/screen/fake_resize.lua | 15 ++++++++++++ tests/examples/sequences/screen/swap.lua | 17 ++++++++++++++ 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 tests/examples/sequences/screen/fake_remove.lua create mode 100644 tests/examples/sequences/screen/fake_resize.lua create mode 100644 tests/examples/sequences/screen/swap.lua diff --git a/objects/screen.c b/objects/screen.c index 22df006a4..b0c394148 100644 --- a/objects/screen.c +++ b/objects/screen.c @@ -1726,6 +1726,9 @@ luaA_screen_fake_add(lua_State *L) } /** Remove a screen. + * + * @DOC_sequences_screen_fake_remove_EXAMPLE@ + * * @method fake_remove */ static int @@ -1753,7 +1756,13 @@ luaA_screen_fake_remove(lua_State *L) return 0; } -/** Fake-resize a screen +/** Resize a screen. + * + * Calling this will resize the screen even if it no longer matches the viewport + * size. + * + * @DOC_sequences_screen_fake_resize_EXAMPLE@ + * * @tparam integer x The new X-coordinate for screen. * @tparam integer y The new Y-coordinate for screen. * @tparam integer width The new width for screen. @@ -1789,6 +1798,9 @@ luaA_screen_fake_resize(lua_State *L) } /** Swap a screen with another one in global screen list. + * + * @DOC_sequences_screen_swap_EXAMPLE@ + * * @client s A screen to swap with. * @method swap */ diff --git a/tests/examples/sequences/screen/fake_remove.lua b/tests/examples/sequences/screen/fake_remove.lua new file mode 100644 index 000000000..ee6a2ac17 --- /dev/null +++ b/tests/examples/sequences/screen/fake_remove.lua @@ -0,0 +1,23 @@ + --DOC_GEN_IMAGE --DOC_ASTERISK +local module = ... --DOC_HIDE +screen[1]:fake_resize(0, 0, 800, 600) --DOC_HIDE +screen.fake_add(800,0,800,600) --DOC_HIDE +screen.fake_add(800*2,0,800,600) --DOC_HIDE +assert(screen.count()==3) --DOC_HIDE +assert(screen[1].geometry.width == 800) --DOC_HIDE +assert(screen[1].geometry.height == 600) --DOC_HIDE +assert(screen[3].geometry.x == 800*2)--DOC_HIDE +local rw, rh = root.size() --DOC_HIDE +assert(rw == 3*800) --DOC_HIDE +assert(rh == 600) --DOC_HIDE + +module.display_tags() --DOC_HIDE + +module.add_event("Calling :fake_remove()", function() --DOC_HIDE + require("gears.timer").run_delayed_calls_now() --DOC_HIDE + screen[2]:fake_remove() +end) --DOC_HIDE + +module.display_tags() --DOC_HIDE + +module.execute {display_screen=true} --DOC_HIDE diff --git a/tests/examples/sequences/screen/fake_resize.lua b/tests/examples/sequences/screen/fake_resize.lua new file mode 100644 index 000000000..c98b8d18f --- /dev/null +++ b/tests/examples/sequences/screen/fake_resize.lua @@ -0,0 +1,15 @@ + --DOC_GEN_IMAGE --DOC_ASTERISK +local module = ... --DOC_HIDE +screen[1]:fake_resize(0, 0, 1280, 720) --DOC_HIDE +assert(screen[1].geometry.width == 1280) --DOC_HIDE +assert(screen[1].geometry.height == 720) --DOC_HIDE + +module.display_tags() --DOC_HIDE + +module.add_event("Calling :fake_resize()", function() --DOC_HIDE + screen[1]:fake_resize(100, 0, 1024, 768) +end) --DOC_HIDE + +module.display_tags() --DOC_HIDE + +module.execute {display_screen=true, show_code_pointer=false} --DOC_HIDE diff --git a/tests/examples/sequences/screen/swap.lua b/tests/examples/sequences/screen/swap.lua new file mode 100644 index 000000000..0c604c664 --- /dev/null +++ b/tests/examples/sequences/screen/swap.lua @@ -0,0 +1,17 @@ + --DOC_GEN_IMAGE --DOC_ASTERISK +local module = ... --DOC_HIDE +screen[1]:fake_resize(0, 0, 1280, 720) --DOC_HIDE +screen.fake_add(1280,0,1280,720) --DOC_HIDE +assert(screen.count()==2) --DOC_HIDE +assert(screen[1].geometry.width == 1280) --DOC_HIDE +assert(screen[1].geometry.height == 720) --DOC_HIDE + +module.display_tags() --DOC_HIDE + +module.add_event("Calling :swap()", function() --DOC_HIDE + screen[2]:swap(screen[1]) +end) --DOC_HIDE + +module.display_tags() --DOC_HIDE + +module.execute {display_screen=true, show_code_pointer=false} --DOC_HIDE