diff options
author | rathnor <rathnor> | 2003-09-11 19:55:27 (GMT) |
---|---|---|
committer | rathnor <rathnor> | 2003-09-11 19:55:27 (GMT) |
commit | 6d6425cbde2a4c2038f513c78e5953d0dbdbc20d (patch) | |
tree | 19edf876933796c277816f568f1754c562eb3f43 | |
parent | 16653d23d5d7a0dd017cce6484e8865f59edb9c6 (diff) | |
download | fluxbox-6d6425cbde2a4c2038f513c78e5953d0dbdbc20d.zip fluxbox-6d6425cbde2a4c2038f513c78e5953d0dbdbc20d.tar.bz2 |
fix gravity handling
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | src/FbWinFrame.cc | 17 | ||||
-rw-r--r-- | src/WinClient.cc | 11 | ||||
-rw-r--r-- | src/WinClient.hh | 8 | ||||
-rw-r--r-- | src/Window.cc | 148 |
5 files changed, 48 insertions, 140 deletions
@@ -1,5 +1,9 @@ | |||
1 | (Format: Year/Month/Day) | 1 | (Format: Year/Month/Day) |
2 | Changes for 0.9.6: | 2 | Changes for 0.9.6: |
3 | *03/09/12: | ||
4 | * Fix window gravity handling (Simon) | ||
5 | - should fix some offset fullscreen issues | ||
6 | FbWinFrame.hh/cc WinClient.hh/cc Window.cc | ||
3 | *03/09/10: | 7 | *03/09/10: |
4 | * Fixed buffer for TextButton (Henrik) | 8 | * Fixed buffer for TextButton (Henrik) |
5 | Reduces flicker | 9 | Reduces flicker |
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index 3dd0f1b..31dfae0 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.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: FbWinFrame.cc,v 1.47 2003/09/11 13:35:37 rathnor Exp $ | 22 | // $Id: FbWinFrame.cc,v 1.48 2003/09/11 19:55:27 rathnor Exp $ |
23 | 23 | ||
24 | #include "FbWinFrame.hh" | 24 | #include "FbWinFrame.hh" |
25 | 25 | ||
@@ -1112,6 +1112,7 @@ void FbWinFrame::updateTransparent() { | |||
1112 | 1112 | ||
1113 | // this function translates its arguments according to win_gravity | 1113 | // this function translates its arguments according to win_gravity |
1114 | // if win_gravity is negative, it does an inverse translation | 1114 | // if win_gravity is negative, it does an inverse translation |
1115 | // This function should be used when a window is mapped/unmapped/pos configured | ||
1115 | void FbWinFrame::gravityTranslate(int &x, int &y, int win_gravity, bool move_frame) { | 1116 | void FbWinFrame::gravityTranslate(int &x, int &y, int win_gravity, bool move_frame) { |
1116 | bool invert = false; | 1117 | bool invert = false; |
1117 | if (win_gravity < 0) { | 1118 | if (win_gravity < 0) { |
@@ -1140,7 +1141,9 @@ void FbWinFrame::gravityTranslate(int &x, int &y, int win_gravity, bool move_fra | |||
1140 | int x_offset = 0; | 1141 | int x_offset = 0; |
1141 | int y_offset = 0; | 1142 | int y_offset = 0; |
1142 | 1143 | ||
1143 | // Start with X offset | 1144 | // no X offset, since we don't have extra frame on the sides |
1145 | |||
1146 | // then y offset | ||
1144 | switch (win_gravity) { | 1147 | switch (win_gravity) { |
1145 | case NorthWestGravity: | 1148 | case NorthWestGravity: |
1146 | case NorthGravity: | 1149 | case NorthGravity: |
@@ -1153,23 +1156,21 @@ void FbWinFrame::gravityTranslate(int &x, int &y, int win_gravity, bool move_fra | |||
1153 | // window shifted down by height of titlebar, and the handle | 1156 | // window shifted down by height of titlebar, and the handle |
1154 | // since that's necessary to get the bottom of the frame | 1157 | // since that's necessary to get the bottom of the frame |
1155 | // all the way up | 1158 | // all the way up |
1156 | x_offset = -(m_titlebar.height() + m_titlebar.borderWidth() | 1159 | y_offset = -(m_titlebar.height() + m_titlebar.borderWidth() |
1157 | + m_handle.height() + m_handle.borderWidth()); | 1160 | + m_handle.height() + m_handle.borderWidth()); |
1158 | break; | 1161 | break; |
1159 | case WestGravity: | 1162 | case WestGravity: |
1160 | case EastGravity: | 1163 | case EastGravity: |
1161 | case CenterGravity: | 1164 | case CenterGravity: |
1162 | // these centered ones are a little more interesting | 1165 | // these centered ones are a little more interesting |
1163 | x_offset = -(m_titlebar.height() + m_titlebar.borderWidth() | 1166 | y_offset = -(m_titlebar.height() + m_titlebar.borderWidth() |
1164 | + m_handle.height() + m_handle.borderWidth()) / 2; | 1167 | + m_handle.height() + m_handle.borderWidth()) / 2; |
1165 | break; | 1168 | break; |
1166 | case StaticGravity: | 1169 | case StaticGravity: |
1167 | x_offset = -(m_titlebar.height() + m_titlebar.borderWidth()); | 1170 | y_offset = -(m_titlebar.height() + m_titlebar.borderWidth()); |
1168 | break; | 1171 | break; |
1169 | } | 1172 | } |
1170 | 1173 | ||
1171 | // no Y offset, since we don't have a frame down there | ||
1172 | |||
1173 | if (invert) { | 1174 | if (invert) { |
1174 | x_offset = -x_offset; | 1175 | x_offset = -x_offset; |
1175 | y_offset = -y_offset; | 1176 | y_offset = -y_offset; |
@@ -1179,6 +1180,6 @@ void FbWinFrame::gravityTranslate(int &x, int &y, int win_gravity, bool move_fra | |||
1179 | y += y_offset; | 1180 | y += y_offset; |
1180 | 1181 | ||
1181 | if (move_frame && (x_offset != 0 || y_offset != 0)) { | 1182 | if (move_frame && (x_offset != 0 || y_offset != 0)) { |
1182 | move(m_window.x() + x_offset, m_window.y() + y_offset); | 1183 | move(x,y); |
1183 | } | 1184 | } |
1184 | } | 1185 | } |
diff --git a/src/WinClient.cc b/src/WinClient.cc index 7332a95..d6cd585 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.23 2003/07/28 18:30:02 fluxgen Exp $ | 22 | // $Id: WinClient.cc,v 1.24 2003/09/11 19:55:27 rathnor Exp $ |
23 | 23 | ||
24 | #include "WinClient.hh" | 24 | #include "WinClient.hh" |
25 | 25 | ||
@@ -48,7 +48,6 @@ WinClient::WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin):FbTk::Fb | |||
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), |
50 | base_width(1), base_height(1), | 50 | base_width(1), base_height(1), |
51 | win_gravity(0), | ||
52 | initial_state(0), | 51 | initial_state(0), |
53 | normal_hint_flags(0), | 52 | normal_hint_flags(0), |
54 | wm_hint_flags(0), | 53 | wm_hint_flags(0), |
@@ -56,6 +55,7 @@ WinClient::WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin):FbTk::Fb | |||
56 | m_modal(0), | 55 | m_modal(0), |
57 | send_focus_message(false), | 56 | send_focus_message(false), |
58 | closable(false), | 57 | closable(false), |
58 | m_win_gravity(0), | ||
59 | m_title(""), m_icon_title(""), | 59 | m_title(""), m_icon_title(""), |
60 | m_class_name(""), m_instance_name(""), | 60 | m_class_name(""), m_instance_name(""), |
61 | m_blackbox_hint(0), | 61 | m_blackbox_hint(0), |
@@ -427,7 +427,7 @@ void WinClient::updateWMNormalHints() { | |||
427 | max_height = 0; | 427 | max_height = 0; |
428 | min_aspect_x = min_aspect_y = | 428 | min_aspect_x = min_aspect_y = |
429 | max_aspect_x = max_aspect_y = 1; | 429 | max_aspect_x = max_aspect_y = 1; |
430 | win_gravity = NorthWestGravity; | 430 | m_win_gravity = NorthWestGravity; |
431 | } else { | 431 | } else { |
432 | normal_hint_flags = sizehint.flags; | 432 | normal_hint_flags = sizehint.flags; |
433 | 433 | ||
@@ -467,9 +467,10 @@ void WinClient::updateWMNormalHints() { | |||
467 | base_width = base_height = 0; | 467 | base_width = base_height = 0; |
468 | 468 | ||
469 | if (sizehint.flags & PWinGravity) | 469 | if (sizehint.flags & PWinGravity) |
470 | win_gravity = sizehint.win_gravity; | 470 | m_win_gravity = sizehint.win_gravity; |
471 | else | 471 | else |
472 | win_gravity = NorthWestGravity; | 472 | m_win_gravity = NorthWestGravity; |
473 | |||
473 | } | 474 | } |
474 | } | 475 | } |
475 | 476 | ||
diff --git a/src/WinClient.hh b/src/WinClient.hh index 755a235..bb89c99 100644 --- a/src/WinClient.hh +++ b/src/WinClient.hh | |||
@@ -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.hh,v 1.12 2003/07/28 15:46:00 rathnor Exp $ | 22 | // $Id: WinClient.hh,v 1.13 2003/09/11 19:55:27 rathnor Exp $ |
23 | 23 | ||
24 | #ifndef WINCLIENT_HH | 24 | #ifndef WINCLIENT_HH |
25 | #define WINCLIENT_HH | 25 | #define WINCLIENT_HH |
@@ -109,6 +109,8 @@ public: | |||
109 | // does this client have a pending unmap or destroy event? | 109 | // does this client have a pending unmap or destroy event? |
110 | bool validateClient() const; | 110 | bool validateClient() const; |
111 | 111 | ||
112 | inline int gravity() const { return m_win_gravity; } | ||
113 | |||
112 | /** | 114 | /** |
113 | !! TODO !! | 115 | !! TODO !! |
114 | remove or move these to private | 116 | remove or move these to private |
@@ -123,7 +125,7 @@ public: | |||
123 | unsigned int | 125 | unsigned int |
124 | min_width, min_height, max_width, max_height, width_inc, height_inc, | 126 | min_width, min_height, max_width, max_height, width_inc, height_inc, |
125 | min_aspect_x, min_aspect_y, max_aspect_x, max_aspect_y, | 127 | min_aspect_x, min_aspect_y, max_aspect_x, max_aspect_y, |
126 | base_width, base_height, win_gravity; | 128 | base_width, base_height; |
127 | unsigned long initial_state, normal_hint_flags, wm_hint_flags; | 129 | unsigned long initial_state, normal_hint_flags, wm_hint_flags; |
128 | 130 | ||
129 | // this structure only contains 3 elements... the Motif 2.0 structure contains | 131 | // this structure only contains 3 elements... the Motif 2.0 structure contains |
@@ -157,6 +159,8 @@ private: | |||
157 | int m_modal; | 159 | int m_modal; |
158 | bool send_focus_message, closable; | 160 | bool send_focus_message, closable; |
159 | 161 | ||
162 | int m_win_gravity; | ||
163 | |||
160 | std::string m_title, m_icon_title; | 164 | std::string m_title, m_icon_title; |
161 | std::string m_class_name, m_instance_name; | 165 | std::string m_class_name, m_instance_name; |
162 | 166 | ||
diff --git a/src/Window.cc b/src/Window.cc index 232f2f3..763fd52 100644 --- a/src/Window.cc +++ b/src/Window.cc | |||
@@ -22,7 +22,7 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: Window.cc,v 1.223 2003/09/10 09:56:18 fluxgen Exp $ | 25 | // $Id: Window.cc,v 1.224 2003/09/11 19:55:27 rathnor Exp $ |
26 | 26 | ||
27 | #include "Window.hh" | 27 | #include "Window.hh" |
28 | 28 | ||
@@ -463,10 +463,22 @@ void FluxboxWindow::init() { | |||
463 | 463 | ||
464 | upsize(); | 464 | upsize(); |
465 | 465 | ||
466 | associateClientWindow(); | ||
467 | |||
468 | grabButtons(); | ||
469 | |||
470 | applyDecorations(true); | ||
471 | |||
472 | if (m_workspace_number < 0 || m_workspace_number >= screen().getCount()) | ||
473 | m_workspace_number = screen().currentWorkspaceID(); | ||
474 | |||
475 | restoreAttributes(); | ||
476 | |||
466 | bool place_window = true; | 477 | bool place_window = true; |
467 | if (fluxbox.isStartup() || m_client->isTransient() || | 478 | if (fluxbox.isStartup() || m_client->isTransient() || |
468 | m_client->normal_hint_flags & (PPosition|USPosition)) { | 479 | m_client->normal_hint_flags & (PPosition|USPosition)) { |
469 | setGravityOffsets(); | 480 | |
481 | frame().gravityTranslate(wattrib.x, wattrib.y, m_client->gravity(), false); | ||
470 | 482 | ||
471 | if (! fluxbox.isStartup()) { | 483 | if (! fluxbox.isStartup()) { |
472 | 484 | ||
@@ -484,17 +496,6 @@ void FluxboxWindow::init() { | |||
484 | 496 | ||
485 | } | 497 | } |
486 | 498 | ||
487 | associateClientWindow(); | ||
488 | |||
489 | grabButtons(); | ||
490 | |||
491 | applyDecorations(true); | ||
492 | |||
493 | if (m_workspace_number < 0 || m_workspace_number >= screen().getCount()) | ||
494 | m_workspace_number = screen().currentWorkspaceID(); | ||
495 | |||
496 | restoreAttributes(); | ||
497 | |||
498 | frame().move(wattrib.x, wattrib.y); | 499 | frame().move(wattrib.x, wattrib.y); |
499 | frame().resizeForClient(wattrib.width, wattrib.height); | 500 | frame().resizeForClient(wattrib.width, wattrib.height); |
500 | 501 | ||
@@ -1762,75 +1763,6 @@ bool FluxboxWindow::getState() { | |||
1762 | return ret; | 1763 | return ret; |
1763 | } | 1764 | } |
1764 | 1765 | ||
1765 | //!! TODO: this functions looks odd | ||
1766 | void FluxboxWindow::setGravityOffsets() { | ||
1767 | int newx = frame().x(); | ||
1768 | int newy = frame().y(); | ||
1769 | // translate x coordinate | ||
1770 | switch (m_client->win_gravity) { | ||
1771 | // handle Westward gravity | ||
1772 | case NorthWestGravity: | ||
1773 | case WestGravity: | ||
1774 | case SouthWestGravity: | ||
1775 | default: | ||
1776 | #ifdef DEBUG | ||
1777 | cerr<<__FILE__<<": Default gravity: SouthWest, NorthWest, West"<<endl; | ||
1778 | #endif // DEBUG | ||
1779 | |||
1780 | newx = frame().x(); | ||
1781 | break; | ||
1782 | |||
1783 | // handle Eastward gravity | ||
1784 | case NorthEastGravity: | ||
1785 | case EastGravity: | ||
1786 | case SouthEastGravity: | ||
1787 | #ifdef DEBUG | ||
1788 | cerr<<__FILE__<<": Gravity: SouthEast, NorthEast, East"<<endl; | ||
1789 | #endif // DEBUG | ||
1790 | |||
1791 | newx = frame().x() + frame().clientArea().width() - frame().width(); | ||
1792 | break; | ||
1793 | |||
1794 | // no x translation desired - default | ||
1795 | case StaticGravity: | ||
1796 | case ForgetGravity: | ||
1797 | case CenterGravity: | ||
1798 | #ifdef DEBUG | ||
1799 | cerr<<__FILE__<<": Gravity: Center, Forget, Static"<<endl; | ||
1800 | #endif // DEBUG | ||
1801 | |||
1802 | newx = frame().x(); | ||
1803 | } | ||
1804 | |||
1805 | // translate y coordinate | ||
1806 | switch (m_client->win_gravity) { | ||
1807 | // handle Northbound gravity | ||
1808 | case NorthWestGravity: | ||
1809 | case NorthGravity: | ||
1810 | case NorthEastGravity: | ||
1811 | default: | ||
1812 | newy = frame().y(); | ||
1813 | break; | ||
1814 | |||
1815 | // handle Southbound gravity | ||
1816 | case SouthWestGravity: | ||
1817 | case SouthGravity: | ||
1818 | case SouthEastGravity: | ||
1819 | newy = frame().y() + frame().clientArea().height() - frame().height(); | ||
1820 | break; | ||
1821 | |||
1822 | // no y translation desired - default | ||
1823 | case StaticGravity: | ||
1824 | case ForgetGravity: | ||
1825 | case CenterGravity: | ||
1826 | newy = frame().y(); | ||
1827 | break; | ||
1828 | } | ||
1829 | // finaly move the frame | ||
1830 | if (frame().x() != newx || frame().y() != newy) | ||
1831 | frame().move(newx, newy); | ||
1832 | } | ||
1833 | |||
1834 | /** | 1766 | /** |
1835 | * Sets the attributes to what they should be | 1767 | * Sets the attributes to what they should be |
1836 | * but doesn't change the actual state | 1768 | * but doesn't change the actual state |
@@ -1948,44 +1880,6 @@ void FluxboxWindow::popupMenu() { | |||
1948 | m_windowmenu.raise(); | 1880 | m_windowmenu.raise(); |
1949 | } | 1881 | } |
1950 | 1882 | ||
1951 | void FluxboxWindow::restoreGravity() { | ||
1952 | // restore x coordinate | ||
1953 | switch (m_client->win_gravity) { | ||
1954 | // handle Westward gravity | ||
1955 | case NorthWestGravity: | ||
1956 | case WestGravity: | ||
1957 | case SouthWestGravity: | ||
1958 | default: | ||
1959 | m_client->x = frame().x(); | ||
1960 | break; | ||
1961 | |||
1962 | // handle Eastward gravity | ||
1963 | case NorthEastGravity: | ||
1964 | case EastGravity: | ||
1965 | case SouthEastGravity: | ||
1966 | m_client->x = (frame().x() + frame().width()) - m_client->width(); | ||
1967 | break; | ||
1968 | } | ||
1969 | |||
1970 | // restore y coordinate | ||
1971 | switch (m_client->win_gravity) { | ||
1972 | // handle Northbound gravity | ||
1973 | case NorthWestGravity: | ||
1974 | case NorthGravity: | ||
1975 | case NorthEastGravity: | ||
1976 | default: | ||
1977 | m_client->y = frame().y(); | ||
1978 | break; | ||
1979 | |||
1980 | // handle Southbound gravity | ||
1981 | case SouthWestGravity: | ||
1982 | case SouthGravity: | ||
1983 | case SouthEastGravity: | ||
1984 | m_client->y = (frame().y() + frame().height()) - m_client->height(); | ||
1985 | break; | ||
1986 | } | ||
1987 | } | ||
1988 | |||
1989 | /** | 1883 | /** |
1990 | Determine if this is the lowest tab of them all | 1884 | Determine if this is the lowest tab of them all |
1991 | */ | 1885 | */ |
@@ -2281,17 +2175,21 @@ void FluxboxWindow::configureRequestEvent(XConfigureRequestEvent &cr) { | |||
2281 | if (client == 0) | 2175 | if (client == 0) |
2282 | return; | 2176 | return; |
2283 | 2177 | ||
2284 | int cx = frame().x(), cy = frame().y(); | 2178 | int cx = frame().x(), cy = frame().y(), ignore = 0; |
2285 | unsigned int cw = frame().width(), ch = frame().height(); | 2179 | unsigned int cw = frame().width(), ch = frame().height(); |
2286 | 2180 | ||
2287 | if (cr.value_mask & CWBorderWidth) | 2181 | if (cr.value_mask & CWBorderWidth) |
2288 | client->old_bw = cr.border_width; | 2182 | client->old_bw = cr.border_width; |
2289 | 2183 | ||
2290 | if (cr.value_mask & CWX) | 2184 | if (cr.value_mask & CWX) { |
2291 | cx = cr.x; | 2185 | cx = cr.x; |
2186 | frame().gravityTranslate(cx, ignore, client->gravity(), false); | ||
2187 | } | ||
2292 | 2188 | ||
2293 | if (cr.value_mask & CWY) | 2189 | if (cr.value_mask & CWY) { |
2294 | cy = cr.y; | 2190 | cy = cr.y; |
2191 | frame().gravityTranslate(ignore, cy, client->gravity(), false); | ||
2192 | } | ||
2295 | 2193 | ||
2296 | if (cr.value_mask & CWWidth) | 2194 | if (cr.value_mask & CWWidth) |
2297 | cw = cr.width; | 2195 | cw = cr.width; |
@@ -3062,8 +2960,8 @@ void FluxboxWindow::restore(WinClient *client, bool remap) { | |||
3062 | XChangeSaveSet(display, client->window(), SetModeDelete); | 2960 | XChangeSaveSet(display, client->window(), SetModeDelete); |
3063 | client->setEventMask(NoEventMask); | 2961 | client->setEventMask(NoEventMask); |
3064 | 2962 | ||
3065 | //!! TODO | 2963 | int wx = frame().x(), wy = frame().y(); // not actually used here |
3066 | //restoreGravity(); | 2964 | frame().gravityTranslate(wx, wy, -client->gravity(), true); // negative to invert |
3067 | 2965 | ||
3068 | client->hide(); | 2966 | client->hide(); |
3069 | 2967 | ||