aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMark Tiefenbruck <mark@fluxbox.org>2008-08-15 11:02:14 (GMT)
committerMark Tiefenbruck <mark@fluxbox.org>2008-08-15 11:02:14 (GMT)
commit80059c6dae8de4962b14f08bd75f1c773e37a78d (patch)
treed94651987a6c9a25d87292c2c5d74018ba541473 /src
parent31b47e78147ca20803b123f392bfd2002b70e052 (diff)
downloadfluxbox_pavel-80059c6dae8de4962b14f08bd75f1c773e37a78d.zip
fluxbox_pavel-80059c6dae8de4962b14f08bd75f1c773e37a78d.tar.bz2
move size hints to a struct
Diffstat (limited to 'src')
-rw-r--r--src/CurrentWindowCmd.cc4
-rw-r--r--src/WinClient.cc153
-rw-r--r--src/WinClient.hh28
-rw-r--r--src/Window.cc26
4 files changed, 116 insertions, 95 deletions
diff --git a/src/CurrentWindowCmd.cc b/src/CurrentWindowCmd.cc
index 9253058..65c5711 100644
--- a/src/CurrentWindowCmd.cc
+++ b/src/CurrentWindowCmd.cc
@@ -391,10 +391,10 @@ ResizeCmd::ResizeCmd(const int step_size_x, const int step_size_y) :
391void ResizeCmd::real_execute() { 391void ResizeCmd::real_execute() {
392 392
393 int w = std::max<int>(static_cast<int>(fbwindow().width() + 393 int w = std::max<int>(static_cast<int>(fbwindow().width() +
394 m_step_size_x * fbwindow().winClient().width_inc), 394 m_step_size_x * fbwindow().winClient().widthInc()),
395 fbwindow().frame().titlebarHeight() * 2 + 10); 395 fbwindow().frame().titlebarHeight() * 2 + 10);
396 int h = std::max<int>(static_cast<int>(fbwindow().height() + 396 int h = std::max<int>(static_cast<int>(fbwindow().height() +
397 m_step_size_y * fbwindow().winClient().height_inc), 397 m_step_size_y * fbwindow().winClient().heightInc()),
398 fbwindow().frame().titlebarHeight() + 10); 398 fbwindow().frame().titlebarHeight() + 10);
399 fbwindow().resize(w, h); 399 fbwindow().resize(w, h);
400} 400}
diff --git a/src/WinClient.cc b/src/WinClient.cc
index a7e689f..9aac38d 100644
--- a/src/WinClient.cc
+++ b/src/WinClient.cc
@@ -67,12 +67,6 @@ WinClient::WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin):
67 transient_for(0), 67 transient_for(0),
68 window_group(0), 68 window_group(0),
69 x(0), y(0), old_bw(0), 69 x(0), y(0), old_bw(0),
70 min_width(1), min_height(1),
71 max_width(0), max_height(0),
72 width_inc(1), height_inc(1),
73 min_aspect_x(0), min_aspect_y(0),
74 max_aspect_x(0), max_aspect_y(0),
75 base_width(1), base_height(1),
76 initial_state(0), 70 initial_state(0),
77 normal_hint_flags(0), 71 normal_hint_flags(0),
78 wm_hint_flags(0), 72 wm_hint_flags(0),
@@ -87,6 +81,15 @@ WinClient::WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin):
87 m_window_type(Focusable::TYPE_NORMAL), 81 m_window_type(Focusable::TYPE_NORMAL),
88 m_mwm_hint(0), 82 m_mwm_hint(0),
89 m_strut(0) { 83 m_strut(0) {
84
85 m_size_hints.min_width = m_size_hints.min_height =
86 m_size_hints.width_inc = m_size_hints.height_inc =
87 m_size_hints.base_width = m_size_hints.base_height = 1;
88
89 m_size_hints.max_width = m_size_hints.max_height =
90 m_size_hints.min_aspect_x = m_size_hints.min_aspect_y =
91 m_size_hints.max_aspect_x = m_size_hints.max_aspect_y = 0;
92
90 updateWMProtocols(); 93 updateWMProtocols();
91 updateMWMHints(); 94 updateMWMHints();
92 updateWMHints(); 95 updateWMHints();
@@ -469,65 +472,65 @@ void WinClient::updateWMNormalHints() {
469 long icccm_mask; 472 long icccm_mask;
470 XSizeHints sizehint; 473 XSizeHints sizehint;
471 if (! XGetWMNormalHints(display(), window(), &sizehint, &icccm_mask)) { 474 if (! XGetWMNormalHints(display(), window(), &sizehint, &icccm_mask)) {
472 min_width = min_height = 475 m_size_hints.min_width = m_size_hints.min_height =
473 base_width = base_height = 476 m_size_hints.base_width = m_size_hints.base_height =
474 width_inc = height_inc = 1; 477 m_size_hints.width_inc = m_size_hints.height_inc = 1;
475 max_width = 0; // unbounded 478 m_size_hints.max_width = 0; // unbounded
476 max_height = 0; 479 m_size_hints.max_height = 0;
477 min_aspect_x = min_aspect_y = 480 m_size_hints.min_aspect_x = m_size_hints.min_aspect_y =
478 max_aspect_x = max_aspect_y = 0; 481 m_size_hints.max_aspect_x = m_size_hints.max_aspect_y = 0;
479 m_win_gravity = NorthWestGravity; 482 m_win_gravity = NorthWestGravity;
480 } else { 483 } else {
481 normal_hint_flags = sizehint.flags; 484 normal_hint_flags = sizehint.flags;
482 485
483 if (sizehint.flags & PMinSize) { 486 if (sizehint.flags & PMinSize) {
484 min_width = sizehint.min_width; 487 m_size_hints.min_width = sizehint.min_width;
485 min_height = sizehint.min_height; 488 m_size_hints.min_height = sizehint.min_height;
486 if (!(sizehint.flags & PBaseSize)) { 489 if (!(sizehint.flags & PBaseSize)) {
487 base_width = min_width; 490 m_size_hints.base_width = m_size_hints.min_width;
488 base_height = min_height; 491 m_size_hints.base_height = m_size_hints.min_height;
489 } 492 }
490 } else { 493 } else {
491 min_width = min_height = 1; 494 m_size_hints.min_width = m_size_hints.min_height = 1;
492 base_width = base_height = 0; 495 m_size_hints.base_width = m_size_hints.base_height = 0;
493 } 496 }
494 497
495 if (sizehint.flags & PBaseSize) { 498 if (sizehint.flags & PBaseSize) {
496 base_width = sizehint.base_width; 499 m_size_hints.base_width = sizehint.base_width;
497 base_height = sizehint.base_height; 500 m_size_hints.base_height = sizehint.base_height;
498 if (!(sizehint.flags & PMinSize)) { 501 if (!(sizehint.flags & PMinSize)) {
499 min_width = base_width; 502 m_size_hints.min_width = m_size_hints.base_width;
500 min_height = base_height; 503 m_size_hints.min_height = m_size_hints.base_height;
501 } 504 }
502 } // default set in PMinSize 505 } // default set in PMinSize
503 506
504 if (sizehint.flags & PMaxSize) { 507 if (sizehint.flags & PMaxSize) {
505 max_width = sizehint.max_width; 508 m_size_hints.max_width = sizehint.max_width;
506 max_height = sizehint.max_height; 509 m_size_hints.max_height = sizehint.max_height;
507 } else { 510 } else {
508 max_width = 0; // unbounded 511 m_size_hints.max_width = 0; // unbounded
509 max_height = 0; 512 m_size_hints.max_height = 0;
510 } 513 }
511 514
512 if (sizehint.flags & PResizeInc) { 515 if (sizehint.flags & PResizeInc) {
513 width_inc = sizehint.width_inc; 516 m_size_hints.width_inc = sizehint.width_inc;
514 height_inc = sizehint.height_inc; 517 m_size_hints.height_inc = sizehint.height_inc;
515 } else 518 } else
516 width_inc = height_inc = 1; 519 m_size_hints.width_inc = m_size_hints.height_inc = 1;
517 520
518 if (width_inc == 0) 521 if (m_size_hints.width_inc == 0)
519 width_inc = 1; 522 m_size_hints.width_inc = 1;
520 if (height_inc == 0) 523 if (m_size_hints.height_inc == 0)
521 height_inc = 1; 524 m_size_hints.height_inc = 1;
522 525
523 if (sizehint.flags & PAspect) { 526 if (sizehint.flags & PAspect) {
524 min_aspect_x = sizehint.min_aspect.x; 527 m_size_hints.min_aspect_x = sizehint.min_aspect.x;
525 min_aspect_y = sizehint.min_aspect.y; 528 m_size_hints.min_aspect_y = sizehint.min_aspect.y;
526 max_aspect_x = sizehint.max_aspect.x; 529 m_size_hints.max_aspect_x = sizehint.max_aspect.x;
527 max_aspect_y = sizehint.max_aspect.y; 530 m_size_hints.max_aspect_y = sizehint.max_aspect.y;
528 } else 531 } else
529 min_aspect_x = min_aspect_y = 532 m_size_hints.min_aspect_x = m_size_hints.min_aspect_y =
530 max_aspect_x = max_aspect_y = 0; 533 m_size_hints.max_aspect_x = m_size_hints.max_aspect_y = 0;
531 534
532 if (sizehint.flags & PWinGravity) 535 if (sizehint.flags & PWinGravity)
533 m_win_gravity = sizehint.win_gravity; 536 m_win_gravity = sizehint.win_gravity;
@@ -725,29 +728,29 @@ void WinClient::applySizeHints(int &width, int &height,
725 int i = width, j = height; 728 int i = width, j = height;
726 729
727 // Check minimum size 730 // Check minimum size
728 if (width < 0 || width < static_cast<signed>(min_width)) 731 if (width < 0 || width < static_cast<signed>(m_size_hints.min_width))
729 width = min_width; 732 width = m_size_hints.min_width;
730 733
731 if (height < 0 || height < static_cast<signed>(min_height)) 734 if (height < 0 || height < static_cast<signed>(m_size_hints.min_height))
732 height = min_height; 735 height = m_size_hints.min_height;
733 736
734 // Check maximum size 737 // Check maximum size
735 if (max_width > 0 && width > static_cast<signed>(max_width)) 738 if (m_size_hints.max_width > 0 && width > static_cast<signed>(m_size_hints.max_width))
736 width = max_width; 739 width = m_size_hints.max_width;
737 740
738 if (max_height > 0 && height > static_cast<signed>(max_height)) 741 if (m_size_hints.max_height > 0 && height > static_cast<signed>(m_size_hints.max_height))
739 height = max_height; 742 height = m_size_hints.max_height;
740 743
741 // we apply aspect ratios before incrementals 744 // we apply aspect ratios before incrementals
742 // Too difficult to exactly satisfy both incremental+aspect 745 // Too difficult to exactly satisfy both incremental+aspect
743 // in most situations 746 // in most situations
744 // (they really shouldn't happen at the same time anyway). 747 // (they really shouldn't happen at the same time anyway).
745 748
746 /* aspect ratios are applied exclusive to the base_width 749 /* aspect ratios are applied exclusive to the m_size_hints.base_width
747 * 750 *
748 * min_aspect_x width max_aspect_x 751 * m_size_hints.min_aspect_x width m_size_hints.max_aspect_x
749 * ------------ < ------- < ------------ 752 * ------------ < ------- < ------------
750 * min_aspect_y height max_aspect_y 753 * m_size_hints.min_aspect_y height m_size_hints.max_aspect_y
751 * 754 *
752 * beware of integer maximum (so I'll use doubles instead and divide) 755 * beware of integer maximum (so I'll use doubles instead and divide)
753 * 756 *
@@ -764,16 +767,16 @@ void WinClient::applySizeHints(int &width, int &height,
764 * is used in that case. 767 * is used in that case.
765 */ 768 */
766 769
767 if (min_aspect_y > 0 && max_aspect_y > 0 && 770 if (m_size_hints.min_aspect_y > 0 && m_size_hints.max_aspect_y > 0 &&
768 (height - base_height) > 0) { 771 (height - m_size_hints.base_height) > 0) {
769 double widthd = static_cast<double>(width - base_width); 772 double widthd = static_cast<double>(width - m_size_hints.base_width);
770 double heightd = static_cast<double>(height - base_height); 773 double heightd = static_cast<double>(height - m_size_hints.base_height);
771 774
772 double min = static_cast<double>(min_aspect_x) / 775 double min = static_cast<double>(m_size_hints.min_aspect_x) /
773 static_cast<double>(min_aspect_y); 776 static_cast<double>(m_size_hints.min_aspect_y);
774 777
775 double max = static_cast<double>(max_aspect_x) / 778 double max = static_cast<double>(m_size_hints.max_aspect_x) /
776 static_cast<double>(max_aspect_y); 779 static_cast<double>(m_size_hints.max_aspect_y);
777 780
778 double actual = widthd / heightd; 781 double actual = widthd / heightd;
779 782
@@ -794,23 +797,23 @@ void WinClient::applySizeHints(int &width, int &height,
794 } 797 }
795 798
796 if (changed) { 799 if (changed) {
797 width = static_cast<int>(widthd) + base_width; 800 width = static_cast<int>(widthd) + m_size_hints.base_width;
798 height = static_cast<int>(heightd) + base_height; 801 height = static_cast<int>(heightd) + m_size_hints.base_height;
799 } 802 }
800 } 803 }
801 } 804 }
802 805
803 // enforce incremental size limits, wrt base size 806 // enforce incremental size limits, wrt base size
804 // only calculate this if we really need to 807 // only calculate this if we really need to
805 i = (width - static_cast<signed>(base_width)) / 808 i = (width - static_cast<signed>(m_size_hints.base_width)) /
806 static_cast<signed>(width_inc); 809 static_cast<signed>(m_size_hints.width_inc);
807 width = i*static_cast<signed>(width_inc) + 810 width = i*static_cast<signed>(m_size_hints.width_inc) +
808 static_cast<signed>(base_width); 811 static_cast<signed>(m_size_hints.base_width);
809 812
810 j = (height - static_cast<signed>(base_height)) / 813 j = (height - static_cast<signed>(m_size_hints.base_height)) /
811 static_cast<signed>(height_inc); 814 static_cast<signed>(m_size_hints.height_inc);
812 height = j*static_cast<signed>(height_inc) + 815 height = j*static_cast<signed>(m_size_hints.height_inc) +
813 static_cast<signed>(base_height); 816 static_cast<signed>(m_size_hints.base_height);
814 817
815 if (display_width) 818 if (display_width)
816 *display_width = i; 819 *display_width = i;
@@ -821,24 +824,24 @@ void WinClient::applySizeHints(int &width, int &height,
821 824
822// check if the given width and height satisfy the size hints 825// check if the given width and height satisfy the size hints
823bool WinClient::checkSizeHints(unsigned int width, unsigned int height) { 826bool WinClient::checkSizeHints(unsigned int width, unsigned int height) {
824 if (width < min_width || height < min_height) 827 if (width < m_size_hints.min_width || height < m_size_hints.min_height)
825 return false; 828 return false;
826 829
827 if (width > max_width || height > max_height) 830 if (width > m_size_hints.max_width || height > m_size_hints.max_height)
828 return false; 831 return false;
829 832
830 if ((width - base_width) % width_inc != 0) 833 if ((width - m_size_hints.base_width) % m_size_hints.width_inc != 0)
831 return false; 834 return false;
832 835
833 if ((height - base_height) % height_inc != 0) 836 if ((height - m_size_hints.base_height) % m_size_hints.height_inc != 0)
834 return false; 837 return false;
835 838
836 double ratio = (double)width / (double)height; 839 double ratio = (double)width / (double)height;
837 840
838 if (min_aspect_y > 0 && (double)min_aspect_x / (double)min_aspect_y > ratio) 841 if (m_size_hints.min_aspect_y > 0 && (double)m_size_hints.min_aspect_x / (double)m_size_hints.min_aspect_y > ratio)
839 return false; 842 return false;
840 843
841 if (max_aspect_y > 0 && (double)max_aspect_x / (double)max_aspect_y < ratio) 844 if (m_size_hints.max_aspect_y > 0 && (double)m_size_hints.max_aspect_x / (double)m_size_hints.max_aspect_y < ratio)
842 return false; 845 return false;
843 846
844 return true; 847 return true;
diff --git a/src/WinClient.hh b/src/WinClient.hh
index 51d5077..51d3b3e 100644
--- a/src/WinClient.hh
+++ b/src/WinClient.hh
@@ -43,6 +43,21 @@ public:
43 unsigned long decorations; // Motif wm decorations 43 unsigned long decorations; // Motif wm decorations
44 } MwmHints; 44 } MwmHints;
45 45
46 typedef struct SizeHints {
47 unsigned int min_width;
48 unsigned int max_width;
49 unsigned int min_height;
50 unsigned int max_height;
51 unsigned int width_inc;
52 unsigned int height_inc;
53 unsigned int min_aspect_x;
54 unsigned int max_aspect_x;
55 unsigned int min_aspect_y;
56 unsigned int max_aspect_y;
57 unsigned int base_width;
58 unsigned int base_height;
59 } SizeHints;
60
46 WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin = 0); 61 WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin = 0);
47 62
48 ~WinClient(); 63 ~WinClient();
@@ -129,8 +144,12 @@ public:
129 144
130 const MwmHints *getMwmHint() const { return m_mwm_hint; } 145 const MwmHints *getMwmHint() const { return m_mwm_hint; }
131 146
132 unsigned int maxWidth() const { return max_width; } 147 unsigned int minWidth() const { return m_size_hints.min_width; }
133 unsigned int maxHeight() const { return max_height; } 148 unsigned int minHeight() const { return m_size_hints.min_height; }
149 unsigned int maxWidth() const { return m_size_hints.max_width; }
150 unsigned int maxHeight() const { return m_size_hints.max_height; }
151 unsigned int widthInc() const { return m_size_hints.width_inc; }
152 unsigned int heightInc() const { return m_size_hints.height_inc; }
134 153
135 static const int PropMwmHintsElements = 3; 154 static const int PropMwmHintsElements = 3;
136 155
@@ -145,10 +164,6 @@ public:
145 164
146 165
147 int x, y, old_bw; 166 int x, y, old_bw;
148 unsigned int
149 min_width, min_height, max_width, max_height, width_inc, height_inc,
150 min_aspect_x, min_aspect_y, max_aspect_x, max_aspect_y,
151 base_width, base_height;
152 unsigned long initial_state, normal_hint_flags, wm_hint_flags; 167 unsigned long initial_state, normal_hint_flags, wm_hint_flags;
153 168
154private: 169private:
@@ -172,6 +187,7 @@ private:
172 187
173 Focusable::WindowType m_window_type; 188 Focusable::WindowType m_window_type;
174 MwmHints *m_mwm_hint; 189 MwmHints *m_mwm_hint;
190 SizeHints m_size_hints;
175 191
176 Strut *m_strut; 192 Strut *m_strut;
177 // map transient_for X window to winclient transient 193 // map transient_for X window to winclient transient
diff --git a/src/Window.cc b/src/Window.cc
index 0c5ae0f..651b995 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -472,8 +472,9 @@ void FluxboxWindow::init() {
472 472
473 if ((m_client->normal_hint_flags & PMinSize) && 473 if ((m_client->normal_hint_flags & PMinSize) &&
474 (m_client->normal_hint_flags & PMaxSize) && 474 (m_client->normal_hint_flags & PMaxSize) &&
475 m_client->max_width != 0 && m_client->max_width <= m_client->min_width && 475 m_client->maxWidth() != 0 && m_client->maxHeight() != 0 &&
476 m_client->max_height != 0 && m_client->max_height <= m_client->min_height) { 476 m_client->maxWidth() <= m_client->minWidth() &&
477 m_client->maxHeight() <= m_client->minHeight()) {
477 decorations.maximize = decorations.handle = 478 decorations.maximize = decorations.handle =
478 functions.resize = functions.maximize = false; 479 functions.resize = functions.maximize = false;
479 decorations.tab = false; //no tab for this window 480 decorations.tab = false; //no tab for this window
@@ -2391,19 +2392,20 @@ void FluxboxWindow::propertyNotifyEvent(WinClient &client, Atom atom) {
2391#ifdef DEBUG 2392#ifdef DEBUG
2392 cerr<<"XA_WM_NORMAL_HINTS("<<title()<<")"<<endl; 2393 cerr<<"XA_WM_NORMAL_HINTS("<<title()<<")"<<endl;
2393#endif // DEBUG 2394#endif // DEBUG
2394 unsigned int old_max_width = client.max_width; 2395 unsigned int old_max_width = client.maxWidth();
2395 unsigned int old_min_width = client.min_width; 2396 unsigned int old_min_width = client.minWidth();
2396 unsigned int old_min_height = client.min_height; 2397 unsigned int old_min_height = client.minHeight();
2397 unsigned int old_max_height = client.max_height; 2398 unsigned int old_max_height = client.maxHeight();
2398 bool changed = false; 2399 bool changed = false;
2399 client.updateWMNormalHints(); 2400 client.updateWMNormalHints();
2400 2401
2401 if (client.min_width != old_min_width || 2402 if (client.minWidth() != old_min_width ||
2402 client.max_width != old_max_width || 2403 client.maxWidth() != old_max_width ||
2403 client.min_height != old_min_height || 2404 client.minHeight() != old_min_height ||
2404 client.max_height != old_max_height) { 2405 client.maxHeight() != old_max_height) {
2405 if (client.max_width != 0 && client.max_width <= client.min_width && 2406 if (client.maxWidth() != 0 && client.maxHeight() != 0 &&
2406 client.max_height != 0 && client.max_height <= client.min_height) { 2407 client.maxWidth() <= client.minWidth() &&
2408 client.maxHeight() <= client.minHeight()) {
2407 if (decorations.maximize || 2409 if (decorations.maximize ||
2408 decorations.handle || 2410 decorations.handle ||
2409 functions.resize || 2411 functions.resize ||