tests: Add some methods to the shims

This commit is contained in:
Emmanuel Lepage Vallee 2017-05-15 02:24:52 -04:00
parent 15b025ff91
commit 8e87bd7c64
7 changed files with 184 additions and 6 deletions

View File

@ -7,7 +7,7 @@ return function(_, _)
-- Set the global shims -- Set the global shims
-- luacheck: globals awesome root tag screen client mouse drawin button -- luacheck: globals awesome root tag screen client mouse drawin button
-- luacheck: globals mousegrabber keygrabber -- luacheck: globals mousegrabber keygrabber dbus
awesome = require( "awesome" ) awesome = require( "awesome" )
root = require( "root" ) root = require( "root" )
tag = require( "tag" ) tag = require( "tag" )
@ -18,6 +18,7 @@ return function(_, _)
button = require( "button" ) button = require( "button" )
keygrabber = require( "keygrabber" ) keygrabber = require( "keygrabber" )
mousegrabber = require( "mousegrabber" ) mousegrabber = require( "mousegrabber" )
dbus = require( "dbus" )
-- Force luacheck to be silent about setting those as unused globals -- Force luacheck to be silent about setting those as unused globals
assert(awesome and root and tag and screen and client and mouse) assert(awesome and root and tag and screen and client and mouse)

View File

@ -1,3 +1,6 @@
local lgi = require("lgi")
local GdkPixbuf = lgi.GdkPixbuf
local Gdk = lgi.Gdk
local gears_obj = require("gears.object") local gears_obj = require("gears.object")
-- Emulate the C API classes. They differ from C API objects as connect_signal -- Emulate the C API classes. They differ from C API objects as connect_signal
@ -45,6 +48,29 @@ awesome.startup = true
function awesome.register_xproperty() function awesome.register_xproperty()
end end
local init, surfaces = false, {}
function awesome.load_image(file)
if not init then
Gdk.init{}
init = true
end
local _, width, height = GdkPixbuf.Pixbuf.get_file_info(file)
local pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(file, width, height)
if not pixbuf then
return nil, "Could not load "..file
end
local s = Gdk.cairo_surface_create_from_pixbuf( pixbuf, 1, nil )
table.insert(surfaces, s)
return s._native, not s and "Could not load surface from "..file or nil, s
end
-- Always show deprecated messages -- Always show deprecated messages
awesome.version = "v9999" awesome.version = "v9999"

View File

@ -51,6 +51,69 @@ function module.get_font()
return f return f
end end
function module.get_font_height()
return 9
end
------------------------------------------------------------------
-- Import the titlebar and layout assets from the default theme --
------------------------------------------------------------------
-- It's fine as long as gears doesn't depend on CAPI and $AWESOME_THEMES_PATH is set.
local themes_path = require("gears.filesystem").get_themes_dir()
-- Define the image to load
module.titlebar_close_button_normal = themes_path.."default/titlebar/close_normal.png"
module.titlebar_close_button_focus = themes_path.."default/titlebar/close_focus.png"
module.titlebar_minimize_button_normal = themes_path.."default/titlebar/minimize_normal.png"
module.titlebar_minimize_button_focus = themes_path.."default/titlebar/minimize_focus.png"
module.titlebar_ontop_button_normal_inactive = themes_path.."default/titlebar/ontop_normal_inactive.png"
module.titlebar_ontop_button_focus_inactive = themes_path.."default/titlebar/ontop_focus_inactive.png"
module.titlebar_ontop_button_normal_active = themes_path.."default/titlebar/ontop_normal_active.png"
module.titlebar_ontop_button_focus_active = themes_path.."default/titlebar/ontop_focus_active.png"
module.titlebar_sticky_button_normal_inactive = themes_path.."default/titlebar/sticky_normal_inactive.png"
module.titlebar_sticky_button_focus_inactive = themes_path.."default/titlebar/sticky_focus_inactive.png"
module.titlebar_sticky_button_normal_active = themes_path.."default/titlebar/sticky_normal_active.png"
module.titlebar_sticky_button_focus_active = themes_path.."default/titlebar/sticky_focus_active.png"
module.titlebar_floating_button_normal_inactive = themes_path.."default/titlebar/floating_normal_inactive.png"
module.titlebar_floating_button_focus_inactive = themes_path.."default/titlebar/floating_focus_inactive.png"
module.titlebar_floating_button_normal_active = themes_path.."default/titlebar/floating_normal_active.png"
module.titlebar_floating_button_focus_active = themes_path.."default/titlebar/floating_focus_active.png"
module.titlebar_maximized_button_normal_inactive = themes_path.."default/titlebar/maximized_normal_inactive.png"
module.titlebar_maximized_button_focus_inactive = themes_path.."default/titlebar/maximized_focus_inactive.png"
module.titlebar_maximized_button_normal_active = themes_path.."default/titlebar/maximized_normal_active.png"
module.titlebar_maximized_button_focus_active = themes_path.."default/titlebar/maximized_focus_active.png"
module.wallpaper = themes_path.."default/background.png"
-- You can use your own layout icons like this:
module.layout_fairh = themes_path.."default/layouts/fairhw.png"
module.layout_fairv = themes_path.."default/layouts/fairvw.png"
module.layout_floating = themes_path.."default/layouts/floatingw.png"
module.layout_magnifier = themes_path.."default/layouts/magnifierw.png"
module.layout_max = themes_path.."default/layouts/maxw.png"
module.layout_fullscreen = themes_path.."default/layouts/fullscreenw.png"
module.layout_tilebottom = themes_path.."default/layouts/tilebottomw.png"
module.layout_tileleft = themes_path.."default/layouts/tileleftw.png"
module.layout_tile = themes_path.."default/layouts/tilew.png"
module.layout_tiletop = themes_path.."default/layouts/tiletopw.png"
module.layout_spiral = themes_path.."default/layouts/spiralw.png"
module.layout_dwindle = themes_path.."default/layouts/dwindlew.png"
module.layout_cornernw = themes_path.."default/layouts/cornernww.png"
module.layout_cornerne = themes_path.."default/layouts/cornernew.png"
module.layout_cornersw = themes_path.."default/layouts/cornersww.png"
module.layout_cornerse = themes_path.."default/layouts/cornersew.png"
-- Taglist
module.taglist_bg_focus = module.bg_highlight
module.taglist_bg_used = module.bg_normal
function module.get() function module.get()
return module return module
end end

