awful: add titlebar support
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
731b309c85
commit
8649c6cb8c
|
@ -22,8 +22,7 @@ include_directories(
|
||||||
${AWESOME_OPTIONAL_INCLUDE_DIRS})
|
${AWESOME_OPTIONAL_INCLUDE_DIRS})
|
||||||
|
|
||||||
set(AWE_LUA_FILES
|
set(AWE_LUA_FILES
|
||||||
${SOURCE_DIR}/lib/tabulous.lua
|
${SOURCE_DIR}/lib/tabulous.lua)
|
||||||
${SOURCE_DIR}/lib/awful.lua)
|
|
||||||
|
|
||||||
set(AWE_CONF_FILE_DEFAULT ${BUILD_DIR}/awesomerc.lua)
|
set(AWE_CONF_FILE_DEFAULT ${BUILD_DIR}/awesomerc.lua)
|
||||||
set(AWE_CONF_FILE rc.lua)
|
set(AWE_CONF_FILE rc.lua)
|
||||||
|
|
|
@ -261,6 +261,7 @@ set(AWESOME_ICON_PATH ${AWESOME_DATA_PATH}/icons)
|
||||||
set(AWESOME_CONFIGURE_FILES
|
set(AWESOME_CONFIGURE_FILES
|
||||||
config.h.in
|
config.h.in
|
||||||
awesomerc.lua.in
|
awesomerc.lua.in
|
||||||
|
lib/awful.lua.in
|
||||||
awesome-version-internal.h.in
|
awesome-version-internal.h.in
|
||||||
awesome.doxygen.in)
|
awesome.doxygen.in)
|
||||||
|
|
||||||
|
|
|
@ -290,6 +290,7 @@ function hook_focus(c)
|
||||||
if not awful.client.ismarked(c) then
|
if not awful.client.ismarked(c) then
|
||||||
c.border_color = border_focus
|
c.border_color = border_focus
|
||||||
end
|
end
|
||||||
|
awful.titlebar.update(c, bg_normal, fg_normal, bg_focus, fg_focus)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Hook function to execute when unfocusing a client.
|
-- Hook function to execute when unfocusing a client.
|
||||||
|
@ -297,6 +298,7 @@ function hook_unfocus(c)
|
||||||
if not awful.client.ismarked(c) then
|
if not awful.client.ismarked(c) then
|
||||||
c.border_color = border_normal
|
c.border_color = border_normal
|
||||||
end
|
end
|
||||||
|
awful.titlebar.update(c, bg_normal, fg_normal, bg_focus, fg_focus)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Hook function to execute when marking a client
|
-- Hook function to execute when marking a client
|
||||||
|
@ -321,6 +323,9 @@ end
|
||||||
function hook_manage(c)
|
function hook_manage(c)
|
||||||
-- Set floating placement to be smart!
|
-- Set floating placement to be smart!
|
||||||
c.floating_placement = "smart"
|
c.floating_placement = "smart"
|
||||||
|
-- Add a titlebar
|
||||||
|
c.titlebar = awful.titlebar.new({ fg = fg, bg = bg })
|
||||||
|
awful.titlebar.update(c, bg_normal, fg_normal, bg_focus, fg_focus)
|
||||||
-- Add mouse bindings
|
-- Add mouse bindings
|
||||||
c:mouse_add(mouse({ }, 1, function (c) c:focus_set(); c:raise() end))
|
c:mouse_add(mouse({ }, 1, function (c) c:focus_set(); c:raise() end))
|
||||||
c:mouse_add(mouse({ modkey }, 1, function (c) c:mouse_move() end))
|
c:mouse_add(mouse({ modkey }, 1, function (c) c:mouse_move() end))
|
||||||
|
@ -368,6 +373,11 @@ function hook_timer ()
|
||||||
-- mytextbox.text = " " .. os.date() .. " "
|
-- mytextbox.text = " " .. os.date() .. " "
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function hook_titleupdate (c)
|
||||||
|
-- Update titlebar
|
||||||
|
awful.titlebar.update(c, bg_normal, fg_normal, bg_focus, fg_focus)
|
||||||
|
end
|
||||||
|
|
||||||
-- Set up some hooks
|
-- Set up some hooks
|
||||||
awful.hooks.focus(hook_focus)
|
awful.hooks.focus(hook_focus)
|
||||||
awful.hooks.unfocus(hook_unfocus)
|
awful.hooks.unfocus(hook_unfocus)
|
||||||
|
@ -377,4 +387,5 @@ awful.hooks.manage(hook_manage)
|
||||||
awful.hooks.mouseover(hook_mouseover)
|
awful.hooks.mouseover(hook_mouseover)
|
||||||
awful.hooks.arrange(hook_arrange)
|
awful.hooks.arrange(hook_arrange)
|
||||||
awful.hooks.timer(1, hook_timer)
|
awful.hooks.timer(1, hook_timer)
|
||||||
|
awful.hooks.titleupdate(hook_titleupdate)
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 421 B |
Binary file not shown.
After Width: | Height: | Size: 723 B |
|
@ -26,6 +26,8 @@ local screen = screen
|
||||||
local client = client
|
local client = client
|
||||||
local tag = tag
|
local tag = tag
|
||||||
local mouse = mouse
|
local mouse = mouse
|
||||||
|
local titlebar = titlebar
|
||||||
|
local widget = widget
|
||||||
local os = os
|
local os = os
|
||||||
local table = table
|
local table = table
|
||||||
local hooks = hooks
|
local hooks = hooks
|
||||||
|
@ -43,6 +45,7 @@ P.screen = {}
|
||||||
P.layout = {}
|
P.layout = {}
|
||||||
P.client = {}
|
P.client = {}
|
||||||
P.tag = {}
|
P.tag = {}
|
||||||
|
P.titlebar = {}
|
||||||
P.widget = {}
|
P.widget = {}
|
||||||
P.widget.taglist = {}
|
P.widget.taglist = {}
|
||||||
P.widget.taglist.label = {}
|
P.widget.taglist.label = {}
|
||||||
|
@ -836,4 +839,47 @@ function P.widget.tasklist.label.currenttags(c, screen, bg_focus, fg_focus)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Create a standard titlebar.
|
||||||
|
-- @param args Arguments.
|
||||||
|
-- fg: the foreground color,
|
||||||
|
-- bg: the background color.
|
||||||
|
-- text_align: the title text alignment.
|
||||||
|
-- @return A brand new titlebar.
|
||||||
|
function P.titlebar.new(args)
|
||||||
|
local tb = titlebar(args)
|
||||||
|
tb:widget_add(widget({ type = "textbox", name = "title" }))
|
||||||
|
local close_button= widget({ type = "textbox", name = "close", align = "right"})
|
||||||
|
close_button:mouse_add(mouse({ }, 1, function (t) t:client_get():kill() end))
|
||||||
|
tb:widget_add(close_button)
|
||||||
|
return tb
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Update a titlebar. This should be called in some hooks.
|
||||||
|
-- @param c The client to update.
|
||||||
|
-- @param bg The background color for normal client.
|
||||||
|
-- @param fg The foreground color for normal client.
|
||||||
|
-- @param bg_focus The background color for focused client.
|
||||||
|
-- @param fg_focus The foreground color for focused client.
|
||||||
|
function P.titlebar.update(c, bg, fg, bg_focus, fg_focus)
|
||||||
|
if c.titlebar then
|
||||||
|
local widgets = c.titlebar:widget_get()
|
||||||
|
if widgets.title then
|
||||||
|
widgets.title.text = " " .. P.escape(c.name)
|
||||||
|
end
|
||||||
|
if client.focus_get() == c then
|
||||||
|
c.titlebar.bg = bg_focus
|
||||||
|
c.titlebar.fg = fg_focus
|
||||||
|
if widgets.close then
|
||||||
|
widgets.close.text = "<bg image=\"@AWESOME_ICON_PATH@/titlebar/closer.png\" resize=\"true\"/>"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
c.titlebar.bg = bg
|
||||||
|
c.titlebar.fg = fg
|
||||||
|
if widgets.close then
|
||||||
|
widgets.close.text = "<bg image=\"@AWESOME_ICON_PATH@/titlebar/close.png\" resize=\"true\"/>"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return P
|
return P
|
Loading…
Reference in New Issue