all repos — fluxbox @ 53ad4872bddb861f39d82d3abb94f86f585b2439

custom fork of the fluxbox windowmanager

clean up
fluxgen fluxgen
commit

53ad4872bddb861f39d82d3abb94f86f585b2439

parent

1aa01577abf19c6073e9599fdddb13596360fa3a

2 files changed, 157 insertions(+), 103 deletions(-)

jump to
M src/Tab.ccsrc/Tab.cc

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Tab.cc,v 1.17 2002/01/26 11:16:25 fluxgen Exp $ +// $Id: Tab.cc,v 1.18 2002/01/27 12:52:02 fluxgen Exp $ #include "Tab.hh"

@@ -275,14 +275,11 @@ //------------ stick --------------------

// Set/reset the the sticky on all windows in the list //--------------------------------------- void Tab::stick() { + Tab *tab; - //get first tab - Tab *first = 0; - first = getFirst(this); - //now do stick for all windows in the list - for (; first!=0; first = first->m_next) { - FluxboxWindow *win = first->m_win; //just for convenient + for (tab = getFirst(this); tab != 0; tab = tab->m_next) { + FluxboxWindow *win = tab->m_win; //just for convenient if (win->isStuck()) { win->blackbox_attrib.flags ^= BaseDisplay::ATTRIB_OMNIPRESENT; win->blackbox_attrib.attrib ^= BaseDisplay::ATTRIB_OMNIPRESENT;

@@ -305,12 +302,12 @@ //------------- resize -------------

// Resize the window's in the tablist //---------------------------------- void Tab::resize() { - Tab *first = getFirst(this); + Tab *tab; //now move and resize the windows in the list - for (; first != 0; first = first->m_next) { - if (first!=this) { - first->m_win->configure(m_win->getXFrame(), m_win->getYFrame(), + for (tab = getFirst(this); tab != 0; tab = tab->m_next) { + if (tab!=this) { + tab->m_win->configure(m_win->getXFrame(), m_win->getYFrame(), m_win->getWidth(), m_win->getHeight()); } }

@@ -326,10 +323,12 @@ //----------- shade --------------

// Shades the windows in the tablist //-------------------------------- void Tab::shade() { - for(Tab *first = getFirst(this); first != 0; first = first->m_next) { - if (first==this) + Tab *tab; + + for(tab = getFirst(this); tab != 0; tab = tab->m_next) { + if (tab==this) continue; - first->m_win->shade(); + tab->m_win->shade(); } if (m_win->getScreen()->getTabPlacement() == PLEFT ||

@@ -390,6 +389,75 @@ m_win->frame.bevel_w, m_win->client.title);

} } +//----------------------------------------------- +//Helper for the Tab::setPosition() call +//returns the y position component correctly +//according to shading in cases PBOTTOM and +//isShaded() +//----------------------------------------------- +int Tab::setPositionShadingHelper(bool shaded) { + if (shaded) { + return m_win->getYFrame() + m_win->getTitleHeight() + + m_win->getScreen()->getBorderWidth2x(); + } else { + return m_win->getYFrame() + m_win->getHeight() + + m_win->getScreen()->getBorderWidth2x(); + } +} + +//----------------------------------------------- +//Helpers for correct alignment of tabs used +//by the setPosition() call +//return x/y positions correctly according to +//alignment, the 1st for cases PTOP and PBOTTOM +//the 2nd for cases PLEFT and PRIGHT +//----------------------------------------------- +int Tab::setPositionTBAlignHelper(Alignment align) { + switch(align) { + + case ARELATIVE: + case ALEFT: + return m_win->getXFrame(); + break; + case ACENTER: + return calcCenterXPos(); + break; + case ARIGHT: + return m_win->getXFrame() + m_win->getWidth() + + m_win->getScreen()->getBorderWidth2x() - m_size_w; + default: +#ifdef DEBUG + cerr << __FILE__ << ":" <<__LINE__ << ": " << + "Unsupported Alignment" << endl; +#endif //DEBUG + return 0; + break; + } +} + +int Tab::setPositionLRAlignHelper(Alignment align) { + switch(align) { + case ALEFT: + return m_win->getYFrame() - m_size_h + m_win->getHeight() + + m_win->getScreen()->getBorderWidth2x(); + break; + case ACENTER: + return calcCenterYPos(); + break; + case ARELATIVE: + case ARIGHT: + return m_win->getYFrame(); + break; + default: +#ifdef DEBUG + cerr << __FILE__ << ":"<< __LINE__ << ": " << + "Unsupported Alignment" << endl; +#endif //DEBUG + return 0; + break; + } +} + //------------- setPosition ----------------- // Position tab ( follow the m_win pos ). // (and resize)

@@ -400,85 +468,62 @@ //don't do anything if the tablist is freezed

