aboutsummaryrefslogtreecommitdiff
path: root/src
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
parentac3fa211bbc79531151e1400404192b1d7e8516f (diff)
downloadfluxbox_pavel-d6befe5371c5df7d719cb184c4d20e38dc841a13.zip
fluxbox_pavel-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')
-rw-r--r--src/Ewmh.cc7
-rw-r--r--src/FbWinFrame.cc103
-rw-r--r--src/FbWinFrame.hh13
-rw-r--r--src/Window.cc23
-rw-r--r--src/Window.hh3
5 files changed, 97 insertions, 52 deletions
diff --git a/src/Ewmh.cc b/src/Ewmh.cc
index 34c166c..d6ccf36 100644
--- a/src/Ewmh.cc
+++ b/src/Ewmh.cc
@@ -706,9 +706,10 @@ bool Ewmh::checkClientMessage(const XClientMessageEvent &ce,
706 // ce.data.l[2] = y 706 // ce.data.l[2] = y
707 // ce.data.l[3] = width 707 // ce.data.l[3] = width
708 // ce.data.l[4] = height 708 // ce.data.l[4] = height
709 // TODO: gravity and flags 709 // TODO: flags
710 winclient->fbwindow()->moveResize(ce.data.l[1], ce.data.l[2], 710 int win_gravity=ce.data.l[0] & 0xFF;
711 ce.data.l[3], ce.data.l[4]); 711 winclient->fbwindow()->moveResizeForClient(ce.data.l[1], ce.data.l[2],
712 ce.data.l[3], ce.data.l[4], win_gravity);
712 return true; 713 return true;
713 } 714 }
714 715
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 }
diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh
index 32161d1..768f733 100644
--- a/src/FbWinFrame.hh
+++ b/src/FbWinFrame.hh
@@ -76,16 +76,16 @@ public:
76 inline bool isVisible() const { return m_visible; } 76 inline bool isVisible() const { return m_visible; }
77 /// shade frame (ie resize to titlebar size) 77 /// shade frame (ie resize to titlebar size)
78 void shade(); 78 void shade();
79 void move(int x, int y); 79 void move(int x, int y, int win_gravity=ForgetGravity);
80 void resize(unsigned int width, unsigned int height); 80 void resize(unsigned int width, unsigned int height, int win_gravity=ForgetGravity);
81 /// resize client to specified size and resize frame to it 81 /// resize client to specified size and resize frame to it
82 void resizeForClient(unsigned int width, unsigned int height); 82 void resizeForClient(unsigned int width, unsigned int height, int win_gravity=ForgetGravity);
83 83
84 // for when there needs to be an atomic move+resize operation 84 // for when there needs to be an atomic move+resize operation
85 void moveResizeForClient(int x, int y, unsigned int width, unsigned int height, bool move = true, bool resize = true); 85 void moveResizeForClient(int x, int y, unsigned int width, unsigned int height, bool move = true, bool resize = true, int win_gravity=ForgetGravity);
86 86
87 // can elect to ignore move or resize (mainly for use of move/resize individual functions 87 // can elect to ignore move or resize (mainly for use of move/resize individual functions
88 void moveResize(int x, int y, unsigned int width, unsigned int height, bool move = true, bool resize = true); 88 void moveResize(int x, int y, unsigned int width, unsigned int height, bool move = true, bool resize = true, int win_gravity=ForgetGravity);
89 89
90 /// set focus/unfocus style 90 /// set focus/unfocus style
91 void setFocus(bool newvalue); 91 void setFocus(bool newvalue);
@@ -133,7 +133,8 @@ public:
133 // this function translates its arguments according to win_gravity 133 // this function translates its arguments according to win_gravity
134 // if win_gravity is negative, it does an inverse translation 134 // if win_gravity is negative, it does an inverse translation
135 void gravityTranslate(int &x, int &y, int win_gravity, bool move_frame = false); 135 void gravityTranslate(int &x, int &y, int win_gravity, bool move_frame = false);
136 136 //use width and height given instead of the real values, allows figuring out where to place a window before doing a moveResize
137 void gravityTranslate(int &x, int &y, unsigned int width, unsigned int height, int win_gravity, bool move_frame = false);
137 void setBorderWidth(unsigned int borderW); 138 void setBorderWidth(unsigned int borderW);
138 139
139 /** 140 /**
diff --git a/src/Window.cc b/src/Window.cc
index 0bee703..e1fea07 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -1387,6 +1387,29 @@ void FluxboxWindow::moveResize(int new_x, int new_y,
1387 1387
1388} 1388}
1389 1389
1390void FluxboxWindow::moveResizeForClient(int new_x, int new_y,
1391 unsigned int new_width, unsigned int new_height, int gravity) {
1392
1393 // magic to detect if moved during initialisation
1394 if (!isInitialized())
1395 m_old_pos_x = 1;
1396 frame().moveResizeForClient(new_x, new_y, new_width, new_height, true, true, gravity);
1397 setFocusFlag(focused);
1398 shaded = false;
1399 sendConfigureNotify();
1400
1401 shape();
1402
1403 if (!moving) {
1404 m_last_resize_x = new_x;
1405 m_last_resize_y = new_y;
1406 }
1407
1408}
1409
1410
1411
1412
1390// returns whether the focus was "set" to this window 1413// returns whether the focus was "set" to this window
1391// it doesn't guarantee that it has focus, but says that we have 1414// it doesn't guarantee that it has focus, but says that we have
1392// tried. A FocusqIn event should eventually arrive for that 1415// tried. A FocusqIn event should eventually arrive for that
diff --git a/src/Window.hh b/src/Window.hh
index ac13da6..f4a038a 100644
--- a/src/Window.hh
+++ b/src/Window.hh
@@ -233,7 +233,8 @@ public:
233 void resize(unsigned int width, unsigned int height); 233 void resize(unsigned int width, unsigned int height);
234 /// move and resize frame to pox x,y and size width, height 234 /// move and resize frame to pox x,y and size width, height
235 void moveResize(int x, int y, unsigned int width, unsigned int height, int gravity = ForgetGravity); 235 void moveResize(int x, int y, unsigned int width, unsigned int height, int gravity = ForgetGravity);
236 236 /// move to pos x,y and resize client window to size width, height
237 void moveResizeForClient(int x, int y, unsigned int width, unsigned int height, int gravity = ForgetGravity);
237 void setWorkspace(int n); 238 void setWorkspace(int n);
238 void changeBlackboxHints(const BlackboxHints &bh); 239 void changeBlackboxHints(const BlackboxHints &bh);
239 void updateFunctions(); 240 void updateFunctions();