From 8649c6cb8cd46cfdd95cf2966b8c5bc9adffd695 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 29 Jul 2008 15:44:09 +0200 Subject: [PATCH] awful: add titlebar support Signed-off-by: Julien Danjou --- CMakeLists.txt | 3 +-- awesomeConfig.cmake | 1 + awesomerc.lua.in | 11 ++++++++ icons/titlebar/close.png | Bin 0 -> 421 bytes icons/titlebar/closer.png | Bin 0 -> 723 bytes lib/{awful.lua => awful.lua.in} | 46 ++++++++++++++++++++++++++++++++ 6 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 icons/titlebar/close.png create mode 100644 icons/titlebar/closer.png rename lib/{awful.lua => awful.lua.in} (93%) 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 0000000000000000000000000000000000000000..ddab69ec092ab8fc8531834101c538c3b05a4d01 GIT binary patch literal 421 zcmV;W0b2fvP)J4Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iON4 z4Ga*QFsq9I00AXQL_t(I%f*y2Zi6rwg+Et~{#?LI77slGQ5Li25}k7>ZUQ4&kQf=V z^Z-a401_#2hYHIAs)nYdZ?XM&PtX4SV`Z&%$K#R1;lR>Jk_2lluRU=-p8;^r0icwc zG=|@ub0ggpH-ryu+m>g+hjv}}f1$(jg{4l@6oCDH@3mQ$jkuwIcwMu~8^-sK3(=-5Rt!bKus;bah&kB8+ zBMt+@vFB%>bhTRjDBf%~BkdG-cj$V(e(rxNB0f|BzR&uG95u2UkZM8{a$j>1@u7t= zW_LQB5E1_d|20GeV+=r{thH~z2T%aJg)3VC@9KKJPCivj;C8!lxm@@J@o4B@4 literal 0 HcmV?d00001 diff --git a/icons/titlebar/closer.png b/icons/titlebar/closer.png new file mode 100644 index 0000000000000000000000000000000000000000..3409c2648b8d3f27d59f8707a57dc8e20809f67a GIT binary patch literal 723 zcmV;^0xbQBP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iON4 z4GbeB;L4o<00L7$dM3IUHiI6{cxw~E46gOU+JpzeDEUo73^URy~{Jbl> zaO-nfo*wl3JX>AmrpNPx16IqD4499LlfmFxMGWARc%6{}x8r1ZcJ|lJl4Vye9P0X? zzzyT^aCqrPYYZ4OZNM0ewKIFXa|G|fPx(9Vuf}+Eem?D16GVZsJjWS>5#iy<2>>4! z7n|Y_j*kI&zp&7(#Ts>0&D5J=JglmVXXqRP)Xrf=5M$Wu^>{QGaR2D2`3rI<> z4(C0!bHAI29?-Q}#_4%#>;Sd*WSUqz$6IT8>|6u-uG49N0DK695U7CwR2th-H;y@J zIku|_lA6Z*3v+-;T@%8zw9}jvuvSvO1>E3$N!WIPTx0C6(6y%uvL(W12&{Y0mPk{0 zte~|%6P=G+#7_U@IIDj~(7Xk@Ey5hIBUApHArP%oBy}PPE#)pSE|SfhfNKnFvOtaeD9`7XrEW)X9<5n(K95wSZ3}%brS{ zC4e36-s(#vvz9E+vDP9YSYvSBH+Q!hk8vSjy~hD_ddAUUQC0bI=LIjr>yO_?qqXmc zhZHRn{LfJU^UKRDb-VjnVY{q+>Tgh%Uzf^qA6UEL57hojzrP{%-B*xX=vdzDKgm_) z_!O#kyj{`cQGH3?4PLLYQ)Mevd7>gtfYJKB?Vppb;TOJ=_LN2Tw~+t<002ovPDHLk FV1iR!MNt3% literal 0 HcmV?d00001 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