if (m_stoptabs) return; - Tab *first = 0; + Tab *tab; int pos_x = 0, pos_y = 0; m_stoptabs = true; //freeze tablist //and check for max tabs - //TODO: optimize! There is many ways to implement this... - //posible movement to a static member function - //Tab placement - if (m_win->getScreen()->getTabPlacement() == PTOP) { - pos_y = m_win->getYFrame() - m_size_h; - - } else if (m_win->getScreen()->getTabPlacement() == PBOTTOM || - m_win->isShaded()) { - if (m_win->isShaded()) - pos_y = m_win->getYFrame() + m_win->getTitleHeight() + - m_win->getScreen()->getBorderWidth2x(); - - else - pos_y = m_win->getYFrame() + m_win->getHeight() + - m_win->getScreen()->getBorderWidth2x(); - - } else if (m_win->getScreen()->getTabPlacement() == PLEFT) { + //Tab placement + alignment + switch (m_win->getScreen()->getTabPlacement()) { + case PTOP: + pos_y = m_win->getYFrame() - m_size_h; + pos_x = setPositionTBAlignHelper( + m_win->getScreen()->getTabAlignment()); + break; + case PBOTTOM: + pos_y = setPositionShadingHelper(m_win->isShaded()); + pos_x = setPositionTBAlignHelper( + m_win->getScreen()->getTabAlignment()); + break; + case PLEFT: pos_x = m_win->getXFrame() - m_size_w; - - } else if (m_win->getScreen()->getTabPlacement() == PRIGHT) { - pos_x = m_win->getXFrame() + m_win->getWidth() + - m_win->getScreen()->getBorderWidth2x(); + pos_y = setPositionLRAlignHelper( + m_win->getScreen()->getTabAlignment()); + break; + case PRIGHT: + pos_x = m_win->getXFrame() + m_win->getWidth() + + m_win->getScreen()->getBorderWidth2x(); + pos_y = setPositionLRAlignHelper( + m_win->getScreen()->getTabAlignment()); + break; + default: + if(m_win->isShaded()) { + pos_y = setPositionShadingHelper(true); + pos_x = setPositionTBAlignHelper( + m_win->getScreen()->getTabAlignment()); + } else { + setPositionShadingHelper(false); + } + break; } - //Tab alignment - if (m_win->getScreen()->getTabPlacement() == PTOP || - m_win->getScreen()->getTabPlacement() == PBOTTOM || - m_win->isShaded()) { - switch(m_win->getScreen()->getTabAlignment()) { - case ARELATIVE: - case ALEFT: - pos_x = m_win->getXFrame(); - break; - case ACENTER: - pos_x = calcCenterXPos(); - break; - case ARIGHT: - pos_x = m_win->getXFrame() + m_win->getWidth() + - m_win->getScreen()->getBorderWidth2x() - m_size_w; - break; - } - } else { //PLeft | PRight - switch(m_win->getScreen()->getTabAlignment()) { - case ALEFT: - pos_y = m_win->getYFrame() - m_size_h + m_win->getHeight() + - m_win->getScreen()->getBorderWidth2x(); - break; - case ACENTER: - pos_y = calcCenterYPos(); - break; - case ARELATIVE: - case ARIGHT: - pos_y = m_win->getYFrame(); - break; - } - } - - for (first = getFirst(this); - first!=0; - pos_x += first->m_inc_x, pos_y += first->m_inc_y, - first = first->m_next){ + for (tab = getFirst(this); + tab!=0; + pos_x += tab->m_inc_x, pos_y += tab->m_inc_y, + tab = tab->m_next){ - XMoveWindow(m_display, first->m_tabwin, pos_x, pos_y); + XMoveWindow(m_display, tab->m_tabwin, pos_x, pos_y); - //dont move fluxboxwindow if the itterator = this - if (first!=this) { - first->m_win->configure(m_win->getXFrame(), m_win->getYFrame(), + //dont move FluxboxWindow if the iterator = this + if (tab!=this) { + tab->m_win->configure(m_win->getXFrame(), m_win->getYFrame(), m_win->getWidth(), m_win->getHeight()); } } - - m_stoptabs = false; + + m_stoptabs = false;//thaw tablist } //------------- calcIncrease ----------------

@@ -490,7 +535,7 @@ #ifdef DEBUG

cerr << "Calculating tab increase" << endl; #endif // DEBUG - Tab *first; + Tab *tab; int inc_x = 0, inc_y = 0; unsigned int tabs = 0, i = 0;

@@ -511,6 +556,8 @@ inc_x = -m_size_w;

