From e3ab62fed1e63be3e7f6b81c316b15097638faf6 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Wed, 18 Jun 2003 13:55:17 +0000 Subject: added strut support --- src/Slit.cc | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- src/Slit.hh | 6 +++++- src/Toolbar.cc | 53 +++++++++++++++++++++++++++++++++++++++++++++++--- src/Toolbar.hh | 8 +++++++- src/Window.cc | 21 +++++++++++++++++--- src/Window.hh | 10 ++++++++-- 6 files changed, 147 insertions(+), 12 deletions(-) diff --git a/src/Slit.cc b/src/Slit.cc index 83d2928..d6629b5 100644 --- a/src/Slit.cc +++ b/src/Slit.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Slit.cc,v 1.60 2003/06/13 05:03:43 fluxgen Exp $ +// $Id: Slit.cc,v 1.61 2003/06/18 13:49:43 fluxgen Exp $ #include "Slit.hh" @@ -291,7 +291,8 @@ Slit::Slit(BScreen &scr, FbTk::XLayer &layer, const char *filename) "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR", False)), //KDE v2.x m_layeritem(0), - m_slit_theme(new SlitTheme(*this)) { + m_slit_theme(new SlitTheme(*this)), + m_strut(0) { // default placement and direction m_direction = screen().getSlitDirection(); @@ -339,10 +340,65 @@ Slit::Slit(BScreen &scr, FbTk::XLayer &layer, const char *filename) Slit::~Slit() { + clearStrut(); if (frame.pixmap != 0) screen().imageControl().removeImage(frame.pixmap); } +void Slit::clearStrut() { + if (m_strut != 0) { + screen().clearStrut(m_strut); + m_strut = 0; + } +} + +void Slit::updateStrut() { + clearStrut(); + // no need for area if we're autohiding + if (doAutoHide()) + return; + + int left = 0, right = 0, top = 0, bottom = 0; + switch (placement()) { + case TOPLEFT: + top = height(); + left = width(); + break; + case TOPCENTER: + top = height(); + break; + case TOPRIGHT: + right = width(); + top = height(); + break; + case BOTTOMLEFT: + bottom = height(); + left = width(); + break; + case BOTTOMCENTER: + // would be strange to have it request size on vertical direction + // each time we add a client + if (direction() == HORIZONTAL) + bottom = height(); + break; + case BOTTOMRIGHT: + if (direction() == HORIZONTAL) + bottom = height(); + else + right = width(); + break; + case CENTERLEFT: + if (direction() == VERTICAL) + left = width(); + break; + case CENTERRIGHT: + if (direction() == VERTICAL) + right = width(); + break; + } + m_strut = screen().requestStrut(left, right, top, bottom); + screen().updateAvailableWorkspaceArea(); +} void Slit::addClient(Window w) { #ifdef DEBUG @@ -777,6 +833,7 @@ void Slit::reconfigure() { m_slitmenu.reconfigure(); updateClientmenu(); + updateStrut(); } diff --git a/src/Slit.hh b/src/Slit.hh index 10b141a..7626665 100644 --- a/src/Slit.hh +++ b/src/Slit.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -/// $Id: Slit.hh,v 1.30 2003/05/17 11:00:50 fluxgen Exp $ +/// $Id: Slit.hh,v 1.31 2003/06/18 13:49:43 fluxgen Exp $ #ifndef SLIT_HH #define SLIT_HH @@ -44,6 +44,7 @@ class SlitTheme; class SlitClient; class BScreen; class FbMenu; +class Strut; /// Handles dock apps class Slit : public FbTk::TimeoutHandler, public FbTk::EventHandler { @@ -117,6 +118,8 @@ private: void removeClient(SlitClient *client, bool remap, bool destroy); void loadClientList(const char *filename); void updateClientmenu(); + void clearStrut(); + void updateStrut(); bool m_hidden, m_do_auto_hide; Direction m_direction; @@ -147,6 +150,7 @@ private: std::auto_ptr m_slit_theme; std::auto_ptr m_transp; static unsigned int s_eventmask; + Strut *m_strut; }; diff --git a/src/Toolbar.cc b/src/Toolbar.cc index 544a1e3..c87e1ca 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Toolbar.cc,v 1.90 2003/06/13 05:04:14 fluxgen Exp $ +// $Id: Toolbar.cc,v 1.91 2003/06/18 13:50:40 fluxgen Exp $ #include "Toolbar.hh" @@ -43,6 +43,7 @@ #include "BoolMenuItem.hh" #include "FbWinFrameTheme.hh" #include "Xinerama.hh" +#include "Strut.hh" // use GNU extensions #ifndef _GNU_SOURCE @@ -279,7 +280,8 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, FbTk::Menu &menu, size_t wi m_theme(scrn.screenNumber()), m_place(scrn.toolbarPlacement()), m_themelistener(*this), - m_layeritem(frame.window, layer) { + m_layeritem(frame.window, layer), + m_strut(0) { // we need to get notified when the theme is reloaded m_theme.addListener(m_themelistener); @@ -339,6 +341,7 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, FbTk::Menu &menu, size_t wi Toolbar::~Toolbar() { + clearStrut(); FbTk::ImageControl &image_ctrl = screen().imageControl(); if (frame.base) image_ctrl.removeImage(frame.base); if (frame.label) image_ctrl.removeImage(frame.label); @@ -349,6 +352,48 @@ Toolbar::~Toolbar() { } +void Toolbar::clearStrut() { + if (m_strut) { + screen().clearStrut(m_strut); + m_strut = 0; + } +} + +void Toolbar::updateStrut() { + clearStrut(); + // we should request space if we're in autohide mode or + // if the user dont want to request space for toolbar. + if (doAutoHide()) + return; + + // request area on screen + int top = 0, bottom = 0, left = 0, right = 0; + switch (m_place) { + case TOPLEFT: + case TOPCENTER: + case TOPRIGHT: + top = height(); + break; + case BOTTOMLEFT: + case BOTTOMCENTER: + case BOTTOMRIGHT: + bottom = height(); + break; + case RIGHTTOP: + case RIGHTCENTER: + case RIGHTBOTTOM: + right = width(); + break; + case LEFTTOP: + case LEFTCENTER: + case LEFTBOTTOM: + left = width(); + break; + }; + m_strut = screen().requestStrut(left, right, top, bottom); + screen().updateAvailableWorkspaceArea(); +} + bool Toolbar::isVertical() const { return (m_place == RIGHTCENTER || m_place == RIGHTTOP || @@ -702,7 +747,9 @@ void Toolbar::reconfigure() { checkClock(true); m_toolbarmenu.reconfigure(); - + // we're done with all resizing and stuff now we can request a new + // area to be reserv on screen + updateStrut(); } diff --git a/src/Toolbar.hh b/src/Toolbar.hh index a1c5c50..f8d3fe4 100644 --- a/src/Toolbar.hh +++ b/src/Toolbar.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Toolbar.hh,v 1.32 2003/06/11 14:50:57 fluxgen Exp $ +// $Id: Toolbar.hh,v 1.33 2003/06/18 13:50:40 fluxgen Exp $ #ifndef TOOLBAR_HH #define TOOLBAR_HH @@ -42,6 +42,8 @@ #include class BScreen; +class Strut; + namespace FbTk { class ImageControl; }; @@ -133,6 +135,8 @@ public: private: + void clearStrut(); + void updateStrut(); bool editing; ///< edit workspace label mode bool hidden; ///< hidden state @@ -189,6 +193,8 @@ private: ThemeListener m_themelistener; FbTk::XLayerItem m_layeritem; + + Strut *m_strut; ///< created and destroyed by BScreen }; diff --git a/src/Window.cc b/src/Window.cc index 0e4e8b0..9eabc0c 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Window.cc,v 1.192 2003/06/15 18:35:32 fluxgen Exp $ +// $Id: Window.cc,v 1.193 2003/06/18 13:55:17 fluxgen Exp $ #include "Window.hh" @@ -246,6 +246,7 @@ FluxboxWindow::FluxboxWindow(WinClient &client, BScreen &scr, FbWinFrameTheme &t m_old_decoration(DECOR_NORMAL), m_client(&client), m_frame(new FbWinFrame(tm, scr.imageControl(), scr.screenNumber(), 0, 0, 100, 100)), + m_strut(0), m_layeritem(m_frame->window(), layer), m_layernum(layer.getLayerNum()), m_parent(scr.rootWindow()) { @@ -279,6 +280,7 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen &scr, FbWinFrameTheme &tm, m_old_decoration(DECOR_NORMAL), m_client(new WinClient(w, *this)), m_frame(new FbWinFrame(tm, scr.imageControl(), scr.screenNumber(), 0, 0, 100, 100)), + m_strut(0), m_layeritem(m_frame->window(), layer), m_layernum(layer.getLayerNum()), m_parent(scr.rootWindow()) { @@ -296,6 +298,9 @@ FluxboxWindow::~FluxboxWindow() { cerr<<__FILE__<<"("<<__LINE__<<"): curr client = "< m_frame; + Strut *m_strut; + FbTk::XLayerItem m_layeritem; int m_layernum; -- cgit v0.11.2