aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Tab.cc103
-rw-r--r--src/Tab.hh3
2 files changed, 53 insertions, 53 deletions
diff --git a/src/Tab.cc b/src/Tab.cc
index b6f002b..88524ad 100644
--- a/src/Tab.cc
+++ b/src/Tab.cc
@@ -13,18 +13,18 @@
13// 13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: Tab.cc,v 1.19 2002/02/02 18:20:44 pekdon Exp $ 22// $Id: Tab.cc,v 1.20 2002/02/04 06:50:48 fluxgen Exp $
23 23
24#include "Tab.hh" 24#include "Tab.hh"
25 25
26#ifdef HAVE_CONFIG_H 26#ifdef HAVE_CONFIG_H
27# include "../config.h" 27# include "../config.h"
28#endif // HAVE_CONFIG_H 28#endif // HAVE_CONFIG_H
29 29
30#include "i18n.hh" 30#include "i18n.hh"
@@ -92,7 +92,7 @@ Tab::~Tab() {
92//------------------------------------------------- 92//-------------------------------------------------
93void Tab::createTabWindow() { 93void Tab::createTabWindow() {
94 unsigned long attrib_mask = CWBackPixmap | CWBackPixel | CWBorderPixel | 94 unsigned long attrib_mask = CWBackPixmap | CWBackPixel | CWBorderPixel |
95 CWColormap | CWOverrideRedirect | CWEventMask; 95 CWColormap | CWOverrideRedirect | CWEventMask;
96 XSetWindowAttributes attrib; 96 XSetWindowAttributes attrib;
97 attrib.background_pixmap = None; 97 attrib.background_pixmap = None;
98 attrib.background_pixel = attrib.border_pixel = 98 attrib.background_pixel = attrib.border_pixel =
@@ -152,11 +152,10 @@ void Tab::focus() {
152//----------------------------------------- 152//-----------------------------------------
153void Tab::raise() { 153void Tab::raise() {
154 //get first tab 154 //get first tab
155 Tab *first = 0; 155 Tab *tab = 0;
156 first = getFirst(this);
157 //raise tabs 156 //raise tabs
158 for (; first!=0; first = first->m_next) 157 for (tab = getFirst(this); tab!=0; tab = tab->m_next)
159 m_win->getScreen()->raiseWindows(&first->m_tabwin, 1); 158 m_win->getScreen()->raiseWindows(&tab->m_tabwin, 1);
160} 159}
161 160
162//-------------- lower -------------------- 161//-------------- lower --------------------
@@ -165,9 +164,9 @@ void Tab::raise() {
165//----------------------------------------- 164//-----------------------------------------
166void Tab::lower() { 165void Tab::lower() {
167 Tab *current = this; 166 Tab *current = this;
168 FluxboxWindow *win = 0; //convinence 167 FluxboxWindow *win = 0; //convenience
169 //this have to be done in the correct order, otherwise we'll switch the window 168 //this have to be done in the correct order, otherwise we'll switch the window
170 //beeing ontop in the group 169 //being ontop in the group
171 do { 170 do {
172 XLowerWindow(m_display, current->m_tabwin); //lower tabwin and tabs window 171 XLowerWindow(m_display, current->m_tabwin); //lower tabwin and tabs window
173 win = current->getWindow(); 172 win = current->getWindow();
@@ -191,42 +190,43 @@ void Tab::loadTheme() {
191 Pixmap tmp = m_focus_pm; 190 Pixmap tmp = m_focus_pm;
192 BTexture *texture = &(m_win->getScreen()->getWindowStyle()->tab.l_focus); 191 BTexture *texture = &(m_win->getScreen()->getWindowStyle()->tab.l_focus);
193 192
194 if (texture->getTexture() & BImage::PARENTRELATIVE ) { 193 if (texture->getTexture() & BImage::PARENTRELATIVE ) {
195 BTexture *pt = &(m_win->getScreen()->getWindowStyle()->tab.t_focus); 194 BTexture *pt = &(m_win->getScreen()->getWindowStyle()->tab.t_focus);
196 if (pt->getTexture() == (BImage::FLAT | BImage::SOLID)) { 195 if (pt->getTexture() == (BImage::FLAT | BImage::SOLID)) {
197 m_focus_pm = None; 196 m_focus_pm = None;
198 m_focus_pixel = pt->getColor()->getPixel(); 197 m_focus_pixel = pt->getColor()->getPixel();
199 } else 198 } else
200 m_focus_pm = 199 m_focus_pm =
201 image_ctrl->renderImage(m_size_w, m_size_h, pt); 200 image_ctrl->renderImage(m_size_w, m_size_h, pt);
202 if (tmp) image_ctrl->removeImage(tmp); 201
203 202 if (tmp) image_ctrl->removeImage(tmp);
203
204 } else { 204 } else {
205 if (texture->getTexture() == (BImage::FLAT | BImage::SOLID)) { 205 if (texture->getTexture() == (BImage::FLAT | BImage::SOLID)) {
206 m_focus_pm = None; 206 m_focus_pm = None;
207 m_focus_pixel = texture->getColor()->getPixel(); 207 m_focus_pixel = texture->getColor()->getPixel();
208 } else 208 } else
209 m_focus_pm = 209 m_focus_pm =
210 image_ctrl->renderImage(m_size_w, m_size_h, texture); 210 image_ctrl->renderImage(m_size_w, m_size_h, texture);
211 if (tmp) image_ctrl->removeImage(tmp); 211 if (tmp) image_ctrl->removeImage(tmp);
212 } 212 }
213 213
214 tmp = m_unfocus_pm; 214 tmp = m_unfocus_pm;
215 texture = &(m_win->getScreen()->getWindowStyle()->tab.l_unfocus); 215 texture = &(m_win->getScreen()->getWindowStyle()->tab.l_unfocus);
216 216
217 if (texture->getTexture() & BImage::PARENTRELATIVE ) { 217 if (texture->getTexture() & BImage::PARENTRELATIVE ) {
218 BTexture *pt = &(m_win->getScreen()->getWindowStyle()->tab.t_unfocus); 218 BTexture *pt = &(m_win->getScreen()->getWindowStyle()->tab.t_unfocus);
219 if (pt->getTexture() == (BImage::FLAT | BImage::SOLID)) { 219 if (pt->getTexture() == (BImage::FLAT | BImage::SOLID)) {
220 m_unfocus_pm = None; 220 m_unfocus_pm = None;
221 m_unfocus_pixel = pt->getColor()->getPixel(); 221 m_unfocus_pixel = pt->getColor()->getPixel();
222 } else 222 } else
223 m_unfocus_pm = 223 m_unfocus_pm =
224 image_ctrl->renderImage(m_size_w, m_size_h, pt); 224 image_ctrl->renderImage(m_size_w, m_size_h, pt);
225 } else { 225 } else {
226 if (texture->getTexture() == (BImage::FLAT | BImage::SOLID)) { 226 if (texture->getTexture() == (BImage::FLAT | BImage::SOLID)) {
227 m_unfocus_pm = None; 227 m_unfocus_pm = None;
228 m_unfocus_pixel = texture->getColor()->getPixel(); 228 m_unfocus_pixel = texture->getColor()->getPixel();
229 } else 229 } else
230 m_unfocus_pm = 230 m_unfocus_pm =
231 image_ctrl->renderImage(m_size_w, m_size_h, texture); 231 image_ctrl->renderImage(m_size_w, m_size_h, texture);
232 } 232 }
@@ -279,14 +279,14 @@ void Tab::stick() {
279 279
280 //now do stick for all windows in the list 280 //now do stick for all windows in the list
281 for (tab = getFirst(this); tab != 0; tab = tab->m_next) { 281 for (tab = getFirst(this); tab != 0; tab = tab->m_next) {
282 FluxboxWindow *win = tab->m_win; //just for convenient 282 FluxboxWindow *win = tab->m_win; //just for convenience
283 if (win->isStuck()) { 283 if (win->isStuck()) {
284 win->blackbox_attrib.flags ^= BaseDisplay::ATTRIB_OMNIPRESENT; 284 win->blackbox_attrib.flags ^= BaseDisplay::ATTRIB_OMNIPRESENT;
285 win->blackbox_attrib.attrib ^= BaseDisplay::ATTRIB_OMNIPRESENT; 285 win->blackbox_attrib.attrib ^= BaseDisplay::ATTRIB_OMNIPRESENT;
286 win->stuck = false; 286 win->stuck = false;
287 if (!win->isIconic()) 287 if (!win->isIconic())
288 win->getScreen()->reassociateWindow(win, -1, true); 288 win->getScreen()->reassociateWindow(win, -1, true);
289 289
290 } else { 290 } else {
291 win->stuck = true; 291 win->stuck = true;
292 win->blackbox_attrib.flags |= BaseDisplay::ATTRIB_OMNIPRESENT; 292 win->blackbox_attrib.flags |= BaseDisplay::ATTRIB_OMNIPRESENT;
@@ -351,7 +351,7 @@ void Tab::draw(bool pressed) {
351 unsigned int tabtext_w; 351 unsigned int tabtext_w;
352 352
353 GC gc = ((m_win->isFocused()) ? m_win->getScreen()->getWindowStyle()->tab.l_text_focus_gc : 353 GC gc = ((m_win->isFocused()) ? m_win->getScreen()->getWindowStyle()->tab.l_text_focus_gc :
354 m_win->getScreen()->getWindowStyle()->tab.l_text_unfocus_gc); 354 m_win->getScreen()->getWindowStyle()->tab.l_text_unfocus_gc);
355 355
356 // Different routines for drawing rotated text 356 // Different routines for drawing rotated text
357 if ((m_win->getScreen()->getTabPlacement() == PLEFT || 357 if ((m_win->getScreen()->getTabPlacement() == PLEFT ||
@@ -543,7 +543,7 @@ void Tab::calcIncrease(void) {
543 543
544 Tab *tab; 544 Tab *tab;
545 int inc_x = 0, inc_y = 0; 545 int inc_x = 0, inc_y = 0;
546 unsigned int tabs = 0, i = 0; 546 unsigned int i = 0, tabs = numObjects();
547 547
548 if (m_win->getScreen()->getTabPlacement() == PTOP || 548 if (m_win->getScreen()->getTabPlacement() == PTOP ||
549 m_win->getScreen()->getTabPlacement() == PBOTTOM || 549 m_win->getScreen()->getTabPlacement() == PBOTTOM ||
@@ -588,9 +588,7 @@ void Tab::calcIncrease(void) {
588 } 588 }
589 } 589 }
590 590
591 for (tab = getFirst(this); tab!=0; tab = tab->m_next, tabs++); 591 for (tab = getFirst(this); tab!=0; tab = tab->m_next, i++) {
592
593 for (tab = getFirst(this); tab!=0; tab = tab->m_next, i++){
594 592
595 //TODO: move this out from here? 593 //TODO: move this out from here?
596 if ((m_win->getScreen()->getTabPlacement() == PTOP || 594 if ((m_win->getScreen()->getTabPlacement() == PTOP ||
@@ -672,7 +670,7 @@ void Tab::buttonReleaseEvent(XButtonEvent *be) {
672 m_win->getScreen()->getRootWindow(), 670 m_win->getScreen()->getRootWindow(),
673 be->x_root, be->y_root, &dest_x, &dest_y, &child)) { 671 be->x_root, be->y_root, &dest_x, &dest_y, &child)) {
674 672
675 Tab *tab = Fluxbox::instance()->searchTab(child); 673 Tab *tab = Fluxbox::instance()->searchTab(child);
676 FluxboxWindow *win = Fluxbox::instance()->searchWindow(child); 674 FluxboxWindow *win = Fluxbox::instance()->searchWindow(child);
677 //search tablist for a tabwindow 675 //search tablist for a tabwindow
678 if ( (tab!=0) || (m_win->getScreen()->isSloppyWindowGrouping() && 676 if ( (tab!=0) || (m_win->getScreen()->isSloppyWindowGrouping() &&
@@ -1067,16 +1065,23 @@ unsigned int Tab::calcRelativeWidth() {
1067 return ((m_win->getWidth() + m_win->getScreen()->getBorderWidth2x())/num); 1065 return ((m_win->getWidth() + m_win->getScreen()->getBorderWidth2x())/num);
1068} 1066}
1069 1067
1068//--------------- numObjects -------------------
1069// Returns the number of objects in
1070// the TabGroup.
1071//-----------------------------------------------
1072unsigned int Tab::numObjects() {
1073 unsigned int num = 0;
1074 for (Tab *tab = getFirst(this); tab != 0; tab = tab->m_next, num++);
1075 return num;
1076}
1077
1070//------------- calcRelativeHeight ------- 1078//------------- calcRelativeHeight -------
1071// Returns: Calculated height for relative 1079// Returns: Calculated height for relative
1072// alignment 1080// alignment
1073//---------------------------------------- 1081//----------------------------------------
1074unsigned int Tab::calcRelativeHeight() { 1082unsigned int Tab::calcRelativeHeight() {
1075 unsigned int num=0; 1083 return ((m_win->getHeight() +
1076 //calculate num objs in list (extract this to a function?) 1084 m_win->getScreen()->getBorderWidth2x())/numObjects());
1077 for (Tab *first=getFirst(this); first!=0; first=first->m_next, num++);
1078
1079 return ((m_win->getHeight() + m_win->getScreen()->getBorderWidth2x())/num);
1080} 1085}
1081 1086
1082//------------- calcCenterXPos ----------- 1087//------------- calcCenterXPos -----------
@@ -1084,11 +1089,8 @@ unsigned int Tab::calcRelativeHeight() {
1084// centered alignment 1089// centered alignment
1085//---------------------------------------- 1090//----------------------------------------
1086unsigned int Tab::calcCenterXPos() { 1091unsigned int Tab::calcCenterXPos() {
1087 unsigned int num=0; 1092 return (m_win->getXFrame() + ((m_win->getWidth() -
1088 //calculate num objs in list (extract this to a function?) 1093 (m_size_w * numObjects())) / 2));
1089 for (Tab *first=getFirst(this); first!=0; first=first->m_next, num++);
1090
1091 return (m_win->getXFrame() + ((m_win->getWidth() - (m_size_w * num)) / 2));
1092} 1094}
1093 1095
1094//------------- calcCenterYPos ----------- 1096//------------- calcCenterYPos -----------
@@ -1096,11 +1098,8 @@ unsigned int Tab::calcCenterXPos() {
1096// centered alignment 1098// centered alignment
1097//---------------------------------------- 1099//----------------------------------------
1098unsigned int Tab::calcCenterYPos() { 1100unsigned int Tab::calcCenterYPos() {
1099 unsigned int num=0; 1101 return (m_win->getYFrame() + ((m_win->getHeight() -
1100 //calculate num objs in list (extract this to a function?) 1102 (m_size_h * numObjects())) / 2));
1101 for (Tab *first=getFirst(this); first!=0; first=first->m_next, num++);
1102
1103 return (m_win->getYFrame() + ((m_win->getHeight() - (m_size_h * num)) / 2));
1104} 1103}
1105 1104
1106 1105
diff --git a/src/Tab.hh b/src/Tab.hh
index 2784365..4f3af12 100644
--- a/src/Tab.hh
+++ b/src/Tab.hh
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: Tab.hh,v 1.9 2002/01/27 12:52:02 fluxgen Exp $ 22// $Id: Tab.hh,v 1.10 2002/02/04 06:51:15 fluxgen Exp $
23 23
24#ifndef _TAB_HH_ 24#ifndef _TAB_HH_
25#define _TAB_HH_ 25#define _TAB_HH_
@@ -100,6 +100,7 @@ private:
100 int setPositionLRAlignHelper(Alignment align); 100 int setPositionLRAlignHelper(Alignment align);
101 void setTabWidth(unsigned int w); 101 void setTabWidth(unsigned int w);
102 void setTabHeight(unsigned int h); 102 void setTabHeight(unsigned int h);
103 unsigned int numObjects();
103 unsigned int calcRelativeWidth(); 104 unsigned int calcRelativeWidth();
104 unsigned int calcRelativeHeight(); 105 unsigned int calcRelativeHeight();
105 unsigned int calcCenterXPos(); 106 unsigned int calcCenterXPos();