diff --git a/CMakeLists.txt b/CMakeLists.txt index c36bc7b0..72a7c22e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,8 +22,7 @@ include_directories( ${AWESOME_OPTIONAL_INCLUDE_DIRS}) set(AWE_LUA_FILES - ${SOURCE_DIR}/lib/tabulous.lua - ${SOURCE_DIR}/lib/awful.lua) + ${SOURCE_DIR}/lib/tabulous.lua) set(AWE_CONF_FILE_DEFAULT ${BUILD_DIR}/awesomerc.lua) set(AWE_CONF_FILE rc.lua) diff --git a/awesomeConfig.cmake b/awesomeConfig.cmake index 8836f0f0..200b0841 100644 --- a/awesomeConfig.cmake +++ b/awesomeConfig.cmake @@ -261,6 +261,7 @@ set(AWESOME_ICON_PATH ${AWESOME_DATA_PATH}/icons) set(AWESOME_CONFIGURE_FILES config.h.in awesomerc.lua.in + lib/awful.lua.in awesome-version-internal.h.in awesome.doxygen.in) diff --git a/awesomerc.lua.in b/awesomerc.lua.in index 8a3097d4..1b439980 100644 --- a/awesomerc.lua.in +++ b/awesomerc.lua.in @@ -290,6 +290,7 @@ function hook_focus(c) if not awful.client.ismarked(c) then c.border_color = border_focus end + awful.titlebar.update(c, bg_normal, fg_normal, bg_focus, fg_focus) end -- Hook function to execute when unfocusing a client. @@ -297,6 +298,7 @@ function hook_unfocus(c) if not awful.client.ismarked(c) then c.border_color = border_normal end + awful.titlebar.update(c, bg_normal, fg_normal, bg_focus, fg_focus) end -- Hook function to execute when marking a client @@ -321,6 +323,9 @@ end function hook_manage(c) -- Set floating placement to be 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 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)) @@ -368,6 +373,11 @@ function hook_timer () -- mytextbox.text = " " .. os.date() .. " " end +function hook_titleupdate (c) + -- Update titlebar + awful.titlebar.update(c, bg_normal, fg_normal, bg_focus, fg_focus) +end + -- Set up some hooks awful.hooks.focus(hook_focus) awful.hooks.unfocus(hook_unfocus) @@ -377,4 +387,5 @@ awful.hooks.manage(hook_manage) awful.hooks.mouseover(hook_mouseover) awful.hooks.arrange(hook_arrange) awful.hooks.timer(1, hook_timer) +awful.hooks.titleupdate(hook_titleupdate) -- }}} diff --git a/icons/titlebar/close.png b/icons/titlebar/close.png new file mode 100644 index 00000000..ddab69ec Binary files /dev/null and b/icons/titlebar/close.png differ diff --git a/icons/titlebar/closer.png b/icons/titlebar/closer.png new file mode 100644 index 00000000..3409c264 Binary files /dev/null and b/icons/titlebar/closer.png differ diff --git a/lib/awful.lua b/lib/awful.lua.in similarity index 93% rename from lib/awful.lua rename to lib/awful.lua.in index 29e2b4f2..b4a257be 100644 --- a/lib/awful.lua +++ b/lib/awful.lua.in @@ -26,6 +26,8 @@ local screen = screen local client = client local tag = tag local mouse = mouse +local titlebar = titlebar +local widget = widget local os = os local table = table local hooks = hooks @@ -43,6 +45,7 @@ P.screen = {} P.layout = {} P.client = {} P.tag = {} +P.titlebar = {} P.widget = {} P.widget.taglist = {} P.widget.taglist.label = {} @@ -836,4 +839,47 @@ function P.widget.tasklist.label.currenttags(c, screen, bg_focus, fg_focus) 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 = "" + end + else + c.titlebar.bg = bg + c.titlebar.fg = fg + if widgets.close then + widgets.close.text = "" + end + end + end +end + return P