From f22435d60bf7a52e00608576074dd791e8731bf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Thu, 11 Aug 2016 23:49:44 +0200 Subject: add support for artificial struts (per head) Allows to maintain access to desktop fractions etc. against maximized windows. Also permits to OnToolbar clicks in this case, eg. to raise it. REQUEST: 150 --- doc/asciidoc/fluxbox.txt | 9 +++++++++ src/Screen.cc | 39 +++++++++++++++++++++++++++++++++++++++ src/Screen.hh | 2 ++ 3 files changed, 50 insertions(+) diff --git a/doc/asciidoc/fluxbox.txt b/doc/asciidoc/fluxbox.txt index 3afec68..87bd554 100644 --- a/doc/asciidoc/fluxbox.txt +++ b/doc/asciidoc/fluxbox.txt @@ -1136,6 +1136,15 @@ Set this to the number of workspaces the users wants. + Default: *4* +*session.screen0.struts*: 'integer', 'integer', 'integer', 'integer':: +Shrink the workspace by left, right, top, bottom pixels (positive integers) +This allows you to add some padding to the workspace eg. to keep a fraction +of the desktop visible against maximized windows. +session.screen0.struts. allows to control this for individual heads +( starts counting at 1) ++ +Default: *0,0,0,0* + *session.cacheLife*: 'minutes':: This tells fluxbox how long unused pixmaps may stay in the X server's memory. diff --git a/src/Screen.cc b/src/Screen.cc index 94e4250..24e0607 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -759,6 +759,7 @@ void BScreen::reconfigure() { m_root_theme->screenNum()); reconfigureTabs(); + reconfigureStruts(); } void BScreen::reconfigureTabs() { @@ -770,6 +771,42 @@ void BScreen::reconfigureTabs() { (*it)->fbwindow()->applyDecorations(); } +static void parseStruts(const std::string &s, int &l, int &r, int &t, int &b) { + std::list v; + FbTk::StringUtil::stringtok(v, s, " ,"); + std::list::iterator it = v.begin(); + if (it != v.end()) l = std::max(0, atoi(it->c_str())); + if (++it != v.end()) r = std::max(0, atoi(it->c_str())); + if (++it != v.end()) t = std::max(0, atoi(it->c_str())); + if (++it != v.end()) b = std::max(0, atoi(it->c_str())); +} + +void BScreen::reconfigureStruts() { + for (std::vector::iterator it = m_head_struts.begin(), + end = m_head_struts.end(); it != end; ++it) { + clearStrut(*it); + } + + m_head_struts.clear(); + + int gl = 0, gr = 0, gt = 0, gb = 0; + parseStruts(FbTk::Resource(resourceManager(), "", + name() + ".struts", + altName() + ".Struts"), gl, gr, gt, gb); + const int nh = std::max(1, numHeads()); + for (int i = 1; i <= nh; ++i) { + int l = gl, r = gr, t = gt, b = gb; + char ai[16]; + sprintf(ai, "%d", i); + parseStruts(FbTk::Resource(resourceManager(), "", + name() + ".struts." + ai, + altName() + ".Struts." + ai), l, r, t, b); + if (l+t+r+b) + m_head_struts.push_back(requestStrut(i, l, r, t, b)); + } + updateAvailableWorkspaceArea(); +} + void BScreen::updateWorkspaceName(unsigned int w) { Workspace *space = getWorkspace(w); if (space) { @@ -1621,6 +1658,8 @@ void BScreen::initXinerama() { #else // XINERAMA m_xinerama.avail = false; #endif // XINERAMA + + reconfigureStruts(); } /* Move windows out of inactive heads */ diff --git a/src/Screen.hh b/src/Screen.hh index ae279f3..32a7f7a 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -341,6 +341,7 @@ public: void reconfigure(); void reconfigureTabs(); + void reconfigureStruts(); void rereadMenu(); void rereadWindowMenu(); void shutdown(); @@ -536,6 +537,7 @@ private: } m_xinerama; std::vector m_head_areas; + std::vector m_head_struts; struct { bool cycling; -- cgit v0.11.2