break; case ARELATIVE: inc_x = calcRelativeWidth(); + break; + default: break; } } else if (m_win->getScreen()->getTabPlacement() == PLEFT ||

@@ -530,12 +577,14 @@ break;

case ARELATIVE: inc_y = calcRelativeHeight(); break; + default: + break; } } - for (first = getFirst(this); first!=0; first = first->m_next, tabs++); + for (tab = getFirst(this); tab!=0; tab = tab->m_next, tabs++); - for (first = getFirst(this); first!=0; first = first->m_next, i++){ + for (tab = getFirst(this); tab!=0; tab = tab->m_next, i++){ //TODO: move this out from here? if ((m_win->getScreen()->getTabPlacement() == PTOP ||

@@ -546,30 +595,30 @@ if (!((m_win->getWidth() +

m_win->getScreen()->getBorderWidth2x()) % tabs) || i >= ((m_win->getWidth() + m_win->getScreen()->getBorderWidth2x()) % tabs)) { - first->setTabWidth(inc_x); - first->m_inc_x = inc_x; + tab->setTabWidth(inc_x); + tab->m_inc_x = inc_x; } else { // adding 1 extra pixel to get tabs like win width - first->setTabWidth(inc_x + 1); - first->m_inc_x = inc_x + 1; + tab->setTabWidth(inc_x + 1); + tab->m_inc_x = inc_x + 1; } - first->m_inc_y = inc_y; + tab->m_inc_y = inc_y; } else if (m_win->getScreen()->getTabAlignment() == ARELATIVE) { if (!((m_win->getHeight() + m_win->getScreen()->getBorderWidth2x()) % tabs) || i >= ((m_win->getHeight() + m_win->getScreen()->getBorderWidth2x()) % tabs)) { - first->setTabHeight(inc_y); - first->m_inc_y = inc_y; + tab->setTabHeight(inc_y); + tab->m_inc_y = inc_y; } else { // adding 1 extra pixel to get tabs match window width - first->setTabHeight(inc_y + 1); - first->m_inc_y = inc_y + 1; + tab->setTabHeight(inc_y + 1); + tab->m_inc_y = inc_y + 1; } - first->m_inc_x = inc_x; + tab->m_inc_x = inc_x; } else { // non relative modes - first->m_inc_x = inc_x; - first->m_inc_y = inc_y; + tab->m_inc_x = inc_x; + tab->m_inc_y = inc_y; } } }

@@ -617,13 +666,11 @@ if (XTranslateCoordinates(m_display, m_win->getScreen()->getRootWindow(),

m_win->getScreen()->getRootWindow(), be->x_root, be->y_root, &dest_x, &dest_y, &child)) { - Tab *tab = 0; - FluxboxWindow *win = 0; + Tab *tab = Fluxbox::instance()->searchTab(child); + FluxboxWindow *win = Fluxbox::instance()->searchWindow(child); //search tablist for a tabwindow - if (((tab = Fluxbox::instance()->searchTab(child))!=0) || - (m_win->getScreen()->isSloppyWindowGrouping() && - ((win = Fluxbox::instance()->searchWindow(child))!=0) && - (tab = win->getTab())!=0)) { + if ( (tab!=0) || (m_win->getScreen()->isSloppyWindowGrouping() && + (win!=0) && (tab = win->getTab())!=0)) { if (tab == this) // inserting ourself to ourself causes a disconnect return;

@@ -639,7 +686,7 @@

} else { disconnect(); - // convinience + // convenience unsigned int placement = m_win->getScreen()->getTabPlacement(); // (ab)using dest_x and dest_y

@@ -661,6 +708,8 @@ break;

case ARIGHT: dest_x -= m_win->getWidth() - m_size_w; break; + default: + break; } } else { // PLEFT & PRIGHT

@@ -673,6 +722,8 @@ dest_y -= (m_win->getHeight() / 2) - (m_size_h / 2);

break; case ALEFT: dest_y -= m_win->getHeight() - m_size_h; + break; + default: break; } }

@@ -979,7 +1030,7 @@ // PLeft || PRight && isTabRotateVertical

// --------------------------------------- void Tab::resizeGroup(void) { #ifdef DEBUG - cerr << "Resising group" << endl; + cerr <<__FILE__<<"("<<__LINE__<<"): Resizing group"<<endl; #endif //DEBUG Tab *first; for (first = getFirst(this); first != 0; first = first->m_next) {
M src/Tab.hhsrc/Tab.hh

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Tab.hh,v 1.8 2002/01/20 02:15:23 fluxgen Exp $ +// $Id: Tab.hh,v 1.9 2002/01/27 12:52:02 fluxgen Exp $ #ifndef _TAB_HH_ #define _TAB_HH_

@@ -95,6 +95,9 @@ static const int m_max_tabs;

bool m_focus, m_moving; // moving and focus void createTabWindow(); // creates the X win of tab void loadTheme(); // loads the textures with right width and height + int setPositionShadingHelper(bool shaded); + int setPositionTBAlignHelper(Alignment align); + int setPositionLRAlignHelper(Alignment align); void setTabWidth(unsigned int w); void setTabHeight(unsigned int h); unsigned int calcRelativeWidth();