aboutsummaryrefslogtreecommitdiff
path: root/src/WinClient.cc
diff options
context:
space:
mode:
authorrathnor <rathnor>2003-09-29 14:58:15 (GMT)
committerrathnor <rathnor>2003-09-29 14:58:15 (GMT)
commit81378f9494db4ab1d033947532d7fac968095ecd (patch)
tree0980a0ed9e2ebcbb2d7b7c88d6fbe1d98ab06dd2 /src/WinClient.cc
parent15dfe811124e3f1be7d9a802290372427dae5afb (diff)
downloadfluxbox-81378f9494db4ab1d033947532d7fac968095ecd.zip
fluxbox-81378f9494db4ab1d033947532d7fac968095ecd.tar.bz2
fix handling of base_Width/height hints in wm_normal_hints
- fixes abiword resize issues
Diffstat (limited to 'src/WinClient.cc')
-rw-r--r--src/WinClient.cc72
1 files changed, 63 insertions, 9 deletions
diff --git a/src/WinClient.cc b/src/WinClient.cc
index 614b7a4..e032304 100644
--- a/src/WinClient.cc
+++ b/src/WinClient.cc
@@ -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: WinClient.cc,v 1.27 2003/09/24 14:02:25 rathnor Exp $ 22// $Id: WinClient.cc,v 1.28 2003/09/29 14:58:15 rathnor Exp $
23 23
24#include "WinClient.hh" 24#include "WinClient.hh"
25 25
@@ -43,7 +43,7 @@ WinClient::WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin):FbTk::Fb
43 window_group(0), 43 window_group(0),
44 x(0), y(0), old_bw(0), 44 x(0), y(0), old_bw(0),
45 min_width(1), min_height(1), 45 min_width(1), min_height(1),
46 max_width(1), max_height(1), 46 max_width(0), max_height(0),
47 width_inc(1), height_inc(1), 47 width_inc(1), height_inc(1),
48 min_aspect_x(1), min_aspect_y(1), 48 min_aspect_x(1), min_aspect_y(1),
49 max_aspect_x(1), max_aspect_y(1), 49 max_aspect_x(1), max_aspect_y(1),
@@ -434,8 +434,23 @@ void WinClient::updateWMNormalHints() {
434 if (sizehint.flags & PMinSize) { 434 if (sizehint.flags & PMinSize) {
435 min_width = sizehint.min_width; 435 min_width = sizehint.min_width;
436 min_height = sizehint.min_height; 436 min_height = sizehint.min_height;
437 } else 437 if (!(sizehint.flags & PBaseSize)) {
438 base_width = min_width;
439 base_height = min_height;
440 }
441 } else {
438 min_width = min_height = 1; 442 min_width = min_height = 1;
443 base_width = base_height = 0;
444 }
445
446 if (sizehint.flags & PBaseSize) {
447 base_width = sizehint.base_width;
448 base_height = sizehint.base_height;
449 if (!(sizehint.flags & PMinSize)) {
450 min_width = base_width;
451 min_height = base_height;
452 }
453 } // default set in PMinSize
439 454
440 if (sizehint.flags & PMaxSize) { 455 if (sizehint.flags & PMaxSize) {
441 max_width = sizehint.max_width; 456 max_width = sizehint.max_width;
@@ -460,12 +475,6 @@ void WinClient::updateWMNormalHints() {
460 min_aspect_x = min_aspect_y = 475 min_aspect_x = min_aspect_y =
461 max_aspect_x = max_aspect_y = 1; 476 max_aspect_x = max_aspect_y = 1;
462 477
463 if (sizehint.flags & PBaseSize) {
464 base_width = sizehint.base_width;
465 base_height = sizehint.base_height;
466 } else
467 base_width = base_height = 0;
468
469 if (sizehint.flags & PWinGravity) 478 if (sizehint.flags & PWinGravity)
470 m_win_gravity = sizehint.win_gravity; 479 m_win_gravity = sizehint.win_gravity;
471 else 480 else
@@ -605,3 +614,48 @@ void WinClient::updateWMProtocols() {
605 } 614 }
606 615
607} 616}
617
618
619/**
620 * Changes width and height to the nearest (lower) value
621 * that conforms to it's size hints.
622 *
623 * display_* give the values that would be displayed
624 * to the user when resizing.
625 * We use pointers for display_* since they are optional.
626 *
627 * See ICCCM section 4.1.2.3
628 */
629void WinClient::applySizeHints(int &width, int &height,
630 int *display_width, int *display_height) {
631
632 int i = width, j = height;
633
634 // Check minimum size
635 if (width < 0 || width < min_width)
636 width = min_width;
637
638 if (height < 0 || height < min_height)
639 height = min_height;
640
641 // Check maximum size
642 if (max_width > 0 && width > max_width)
643 width = max_width;
644
645 if (max_height > 0 && height > max_height)
646 height = max_height;
647
648 // enforce incremental size limits, wrt base size
649 // only calculate this if we really need to
650 i = (width - base_width) / width_inc;
651 width = i*width_inc + base_width;
652
653 j = (height - base_height) / height_inc;
654 height = j*height_inc + base_height;
655
656 if (display_width)
657 *display_width = i;
658
659 if (display_height)
660 *display_height = j;
661}