diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | src/Container.cc | 40 | ||||
-rw-r--r-- | src/FbWinFrame.cc | 12 |
3 files changed, 28 insertions, 29 deletions
@@ -1,5 +1,10 @@ | |||
1 | (Format: Year/Month/Day) | 1 | (Format: Year/Month/Day) |
2 | Changes for 0.9.16: | 2 | Changes for 0.9.16: |
3 | *06/06/10: | ||
4 | * Fix some external tab alignment on shade (Simon) | ||
5 | FbWinFrame.cc | ||
6 | * Fix container size rounding for right alignment (Simon) | ||
7 | Container.cc | ||
3 | *06/06/01: | 8 | *06/06/01: |
4 | * Update of new manpage (thanx Guillermo Patterer) | 9 | * Update of new manpage (thanx Guillermo Patterer) |
5 | *06/05/23: | 10 | *06/05/23: |
diff --git a/src/Container.cc b/src/Container.cc index 4cd0fa8..5e7cb7d 100644 --- a/src/Container.cc +++ b/src/Container.cc | |||
@@ -272,35 +272,10 @@ void Container::setMaxTotalSize(unsigned int size) { | |||
272 | if (m_max_total_size == size) | 272 | if (m_max_total_size == size) |
273 | return; | 273 | return; |
274 | 274 | ||
275 | unsigned int old = m_max_total_size; | ||
276 | m_max_total_size = size; | 275 | m_max_total_size = size; |
277 | 276 | ||
278 | repositionItems(); | 277 | repositionItems(); |
279 | return; | 278 | return; |
280 | |||
281 | if (m_max_total_size && width() > m_max_total_size) { | ||
282 | resize(m_max_total_size, height()); | ||
283 | } else if (!m_max_total_size && old) { // going from restricted to unrestricted | ||
284 | repositionItems(); | ||
285 | } else { | ||
286 | // this is a bit of duplication from repositionItems | ||
287 | // for when we are allowed to grow ourself | ||
288 | Alignment align = alignment(); | ||
289 | size_t num_items = m_item_list.size(); | ||
290 | if (m_max_total_size && (align == RIGHT || align == LEFT) && | ||
291 | num_items) { | ||
292 | unsigned int max_width_per_client = maxWidthPerClient(); | ||
293 | unsigned int borderW = m_item_list.front()->borderWidth(); | ||
294 | |||
295 | unsigned int preferred_width = (max_width_per_client + borderW) * num_items - borderW; | ||
296 | |||
297 | if (preferred_width > m_max_total_size) | ||
298 | preferred_width = m_max_total_size; | ||
299 | |||
300 | if (preferred_width != width()) | ||
301 | repositionItems(); | ||
302 | } | ||
303 | } | ||
304 | } | 279 | } |
305 | 280 | ||
306 | void Container::setAlignment(Container::Alignment a) { | 281 | void Container::setAlignment(Container::Alignment a) { |
@@ -401,7 +376,6 @@ void Container::repositionItems() { | |||
401 | total_width = m_max_total_size; | 376 | total_width = m_max_total_size; |
402 | if (m_max_total_size > ((num_items - 1)*borderW)) { // don't go negative with unsigned nums | 377 | if (m_max_total_size > ((num_items - 1)*borderW)) { // don't go negative with unsigned nums |
403 | max_width_per_client = ( m_max_total_size - (num_items - 1)*borderW ) / num_items; | 378 | max_width_per_client = ( m_max_total_size - (num_items - 1)*borderW ) / num_items; |
404 | total_width = (max_width_per_client + borderW) * num_items - borderW; | ||
405 | } else | 379 | } else |
406 | max_width_per_client = 1; | 380 | max_width_per_client = 1; |
407 | } | 381 | } |
@@ -429,7 +403,11 @@ void Container::repositionItems() { | |||
429 | ItemList::iterator it = m_item_list.begin(); | 403 | ItemList::iterator it = m_item_list.begin(); |
430 | const ItemList::iterator it_end = m_item_list.end(); | 404 | const ItemList::iterator it_end = m_item_list.end(); |
431 | 405 | ||
432 | int rounding_error = total_width - ((max_width_per_client + borderW)* num_items - borderW); | 406 | int rounding_error = 0; |
407 | |||
408 | if (align == RELATIVE || total_width == m_max_total_size) { | ||
409 | rounding_error = total_width - ((max_width_per_client + borderW)* num_items - borderW); | ||
410 | } | ||
433 | 411 | ||
434 | int next_x = -borderW; // zero so the border of the first shows | 412 | int next_x = -borderW; // zero so the border of the first shows |
435 | int extra = 0; | 413 | int extra = 0; |
@@ -443,10 +421,16 @@ void Container::repositionItems() { | |||
443 | unsigned int tmpw, tmph; | 421 | unsigned int tmpw, tmph; |
444 | for (; it != it_end; ++it, next_x += direction*(max_width_per_client + borderW + extra)) { | 422 | for (; it != it_end; ++it, next_x += direction*(max_width_per_client + borderW + extra)) { |
445 | // we only need to do error stuff with alignment RELATIVE | 423 | // we only need to do error stuff with alignment RELATIVE |
446 | if (rounding_error != 0 && align == RELATIVE) { | 424 | // OR with max_total_size triggered |
425 | if (rounding_error) { | ||
447 | --rounding_error; | 426 | --rounding_error; |
448 | extra = 1; | 427 | extra = 1; |
428 | //counter for different direction | ||
429 | if (align == RIGHT && !extra) | ||
430 | --next_x; | ||
449 | } else { | 431 | } else { |
432 | if (extra && align == RIGHT) // last extra | ||
433 | ++next_x; | ||
450 | extra = 0; | 434 | extra = 0; |
451 | } | 435 | } |
452 | // rotate the x and y coords | 436 | // rotate the x and y coords |
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index d3dd682..00583d7 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc | |||
@@ -348,6 +348,7 @@ void FbWinFrame::alignTabs() { | |||
348 | if (orig_orient != FbTk::ROT0) m_tab_container.hide(); | 348 | if (orig_orient != FbTk::ROT0) m_tab_container.hide(); |
349 | m_tab_container.setOrientation(FbTk::ROT0); | 349 | m_tab_container.setOrientation(FbTk::ROT0); |
350 | m_tab_container.setAlignment(Container::LEFT); | 350 | m_tab_container.setAlignment(Container::LEFT); |
351 | m_tab_container.setMaxTotalSize(m_window.width()); | ||
351 | tabx = x(); | 352 | tabx = x(); |
352 | taby = y() - yOffset(); | 353 | taby = y() - yOffset(); |
353 | break; | 354 | break; |
@@ -355,6 +356,7 @@ void FbWinFrame::alignTabs() { | |||
355 | if (orig_orient != FbTk::ROT0) m_tab_container.hide(); | 356 | if (orig_orient != FbTk::ROT0) m_tab_container.hide(); |
356 | m_tab_container.setOrientation(FbTk::ROT0); | 357 | m_tab_container.setOrientation(FbTk::ROT0); |
357 | m_tab_container.setAlignment(Container::RIGHT); | 358 | m_tab_container.setAlignment(Container::RIGHT); |
359 | m_tab_container.setMaxTotalSize(m_window.width()); | ||
358 | tabx = x() + width() - m_tab_container.width(); | 360 | tabx = x() + width() - m_tab_container.width(); |
359 | taby = y() - yOffset(); | 361 | taby = y() - yOffset(); |
360 | break; | 362 | break; |
@@ -362,6 +364,7 @@ void FbWinFrame::alignTabs() { | |||
362 | if (orig_orient != FbTk::ROT270) m_tab_container.hide(); | 364 | if (orig_orient != FbTk::ROT270) m_tab_container.hide(); |
363 | m_tab_container.setOrientation(FbTk::ROT270); | 365 | m_tab_container.setOrientation(FbTk::ROT270); |
364 | m_tab_container.setAlignment(Container::RIGHT); | 366 | m_tab_container.setAlignment(Container::RIGHT); |
367 | m_tab_container.setMaxTotalSize(m_window.height()); | ||
365 | tabx = x() - xOffset(); | 368 | tabx = x() - xOffset(); |
366 | taby = y(); | 369 | taby = y(); |
367 | break; | 370 | break; |
@@ -369,6 +372,7 @@ void FbWinFrame::alignTabs() { | |||
369 | if (orig_orient != FbTk::ROT270) m_tab_container.hide(); | 372 | if (orig_orient != FbTk::ROT270) m_tab_container.hide(); |
370 | m_tab_container.setOrientation(FbTk::ROT270); | 373 | m_tab_container.setOrientation(FbTk::ROT270); |
371 | m_tab_container.setAlignment(Container::LEFT); | 374 | m_tab_container.setAlignment(Container::LEFT); |
375 | m_tab_container.setMaxTotalSize(m_window.height()); | ||
372 | tabx = x() - xOffset(); | 376 | tabx = x() - xOffset(); |
373 | taby = y() + height() - m_tab_container.height(); | 377 | taby = y() + height() - m_tab_container.height(); |
374 | break; | 378 | break; |
@@ -376,6 +380,7 @@ void FbWinFrame::alignTabs() { | |||
376 | if (orig_orient != FbTk::ROT90) m_tab_container.hide(); | 380 | if (orig_orient != FbTk::ROT90) m_tab_container.hide(); |
377 | m_tab_container.setOrientation(FbTk::ROT90); | 381 | m_tab_container.setOrientation(FbTk::ROT90); |
378 | m_tab_container.setAlignment(Container::LEFT); | 382 | m_tab_container.setAlignment(Container::LEFT); |
383 | m_tab_container.setMaxTotalSize(m_window.height()); | ||
379 | tabx = x() + width() + m_window.borderWidth(); | 384 | tabx = x() + width() + m_window.borderWidth(); |
380 | taby = y(); | 385 | taby = y(); |
381 | break; | 386 | break; |
@@ -383,6 +388,7 @@ void FbWinFrame::alignTabs() { | |||
383 | if (orig_orient != FbTk::ROT90) m_tab_container.hide(); | 388 | if (orig_orient != FbTk::ROT90) m_tab_container.hide(); |
384 | m_tab_container.setOrientation(FbTk::ROT90); | 389 | m_tab_container.setOrientation(FbTk::ROT90); |
385 | m_tab_container.setAlignment(Container::RIGHT); | 390 | m_tab_container.setAlignment(Container::RIGHT); |
391 | m_tab_container.setMaxTotalSize(m_window.height()); | ||
386 | tabx = x() + width() + m_window.borderWidth(); | 392 | tabx = x() + width() + m_window.borderWidth(); |
387 | taby = y() + height() - m_tab_container.height(); | 393 | taby = y() + height() - m_tab_container.height(); |
388 | break; | 394 | break; |
@@ -390,6 +396,7 @@ void FbWinFrame::alignTabs() { | |||
390 | if (orig_orient != FbTk::ROT0) m_tab_container.hide(); | 396 | if (orig_orient != FbTk::ROT0) m_tab_container.hide(); |
391 | m_tab_container.setOrientation(FbTk::ROT0); | 397 | m_tab_container.setOrientation(FbTk::ROT0); |
392 | m_tab_container.setAlignment(Container::LEFT); | 398 | m_tab_container.setAlignment(Container::LEFT); |
399 | m_tab_container.setMaxTotalSize(m_window.width()); | ||
393 | tabx = x(); | 400 | tabx = x(); |
394 | taby = y() + height() + m_window.borderWidth(); | 401 | taby = y() + height() + m_window.borderWidth(); |
395 | break; | 402 | break; |
@@ -397,6 +404,7 @@ void FbWinFrame::alignTabs() { | |||
397 | if (orig_orient != FbTk::ROT0) m_tab_container.hide(); | 404 | if (orig_orient != FbTk::ROT0) m_tab_container.hide(); |
398 | m_tab_container.setOrientation(FbTk::ROT0); | 405 | m_tab_container.setOrientation(FbTk::ROT0); |
399 | m_tab_container.setAlignment(Container::RIGHT); | 406 | m_tab_container.setAlignment(Container::RIGHT); |
407 | m_tab_container.setMaxTotalSize(m_window.width()); | ||
400 | tabx = x() + width() - m_tab_container.width(); | 408 | tabx = x() + width() - m_tab_container.width(); |
401 | taby = y() + height() + m_window.borderWidth(); | 409 | taby = y() + height() + m_window.borderWidth(); |
402 | break; | 410 | break; |
@@ -404,7 +412,6 @@ void FbWinFrame::alignTabs() { | |||
404 | 412 | ||
405 | unsigned int w = m_window.width(), h = m_window.height(); | 413 | unsigned int w = m_window.width(), h = m_window.height(); |
406 | translateSize(m_tab_container.orientation(), w, h); | 414 | translateSize(m_tab_container.orientation(), w, h); |
407 | m_tab_container.setMaxTotalSize(w); | ||
408 | 415 | ||
409 | if (m_tab_container.orientation() != orig_orient || | 416 | if (m_tab_container.orientation() != orig_orient || |
410 | m_tab_container.maxWidthPerClient() != orig_tabwidth) { | 417 | m_tab_container.maxWidthPerClient() != orig_tabwidth) { |
@@ -417,6 +424,9 @@ void FbWinFrame::alignTabs() { | |||
417 | } | 424 | } |
418 | 425 | ||
419 | if (m_tab_container.parent()->window() != m_screen.rootWindow().window()) { | 426 | if (m_tab_container.parent()->window() != m_screen.rootWindow().window()) { |
427 | // because the label might be using the same cached pixmap as tab container! | ||
428 | renderTitlebar(); | ||
429 | applyTitlebar(); | ||
420 | m_tab_container.reparent(m_screen.rootWindow(), tabx, taby); | 430 | m_tab_container.reparent(m_screen.rootWindow(), tabx, taby); |
421 | m_layeritem.addWindow(m_tab_container); | 431 | m_layeritem.addWindow(m_tab_container); |
422 | } else { | 432 | } else { |