all repos — fluxbox @ d6befe5371c5df7d719cb184c4d20e38dc841a13

custom fork of the fluxbox windowmanager

fix for gravity field on _NET_MOVERESIZE_WINDOW messages, patch from Rob Stevens <stever3 at nycap dot rr dot com>
mathias mathias
commit

d6befe5371c5df7d719cb184c4d20e38dc841a13

parent

ac3fa211bbc79531151e1400404192b1d7e8516f

6 files changed, 100 insertions(+), 53 deletions(-)

jump to
M ChangeLogChangeLog

@@ -1,7 +1,9 @@

(Format: Year/Month/Day) Changes for 0.9.13 *05/03/16: - added new option to specify, on which screen fluxbox should handle + * fix for gravity field on _NET_MOVERESIZE_WINDOW (thanx to Rob Stevens) + Ewmh.cc, Window.(cc,hh), FbWinFrame.(cc,hh) + * added new option to specify, on which screen fluxbox should handle the windows. default behavior is to handle each available screen. closes #1159809. (Mathias)
M src/Ewmh.ccsrc/Ewmh.cc

@@ -706,9 +706,10 @@ // ce.data.l[1] = x

// ce.data.l[2] = y // ce.data.l[3] = width // ce.data.l[4] = height - // TODO: gravity and flags - winclient->fbwindow()->moveResize(ce.data.l[1], ce.data.l[2], - ce.data.l[3], ce.data.l[4]); + // TODO: flags + int win_gravity=ce.data.l[0] & 0xFF; + winclient->fbwindow()->moveResizeForClient(ce.data.l[1], ce.data.l[2], + ce.data.l[3], ce.data.l[4], win_gravity); return true; }
M src/FbWinFrame.ccsrc/FbWinFrame.cc

