From 6d6425cbde2a4c2038f513c78e5953d0dbdbc20d Mon Sep 17 00:00:00 2001 From: rathnor Date: Thu, 11 Sep 2003 19:55:27 +0000 Subject: fix gravity handling --- ChangeLog | 4 ++ src/FbWinFrame.cc | 17 ++++--- src/WinClient.cc | 11 ++-- src/WinClient.hh | 8 ++- src/Window.cc | 148 +++++++++--------------------------------------------- 5 files changed, 48 insertions(+), 140 deletions(-) diff --git a/ChangeLog b/ChangeLog index c1044bb..dec350c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 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 @@ // 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 @@ void FbWinFrame::updateTransparent() { // 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 @@ void FbWinFrame::gravityTranslate(int &x, int &y, int win_gravity, bool move_fra 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,23 +1156,21 @@ void FbWinFrame::gravityTranslate(int &x, int &y, int win_gravity, bool move_fra // 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; y_offset = -y_offset; @@ -1179,6 +1180,6 @@ void FbWinFrame::gravityTranslate(int &x, int &y, int win_gravity, bool move_fra 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); } } 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 @@ // 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 @@ WinClient::WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin):FbTk::Fb 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 @@ WinClient::WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin):FbTk::Fb 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 @@ void WinClient::updateWMNormalHints() { 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 @@ void WinClient::updateWMNormalHints() { 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; + } } 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 @@ // 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 @@ public: // 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 @@ public: 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 @@ -157,6 +159,8 @@ private: 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; 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 @@ // 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 @@ void FluxboxWindow::init() { 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()) { @@ -484,17 +496,6 @@ void FluxboxWindow::init() { } - 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 @@ bool FluxboxWindow::getState() { 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"<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 @@ -1948,44 +1880,6 @@ void FluxboxWindow::popupMenu() { 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; - } -} - /** Determine if this is the lowest tab of them all */ @@ -2281,17 +2175,21 @@ void FluxboxWindow::configureRequestEvent(XConfigureRequestEvent &cr) { 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 @@ void FluxboxWindow::restore(WinClient *client, bool remap) { 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(); -- cgit v0.11.2