diff --git a/objects/selection_getter.c b/objects/selection_getter.c index f932be95..9b8f4160 100644 --- a/objects/selection_getter.c +++ b/objects/selection_getter.c @@ -54,8 +54,14 @@ luaA_selection_getter_new(lua_State *L) selection_getter_t *selection; xcb_atom_t name_atom, target_atom; - name = luaL_checklstring(L, 2, &name_length); - target = luaL_checklstring(L, 3, &target_length); + luaA_checktable(L, 2); + lua_pushliteral(L, "selection"); + lua_gettable(L, 2); + lua_pushliteral(L, "target"); + lua_gettable(L, 2); + + name = luaL_checklstring(L, -2, &name_length); + target = luaL_checklstring(L, -1, &target_length); /* Create a selection object */ selection = (void *) selection_getter_class.allocator(L); diff --git a/tests/test-selection-getter.lua b/tests/test-selection-getter.lua index a11296ba..a2ae4d71 100644 --- a/tests/test-selection-getter.lua +++ b/tests/test-selection-getter.lua @@ -61,7 +61,7 @@ runner.run_steps{ -- Now query the state of the clipboard (should be empty) continue = false - local s = selection_getter("CLIPBOARD", "TARGETS") + local s = selection_getter{ selection = "CLIPBOARD", target = "TARGETS" } s:connect_signal("data", function(...) error("Got unexpected data: " .. dump_return{...}) end) s:connect_signal("data_end", function() assert(not continue) @@ -97,7 +97,7 @@ runner.run_steps{ -- Query whether the clipboard contains a text (UTF8_STRING) continue = false - local s = selection_getter("CLIPBOARD", "TARGETS") + local s = selection_getter{ selection = "CLIPBOARD", target = "TARGETS" } local data = nil s:connect_signal("data", function(_, d) assert(not data) @@ -120,7 +120,7 @@ runner.run_steps{ -- Query the text in the clipboard continue = false - local s = selection_getter("CLIPBOARD", "UTF8_STRING") + local s = selection_getter{ selection = "CLIPBOARD", target = "UTF8_STRING" } local data = nil s:connect_signal("data", function(_, d) assert(data == nil) @@ -161,7 +161,7 @@ runner.run_steps{ -- Query the image in the clipboard continue = false - local s = selection_getter("CLIPBOARD", "image/bmp") + local s = selection_getter{ selection = "CLIPBOARD", target = "image/bmp" } local data = {} s:connect_signal("data", function(_, d) table.insert(data, d)