aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/FbWinFrame.cc118
-rw-r--r--src/IconButton.cc4
2 files changed, 62 insertions, 60 deletions
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc
index 5501413..873276f 100644
--- a/src/FbWinFrame.cc
+++ b/src/FbWinFrame.cc
@@ -52,14 +52,15 @@ namespace {
52 52
53enum { UNFOCUS = 0, FOCUS, PRESSED }; 53enum { UNFOCUS = 0, FOCUS, PRESSED };
54 54
55const long _mask = ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | EnterWindowMask | LeaveWindowMask; 55const int s_button_size = 26;
56const long s_mask = ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | EnterWindowMask | LeaveWindowMask;
56 57
57const struct { 58const struct {
58 FbWinFrame::TabPlacement where; 59 FbWinFrame::TabPlacement where;
59 FbTk::Orientation orient; 60 FbTk::Orientation orient;
60 FbTk::Container::Alignment align; 61 FbTk::Container::Alignment align;
61 bool is_horizontal; 62 bool is_horizontal;
62} _values[] = { 63} s_place[] = {
63 { /* unused */ }, 64 { /* unused */ },
64 { FbWinFrame::TOPLEFT, FbTk::ROT0, FbTk::Container::LEFT, true }, 65 { FbWinFrame::TOPLEFT, FbTk::ROT0, FbTk::Container::LEFT, true },
65 { FbWinFrame::TOP, FbTk::ROT0, FbTk::Container::CENTER, true }, 66 { FbWinFrame::TOP, FbTk::ROT0, FbTk::Container::CENTER, true },
@@ -112,30 +113,30 @@ FbWinFrame::FbWinFrame(BScreen &screen, unsigned int client_depth,
112 m_theme(theme), 113 m_theme(theme),
113 m_imagectrl(screen.imageControl()), 114 m_imagectrl(screen.imageControl()),
114 m_state(state), 115 m_state(state),
115 m_window(theme->screenNum(), state.x, state.y, state.width, state.height, _mask, true, false, 116 m_window(theme->screenNum(), state.x, state.y, state.width, state.height, s_mask, true, false,
116 client_depth, InputOutput, 117 client_depth, InputOutput,
117 ((client_depth == 32) && (screen.rootWindow().depth() == 32) ? screen.rootWindow().visual() : CopyFromParent), 118 ((client_depth == 32) && (screen.rootWindow().depth() == 32) ? screen.rootWindow().visual() : CopyFromParent),
118 ((client_depth == 32) && (screen.rootWindow().depth() == 32) ? screen.rootWindow().colormap() : CopyFromParent)), 119 ((client_depth == 32) && (screen.rootWindow().depth() == 32) ? screen.rootWindow().colormap() : CopyFromParent)),
119 m_layeritem(window(), *screen.layerManager().getLayer(ResourceLayer::NORMAL)), 120 m_layeritem(window(), *screen.layerManager().getLayer(ResourceLayer::NORMAL)),
120 m_titlebar(m_window, 0, 0, 100, 16, _mask, false, false, 121 m_titlebar(m_window, 0, 0, 100, 16, s_mask, false, false,
121 screen.rootWindow().decorationDepth(), InputOutput, 122 screen.rootWindow().decorationDepth(), InputOutput,
122 screen.rootWindow().decorationVisual(), 123 screen.rootWindow().decorationVisual(),
123 screen.rootWindow().decorationColormap()), 124 screen.rootWindow().decorationColormap()),
124 m_tab_container(m_titlebar), 125 m_tab_container(m_titlebar),
125 m_label(m_titlebar, m_theme->font(), FbTk::BiDiString("")), 126 m_label(m_titlebar, m_theme->font(), FbTk::BiDiString("")),
126 m_handle(m_window, 0, 0, 100, 5, _mask, false, false, 127 m_handle(m_window, 0, 0, 100, 5, s_mask, false, false,
127 screen.rootWindow().decorationDepth(), InputOutput, 128 screen.rootWindow().decorationDepth(), InputOutput,
128 screen.rootWindow().decorationVisual(), 129 screen.rootWindow().decorationVisual(),
129 screen.rootWindow().decorationColormap()), 130 screen.rootWindow().decorationColormap()),
130 m_grip_right(m_handle, 0, 0, 10, 4, _mask, false, false, 131 m_grip_right(m_handle, 0, 0, 10, 4, s_mask, false, false,
131 screen.rootWindow().decorationDepth(), InputOutput, 132 screen.rootWindow().decorationDepth(), InputOutput,
132 screen.rootWindow().decorationVisual(), 133 screen.rootWindow().decorationVisual(),
133 screen.rootWindow().decorationColormap()), 134 screen.rootWindow().decorationColormap()),
134 m_grip_left(m_handle, 0, 0, 10, 4, _mask, false, false, 135 m_grip_left(m_handle, 0, 0, 10, 4, s_mask, false, false,
135 screen.rootWindow().decorationDepth(), InputOutput, 136 screen.rootWindow().decorationDepth(), InputOutput,
136 screen.rootWindow().decorationVisual(), 137 screen.rootWindow().decorationVisual(),
137 screen.rootWindow().decorationColormap()), 138 screen.rootWindow().decorationColormap()),
138 m_clientarea(m_window, 0, 0, 100, 100, _mask), 139 m_clientarea(m_window, 0, 0, 100, 100, s_mask),
139 m_bevel(1), 140 m_bevel(1),
140 m_use_titlebar(true), 141 m_use_titlebar(true),
141 m_use_tabs(true), 142 m_use_tabs(true),
@@ -159,6 +160,7 @@ bool FbWinFrame::setTabMode(TabMode tabmode) {
159 if (m_tabmode == tabmode) 160 if (m_tabmode == tabmode)
160 return false; 161 return false;
161 162
163 FbTk::Container& tabs = tabcontainer();
162 bool ret = true; 164 bool ret = true;
163 165
164 // setting tabmode to notset forces it through when 166 // setting tabmode to notset forces it through when
@@ -171,52 +173,47 @@ bool FbWinFrame::setTabMode(TabMode tabmode) {
171 // reparent tab container 173 // reparent tab container
172 if (tabmode == EXTERNAL) { 174 if (tabmode == EXTERNAL) {
173 m_label.show(); 175 m_label.show();
174 m_tab_container.setBorderWidth(m_window.borderWidth()); 176 tabs.setBorderWidth(m_window.borderWidth());
175 m_tab_container.setEventMask( 177 tabs.setEventMask(s_mask);
176 ButtonPressMask | ButtonReleaseMask |
177 ButtonMotionMask | ExposureMask |
178 EnterWindowMask | LeaveWindowMask);
179
180 alignTabs(); 178 alignTabs();
181 179
182 // TODO: tab position 180 // TODO: tab position
183 if (m_use_tabs && m_visible) 181 if (m_use_tabs && m_visible)
184 m_tab_container.show(); 182 tabs.show();
185 else { 183 else {
186 ret = false; 184 ret = false;
187 m_tab_container.hide(); 185 tabs.hide();
188 } 186 }
189 187
190 } else { 188 } else {
191 m_tab_container.setUpdateLock(true); 189 tabs.setUpdateLock(true);
192 190
193 m_tab_container.setAlignment(FbTk::Container::RELATIVE); 191 tabs.setAlignment(FbTk::Container::RELATIVE);
194 m_tab_container.setOrientation(FbTk::ROT0); 192 tabs.setOrientation(FbTk::ROT0);
195 if (m_tab_container.parent()->window() == m_screen.rootWindow().window()) { 193 if (tabs.parent()->window() == m_screen.rootWindow().window()) {
196 m_layeritem.removeWindow(m_tab_container); 194 m_layeritem.removeWindow(m_tab_container);
197 m_tab_container.hide(); 195 tabs.hide();
198 m_tab_container.reparent(m_titlebar, m_label.x(), m_label.y()); 196 tabs.reparent(m_titlebar, m_label.x(), m_label.y());
199 m_tab_container.invalidateBackground(); 197 tabs.invalidateBackground();
200 m_tab_container.resize(m_label.width(), m_label.height()); 198 tabs.resize(m_label.width(), m_label.height());
201 m_tab_container.raise(); 199 tabs.raise();
202 } 200 }
203 m_tab_container.setBorderWidth(0); 201 tabs.setBorderWidth(0);
204 m_tab_container.setMaxTotalSize(0); 202 tabs.setMaxTotalSize(0);
205 m_tab_container.setUpdateLock(false); 203 tabs.setUpdateLock(false);
206 m_tab_container.setMaxSizePerClient(0); 204 tabs.setMaxSizePerClient(0);
207 205
208 renderTabContainer(); 206 renderTabContainer();
209 applyTabContainer(); 207 applyTabContainer();
210 m_tab_container.clear();
211 208
212 m_tab_container.raise(); 209 tabs.clear();
213 m_tab_container.show(); 210 tabs.raise();
211 tabs.show();
214 212
215 if (!m_use_tabs) 213 if (!m_use_tabs)
216 ret = false; 214 ret = false;
217 215
218 m_label.hide(); 216 m_label.hide();
219// reconfigure();
220 } 217 }
221 218
222 return ret; 219 return ret;
@@ -307,7 +304,7 @@ void FbWinFrame::moveResize(int x, int y, unsigned int width, unsigned int heigh
307 if (resize) { 304 if (resize) {
308 if (m_tabmode == EXTERNAL) { 305 if (m_tabmode == EXTERNAL) {
309 unsigned int s = width; 306 unsigned int s = width;
310 if (!_values[m_screen.getTabPlacement()].is_horizontal) { 307 if (!s_place[m_screen.getTabPlacement()].is_horizontal) {
311 s = height; 308 s = height;
312 } 309 }
313 m_tab_container.setMaxTotalSize(s); 310 m_tab_container.setMaxTotalSize(s);
@@ -323,7 +320,7 @@ void FbWinFrame::quietMoveResize(int x, int y,
323 window().width(), window().height()); 320 window().width(), window().height());
324 if (m_tabmode == EXTERNAL) { 321 if (m_tabmode == EXTERNAL) {
325 unsigned int s = width; 322 unsigned int s = width;
326 if (!_values[m_screen.getTabPlacement()].is_horizontal) { 323 if (!s_place[m_screen.getTabPlacement()].is_horizontal) {
327 s = height; 324 s = height;
328 } 325 }
329 m_tab_container.setMaxTotalSize(s); 326 m_tab_container.setMaxTotalSize(s);
@@ -349,14 +346,14 @@ void FbWinFrame::alignTabs() {
349 int tab_y = y(); 346 int tab_y = y();
350 347
351 TabPlacement p = m_screen.getTabPlacement(); 348 TabPlacement p = m_screen.getTabPlacement();
352 if (orig_orient != _values[p].orient) { 349 if (orig_orient != s_place[p].orient) {
353 tabs.hide(); 350 tabs.hide();
354 } 351 }
355 if (!_values[p].is_horizontal) { 352 if (!s_place[p].is_horizontal) {
356 size = height(); 353 size = height();
357 } 354 }
358 tabs.setOrientation(_values[p].orient); 355 tabs.setOrientation(s_place[p].orient);
359 tabs.setAlignment(_values[p].align); 356 tabs.setAlignment(s_place[p].align);
360 tabs.setMaxTotalSize(size); 357 tabs.setMaxTotalSize(size);
361 358
362 int w = static_cast<int>(width()); 359 int w = static_cast<int>(width());
@@ -875,7 +872,7 @@ void FbWinFrame::reconfigure() {
875 if (m_tabmode == EXTERNAL) { 872 if (m_tabmode == EXTERNAL) {
876 unsigned int h = buttonHeight(); 873 unsigned int h = buttonHeight();
877 unsigned int w = m_tab_container.width(); 874 unsigned int w = m_tab_container.width();
878 if (!_values[m_screen.getTabPlacement()].is_horizontal) { 875 if (!s_place[m_screen.getTabPlacement()].is_horizontal) {
879 w = m_tab_container.height(); 876 w = m_tab_container.height();
880 std::swap(w, h); 877 std::swap(w, h);
881 } 878 }
@@ -1244,7 +1241,7 @@ void FbWinFrame::init() {
1244 m_button_face.pm[UNFOCUS] = m_button_face.pm[FOCUS] = m_button_face.pm[PRESSED] = 0; 1241 m_button_face.pm[UNFOCUS] = m_button_face.pm[FOCUS] = m_button_face.pm[PRESSED] = 0;
1245 m_grip_face.pm[UNFOCUS] = m_grip_face.pm[FOCUS] = 0; 1242 m_grip_face.pm[UNFOCUS] = m_grip_face.pm[FOCUS] = 0;
1246 1243
1247 m_button_size = 26; 1244 m_button_size = s_button_size;
1248 1245
1249 m_label.setBorderWidth(0); 1246 m_label.setBorderWidth(0);
1250 1247
@@ -1271,10 +1268,12 @@ void FbWinFrame::init() {
1271*/ 1268*/
1272void FbWinFrame::applyButton(FbTk::Button &btn) { 1269void FbWinFrame::applyButton(FbTk::Button &btn) {
1273 1270
1271 FbWinFrame::BtnFace& face = m_button_face;
1272
1274 if (m_button_face.pm[PRESSED]) { 1273 if (m_button_face.pm[PRESSED]) {
1275 btn.setPressedPixmap(m_button_face.pm[PRESSED]); 1274 btn.setPressedPixmap(face.pm[PRESSED]);
1276 } else { 1275 } else {
1277 btn.setPressedColor(m_button_face.color[PRESSED]); 1276 btn.setPressedColor(face.color[PRESSED]);
1278 } 1277 }
1279 1278
1280 bool f = m_state.focused; 1279 bool f = m_state.focused;
@@ -1282,16 +1281,17 @@ void FbWinFrame::applyButton(FbTk::Button &btn) {
1282 btn.setAlpha(getAlpha(f)); 1281 btn.setAlpha(getAlpha(f));
1283 btn.setGC(theme()->buttonPicGC()); 1282 btn.setGC(theme()->buttonPicGC());
1284 1283
1285 bg_pm_or_color(btn, m_button_face.pm[f], m_button_face.color[f]); 1284 bg_pm_or_color(btn, face.pm[f], face.color[f]);
1286} 1285}
1287 1286
1288 1287
1289void FbWinFrame::applyTabContainer() { 1288void FbWinFrame::applyTabContainer() {
1290 1289
1291 m_tab_container.setAlpha(getAlpha(m_state.focused)); 1290 FbTk::Container& tabs = tabcontainer();
1292 bg_pm_or_color(m_tab_container, 1291 FbWinFrame::Face& face = m_tabcontainer_face;
1293 m_tabcontainer_face.pm[m_state.focused], 1292
1294 m_tabcontainer_face.color[m_state.focused]); 1293 tabs.setAlpha(getAlpha(m_state.focused));
1294 bg_pm_or_color(tabs, face.pm[m_state.focused], face.color[m_state.focused]);
1295 1295
1296 // and the labelbuttons in it 1296 // and the labelbuttons in it
1297 FbTk::Container::ItemList::iterator btn_it = m_tab_container.begin(); 1297 FbTk::Container::ItemList::iterator btn_it = m_tab_container.begin();
@@ -1369,12 +1369,13 @@ bool FbWinFrame::setBorderWidth(bool do_move) {
1369 1369
1370 if (border_width && 1370 if (border_width &&
1371 theme()->border().color().pixel() != window().borderColor()) { 1371 theme()->border().color().pixel() != window().borderColor()) {
1372 window().setBorderColor(theme()->border().color()); 1372 FbTk::Color c = theme()->border().color();
1373 titlebar().setBorderColor(theme()->border().color()); 1373 window().setBorderColor(c);
1374 handle().setBorderColor(theme()->border().color()); 1374 titlebar().setBorderColor(c);
1375 gripLeft().setBorderColor(theme()->border().color()); 1375 handle().setBorderColor(c);
1376 gripRight().setBorderColor(theme()->border().color()); 1376 gripLeft().setBorderColor(c);
1377 tabcontainer().setBorderColor(theme()->border().color()); 1377 gripRight().setBorderColor(c);
1378 tabcontainer().setBorderColor(c);
1378 } 1379 }
1379 1380
1380 if (border_width == handle().borderWidth() && 1381 if (border_width == handle().borderWidth() &&
@@ -1463,8 +1464,9 @@ void FbWinFrame::gravityTranslate(int &x, int &y,
1463 // is removed by fluxbox, so the gravity needs to account for this change 1464 // is removed by fluxbox, so the gravity needs to account for this change
1464 1465
1465 // these functions already check if the title/handle is used 1466 // these functions already check if the title/handle is used
1466 int bw_diff = client_bw - m_window.borderWidth(); 1467 int bw = static_cast<int>(m_window.borderWidth());
1467 int height_diff = 2*bw_diff - titlebarHeight() - handleHeight(); 1468 int bw_diff = static_cast<int>(client_bw) - bw;
1469 int height_diff = 2*bw_diff - static_cast<int>(titlebarHeight()) - static_cast<int>(handleHeight());
1468 int width_diff = 2*bw_diff; 1470 int width_diff = 2*bw_diff;
1469 1471
1470 if (win_gravity == SouthWestGravity || win_gravity == SouthGravity || 1472 if (win_gravity == SouthWestGravity || win_gravity == SouthGravity ||
@@ -1504,7 +1506,7 @@ void FbWinFrame::gravityTranslate(int &x, int &y,
1504int FbWinFrame::widthOffset() const { 1506int FbWinFrame::widthOffset() const {
1505 if (m_tabmode != EXTERNAL || !m_use_tabs) 1507 if (m_tabmode != EXTERNAL || !m_use_tabs)
1506 return 0; 1508 return 0;
1507 if (_values[m_screen.getTabPlacement()].is_horizontal) { 1509 if (s_place[m_screen.getTabPlacement()].is_horizontal) {
1508 return 0; 1510 return 0;
1509 } 1511 }
1510 return m_tab_container.width() + m_window.borderWidth(); 1512 return m_tab_container.width() + m_window.borderWidth();
@@ -1514,7 +1516,7 @@ int FbWinFrame::heightOffset() const {
1514 if (m_tabmode != EXTERNAL || !m_use_tabs) 1516 if (m_tabmode != EXTERNAL || !m_use_tabs)
1515 return 0; 1517 return 0;
1516 1518
1517 if (!_values[m_screen.getTabPlacement()].is_horizontal) { 1519 if (!s_place[m_screen.getTabPlacement()].is_horizontal) {
1518 return 0; 1520 return 0;
1519 } 1521 }
1520 return m_tab_container.height() + m_window.borderWidth(); 1522 return m_tab_container.height() + m_window.borderWidth();
diff --git a/src/IconButton.cc b/src/IconButton.cc
index f1dd1f0..d1f1451 100644
--- a/src/IconButton.cc
+++ b/src/IconButton.cc
@@ -250,6 +250,7 @@ void IconButton::setupWindow() {
250} 250}
251 251
252void IconButton::drawText(int x, int y, FbTk::FbDrawable *drawable) { 252void IconButton::drawText(int x, int y, FbTk::FbDrawable *drawable) {
253
253 // offset text 254 // offset text
254 if (m_icon_pixmap.drawable() != 0) 255 if (m_icon_pixmap.drawable() != 0)
255 FbTk::TextButton::drawText(m_icon_window.x() + m_icon_window.width() + 1, y, drawable); 256 FbTk::TextButton::drawText(m_icon_window.x() + m_icon_window.width() + 1, y, drawable);
@@ -269,8 +270,7 @@ bool IconButton::setOrientation(FbTk::Orientation orient) {
269 FbTk::translatePosition(orient, iconx, icony, m_icon_window.width(), m_icon_window.height(), 0); 270 FbTk::translatePosition(orient, iconx, icony, m_icon_window.width(), m_icon_window.height(), 0);
270 m_icon_window.move(iconx, icony); 271 m_icon_window.move(iconx, icony);
271 return true; 272 return true;
272 } else {
273 return false;
274 } 273 }
274 return false;
275} 275}
276 276