all repos — fluxbox @ 6d6425cbde2a4c2038f513c78e5953d0dbdbc20d

custom fork of the fluxbox windowmanager

fix gravity handling
rathnor rathnor
commit

6d6425cbde2a4c2038f513c78e5953d0dbdbc20d

parent

16653d23d5d7a0dd017cce6484e8865f59edb9c6

5 files changed, 48 insertions(+), 140 deletions(-)

jump to
M ChangeLogChangeLog

@@ -1,5 +1,9 @@

(Format: Year/Month/Day) Changes for 0.9.6: +*03/09/12: + * Fix window gravity handling (Simon) + - should fix some offset fullscreen issues + FbWinFrame.hh/cc WinClient.hh/cc Window.cc *03/09/10: * Fixed buffer for TextButton (Henrik) Reduces flicker
M src/FbWinFrame.ccsrc/FbWinFrame.cc

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbWinFrame.cc,v 1.47 2003/09/11 13:35:37 rathnor Exp $ +// $Id: FbWinFrame.cc,v 1.48 2003/09/11 19:55:27 rathnor Exp $ #include "FbWinFrame.hh"

@@ -1112,6 +1112,7 @@

// 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) { bool invert = false; if (win_gravity < 0) {

@@ -1140,7 +1141,9 @@

int x_offset = 0; int y_offset = 0; - // Start with X offset + // no X offset, since we don't have extra frame on the sides + + // then y offset switch (win_gravity) { case NorthWestGravity: case NorthGravity:

@@ -1153,22 +1156,20 @@ 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 - x_offset = -(m_titlebar.height() + m_titlebar.borderWidth() + y_offset = -(m_titlebar.height() + m_titlebar.borderWidth() + m_handle.height() + m_handle.borderWidth()); break; case WestGravity: case EastGravity: case CenterGravity: // these centered ones are a little more interesting - x_offset = -(m_titlebar.height() + m_titlebar.borderWidth() + y_offset = -(m_titlebar.height() + m_titlebar.borderWidth() + m_handle.height() + m_handle.borderWidth()) / 2; break; case StaticGravity: - x_offset = -(m_titlebar.height() + m_titlebar.borderWidth()); + y_offset = -(m_titlebar.height() + m_titlebar.borderWidth()); break; } - - // no Y offset, since we don't have a frame down there if (invert) { x_offset = -x_offset;

@@ -1179,6 +1180,6 @@ x += x_offset;

y += y_offset; if (move_frame && (x_offset != 0 || y_offset != 0)) { - move(m_window.x() + x_offset, m_window.y() + y_offset); + move(x,y); } }
M src/WinClient.ccsrc/WinClient.cc

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: WinClient.cc,v 1.23 2003/07/28 18:30:02 fluxgen Exp $ +// $Id: WinClient.cc,v 1.24 2003/09/11 19:55:27 rathnor Exp $ #include "WinClient.hh"

@@ -48,7 +48,6 @@ width_inc(1), height_inc(1),

min_aspect_x(1), min_aspect_y(1), max_aspect_x(1), max_aspect_y(1), base_width(1), base_height(1), - win_gravity(0), initial_state(0), normal_hint_flags(0), wm_hint_flags(0),

@@ -56,6 +55,7 @@ m_win(fbwin),

m_modal(0), send_focus_message(false), closable(false), + m_win_gravity(0), m_title(""), m_icon_title(""), m_class_name(""), m_instance_name(""), m_blackbox_hint(0),

@@ -427,7 +427,7 @@ max_width = 0; // unbounded

max_height = 0; min_aspect_x = min_aspect_y = max_aspect_x = max_aspect_y = 1; - win_gravity = NorthWestGravity; + m_win_gravity = NorthWestGravity; } else { normal_hint_flags = sizehint.flags;

@@ -467,9 +467,10 @@ } else

base_width = base_height = 0; if (sizehint.flags & PWinGravity) - win_gravity = sizehint.win_gravity; + m_win_gravity = sizehint.win_gravity; else - win_gravity = NorthWestGravity; + m_win_gravity = NorthWestGravity; + } }
M src/WinClient.hhsrc/WinClient.hh

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: WinClient.hh,v 1.12 2003/07/28 15:46:00 rathnor Exp $ +// $Id: WinClient.hh,v 1.13 2003/09/11 19:55:27 rathnor Exp $ #ifndef WINCLIENT_HH #define WINCLIENT_HH

@@ -109,6 +109,8 @@

// does this client have a pending unmap or destroy event? bool validateClient() const; + inline int gravity() const { return m_win_gravity; } + /** !! TODO !! remove or move these to private

@@ -123,7 +125,7 @@ int x, y, old_bw;

unsigned int min_width, min_height, max_width, max_height, width_inc, height_inc, min_aspect_x, min_aspect_y, max_aspect_x, max_aspect_y, - base_width, base_height, win_gravity; + base_width, base_height; unsigned long initial_state, normal_hint_flags, wm_hint_flags; // this structure only contains 3 elements... the Motif 2.0 structure contains

@@ -156,6 +158,8 @@ // number of transients which we are modal for

// or indicates that we are modal if don't have any transients int m_modal; bool send_focus_message, closable; + + int m_win_gravity; std::string m_title, m_icon_title; std::string m_class_name, m_instance_name;
M src/Window.ccsrc/Window.cc

