diff options
author | Mark Tiefenbruck <mark@fluxbox.org> | 2008-08-16 07:22:12 (GMT) |
---|---|---|
committer | Mark Tiefenbruck <mark@fluxbox.org> | 2008-08-16 07:22:12 (GMT) |
commit | fe412dbeef7af324a376cba338bff8c24e032d2e (patch) | |
tree | eab03ffc2e6b94e70d78c29ae3384b2c265e7a18 /src | |
parent | 1d8dfcdf9ad5405f4eef18dc009ce8cfe6d27f29 (diff) | |
download | fluxbox_lack-fe412dbeef7af324a376cba338bff8c24e032d2e.zip fluxbox_lack-fe412dbeef7af324a376cba338bff8c24e032d2e.tar.bz2 |
move interpretation of normal hints to size hint class
Diffstat (limited to 'src')
-rw-r--r-- | src/FbWinFrame.cc | 67 | ||||
-rw-r--r-- | src/FbWinFrame.hh | 12 | ||||
-rw-r--r-- | src/Keys.cc | 2 | ||||
-rw-r--r-- | src/WinClient.cc | 57 | ||||
-rw-r--r-- | src/WinClient.hh | 6 |
5 files changed, 71 insertions, 73 deletions
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index 36d2942..c7eaef3 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc | |||
@@ -85,7 +85,6 @@ FbWinFrame::FbWinFrame(BScreen &screen, | |||
85 | m_visible(false), | 85 | m_visible(false), |
86 | m_button_pm(0), | 86 | m_button_pm(0), |
87 | m_tabmode(screen.getDefaultInternalTabs()?INTERNAL:EXTERNAL), | 87 | m_tabmode(screen.getDefaultInternalTabs()?INTERNAL:EXTERNAL), |
88 | m_active_gravity(0), | ||
89 | m_active_orig_client_bw(0), | 88 | m_active_orig_client_bw(0), |
90 | m_need_render(true), | 89 | m_need_render(true), |
91 | m_button_size(1), | 90 | m_button_size(1), |
@@ -846,7 +845,7 @@ void FbWinFrame::reconfigure() { | |||
846 | 845 | ||
847 | int grav_x=0, grav_y=0; | 846 | int grav_x=0, grav_y=0; |
848 | // negate gravity | 847 | // negate gravity |
849 | gravityTranslate(grav_x, grav_y, -m_active_gravity, m_active_orig_client_bw, false); | 848 | gravityTranslate(grav_x, grav_y, -sizeHints().win_gravity, m_active_orig_client_bw, false); |
850 | 849 | ||
851 | m_bevel = theme()->bevelWidth(); | 850 | m_bevel = theme()->bevelWidth(); |
852 | setBorderWidth(); | 851 | setBorderWidth(); |
@@ -941,7 +940,7 @@ void FbWinFrame::reconfigure() { | |||
941 | m_window.width(), client_height); | 940 | m_window.width(), client_height); |
942 | } | 941 | } |
943 | 942 | ||
944 | gravityTranslate(grav_x, grav_y, m_active_gravity, m_active_orig_client_bw, false); | 943 | gravityTranslate(grav_x, grav_y, sizeHints().win_gravity, m_active_orig_client_bw, false); |
945 | // if the location changes, shift it | 944 | // if the location changes, shift it |
946 | if (grav_x != 0 || grav_y != 0) | 945 | if (grav_x != 0 || grav_y != 0) |
947 | move(grav_x + x(), grav_y + y()); | 946 | move(grav_x + x(), grav_y + y()); |
@@ -1456,7 +1455,7 @@ bool FbWinFrame::useHandle() const { | |||
1456 | void FbWinFrame::applyDecorations() { | 1455 | void FbWinFrame::applyDecorations() { |
1457 | int grav_x=0, grav_y=0; | 1456 | int grav_x=0, grav_y=0; |
1458 | // negate gravity | 1457 | // negate gravity |
1459 | gravityTranslate(grav_x, grav_y, -m_active_gravity, m_active_orig_client_bw, | 1458 | gravityTranslate(grav_x, grav_y, -sizeHints().win_gravity, m_active_orig_client_bw, |
1460 | false); | 1459 | false); |
1461 | 1460 | ||
1462 | bool client_move = setBorderWidth(false); | 1461 | bool client_move = setBorderWidth(false); |
@@ -1488,7 +1487,7 @@ void FbWinFrame::applyDecorations() { | |||
1488 | client_move |= hideHandle(); | 1487 | client_move |= hideHandle(); |
1489 | 1488 | ||
1490 | // apply gravity once more | 1489 | // apply gravity once more |
1491 | gravityTranslate(grav_x, grav_y, m_active_gravity, m_active_orig_client_bw, | 1490 | gravityTranslate(grav_x, grav_y, sizeHints().win_gravity, m_active_orig_client_bw, |
1492 | false); | 1491 | false); |
1493 | 1492 | ||
1494 | // if the location changes, shift it | 1493 | // if the location changes, shift it |
@@ -1523,7 +1522,7 @@ bool FbWinFrame::setBorderWidth(bool do_move) { | |||
1523 | int grav_x=0, grav_y=0; | 1522 | int grav_x=0, grav_y=0; |
1524 | // negate gravity | 1523 | // negate gravity |
1525 | if (do_move) | 1524 | if (do_move) |
1526 | gravityTranslate(grav_x, grav_y, -m_active_gravity, | 1525 | gravityTranslate(grav_x, grav_y, -sizeHints().win_gravity, |
1527 | m_active_orig_client_bw, false); | 1526 | m_active_orig_client_bw, false); |
1528 | 1527 | ||
1529 | int bw_changes = 0; | 1528 | int bw_changes = 0; |
@@ -1551,7 +1550,7 @@ bool FbWinFrame::setBorderWidth(bool do_move) { | |||
1551 | 1550 | ||
1552 | if (do_move) { | 1551 | if (do_move) { |
1553 | frameExtentSig().notify(); | 1552 | frameExtentSig().notify(); |
1554 | gravityTranslate(grav_x, grav_y, m_active_gravity, | 1553 | gravityTranslate(grav_x, grav_y, sizeHints().win_gravity, |
1555 | m_active_orig_client_bw, false); | 1554 | m_active_orig_client_bw, false); |
1556 | // if the location changes, shift it | 1555 | // if the location changes, shift it |
1557 | if (grav_x != 0 || grav_y != 0) | 1556 | if (grav_x != 0 || grav_y != 0) |
@@ -1725,6 +1724,60 @@ void FbWinFrame::displaySize(unsigned int width, unsigned int height) const { | |||
1725 | m_screen.showGeometry(i, j); | 1724 | m_screen.showGeometry(i, j); |
1726 | } | 1725 | } |
1727 | 1726 | ||
1727 | void FbWinFrame::SizeHints::reset(const XSizeHints &sizehint) { | ||
1728 | if (sizehint.flags & PMinSize) { | ||
1729 | min_width = sizehint.min_width; | ||
1730 | min_height = sizehint.min_height; | ||
1731 | } else | ||
1732 | min_width = min_height = 1; | ||
1733 | |||
1734 | if (sizehint.flags & PBaseSize) { | ||
1735 | base_width = sizehint.base_width; | ||
1736 | base_height = sizehint.base_height; | ||
1737 | if (!(sizehint.flags & PMinSize)) { | ||
1738 | min_width = base_width; | ||
1739 | min_height = base_height; | ||
1740 | } | ||
1741 | } else | ||
1742 | base_width = base_height = 0; | ||
1743 | |||
1744 | if (sizehint.flags & PMaxSize) { | ||
1745 | max_width = sizehint.max_width; | ||
1746 | max_height = sizehint.max_height; | ||
1747 | } else | ||
1748 | max_width = max_height = 0; // unbounded | ||
1749 | |||
1750 | if (sizehint.flags & PResizeInc) { | ||
1751 | width_inc = sizehint.width_inc; | ||
1752 | height_inc = sizehint.height_inc; | ||
1753 | } else | ||
1754 | width_inc = height_inc = 1; | ||
1755 | |||
1756 | if (sizehint.flags & PAspect) { | ||
1757 | min_aspect_x = sizehint.min_aspect.x; | ||
1758 | min_aspect_y = sizehint.min_aspect.y; | ||
1759 | max_aspect_x = sizehint.max_aspect.x; | ||
1760 | max_aspect_y = sizehint.max_aspect.y; | ||
1761 | } else | ||
1762 | min_aspect_x = min_aspect_y = max_aspect_x = max_aspect_y = 0; | ||
1763 | |||
1764 | if (sizehint.flags & PWinGravity) | ||
1765 | win_gravity = sizehint.win_gravity; | ||
1766 | else | ||
1767 | win_gravity = NorthWestGravity; | ||
1768 | |||
1769 | // some sanity checks | ||
1770 | if (width_inc == 0) | ||
1771 | width_inc = 1; | ||
1772 | if (height_inc == 0) | ||
1773 | height_inc = 1; | ||
1774 | |||
1775 | if (base_width > min_width) | ||
1776 | min_width = base_width; | ||
1777 | if (base_height > min_height) | ||
1778 | min_height = base_height; | ||
1779 | } | ||
1780 | |||
1728 | /* For aspect ratios | 1781 | /* For aspect ratios |
1729 | Note that its slightly simplified in that only the | 1782 | Note that its slightly simplified in that only the |
1730 | line gradient is given - this is because for aspect | 1783 | line gradient is given - this is because for aspect |
diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh index 5c93727..85f0c21 100644 --- a/src/FbWinFrame.hh +++ b/src/FbWinFrame.hh | |||
@@ -33,6 +33,8 @@ | |||
33 | #include "FbTk/Container.hh" | 33 | #include "FbTk/Container.hh" |
34 | #include "FbTk/Shape.hh" | 34 | #include "FbTk/Shape.hh" |
35 | 35 | ||
36 | #include <X11/Xutil.h> | ||
37 | |||
36 | #include <vector> | 38 | #include <vector> |
37 | #include <memory> | 39 | #include <memory> |
38 | 40 | ||
@@ -101,7 +103,10 @@ public: | |||
101 | min_width(1), max_width(0), min_height(1), max_height(0), | 103 | min_width(1), max_width(0), min_height(1), max_height(0), |
102 | width_inc(1), height_inc(1), base_width(0), base_height(0), | 104 | width_inc(1), height_inc(1), base_width(0), base_height(0), |
103 | min_aspect_x(0), max_aspect_x(0), | 105 | min_aspect_x(0), max_aspect_x(0), |
104 | min_aspect_y(0), max_aspect_y(0) { } | 106 | min_aspect_y(0), max_aspect_y(0), |
107 | win_gravity(0) { } | ||
108 | |||
109 | void reset(const XSizeHints &sizehint); | ||
105 | 110 | ||
106 | void apply(unsigned int &w, unsigned int &h, | 111 | void apply(unsigned int &w, unsigned int &h, |
107 | bool maximizing = false) const; | 112 | bool maximizing = false) const; |
@@ -112,6 +117,7 @@ public: | |||
112 | unsigned int min_width, max_width, min_height, max_height, | 117 | unsigned int min_width, max_width, min_height, max_height, |
113 | width_inc, height_inc, base_width, base_height, | 118 | width_inc, height_inc, base_width, base_height, |
114 | min_aspect_x, max_aspect_x, min_aspect_y, max_aspect_y; | 119 | min_aspect_x, max_aspect_x, min_aspect_y, max_aspect_y; |
120 | int win_gravity; | ||
115 | }; | 121 | }; |
116 | 122 | ||
117 | class State { | 123 | class State { |
@@ -241,7 +247,7 @@ public: | |||
241 | // this function translates its arguments according to win_gravity | 247 | // this function translates its arguments according to win_gravity |
242 | // if win_gravity is negative, it does an inverse translation | 248 | // if win_gravity is negative, it does an inverse translation |
243 | void gravityTranslate(int &x, int &y, int win_gravity, unsigned int client_bw, bool move_frame = false); | 249 | void gravityTranslate(int &x, int &y, int win_gravity, unsigned int client_bw, bool move_frame = false); |
244 | void setActiveGravity(int gravity, unsigned int orig_client_bw) { m_active_gravity = gravity; m_active_orig_client_bw = orig_client_bw; } | 250 | void setActiveGravity(int gravity, unsigned int orig_client_bw) { m_state.size_hints.win_gravity = gravity; m_active_orig_client_bw = orig_client_bw; } |
245 | 251 | ||
246 | /** | 252 | /** |
247 | @name Event handlers | 253 | @name Event handlers |
@@ -437,8 +443,6 @@ private: | |||
437 | 443 | ||
438 | TabMode m_tabmode; | 444 | TabMode m_tabmode; |
439 | 445 | ||
440 | // last gravity that this window was *actively* placed with | ||
441 | int m_active_gravity; | ||
442 | unsigned int m_active_orig_client_bw; | 446 | unsigned int m_active_orig_client_bw; |
443 | State m_state; | 447 | State m_state; |
444 | 448 | ||
diff --git a/src/Keys.cc b/src/Keys.cc index 3b0c206..f201e64 100644 --- a/src/Keys.cc +++ b/src/Keys.cc | |||
@@ -170,7 +170,7 @@ Keys::t_key::~t_key() { | |||
170 | 170 | ||
171 | 171 | ||
172 | 172 | ||
173 | Keys::Keys(): next_key(0), m_reloader(new FbTk::AutoReloadHelper()) { | 173 | Keys::Keys(): m_reloader(new FbTk::AutoReloadHelper()), next_key(0) { |
174 | m_reloader->setReloadCmd(FbTk::RefCount<FbTk::Command<void> >(new FbTk::SimpleCommand<Keys>(*this, &Keys::reload))); | 174 | m_reloader->setReloadCmd(FbTk::RefCount<FbTk::Command<void> >(new FbTk::SimpleCommand<Keys>(*this, &Keys::reload))); |
175 | } | 175 | } |
176 | 176 | ||
diff --git a/src/WinClient.cc b/src/WinClient.cc index 2c9cdc6..14414b0 100644 --- a/src/WinClient.cc +++ b/src/WinClient.cc | |||
@@ -75,7 +75,6 @@ WinClient::WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin): | |||
75 | accepts_input(false), | 75 | accepts_input(false), |
76 | send_focus_message(false), | 76 | send_focus_message(false), |
77 | send_close_message(false), | 77 | send_close_message(false), |
78 | m_win_gravity(0), | ||
79 | m_title_override(false), | 78 | m_title_override(false), |
80 | m_icon_override(false), | 79 | m_icon_override(false), |
81 | m_window_type(Focusable::TYPE_NORMAL), | 80 | m_window_type(Focusable::TYPE_NORMAL), |
@@ -467,61 +466,7 @@ void WinClient::updateWMNormalHints() { | |||
467 | sizehint.flags = 0; | 466 | sizehint.flags = 0; |
468 | 467 | ||
469 | normal_hint_flags = sizehint.flags; | 468 | normal_hint_flags = sizehint.flags; |
470 | 469 | m_size_hints.reset(sizehint); | |
471 | if (sizehint.flags & PMinSize) { | ||
472 | m_size_hints.min_width = sizehint.min_width; | ||
473 | m_size_hints.min_height = sizehint.min_height; | ||
474 | } else | ||
475 | m_size_hints.min_width = m_size_hints.min_height = 1; | ||
476 | |||
477 | if (sizehint.flags & PBaseSize) { | ||
478 | m_size_hints.base_width = sizehint.base_width; | ||
479 | m_size_hints.base_height = sizehint.base_height; | ||
480 | if (!(sizehint.flags & PMinSize)) { | ||
481 | m_size_hints.min_width = m_size_hints.base_width; | ||
482 | m_size_hints.min_height = m_size_hints.base_height; | ||
483 | } | ||
484 | } else | ||
485 | m_size_hints.base_width = m_size_hints.base_height = 0; | ||
486 | |||
487 | if (sizehint.flags & PMaxSize) { | ||
488 | m_size_hints.max_width = sizehint.max_width; | ||
489 | m_size_hints.max_height = sizehint.max_height; | ||
490 | } else { | ||
491 | m_size_hints.max_width = 0; // unbounded | ||
492 | m_size_hints.max_height = 0; | ||
493 | } | ||
494 | |||
495 | if (sizehint.flags & PResizeInc) { | ||
496 | m_size_hints.width_inc = sizehint.width_inc; | ||
497 | m_size_hints.height_inc = sizehint.height_inc; | ||
498 | } else | ||
499 | m_size_hints.width_inc = m_size_hints.height_inc = 1; | ||
500 | |||
501 | if (sizehint.flags & PAspect) { | ||
502 | m_size_hints.min_aspect_x = sizehint.min_aspect.x; | ||
503 | m_size_hints.min_aspect_y = sizehint.min_aspect.y; | ||
504 | m_size_hints.max_aspect_x = sizehint.max_aspect.x; | ||
505 | m_size_hints.max_aspect_y = sizehint.max_aspect.y; | ||
506 | } else | ||
507 | m_size_hints.min_aspect_x = m_size_hints.min_aspect_y = | ||
508 | m_size_hints.max_aspect_x = m_size_hints.max_aspect_y = 0; | ||
509 | |||
510 | if (sizehint.flags & PWinGravity) | ||
511 | m_win_gravity = sizehint.win_gravity; | ||
512 | else | ||
513 | m_win_gravity = NorthWestGravity; | ||
514 | |||
515 | // some sanity checks | ||
516 | if (m_size_hints.width_inc == 0) | ||
517 | m_size_hints.width_inc = 1; | ||
518 | if (m_size_hints.height_inc == 0) | ||
519 | m_size_hints.height_inc = 1; | ||
520 | |||
521 | if (m_size_hints.base_width > m_size_hints.min_width) | ||
522 | m_size_hints.min_width = m_size_hints.base_width; | ||
523 | if (m_size_hints.base_height > m_size_hints.min_height) | ||
524 | m_size_hints.min_height = m_size_hints.base_height; | ||
525 | } | 470 | } |
526 | 471 | ||
527 | Window WinClient::getGroupLeftWindow() const { | 472 | Window WinClient::getGroupLeftWindow() const { |
diff --git a/src/WinClient.hh b/src/WinClient.hh index 54c431d..a119f7d 100644 --- a/src/WinClient.hh +++ b/src/WinClient.hh | |||
@@ -27,8 +27,6 @@ | |||
27 | #include "FbTk/FbWindow.hh" | 27 | #include "FbTk/FbWindow.hh" |
28 | #include "FbTk/FbString.hh" | 28 | #include "FbTk/FbString.hh" |
29 | 29 | ||
30 | #include <X11/Xutil.h> | ||
31 | |||
32 | class BScreen; | 30 | class BScreen; |
33 | class Strut; | 31 | class Strut; |
34 | 32 | ||
@@ -110,7 +108,7 @@ public: | |||
110 | bool isStateModal() const { return m_modal; } | 108 | bool isStateModal() const { return m_modal; } |
111 | void setStateModal(bool state); | 109 | void setStateModal(bool state); |
112 | 110 | ||
113 | int gravity() const { return m_win_gravity; } | 111 | int gravity() const { return m_size_hints.win_gravity; } |
114 | 112 | ||
115 | bool hasGroupLeftWindow() const; | 113 | bool hasGroupLeftWindow() const; |
116 | // grouping is tracked by remembering the window to the left in the group | 114 | // grouping is tracked by remembering the window to the left in the group |
@@ -155,8 +153,6 @@ private: | |||
155 | bool m_modal; | 153 | bool m_modal; |
156 | bool accepts_input, send_focus_message, send_close_message; | 154 | bool accepts_input, send_focus_message, send_close_message; |
157 | 155 | ||
158 | int m_win_gravity; | ||
159 | |||
160 | bool m_title_override; | 156 | bool m_title_override; |
161 | bool m_icon_override; | 157 | bool m_icon_override; |
162 | 158 | ||