added strut support

This commit is contained in:
fluxgen 2003-06-18 13:55:17 +00:00
parent 501168b557
commit e3ab62fed1
6 changed files with 147 additions and 12 deletions

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // 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" #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 "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR", False)), //KDE v2.x
m_layeritem(0), m_layeritem(0),
m_slit_theme(new SlitTheme(*this)) { m_slit_theme(new SlitTheme(*this)),
m_strut(0) {
// default placement and direction // default placement and direction
m_direction = screen().getSlitDirection(); m_direction = screen().getSlitDirection();
@ -339,10 +340,65 @@ Slit::Slit(BScreen &scr, FbTk::XLayer &layer, const char *filename)
Slit::~Slit() { Slit::~Slit() {
clearStrut();
if (frame.pixmap != 0) if (frame.pixmap != 0)
screen().imageControl().removeImage(frame.pixmap); 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) { void Slit::addClient(Window w) {
#ifdef DEBUG #ifdef DEBUG
@ -777,6 +833,7 @@ void Slit::reconfigure() {
m_slitmenu.reconfigure(); m_slitmenu.reconfigure();
updateClientmenu(); updateClientmenu();
updateStrut();
} }

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // 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 #ifndef SLIT_HH
#define SLIT_HH #define SLIT_HH
@ -44,6 +44,7 @@ class SlitTheme;
class SlitClient; class SlitClient;
class BScreen; class BScreen;
class FbMenu; class FbMenu;
class Strut;
/// Handles dock apps /// Handles dock apps
class Slit : public FbTk::TimeoutHandler, public FbTk::EventHandler { class Slit : public FbTk::TimeoutHandler, public FbTk::EventHandler {
@ -117,6 +118,8 @@ private:
void removeClient(SlitClient *client, bool remap, bool destroy); void removeClient(SlitClient *client, bool remap, bool destroy);
void loadClientList(const char *filename); void loadClientList(const char *filename);
void updateClientmenu(); void updateClientmenu();
void clearStrut();
void updateStrut();
bool m_hidden, m_do_auto_hide; bool m_hidden, m_do_auto_hide;
Direction m_direction; Direction m_direction;
@ -147,6 +150,7 @@ private:
std::auto_ptr<SlitTheme> m_slit_theme; std::auto_ptr<SlitTheme> m_slit_theme;
std::auto_ptr<FbTk::Transparent> m_transp; std::auto_ptr<FbTk::Transparent> m_transp;
static unsigned int s_eventmask; static unsigned int s_eventmask;
Strut *m_strut;
}; };

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // 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" #include "Toolbar.hh"
@ -43,6 +43,7 @@
#include "BoolMenuItem.hh" #include "BoolMenuItem.hh"
#include "FbWinFrameTheme.hh" #include "FbWinFrameTheme.hh"
#include "Xinerama.hh" #include "Xinerama.hh"
#include "Strut.hh"
// use GNU extensions // use GNU extensions
#ifndef _GNU_SOURCE #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_theme(scrn.screenNumber()),
m_place(scrn.toolbarPlacement()), m_place(scrn.toolbarPlacement()),
m_themelistener(*this), 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 // we need to get notified when the theme is reloaded
m_theme.addListener(m_themelistener); m_theme.addListener(m_themelistener);
@ -339,6 +341,7 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, FbTk::Menu &menu, size_t wi
Toolbar::~Toolbar() { Toolbar::~Toolbar() {
clearStrut();
FbTk::ImageControl &image_ctrl = screen().imageControl(); FbTk::ImageControl &image_ctrl = screen().imageControl();
if (frame.base) image_ctrl.removeImage(frame.base); if (frame.base) image_ctrl.removeImage(frame.base);
if (frame.label) image_ctrl.removeImage(frame.label); 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 { bool Toolbar::isVertical() const {
return (m_place == RIGHTCENTER || return (m_place == RIGHTCENTER ||
m_place == RIGHTTOP || m_place == RIGHTTOP ||
@ -702,7 +747,9 @@ void Toolbar::reconfigure() {
checkClock(true); checkClock(true);
m_toolbarmenu.reconfigure(); m_toolbarmenu.reconfigure();
// we're done with all resizing and stuff now we can request a new
// area to be reserv on screen
updateStrut();
} }

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // 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 #ifndef TOOLBAR_HH
#define TOOLBAR_HH #define TOOLBAR_HH
@ -42,6 +42,8 @@
#include <memory> #include <memory>
class BScreen; class BScreen;
class Strut;
namespace FbTk { namespace FbTk {
class ImageControl; class ImageControl;
}; };
@ -133,6 +135,8 @@ public:
private: private:
void clearStrut();
void updateStrut();
bool editing; ///< edit workspace label mode bool editing; ///< edit workspace label mode
bool hidden; ///< hidden state bool hidden; ///< hidden state
@ -189,6 +193,8 @@ private:
ThemeListener m_themelistener; ThemeListener m_themelistener;
FbTk::XLayerItem m_layeritem; FbTk::XLayerItem m_layeritem;
Strut *m_strut; ///< created and destroyed by BScreen
}; };

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // 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" #include "Window.hh"
@ -246,6 +246,7 @@ FluxboxWindow::FluxboxWindow(WinClient &client, BScreen &scr, FbWinFrameTheme &t
m_old_decoration(DECOR_NORMAL), m_old_decoration(DECOR_NORMAL),
m_client(&client), m_client(&client),
m_frame(new FbWinFrame(tm, scr.imageControl(), scr.screenNumber(), 0, 0, 100, 100)), m_frame(new FbWinFrame(tm, scr.imageControl(), scr.screenNumber(), 0, 0, 100, 100)),
m_strut(0),
m_layeritem(m_frame->window(), layer), m_layeritem(m_frame->window(), layer),
m_layernum(layer.getLayerNum()), m_layernum(layer.getLayerNum()),
m_parent(scr.rootWindow()) { m_parent(scr.rootWindow()) {
@ -279,6 +280,7 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen &scr, FbWinFrameTheme &tm,
m_old_decoration(DECOR_NORMAL), m_old_decoration(DECOR_NORMAL),
m_client(new WinClient(w, *this)), m_client(new WinClient(w, *this)),
m_frame(new FbWinFrame(tm, scr.imageControl(), scr.screenNumber(), 0, 0, 100, 100)), m_frame(new FbWinFrame(tm, scr.imageControl(), scr.screenNumber(), 0, 0, 100, 100)),
m_strut(0),
m_layeritem(m_frame->window(), layer), m_layeritem(m_frame->window(), layer),
m_layernum(layer.getLayerNum()), m_layernum(layer.getLayerNum()),
m_parent(scr.rootWindow()) { m_parent(scr.rootWindow()) {
@ -296,6 +298,9 @@ FluxboxWindow::~FluxboxWindow() {
cerr<<__FILE__<<"("<<__LINE__<<"): curr client = "<<m_client<<endl; cerr<<__FILE__<<"("<<__LINE__<<"): curr client = "<<m_client<<endl;
cerr<<__FILE__<<"("<<__LINE__<<"): m_labelbuttons.size = "<<m_labelbuttons.size()<<endl; cerr<<__FILE__<<"("<<__LINE__<<"): m_labelbuttons.size = "<<m_labelbuttons.size()<<endl;
#endif // DEBUG #endif // DEBUG
clearStrut();
if (moving || resizing || m_attaching_tab) { if (moving || resizing || m_attaching_tab) {
screen().hideGeometry(); screen().hideGeometry();
XUngrabPointer(display, CurrentTime); XUngrabPointer(display, CurrentTime);
@ -1989,8 +1994,6 @@ void FluxboxWindow::handleEvent(XEvent &event) {
} }
break; break;
default: default:
#ifdef SHAPE #ifdef SHAPE
if (Fluxbox::instance()->haveShape() && if (Fluxbox::instance()->haveShape() &&
@ -2714,6 +2717,18 @@ void FluxboxWindow::toggleDecoration() {
} }
} }
void FluxboxWindow::setStrut(Strut *strut) {
clearStrut();
m_strut = strut;
}
void FluxboxWindow::clearStrut() {
if (m_strut != 0) {
screen().clearStrut(m_strut);
m_strut = 0;
}
}
unsigned int FluxboxWindow::decorationMask() const { unsigned int FluxboxWindow::decorationMask() const {
unsigned int ret = 0; unsigned int ret = 0;
if (decorations.titlebar) if (decorations.titlebar)

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: Window.hh,v 1.78 2003/06/15 18:34:48 fluxgen Exp $ // $Id: Window.hh,v 1.79 2003/06/18 13:55:16 fluxgen Exp $
#ifndef WINDOW_HH #ifndef WINDOW_HH
#define WINDOW_HH #define WINDOW_HH
@ -44,9 +44,10 @@
class WinClient; class WinClient;
class FbWinFrameTheme; class FbWinFrameTheme;
class BScreen; class BScreen;
class Strut;
class TextButton; class TextButton;
class FbWinFrame; class FbWinFrame;
namespace FbTk { namespace FbTk {
class MenuTheme; class MenuTheme;
class ImageControl; class ImageControl;
@ -242,6 +243,9 @@ public:
DECORM_LAST = (1<<11) // useful for getting "All" DECORM_LAST = (1<<11) // useful for getting "All"
}; };
void setStrut(Strut *strut);
void clearStrut();
unsigned int decorationMask() const; unsigned int decorationMask() const;
void setDecorationMask(unsigned int mask); void setDecorationMask(unsigned int mask);
@ -441,6 +445,8 @@ private:
m_last_button_y; ///< last known y position of the mouse button m_last_button_y; ///< last known y position of the mouse button
std::auto_ptr<FbWinFrame> m_frame; std::auto_ptr<FbWinFrame> m_frame;
Strut *m_strut;
FbTk::XLayerItem m_layeritem; FbTk::XLayerItem m_layeritem;
int m_layernum; int m_layernum;