@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Window.cc,v 1.223 2003/09/10 09:56:18 fluxgen Exp $ +// $Id: Window.cc,v 1.224 2003/09/11 19:55:27 rathnor Exp $ #include "Window.hh"

@@ -463,10 +463,22 @@ }

upsize(); + associateClientWindow(); + + grabButtons(); + + applyDecorations(true); + + if (m_workspace_number < 0 || m_workspace_number >= screen().getCount()) + m_workspace_number = screen().currentWorkspaceID(); + + restoreAttributes(); + bool place_window = true; if (fluxbox.isStartup() || m_client->isTransient() || m_client->normal_hint_flags & (PPosition|USPosition)) { - setGravityOffsets(); + + frame().gravityTranslate(wattrib.x, wattrib.y, m_client->gravity(), false); if (! fluxbox.isStartup()) {

@@ -483,17 +495,6 @@ } else

place_window = false; } - - associateClientWindow(); - - grabButtons(); - - applyDecorations(true); - - if (m_workspace_number < 0 || m_workspace_number >= screen().getCount()) - m_workspace_number = screen().currentWorkspaceID(); - - restoreAttributes(); frame().move(wattrib.x, wattrib.y); frame().resizeForClient(wattrib.width, wattrib.height);

@@ -1762,75 +1763,6 @@

return ret; } -//!! TODO: this functions looks odd -void FluxboxWindow::setGravityOffsets() { - int newx = frame().x(); - int newy = frame().y(); - // translate x coordinate - switch (m_client->win_gravity) { - // handle Westward gravity - case NorthWestGravity: - case WestGravity: - case SouthWestGravity: - default: -#ifdef DEBUG - cerr<<__FILE__<<": Default gravity: SouthWest, NorthWest, West"<<endl; -#endif // DEBUG - - newx = frame().x(); - break; - - // handle Eastward gravity - case NorthEastGravity: - case EastGravity: - case SouthEastGravity: -#ifdef DEBUG - cerr<<__FILE__<<": Gravity: SouthEast, NorthEast, East"<<endl; -#endif // DEBUG - - newx = frame().x() + frame().clientArea().width() - frame().width(); - break; - - // no x translation desired - default - case StaticGravity: - case ForgetGravity: - case CenterGravity: -#ifdef DEBUG - cerr<<__FILE__<<": Gravity: Center, Forget, Static"<<endl; -#endif // DEBUG - - newx = frame().x(); - } - - // translate y coordinate - switch (m_client->win_gravity) { - // handle Northbound gravity - case NorthWestGravity: - case NorthGravity: - case NorthEastGravity: - default: - newy = frame().y(); - break; - - // handle Southbound gravity - case SouthWestGravity: - case SouthGravity: - case SouthEastGravity: - newy = frame().y() + frame().clientArea().height() - frame().height(); - break; - - // no y translation desired - default - case StaticGravity: - case ForgetGravity: - case CenterGravity: - newy = frame().y(); - break; - } - // finaly move the frame - if (frame().x() != newx || frame().y() != newy) - frame().move(newx, newy); -} - /** * Sets the attributes to what they should be * but doesn't change the actual state

@@ -1946,44 +1878,6 @@

m_windowmenu.move(m_last_button_x, frame().y() + diff_y); m_windowmenu.show(); m_windowmenu.raise(); -} - -void FluxboxWindow::restoreGravity() { - // restore x coordinate - switch (m_client->win_gravity) { - // handle Westward gravity - case NorthWestGravity: - case WestGravity: - case SouthWestGravity: - default: - m_client->x = frame().x(); - break; - - // handle Eastward gravity - case NorthEastGravity: - case EastGravity: - case SouthEastGravity: - m_client->x = (frame().x() + frame().width()) - m_client->width(); - break; - } - - // restore y coordinate - switch (m_client->win_gravity) { - // handle Northbound gravity - case NorthWestGravity: - case NorthGravity: - case NorthEastGravity: - default: - m_client->y = frame().y(); - break; - - // handle Southbound gravity - case SouthWestGravity: - case SouthGravity: - case SouthEastGravity: - m_client->y = (frame().y() + frame().height()) - m_client->height(); - break; - } } /**

@@ -2281,17 +2175,21 @@ WinClient *client = findClient(cr.window);

if (client == 0) return; - int cx = frame().x(), cy = frame().y(); + int cx = frame().x(), cy = frame().y(), ignore = 0; unsigned int cw = frame().width(), ch = frame().height(); if (cr.value_mask & CWBorderWidth) client->old_bw = cr.border_width; - if (cr.value_mask & CWX) + if (cr.value_mask & CWX) { cx = cr.x; + frame().gravityTranslate(cx, ignore, client->gravity(), false); + } - if (cr.value_mask & CWY) + if (cr.value_mask & CWY) { cy = cr.y; + frame().gravityTranslate(ignore, cy, client->gravity(), false); + } if (cr.value_mask & CWWidth) cw = cr.width;

@@ -3062,8 +2960,8 @@

XChangeSaveSet(display, client->window(), SetModeDelete); client->setEventMask(NoEventMask); - //!! TODO - //restoreGravity(); + int wx = frame().x(), wy = frame().y(); // not actually used here + frame().gravityTranslate(wx, wy, -client->gravity(), true); // negative to invert client->hide();