From 4b2ba8de473c028c16796f5c6cfcd41e97ef239e Mon Sep 17 00:00:00 2001 From: rathnor Date: Sat, 22 Mar 2003 05:13:08 +0000 Subject: fix outline moving and warping (Simon) --- ChangeLog | 3 +++ src/Screen.cc | 6 ++++-- src/Window.cc | 68 ++++++++++++++++++++++++++++++++++++++++++---------------- src/Window.hh | 3 ++- src/fluxbox.cc | 17 +++++++++------ 5 files changed, 69 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index b8797a7..e8e47fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ (Format: Year/Month/Day) Changes for 0.9.1: +*03/03/22: + * Fix outline moving, warping, etc (Simon) + Window.hh/cc Screen.cc fluxbox.cc *03/03/03: * Add code for Toolbar modes (Simon) AtomHandler.hh EventManager.cc Ewmh.hh/cc Gnome.hh/cc diff --git a/src/Screen.cc b/src/Screen.cc index 076965f..15ec44b 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.cc,v 1.117 2003/03/03 21:51:04 rathnor Exp $ +// $Id: Screen.cc,v 1.118 2003/03/22 05:13:08 rathnor Exp $ #include "Screen.hh" @@ -961,7 +961,9 @@ void BScreen::changeWorkspaceID(unsigned int id) { #endif // DEBUG if (focused && focused->isMoving()) { - reassociateGroup(focused, id, true); + if (doOpaqueMove()) + reassociateGroup(focused, id, true); + // don't reassociate if not opaque moving focused->pauseMoving(); } diff --git a/src/Window.cc b/src/Window.cc index a950ae4..5692008 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.128 2003/03/03 21:51:09 rathnor Exp $ +// $Id: Window.cc,v 1.129 2003/03/22 05:13:08 rathnor Exp $ #include "Window.hh" @@ -190,7 +190,7 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s, int screen_num, // display connection display = FbTk::App::instance()->display(); - blackbox_attrib.workspace = workspace_number = window_number = -1; + blackbox_attrib.workspace = workspace_number = move_ws = window_number = -1; blackbox_attrib.flags = blackbox_attrib.attrib = blackbox_attrib.stack = 0; blackbox_attrib.premax_x = blackbox_attrib.premax_y = 0; @@ -1054,7 +1054,7 @@ void FluxboxWindow::iconify() { void FluxboxWindow::deiconify(bool reassoc, bool do_raise) { if (iconic || reassoc) { screen->reassociateWindow(this, screen->getCurrentWorkspace()->workspaceID(), false); - } else if (workspace_number != screen->getCurrentWorkspace()->workspaceID()) + } else if (moving || workspace_number != screen->getCurrentWorkspace()->workspaceID()) return; bool was_iconic = iconic; @@ -1120,9 +1120,6 @@ void FluxboxWindow::withdraw() { visible = false; iconic = false; - if (isMoving()) - stopMoving(); - if (isResizing()) stopResizing(); @@ -2065,6 +2062,9 @@ void FluxboxWindow::buttonReleaseEvent(XButtonEvent &re) { void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { + if (isMoving() && me.window == screen->getRootWindow()) { + me.window = m_frame.window().window(); + } if ((me.state & Button1Mask) && functions.move && (m_frame.titlebar() == me.window || m_frame.label() == me.window || m_frame.handle() == me.window || m_frame.window() == me.window) && !isResizing()) { @@ -2084,30 +2084,32 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { last_resize_x = me.x_root; last_resize_y = me.y_root; if (moved_x && screen->isWorkspaceWarping()) { - int cur_id = screen->getCurrentWorkspaceID(); - int new_id = cur_id; + unsigned int cur_id = screen->getCurrentWorkspaceID(); + unsigned int new_id = cur_id; const int warpPad = screen->getEdgeSnapThreshold(); + // 1) if we're inside the border threshold + // 2) if we moved in the right direction if (me.x_root >= int(screen->getWidth()) - warpPad - 1 && - m_frame.x() < int(me.x_root - button_grab_x - screen->getBorderWidth())) { + moved_x > 0) { //warp right new_id = (cur_id + 1) % screen->getCount(); dx = - me.x_root; // move mouse back to x=0 } else if (me.x_root <= warpPad && - m_frame.x() > int(me.x_root - button_grab_x - screen->getBorderWidth())) { + moved_x < 0) { //warp left - new_id = (cur_id - 1 + screen->getCount()) % screen->getCount(); + new_id = (cur_id + screen->getCount() - 1) % screen->getCount(); dx = screen->getWidth() - me.x_root-1; // move mouse to screen width - 1 } - if (new_id != cur_id) { XWarpPointer(display, None, None, 0, 0, 0, 0, dx, 0); - + screen->changeWorkspaceID(new_id); last_resize_x = me.x_root + dx; - // change dx to be relative to window rather than motion event - dx += m_frame.x(); + // dx is the difference, so our new x is what it would have been + // without the warp, plus the difference. + dx += me.x_root - button_grab_x; } } @@ -2117,7 +2119,6 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { last_move_x, last_move_y, m_frame.width() + 2*frame().window().borderWidth(), m_frame.height() + 2*frame().window().borderWidth()); - XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), dx, dy, m_frame.width() + 2*frame().window().borderWidth(), @@ -2299,17 +2300,21 @@ bool FluxboxWindow::validateClient() { void FluxboxWindow::startMoving(Window win) { moving = true; Fluxbox *fluxbox = Fluxbox::instance(); - XGrabPointer(display, win, False, Button1MotionMask | + // grabbing (and masking) on the root window allows us to + // freely map and unmap the window we're moving. + XGrabPointer(display, screen->getRootWindow(), False, Button1MotionMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, fluxbox->getMoveCursor(), CurrentTime); if (m_windowmenu.isVisible()) m_windowmenu.hide(); - fluxbox->maskWindowEvents(client.window, this); + move_ws = workspace_number; + fluxbox->maskWindowEvents(screen->getRootWindow(), this); last_move_x = frame().x(); last_move_y = frame().y(); if (! screen->doOpaqueMove()) { + fluxbox->grab(); XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), frame().x(), frame().y(), frame().width() + 2*frame().window().borderWidth(), @@ -2331,6 +2336,11 @@ void FluxboxWindow::stopMoving() { frame().width() + 2*frame().window().borderWidth(), frame().height() + 2*frame().window().borderWidth()); moveResize(last_move_x, last_move_y, m_frame.width(), m_frame.height()); + if (workspace_number != screen->getCurrentWorkspaceID()) { + screen->reassociateGroup(this, screen->getCurrentWorkspaceID(), true); + m_frame.show(); + } + fluxbox->ungrab(); } else moveResize(m_frame.x(), m_frame.y(), m_frame.width(), m_frame.height()); @@ -2341,11 +2351,31 @@ void FluxboxWindow::stopMoving() { } void FluxboxWindow::pauseMoving() { + if (screen->doOpaqueMove()) { + return; + } + XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), + last_move_x, last_move_y, + m_frame.width() + 2*frame().window().borderWidth(), + m_frame.height() + 2*frame().window().borderWidth()); + } void FluxboxWindow::resumeMoving() { + if (screen->doOpaqueMove()) { + return; + } + + if (workspace_number == screen->getCurrentWorkspaceID()) { + m_frame.show(); + } + XSync(display,false); + XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), + last_move_x, last_move_y, + m_frame.width() + 2*frame().window().borderWidth(), + m_frame.height() + 2*frame().window().borderWidth()); } @@ -2385,7 +2415,7 @@ void FluxboxWindow::stopResizing(Window win) { XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), last_resize_x, last_resize_y, - last_resize_w - 1 + 2 * m_frame.window().borderWidth(), + last_resize_w - 1 + 2 * m_frame.window().borderWidth(), last_resize_h - 1 + 2 * m_frame.window().borderWidth()); screen->hideGeometry(); diff --git a/src/Window.hh b/src/Window.hh index b8dc179..37dad15 100644 --- a/src/Window.hh +++ b/src/Window.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Window.hh,v 1.52 2003/02/23 01:08:09 fluxgen Exp $ +// $Id: Window.hh,v 1.53 2003/03/22 05:13:08 rathnor Exp $ #ifndef WINDOW_HH #define WINDOW_HH @@ -356,6 +356,7 @@ private: int last_resize_x, last_resize_y; // handles last button press event for resize int last_move_x, last_move_y; // handles last pos for non opaque moving unsigned int last_resize_h, last_resize_w; // handles height/width for resize "window" + unsigned int move_ws; // handles home workspace for opaque workspace warping int focus_mode, window_number; unsigned int workspace_number; diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 6155a72..8c9ee65 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: fluxbox.cc,v 1.103 2003/03/03 21:51:11 rathnor Exp $ +// $Id: fluxbox.cc,v 1.104 2003/03/22 05:13:08 rathnor Exp $ #include "fluxbox.hh" @@ -614,12 +614,17 @@ void Fluxbox::setupConfigFiles() { void Fluxbox::handleEvent(XEvent * const e) { - if ((masked == e->xany.window) && masked_window && - (e->type == MotionNotify)) { - last_time = e->xmotion.time; - masked_window->motionNotifyEvent(e->xmotion); + // it is possible (e.g. during moving) for a window + // to mask all events to go to it + if ((masked == e->xany.window) && masked_window) { + if (e->type == MotionNotify) { + last_time = e->xmotion.time; + masked_window->motionNotifyEvent(e->xmotion); + return; + } else if (e->type == ButtonRelease) { + e->xbutton.window = masked_window->getFbWindow().window(); + } - return; } // try FbTk::EventHandler first FbTk::EventManager::instance()->handleEvent(*e); -- cgit v0.11.2