From 086fb1135186d4c8c4ae16d6e969dc3be0fb8a02 Mon Sep 17 00:00:00 2001 From: "B. Stack" Date: Sat, 26 Nov 2022 08:24:06 -0500 Subject: store local hostname on WinClient instance so we do not have to run gethostname() for all title changes, just at each new window instantiation. --- .../patches/add-clientmachine-if-forwarded.patch | 49 ++++++++++++++++++---- 1 file changed, 41 insertions(+), 8 deletions(-) (limited to 'fluxbox') diff --git a/fluxbox/debian/patches/add-clientmachine-if-forwarded.patch b/fluxbox/debian/patches/add-clientmachine-if-forwarded.patch index 5191173..f8a7f27 100644 --- a/fluxbox/debian/patches/add-clientmachine-if-forwarded.patch +++ b/fluxbox/debian/patches/add-clientmachine-if-forwarded.patch @@ -79,7 +79,27 @@ Inspired by xfwm4's ability to display the remote host running an X11 window. Th using std::string; using std::list; -@@ -217,6 +218,10 @@ bool WinClient::getAttrib(XWindowAttribu +@@ -58,8 +59,10 @@ using std::cerr; + using std::hex; + using std::dec; + ++ + namespace { + ++ + void sendMessage(const WinClient& win, Atom atom, Time time) { + XEvent ce; + ce.xclient.type = ClientMessage; +@@ -104,6 +107,8 @@ WinClient::WinClient(Window win, BScreen + updateWMHints(); + updateWMNormalHints(); + updateWMClassHint(); ++ gethostname(hostname_char, 512); ++ hostname = FbTk::FbString(hostname_char); + updateTitle(); + Fluxbox::instance()->saveWindowSearch(win, this); + if (window_group != None) +@@ -217,6 +222,10 @@ bool WinClient::getAttrib(XWindowAttribu return XGetWindowAttributes(display(), window(), &attr); } @@ -90,15 +110,13 @@ Inspired by xfwm4's ability to display the remote host running an X11 window. Th bool WinClient::getWMName(XTextProperty &textprop) const { return XGetWMName(display(), window(), &textprop); } -@@ -319,7 +324,14 @@ void WinClient::updateTitle() { +@@ -319,7 +328,12 @@ void WinClient::updateTitle() { if (m_title_override) return; - m_title.setLogical(FbTk::FbString(Xutil::getWMName(window()), 0, 512)); + FbTk::FbString fullname = FbTk::FbString(Xutil::getWMName(window()), 0, 512); + FbTk::FbString clientmachine = FbTk::FbString(Xutil::getWMClientMachine(window()), 0, 512); -+ char *host = new char[512]; gethostname(host, 512); -+ FbTk::FbString hostname = FbTk::FbString(host); + if (clientmachine != "Unnamed" && clientmachine != "" && clientmachine != hostname) { + fullname += " (on " + clientmachine + ")"; + } @@ -106,15 +124,13 @@ Inspired by xfwm4's ability to display the remote host running an X11 window. Th m_title_update_timer.start(); } -@@ -328,7 +340,14 @@ void WinClient::emitTitleSig() { +@@ -328,7 +342,12 @@ void WinClient::emitTitleSig() { } void WinClient::setTitle(const FbTk::FbString &title) { - m_title.setLogical(title); + FbTk::FbString fullname = title; + FbTk::FbString clientmachine = FbTk::FbString(Xutil::getWMClientMachine(window()), 0, 512); -+ char *host = new char[512]; gethostname(host, 512); -+ FbTk::FbString hostname = FbTk::FbString(host); + if (clientmachine != "Unnamed" && clientmachine != "" && clientmachine != hostname) { + fullname += " (on " + clientmachine + ")"; + } @@ -124,7 +140,15 @@ Inspired by xfwm4's ability to display the remote host running an X11 window. Th } --- a/src/WinClient.hh +++ b/src/WinClient.hh -@@ -91,6 +91,7 @@ public: +@@ -31,6 +31,7 @@ + class BScreen; + class Strut; + ++ + /// Holds client window info + class WinClient: public Focusable, public FbTk::FbWindow { + public: +@@ -91,6 +92,7 @@ public: // bool getAttrib(XWindowAttributes &attr) const; @@ -132,3 +156,12 @@ Inspired by xfwm4's ability to display the remote host running an X11 window. Th bool getWMName(XTextProperty &textprop) const; bool getWMIconName(XTextProperty &textprop) const; std::string getWMRole() const; +@@ -141,6 +143,8 @@ public: + unsigned long initial_state, normal_hint_flags, wm_hint_flags; + + private: ++ char hostname_char[512]; ++ FbTk::FbString hostname; + /// removes client from any waiting list and clears empty waiting lists + void removeTransientFromWaitingList(); + -- cgit