From 01bd2d18965ade682b2c28e96ff49d8f9e10fc16 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 17 Feb 2019 08:00:57 +0100 Subject: [PATCH] selection_acquire: Change the API to a table As requested in the review, instead of just having a single string argument, selection_acquire() now has a table as its argument. It searches the string under the "selection" key here. Signed-off-by: Uli Schlachter --- objects/selection_acquire.c | 5 ++++- tests/test-selection-transfer.lua | 12 ++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/objects/selection_acquire.c b/objects/selection_acquire.c index 11395813e..46868b113 100644 --- a/objects/selection_acquire.c +++ b/objects/selection_acquire.c @@ -139,7 +139,10 @@ luaA_selection_acquire_new(lua_State *L) xcb_atom_t name_atom; selection_acquire_t *selection; - name = luaL_checklstring(L, 2, &name_length); + luaA_checktable(L, 2); + lua_pushliteral(L, "selection"); + lua_gettable(L, 2); + name = luaL_checklstring(L, -1, &name_length); /* Get the atom identifying the selection */ reply = xcb_intern_atom_reply(globalconf.connection, diff --git a/tests/test-selection-transfer.lua b/tests/test-selection-transfer.lua index 8a8777205..018caa8d6 100644 --- a/tests/test-selection-transfer.lua +++ b/tests/test-selection-transfer.lua @@ -66,20 +66,20 @@ end runner.run_steps{ function() -- Get the selection - local s = assert(selection_acquire("CLIPBOARD"), + local s = assert(selection_acquire{ selection = "CLIPBOARD" }, "Failed to acquire the clipboard selection") -- Steal selection ownership from ourselves and test that it works local s_released s:connect_signal("release", function() s_released = true end) - selection = assert(selection_acquire("CLIPBOARD"), + selection = assert(selection_acquire{ selection = "CLIPBOARD" }, "Failed to acquire the clipboard selection") assert(s_released) -- Now test selection transfers - selection = assert(selection_acquire("CLIPBOARD"), + selection = assert(selection_acquire{ selection = "CLIPBOARD" }, "Failed to acquire the clipboard selection") selection:connect_signal("request", function(_, target, transfer) if target == "TARGETS" then @@ -108,7 +108,7 @@ runner.run_steps{ continue = false -- Now test piece-wise selection transfers - selection = assert(selection_acquire("CLIPBOARD"), + selection = assert(selection_acquire{ selection = "CLIPBOARD" }, "Failed to acquire the clipboard selection") selection:connect_signal("request", function(_, target, transfer) if target == "TARGETS" then @@ -148,7 +148,7 @@ runner.run_steps{ continue = false -- Now test a huge transfer - selection = assert(selection_acquire("CLIPBOARD"), + selection = assert(selection_acquire{ selection = "CLIPBOARD" }, "Failed to acquire the clipboard selection") selection:connect_signal("request", function(_, target, transfer) if target == "TARGETS" then @@ -212,7 +212,7 @@ runner.run_steps{ continue = false -- Test for "release" signal when we lose selection - selection = assert(selection_acquire("CLIPBOARD"), + selection = assert(selection_acquire{ selection = "CLIPBOARD" }, "Failed to acquire the clipboard selection") selection:connect_signal("release", function() selection_released = true end) awesome.sync()