View File

@ -14,6 +14,14 @@ end
-- CURRENTLY UNUSED -- CURRENTLY UNUSED
-- end -- end
local function titlebar_meta(c)
for _, position in ipairs {"top", "bottom", "left", "right" } do
c["titlebar_"..position] = function(size) --luacheck: no unused
return drawin{}
end
end
end
-- Create fake clients to move around -- Create fake clients to move around
function client.gen_fake(args) function client.gen_fake(args)
local ret = gears_obj() local ret = gears_obj()
@ -22,6 +30,7 @@ function client.gen_fake(args)
ret.valid = true ret.valid = true
ret.size_hints = {} ret.size_hints = {}
ret.border_width = 1 ret.border_width = 1
ret.icon_sizes = {{16,16}}
-- Apply all properties -- Apply all properties
for k,v in pairs(args or {}) do for k,v in pairs(args or {}) do
@ -71,6 +80,20 @@ function client.gen_fake(args)
return nil return nil
end end
function ret:get_icon(_)
return require("beautiful").awesome_icon
end
function ret:raise()
--TODO
end
function ret:lower()
--TODO
end
titlebar_meta(ret)
function ret:tags(new) --FIXME function ret:tags(new) --FIXME
if new then if new then
ret._tags = new ret._tags = new
@ -92,6 +115,7 @@ function client.gen_fake(args)
-- Record the geometry -- Record the geometry
ret._old_geo = {} ret._old_geo = {}
push_geometry(ret) push_geometry(ret)
ret._old_geo[1]._hide = args.hide_first
-- Set the attributes -- Set the attributes
ret.screen = args.screen or screen[1] ret.screen = args.screen or screen[1]

View File

@ -0,0 +1,13 @@
local dbus = awesome._shim_fake_class()
function dbus.notify_send(...)
dbus.emit_signal("org.freedesktop.Notifications", ...)
end
function dbus.request_name()
-- Ignore
end
return dbus
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -1,19 +1,51 @@
local gears_obj = require("gears.object") local gears_obj = require("gears.object")
local drawin, meta = awesome._shim_fake_class() local drawin, meta = awesome._shim_fake_class()
local drawins = setmetatable({}, {__mode="v"})
local function new_drawin(_, args) local function new_drawin(_, args)
local ret = gears_obj() local ret = gears_obj()
ret.data = {drawable = gears_obj()} ret.data = {drawable = gears_obj()}
for k, v in pairs(args) do ret.x=0
rawset(ret, k, v) ret.y=0
ret.width=1
ret.height=1
ret.geometry = function(_, new)
new = new or {}
ret.x = new.x or ret.x
ret.y = new.y or ret.y
ret.width = new.width or ret.width
ret.height = new.height or ret.height
return {
x = ret.x,
y = ret.y,
width = ret.width,
height = ret.height
}
end end
return setmetatable(ret, { for _, k in pairs{ "buttons", "struts", "get_xproperty", "set_xproperty" } do
ret[k] = function() end
end
local md = setmetatable(ret, {
__index = function(...) return meta.__index(...) end, __index = function(...) return meta.__index(...) end,
__newindex = function(...) return meta.__newindex(...) end __newindex = function(...) return meta.__newindex(...) end
}) })
for k, v in pairs(args) do
ret[k] = v
end
table.insert(drawins, md)
return md
end
function drawin.get()
return drawins
end end
return setmetatable(drawin, { return setmetatable(drawin, {

View File

@ -7,6 +7,7 @@ screen.count = 1
local function create_screen(args) local function create_screen(args)
local s = gears_obj() local s = gears_obj()
s.data = {} s.data = {}
s.valid = true
-- Copy the geo in case the args are mutated -- Copy the geo in case the args are mutated
local geo = { local geo = {
@ -53,7 +54,10 @@ local screens = {}
function screen._add_screen(args) function screen._add_screen(args)
local s = create_screen(args) local s = create_screen(args)
table.insert(screens, s) table.insert(screens, s)
s.index = #screens
-- Skip the metatable or it will have side effects
rawset(s, "index", #screens)
screen[#screen+1] = s screen[#screen+1] = s
screen[s] = s screen[s] = s
end end
@ -94,8 +98,23 @@ function screen._setup_grid(w, h, rows, args)
end end
end end
local function iter_scr(_, _, s)
if not s then
assert(screen[1])
return screen[1], 1
end
local i = s.index
if i + 1 < #screen then
return screen[i+1], i+1
end
end
screen._add_screen {width=320, height=240} screen._add_screen {width=320, height=240}
return screen return setmetatable(screen, {
__call = iter_scr
})
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80