@@ -166,16 +166,16 @@ }

} -void FbWinFrame::move(int x, int y) { - moveResize(x, y, 0, 0, true, false); +void FbWinFrame::move(int x, int y, int win_gravity) { + moveResize(x, y, 0, 0, true, false, win_gravity); } -void FbWinFrame::resize(unsigned int width, unsigned int height) { - moveResize(0, 0, width, height, false, true); +void FbWinFrame::resize(unsigned int width, unsigned int height, int win_gravity) { + moveResize(0, 0, width, height, false, true, win_gravity); } // need an atomic moveresize where possible -void FbWinFrame::moveResizeForClient(int x, int y, unsigned int width, unsigned int height, bool move, bool resize) { +void FbWinFrame::moveResizeForClient(int x, int y, unsigned int width, unsigned int height, bool move, bool resize, int win_gravity) { // total height for frame unsigned int total_height = height;

@@ -188,14 +188,17 @@ // having a handle = 1 extra border + handle height

if (m_use_handle) total_height += m_handle.height() + m_handle.borderWidth(); } - moveResize(x, y, width, total_height, move, resize); + moveResize(x, y, width, total_height, move, resize, win_gravity); } -void FbWinFrame::resizeForClient(unsigned int width, unsigned int height) { - moveResizeForClient(0, 0, width, height, false, true); +void FbWinFrame::resizeForClient(unsigned int width, unsigned int height, int win_gravity) { + moveResizeForClient(0, 0, width, height, false, true, win_gravity); } -void FbWinFrame::moveResize(int x, int y, unsigned int width, unsigned int height, bool move, bool resize) { +void FbWinFrame::moveResize(int x, int y, unsigned int width, unsigned int height, bool move, bool resize, int win_gravity) { + if(win_gravity!=ForgetGravity) { + gravityTranslate(x, y, width + m_window.borderWidth()*2, height + m_window.borderWidth()*2, win_gravity, false); + } if (move && x == window().x() && y == window().y()) move = false;

@@ -1456,6 +1459,10 @@ // this function translates its arguments according to win_gravity

// if win_gravity is negative, it does an inverse translation // This function should be used when a window is mapped/unmapped/pos configured void FbWinFrame::gravityTranslate(int &x, int &y, int win_gravity, bool move_frame) { + gravityTranslate(x, y, m_window.width(), m_window.height(), win_gravity, move_frame); +} +//use width and height given instead of the real values, allows figuring out where to place a window before doing a moveResize +void FbWinFrame::gravityTranslate(int &x, int &y, unsigned int width, unsigned int height, int win_gravity, bool move_frame) { bool invert = false; if (win_gravity < 0) { invert = true;

@@ -1483,43 +1490,56 @@

int x_offset = 0; int y_offset = 0; - // mostly no X offset, since we don't have extra frame on the sides - switch (win_gravity) { - case NorthWestGravity: - case NorthGravity: - case NorthEastGravity: - // no offset, since the top point is still the same - break; - case SouthWestGravity: - case SouthGravity: - case SouthEastGravity: - // window shifted down by height of titlebar, and the handle - // since that's necessary to get the bottom of the frame - // all the way up - if (m_use_titlebar) - y_offset -= m_titlebar.height() + m_titlebar.borderWidth(); - if (m_use_handle) - y_offset -= m_handle.height() + m_handle.borderWidth(); - break; - case WestGravity: - case EastGravity: - case CenterGravity: - // these centered ones are a little more interesting - if (m_use_titlebar) - y_offset -= m_titlebar.height() + m_titlebar.borderWidth(); - if (m_use_handle) - y_offset -= m_handle.height() + m_handle.borderWidth(); - y_offset /= 2; - break; - case StaticGravity: + /* win_gravity: placed at the reference point + * StaticGravity the left top corner of the client window + * NorthWestGravity the left top corner of the frame window + * NorthGravity the center of the frame window's top side + * NorthEastGravity the right top corner of the frame window + * EastGravity the center of the frame window's right side + * SouthEastGravity the right bottom corner of the frame window + * SouthGravity the center of the frame window's bottom side + * SouthWestGravity the left bottom corner of the frame window + * WestGravity the center of the frame window's left side + * CenterGravity the center of the frame window + */ + + + //vertical offset + //North Gravities don't require a vertical offset + //South Gravities + if (win_gravity==SouthWestGravity || win_gravity==SouthGravity || + win_gravity==SouthEastGravity) { + //We start on the frame so going the full height would take us one pixel past the edge of the frame + y_offset-=height-1; + } + + //vertical centering + if (win_gravity==WestGravity || win_gravity==CenterGravity || + win_gravity==EastGravity) { + y_offset-=height/2; + } + + //horizontal offset + //West Gravities don't require a horizontal offset + //East Gravities + if (win_gravity==NorthEastGravity || win_gravity==EastGravity || + win_gravity==SouthEastGravity ) { + //Starting on the frame so offset of one width would end up one pixel beyond the border + x_offset-=width-1; + } + //horizontal centering + if (win_gravity==NorthGravity || win_gravity==CenterGravity || + win_gravity==SouthGravity ) { + x_offset-=width/2; + } + + if( win_gravity==StaticGravity ) { if (m_use_titlebar) y_offset -= m_titlebar.height() + m_titlebar.borderWidth(); - // static is the only one that also has the - // border taken into account x_offset -= m_window.borderWidth(); y_offset -= m_window.borderWidth(); - break; } + if (invert) { x_offset = -x_offset;

@@ -1528,7 +1548,6 @@ }

x += x_offset; y += y_offset; - if (move_frame && (x_offset != 0 || y_offset != 0)) { move(x, y); }
M src/FbWinFrame.hhsrc/FbWinFrame.hh

@@ -76,16 +76,16 @@ void show();

inline bool isVisible() const { return m_visible; } /// shade frame (ie resize to titlebar size) void shade(); - void move(int x, int y); - void resize(unsigned int width, unsigned int height); + void move(int x, int y, int win_gravity=ForgetGravity); + void resize(unsigned int width, unsigned int height, int win_gravity=ForgetGravity); /// resize client to specified size and resize frame to it - void resizeForClient(unsigned int width, unsigned int height); + void resizeForClient(unsigned int width, unsigned int height, int win_gravity=ForgetGravity); // for when there needs to be an atomic move+resize operation - void moveResizeForClient(int x, int y, unsigned int width, unsigned int height, bool move = true, bool resize = true); + void moveResizeForClient(int x, int y, unsigned int width, unsigned int height, bool move = true, bool resize = true, int win_gravity=ForgetGravity); // can elect to ignore move or resize (mainly for use of move/resize individual functions - void moveResize(int x, int y, unsigned int width, unsigned int height, bool move = true, bool resize = true); + void moveResize(int x, int y, unsigned int width, unsigned int height, bool move = true, bool resize = true, int win_gravity=ForgetGravity); /// set focus/unfocus style void setFocus(bool newvalue);

@@ -133,7 +133,8 @@

// this function translates its arguments according to win_gravity // if win_gravity is negative, it does an inverse translation void gravityTranslate(int &x, int &y, int win_gravity, bool move_frame = false); - + //use width and height given instead of the real values, allows figuring out where to place a window before doing a moveResize + void gravityTranslate(int &x, int &y, unsigned int width, unsigned int height, int win_gravity, bool move_frame = false); void setBorderWidth(unsigned int borderW); /**
M src/Window.ccsrc/Window.cc

@@ -1387,6 +1387,29 @@ }

} +void FluxboxWindow::moveResizeForClient(int new_x, int new_y, + unsigned int new_width, unsigned int new_height, int gravity) { + + // magic to detect if moved during initialisation + if (!isInitialized()) + m_old_pos_x = 1; + frame().moveResizeForClient(new_x, new_y, new_width, new_height, true, true, gravity); + setFocusFlag(focused); + shaded = false; + sendConfigureNotify(); + + shape(); + + if (!moving) { + m_last_resize_x = new_x; + m_last_resize_y = new_y; + } + +} + + + + // returns whether the focus was "set" to this window // it doesn't guarantee that it has focus, but says that we have // tried. A FocusqIn event should eventually arrive for that
M src/Window.hhsrc/Window.hh

@@ -233,7 +233,8 @@ /// resize frame to width, height

void resize(unsigned int width, unsigned int height); /// move and resize frame to pox x,y and size width, height void moveResize(int x, int y, unsigned int width, unsigned int height, int gravity = ForgetGravity); - + /// move to pos x,y and resize client window to size width, height + void moveResizeForClient(int x, int y, unsigned int width, unsigned int height, int gravity = ForgetGravity); void setWorkspace(int n); void changeBlackboxHints(const BlackboxHints &bh); void updateFunctions();