aboutsummaryrefslogtreecommitdiff
path: root/src/FbWinFrame.cc
diff options
context:
space:
mode:
authormathias <mathias>2005-03-16 23:19:36 (GMT)
committermathias <mathias>2005-03-16 23:19:36 (GMT)
commitd6befe5371c5df7d719cb184c4d20e38dc841a13 (patch)
treefc4a6e98a0cfd804eab303b8d5950de9b74c355f /src/FbWinFrame.cc
parentac3fa211bbc79531151e1400404192b1d7e8516f (diff)
downloadfluxbox-d6befe5371c5df7d719cb184c4d20e38dc841a13.zip
fluxbox-d6befe5371c5df7d719cb184c4d20e38dc841a13.tar.bz2
fix for gravity field on _NET_MOVERESIZE_WINDOW messages, patch from Rob Stevens <stever3 at nycap dot rr dot com>
Diffstat (limited to 'src/FbWinFrame.cc')
-rw-r--r--src/FbWinFrame.cc103
1 files changed, 61 insertions, 42 deletions
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc
index 266f5c4..d4a3d66 100644
--- a/src/FbWinFrame.cc
+++ b/src/FbWinFrame.cc
@@ -166,16 +166,16 @@ void FbWinFrame::shade() {
166} 166}
167 167
168 168
169void FbWinFrame::move(int x, int y) { 169void FbWinFrame::move(int x, int y, int win_gravity) {
170 moveResize(x, y, 0, 0, true, false); 170 moveResize(x, y, 0, 0, true, false, win_gravity);
171} 171}
172 172
173void FbWinFrame::resize(unsigned int width, unsigned int height) { 173void FbWinFrame::resize(unsigned int width, unsigned int height, int win_gravity) {
174 moveResize(0, 0, width, height, false, true); 174 moveResize(0, 0, width, height, false, true, win_gravity);
175} 175}
176 176
177// need an atomic moveresize where possible 177// need an atomic moveresize where possible
178void FbWinFrame::moveResizeForClient(int x, int y, unsigned int width, unsigned int height, bool move, bool resize) { 178void FbWinFrame::moveResizeForClient(int x, int y, unsigned int width, unsigned int height, bool move, bool resize, int win_gravity) {
179 // total height for frame 179 // total height for frame
180 180
181 unsigned int total_height = height; 181 unsigned int total_height = height;
@@ -188,14 +188,17 @@ void FbWinFrame::moveResizeForClient(int x, int y, unsigned int width, unsigned
188 if (m_use_handle) 188 if (m_use_handle)
189 total_height += m_handle.height() + m_handle.borderWidth(); 189 total_height += m_handle.height() + m_handle.borderWidth();
190 } 190 }
191 moveResize(x, y, width, total_height, move, resize); 191 moveResize(x, y, width, total_height, move, resize, win_gravity);
192} 192}
193 193
194void FbWinFrame::resizeForClient(unsigned int width, unsigned int height) { 194void FbWinFrame::resizeForClient(unsigned int width, unsigned int height, int win_gravity) {
195 moveResizeForClient(0, 0, width, height, false, true); 195 moveResizeForClient(0, 0, width, height, false, true, win_gravity);
196} 196}
197 197
198void FbWinFrame::moveResize(int x, int y, unsigned int width, unsigned int height, bool move, bool resize) { 198void FbWinFrame::moveResize(int x, int y, unsigned int width, unsigned int height, bool move, bool resize, int win_gravity) {
199 if(win_gravity!=ForgetGravity) {
200 gravityTranslate(x, y, width + m_window.borderWidth()*2, height + m_window.borderWidth()*2, win_gravity, false);
201 }
199 if (move && x == window().x() && y == window().y()) 202 if (move && x == window().x() && y == window().y())
200 move = false; 203 move = false;
201 204
@@ -1456,6 +1459,10 @@ void FbWinFrame::updateTransparent() {
1456// if win_gravity is negative, it does an inverse translation 1459// if win_gravity is negative, it does an inverse translation
1457// This function should be used when a window is mapped/unmapped/pos configured 1460// This function should be used when a window is mapped/unmapped/pos configured
1458void FbWinFrame::gravityTranslate(int &x, int &y, int win_gravity, bool move_frame) { 1461void FbWinFrame::gravityTranslate(int &x, int &y, int win_gravity, bool move_frame) {
1462 gravityTranslate(x, y, m_window.width(), m_window.height(), win_gravity, move_frame);
1463}
1464//use width and height given instead of the real values, allows figuring out where to place a window before doing a moveResize
1465void FbWinFrame::gravityTranslate(int &x, int &y, unsigned int width, unsigned int height, int win_gravity, bool move_frame) {
1459 bool invert = false; 1466 bool invert = false;
1460 if (win_gravity < 0) { 1467 if (win_gravity < 0) {
1461 invert = true; 1468 invert = true;
@@ -1483,44 +1490,57 @@ void FbWinFrame::gravityTranslate(int &x, int &y, int win_gravity, bool move_fra
1483 int x_offset = 0; 1490 int x_offset = 0;
1484 int y_offset = 0; 1491 int y_offset = 0;
1485 1492
1486 // mostly no X offset, since we don't have extra frame on the sides 1493 /* win_gravity: placed at the reference point
1487 switch (win_gravity) { 1494 * StaticGravity the left top corner of the client window
1488 case NorthWestGravity: 1495 * NorthWestGravity the left top corner of the frame window
1489 case NorthGravity: 1496 * NorthGravity the center of the frame window's top side
1490 case NorthEastGravity: 1497 * NorthEastGravity the right top corner of the frame window
1491 // no offset, since the top point is still the same 1498 * EastGravity the center of the frame window's right side
1492 break; 1499 * SouthEastGravity the right bottom corner of the frame window
1493 case SouthWestGravity: 1500 * SouthGravity the center of the frame window's bottom side
1494 case SouthGravity: 1501 * SouthWestGravity the left bottom corner of the frame window
1495 case SouthEastGravity: 1502 * WestGravity the center of the frame window's left side
1496 // window shifted down by height of titlebar, and the handle 1503 * CenterGravity the center of the frame window
1497 // since that's necessary to get the bottom of the frame 1504 */
1498 // all the way up 1505
1499 if (m_use_titlebar) 1506
1500 y_offset -= m_titlebar.height() + m_titlebar.borderWidth(); 1507 //vertical offset
1501 if (m_use_handle) 1508 //North Gravities don't require a vertical offset
1502 y_offset -= m_handle.height() + m_handle.borderWidth(); 1509 //South Gravities
1503 break; 1510 if (win_gravity==SouthWestGravity || win_gravity==SouthGravity ||
1504 case WestGravity: 1511 win_gravity==SouthEastGravity) {
1505 case EastGravity: 1512 //We start on the frame so going the full height would take us one pixel past the edge of the frame
1506 case CenterGravity: 1513 y_offset-=height-1;
1507 // these centered ones are a little more interesting 1514 }
1508 if (m_use_titlebar) 1515
1509 y_offset -= m_titlebar.height() + m_titlebar.borderWidth(); 1516 //vertical centering
1510 if (m_use_handle) 1517 if (win_gravity==WestGravity || win_gravity==CenterGravity ||
1511 y_offset -= m_handle.height() + m_handle.borderWidth(); 1518 win_gravity==EastGravity) {
1512 y_offset /= 2; 1519 y_offset-=height/2;
1513 break; 1520 }
1514 case StaticGravity: 1521
1522 //horizontal offset
1523 //West Gravities don't require a horizontal offset
1524 //East Gravities
1525 if (win_gravity==NorthEastGravity || win_gravity==EastGravity ||
1526 win_gravity==SouthEastGravity ) {
1527 //Starting on the frame so offset of one width would end up one pixel beyond the border
1528 x_offset-=width-1;
1529 }
1530 //horizontal centering
1531 if (win_gravity==NorthGravity || win_gravity==CenterGravity ||
1532 win_gravity==SouthGravity ) {
1533 x_offset-=width/2;
1534 }
1535
1536 if( win_gravity==StaticGravity ) {
1515 if (m_use_titlebar) 1537 if (m_use_titlebar)
1516 y_offset -= m_titlebar.height() + m_titlebar.borderWidth(); 1538 y_offset -= m_titlebar.height() + m_titlebar.borderWidth();
1517 // static is the only one that also has the
1518 // border taken into account
1519 x_offset -= m_window.borderWidth(); 1539 x_offset -= m_window.borderWidth();
1520 y_offset -= m_window.borderWidth(); 1540 y_offset -= m_window.borderWidth();
1521 break;
1522 } 1541 }
1523 1542
1543
1524 if (invert) { 1544 if (invert) {
1525 x_offset = -x_offset; 1545 x_offset = -x_offset;
1526 y_offset = -y_offset; 1546 y_offset = -y_offset;
@@ -1528,7 +1548,6 @@ void FbWinFrame::gravityTranslate(int &x, int &y, int win_gravity, bool move_fra
1528 1548
1529 x += x_offset; 1549 x += x_offset;
1530 y += y_offset; 1550 y += y_offset;
1531
1532 if (move_frame && (x_offset != 0 || y_offset != 0)) { 1551 if (move_frame && (x_offset != 0 || y_offset != 0)) {
1533 move(x, y); 1552 move(x, y);
1534 } 1553 }